Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the doc for std::prelude to the correct behavior #73484

Merged
merged 1 commit into from
Jun 20, 2020

Conversation

poliorcetics
Copy link
Contributor

Fixes #64686.

One line change to ensure the docs are correct about the behavior of the compiler when insertingstd::prelude::v1.

I don't think examples are necessary but I can add some (especially those from the original issue) if needed.

@rust-highfive
Copy link
Collaborator

r? @sfackler

(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 Jun 18, 2020
@ehuss
Copy link
Contributor

ehuss commented Jun 18, 2020

I don't think this is correct.

Name resolution works through a chain of lookups. For example, it will roughly look in order:

  1. local variables
  2. items in unnamed blocks
  3. items in the current module
  4. crate names in the "extern prelude"
  5. standard library prelude
  6. language prelude (built-in types)

where each one can shadow the one below it. I don't think there is an equivalent way to express this through Rust code. Also std arrives in the extern prelude, not the library prelude (and the extern prelude contains a bunch of other things). I personally would just remove the "On a technical level..." section since it is wrong, and I think it is somewhat distracting to explain the details. All the reader needs to know is that the prelude items are implicitly in scope everywhere.

@sfackler
Copy link
Member

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Jun 19, 2020

📌 Commit 8f0bd5f has been approved by sfackler

@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 Jun 19, 2020
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 20, 2020
…arth

Rollup of 16 pull requests

Successful merges:

 - rust-lang#71420 (Specialization is unsound)
 - rust-lang#71899 (Refactor `try_find` a little)
 - rust-lang#72689 (add str to common types)
 - rust-lang#72791 (update coerce docs and unify relevant tests)
 - rust-lang#72934 (forbid mutable references in all constant contexts except for const-fns)
 - rust-lang#73027 (Make `need_type_info_err` more conservative)
 - rust-lang#73347 (Diagnose use of incompatible sanitizers)
 - rust-lang#73359 (shim.rs: avoid creating `Call` terminators calling `Self`)
 - rust-lang#73399 (Clean up E0668 explanation)
 - rust-lang#73436 (Clean up E0670 explanation)
 - rust-lang#73440 (Add src/librustdoc as an alias for src/tools/rustdoc)
 - rust-lang#73442 (pretty/mir: const value enums with no variants)
 - rust-lang#73452 (Unify region variables when projecting associated types)
 - rust-lang#73458 (Use alloc::Layout in DroplessArena API)
 - rust-lang#73484 (Update the doc for std::prelude to the correct behavior)
 - rust-lang#73506 (Bump Rustfmt and RLS)

Failed merges:

r? @ghost
@bors bors merged commit 7777b0b into rust-lang:master Jun 20, 2020
@cuviper cuviper added this to the 1.46 milestone May 2, 2024
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.

Incorrect description of std::prelude name resolution in standard library docs
6 participants