Skip to content

Conversation

sdroege
Copy link
Contributor

@sdroege sdroege commented Feb 4, 2021

As it is a safe trait it does not provide any guarantee that the
returned length is correct and as such unsafe code must not rely on it.

That's why TrustedLen exists.

Fixes #81739

@rust-highfive
Copy link
Contributor

r? @kennytm

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 4, 2021
@rust-log-analyzer
Copy link
Collaborator

The job mingw-check failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
configure: rust.channel         := nightly
configure: rust.debug-assertions := True
configure: llvm.assertions      := True
configure: dist.missing-tools   := True
configure: build.configure-args := ['--enable-sccache', '--disable-manage-submodu ...
configure: writing `config.toml` in current directory
configure: 
configure: run `python /checkout/x.py --help`
configure: 
---
 Documenting core v0.0.0 (/checkout/library/core)
error: unresolved link to `core::iter::TrustedLen`
  --> library/core/src/iter/traits/exact_size.rs:19:26
   |
19 | /// unstable and unsafe [`core::iter::TrustedLen`] trait gives this additional
   |                          ^^^^^^^^^^^^^^^^^^^^^^^^ no item named `core` in scope
   |
   = note: `-D broken-intra-doc-links` implied by `-D warnings`
error: unresolved link to `core::iter::TrustedLen`
  --> library/core/src/iter/traits/exact_size.rs:19:26
   |
   |
19 | /// unstable and unsafe [`core::iter::TrustedLen`] trait gives this additional
   |                          ^^^^^^^^^^^^^^^^^^^^^^^^ no item named `core` in scope
error: aborting due to 2 previous errors

error: could not document `core`


Caused by:
  process didn't exit successfully: `/checkout/obj/build/bootstrap/debug/rustdoc --edition=2018 --crate-type lib --crate-name core library/core/src/lib.rs --target x86_64-unknown-linux-gnu -o /checkout/obj/build/x86_64-unknown-linux-gnu/stage0-std/x86_64-unknown-linux-gnu/doc --error-format=json --json=diagnostic-rendered-ansi --markdown-css rust.css --markdown-no-toc -Z unstable-options --resource-suffix 1.51.0 --index-page /checkout/src/doc/index.md -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-std/x86_64-unknown-linux-gnu/release/deps -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-std/release/deps --cfg=bootstrap -Dwarnings -Winvalid_codeblock_attributes --crate-version '1.51.0-nightly
  (3838eda0f
  2021-02-04)'` (exit code: 1)


command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "rustdoc" "--target" "x86_64-unknown-linux-gnu" "-Zbinary-dep-depinfo" "-j" "16" "--release" "--locked" "--color" "always" "--features" "panic-unwind backtrace compiler-builtins-c" "--manifest-path" "/checkout/library/test/Cargo.toml" "-p" "core" "--" "--markdown-css" "rust.css" "--markdown-no-toc" "-Z" "unstable-options" "--resource-suffix" "1.51.0" "--index-page" "/checkout/src/doc/index.md"


failed to run: /checkout/obj/build/bootstrap/debug/bootstrap doc --stage 0 library/std
Build completed unsuccessfully in 0:00:09

@sdroege sdroege force-pushed the exact-size-iterator-correctness branch from c43e3fe to bed9e88 Compare February 4, 2021 09:12
… `ExactSizeIterator` docs

As it is a safe trait it does not provide any guarantee that the
returned length is correct and as such unsafe code must not rely on it.

That's why `TrustedLen` exists.

Fixes rust-lang#81739
@sdroege sdroege force-pushed the exact-size-iterator-correctness branch from bed9e88 to f436630 Compare February 4, 2021 09:31
@kennytm
Copy link
Member

kennytm commented Feb 6, 2021

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Feb 6, 2021

📌 Commit f436630 has been approved by kennytm

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 6, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 7, 2021
…laumeGomez

Rollup of 5 pull requests

Successful merges:

 - rust-lang#81526 (btree: use Option's unwrap_unchecked())
 - rust-lang#81742 (Add a note about the correctness and the effect on unsafe code to the `ExactSizeIterator` docs)
 - rust-lang#81830 (Add long error explanation for E0542)
 - rust-lang#81835 (Improve long explanation for E0546)
 - rust-lang#81843 (Add regression test for rust-lang#29821)

Failed merges:

 - rust-lang#81836 (Add long explanation for E0547)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit f706216 into rust-lang:master Feb 7, 2021
@rustbot rustbot added this to the 1.52.0 milestone Feb 7, 2021
@sdroege sdroege deleted the exact-size-iterator-correctness branch February 9, 2021 08:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a safety warning in ExactSizeIterator documentation
6 participants