-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Exclude dependencies of std
for diagnostics
#135278
base: master
Are you sure you want to change the base?
Conversation
There are a few locations where the crate name is checked against an enumerated list of `std`, `core`, `alloc`, and `proc_macro`, or some subset thereof. In most of these cases, all four crates should likely be treated the same. Change this so the crates are listed in one place, and that list is used wherever a list of `std` crates is needed. `test` could be considered relevant in some of these cases, but generally treating it separate from the others seems preferable while it is unstable. There are also a few places that Clippy will be able to use this.
Currently `root` or `crate_root` is used to refer to an instance of `CrateRoot` (representation of a crate's serialized metadata), but the name `root` sometimes also refers to a `CratePath` representing a "root" node in the dependency graph. In order to disambiguate, rename all instances of the latter to `dep_root`.
Dependencies of `std`, `core` and others are members of the crate graph, but should not be available for access by the local crate or show up in user-facing diagnostics. To support restricting this, introduce a `stdlib_private_dep` field on `CrateMetadata` that contains this information.
Add a query for crates that are visible and shoule appear in diagnostics. This excludes stdlib-private crates unless the `rustc_private` feature is set, in which case there is no difference from the existing `.crates(())` query.
For places where we don't want stdlib-private crates to be accessible, use `.visible_crates()` rather than `.crates()`. The current effect is that items in stdlib-private crates will no longer show up in diagnostics related to trait selection. Fixes: rust-lang#135232
r? @SparrowLii rustbot has assigned @SparrowLii. Use |
Unsure whether adding a query is okay or if this should just be a filtering method on @rustbot author |
Another option is to drop Open to suggestions here. |
Currently crates in the sysroot can show up in diagnostic suggestions, such as in #135232. To prevent this, do the following:
stdlib_private_dep
visible_crates
that excludes these.visible_crates(())
rather than.crates(())
for user-facing areas of codeThis may be reviewed per-commit. This PR includes #135247, I'll rebase if that merges first.
Fixes: #135232