Exclude dependencies of std for diagnostics#135278
Conversation
|
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. |
6a3e3c6 to
a04ed09
Compare
|
Okay, I think I have something workable here. I dropped @rustbot ready |
There was a problem hiding this comment.
This change makes sense, but I'm not sure it is the best for diagnostics' design.
@compiler-errors Could you help have a review?
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Exclude dependencies of `std` for diagnostics Currently crates in the sysroot can show up in diagnostic suggestions, such as in rust-lang#135232. To prevent this, introduce a query `visible_crates` that excludes crates marked `is_private_dep` and use this query in user-facing areas of code. Setting `#![feature(rustc_private)]` overrides this to just use all crates, since `rustc_private` enables use of `std`'s private dependencies. Notably, this changes `all_traits` to use `.visible_crates(())` rather than `.crates(())`. This is not strictly required and filtering could happen later as-needed; however, I cannot think of any cases where traits from private dependencies should be relevant in trait selection or diagnostics, so filtering at this earlier point seems more likely to avoid similar issues in the future. This may be reviewed per-commit. Fixes: rust-lang#135232
a04ed09 to
871d75a
Compare
|
HIR ty lowering was modified cc @fmease |
compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs
Outdated
Show resolved
Hide resolved
35ad309 to
c0eb4af
Compare
This comment has been minimized.
This comment has been minimized.
|
(^ spurious CI failure) |
|
@bors try @rust-timer queue |
Update `compiler-builtins` to 0.1.144 The change between 0.1.143 and 0.1.144 includes refactoring that was in compiler-builtins before, but had to be reverted before landing in rust-lang/rust because the traits were leaking into diagnostics [1]. Recently a fix for this issue was merged [2] so the cleanup is reapplied here. This also acts as a regression test for [2]. [1]: rust-lang#128691 (comment) [2]: rust-lang#135278
Update `compiler-builtins` to 0.1.144 The change between 0.1.143 and 0.1.144 includes refactoring that was in compiler-builtins before, but had to be reverted before landing in rust-lang/rust because the traits were leaking into diagnostics [1]. Recently a fix for this issue was merged [2] so the cleanup is reapplied here. This also acts as a regression test for [2]. [1]: rust-lang#128691 (comment) [2]: rust-lang#135278
Update `compiler-builtins` to 0.1.144 The change between 0.1.143 and 0.1.144 includes refactoring that was in compiler-builtins before, but had to be reverted before landing in rust-lang/rust because the traits were leaking into diagnostics [1]. Recently a fix for this issue was merged [2] so the cleanup is reapplied here. This also acts as a regression test for [2]. [1]: rust-lang#128691 (comment) [2]: rust-lang#135278
Update `compiler-builtins` to 0.1.144 The change between 0.1.143 and 0.1.144 includes refactoring that was in compiler-builtins before, but had to be reverted before landing in rust-lang/rust because the traits were leaking into diagnostics [1]. Recently a fix for this issue was merged [2] so the cleanup is reapplied here. This also acts as a regression test for [2]. [1]: rust-lang#128691 (comment) [2]: rust-lang#135278
Update `compiler-builtins` to 0.1.144 The change between 0.1.143 and 0.1.144 includes refactoring that was in compiler-builtins before, but had to be reverted before landing in rust-lang/rust because the traits were leaking into diagnostics [1]. Recently a fix for this issue was merged [2] so the cleanup is reapplied here. This also acts as a regression test for [2]. [1]: rust-lang#128691 (comment) [2]: rust-lang#135278 try-job: test-various
The change between 0.1.143 and 0.1.144 includes refactoring that was in compiler-builtins before, but had to be reverted before landing in rust-lang/rust because the traits were leaking into diagnostics [1]. Recently a fix for this issue was merged [2] so the cleanup is reapplied here. This also acts as a regression test for [2]. [1]: rust-lang#128691 (comment) [2]: rust-lang#135278
The change between 0.1.143 and 0.1.144 includes refactoring that was in compiler-builtins before, but had to be reverted before landing in rust-lang/rust because the traits were leaking into diagnostics [1]. Recently a fix for this issue was merged [2] so the cleanup is reapplied here. This also acts as a regression test for [2]. [1]: rust-lang#128691 (comment) [2]: rust-lang#135278
The change between 0.1.143 and 0.1.144 includes refactoring that was in compiler-builtins before, but had to be reverted before landing in rust-lang/rust because the traits were leaking into diagnostics [1]. Recently a fix for this issue was merged [2] so the cleanup is reapplied here. This also acts as a regression test for [2]. [1]: rust-lang#128691 (comment) [2]: rust-lang#135278
The change between 0.1.143 and 0.1.144 includes refactoring that was in compiler-builtins before, but had to be reverted before landing in rust-lang/rust because the traits were leaking into diagnostics [1]. Recently a fix for this issue was merged [2] so the cleanup is reapplied here. This also acts as a regression test for [2]. [1]: rust-lang#128691 (comment) [2]: rust-lang#135278
…, r=<try> Resolve `compiler_builtins` not being treated as private; clean up rust-lang#135278 Follow up of rust-lang#135278 try-job: test-various
The change between 0.1.143 and 0.1.144 includes refactoring that was in compiler-builtins before, but had to be reverted before landing in rust-lang/rust because the traits were leaking into diagnostics [1]. Recently a fix for this issue was merged [2] so the cleanup is reapplied here. This also acts as a regression test for [2]. [1]: rust-lang#128691 (comment) [2]: rust-lang#135278
…, r=<try> Resolve `compiler_builtins` not being treated as private; clean up rust-lang#135278 Follow up of rust-lang#135278 Do the following (one per commit): * Do not make dependencies of `std` private by default * Update remaining sysroot crates to use `public-dependencies` * Force `compiler_builtins` to be private, since it is an injected `extern crate` * Ensure that marking a dependency private makes its dependents private by default as well * Do the `compiler_builtins` update that has been blocked on this try-job: test-various
The change between 0.1.143 and 0.1.144 includes refactoring that was in compiler-builtins before, but had to be reverted before landing in rust-lang/rust because the traits were leaking into diagnostics [1]. Recently a fix for this issue was merged [2] so the cleanup is reapplied here. This also acts as a regression test for [2]. [1]: rust-lang#128691 (comment) [2]: rust-lang#135278
…, r=<try> Resolve `compiler_builtins` not being treated as private; clean up rust-lang#135278 Follow up of rust-lang#135278 Do the following (one per commit): * Do not make dependencies of `std` private by default * Update remaining sysroot crates to use `public-dependencies` * Force `compiler_builtins` to be private, since it is an injected `extern crate` * Ensure that marking a dependency private makes its dependents private by default as well * Do the `compiler_builtins` update that has been blocked on this try-job: test-various
The change between 0.1.143 and 0.1.144 includes refactoring that was in compiler-builtins before, but had to be reverted before landing in rust-lang/rust because the traits were leaking into diagnostics [1]. Recently a fix for this issue was merged [2] so the cleanup is reapplied here. This also acts as a regression test for [2]. [1]: rust-lang#128691 (comment) [2]: rust-lang#135278
`compiler_builtins` is always available as an injected dependency, introduced in AST as `extern crate compiler_builtins as _`. This makes it indistinguishable from any other user-specified `extern crate`, meaning `is_private_dep` does not see it as a dependency that should be marked private; this is the reason that `compiler_builtins` sometimes leaks into diagnostics, and has slightly different behavior from other stdlib dependencies tested in [1]. There is no easy way to know that an instance of `extern crate compiler_builtins` was the injected version; however, `compiler_builtins` To get around this, always mark `compiler_builtins` private. The items in this crate are never used directly, and this is the most [1]: rust-lang#135278
The change between 0.1.143 and 0.1.144 includes refactoring that was in compiler-builtins before, but had to be reverted before landing in rust-lang/rust because the traits were leaking into diagnostics [1]. Recently a fix for this issue was merged [2] so the cleanup is reapplied here. This also acts as a regression test for [2]. [1]: rust-lang#128691 (comment) [2]: rust-lang#135278
`compiler_builtins` is always available as an injected dependency, introduced in AST as `extern crate compiler_builtins as _`. This makes it indistinguishable from any other user-specified `extern crate`, meaning `is_private_dep` does not see it as a dependency that should be marked private; this is the reason that `compiler_builtins` sometimes leaks into diagnostics, and has slightly different behavior from other stdlib dependencies tested in [1]. There is no easy way to know that an instance of `extern crate compiler_builtins` was the injected version; however, `compiler_builtins` To get around this, always mark `compiler_builtins` private. The items in this crate are never used directly, and this is the most [1]: rust-lang#135278
The change between 0.1.143 and 0.1.144 includes refactoring that was in compiler-builtins before, but had to be reverted before landing in rust-lang/rust because the traits were leaking into diagnostics [1]. Recently a fix for this issue was merged [2] so the cleanup is reapplied here. This also acts as a regression test for [2]. [1]: rust-lang#128691 (comment) [2]: rust-lang#135278
The change between 0.1.143 and 0.1.144 includes refactoring that was in compiler-builtins before, but had to be reverted before landing in rust-lang/rust because the traits were leaking into diagnostics [1]. Recently a fix for this issue was merged [2] so the cleanup is reapplied here. This also acts as a regression test for [2]. [1]: rust-lang#128691 (comment) [2]: rust-lang#135278
The change between 0.1.143 and 0.1.144 includes refactoring that was in compiler-builtins before, but had to be reverted before landing in rust-lang/rust because the traits were leaking into diagnostics [1]. Recently a fix for this issue was merged [2] so the cleanup is reapplied here. This also acts as a regression test for [2]. [1]: rust-lang#128691 (comment) [2]: rust-lang#135278
The change between 0.1.143 and 0.1.144 includes refactoring that was in compiler-builtins before, but had to be reverted before landing in rust-lang/rust because the traits were leaking into diagnostics [1]. Recently a fix for this issue was merged [2] so the cleanup is reapplied here. This also acts as a regression test for [2]. [1]: rust-lang#128691 (comment) [2]: rust-lang#135278
The change between 0.1.143 and 0.1.144 includes refactoring that was in compiler-builtins before, but had to be reverted before landing in rust-lang/rust because the traits were leaking into diagnostics [1]. Recently a fix for this issue was merged [2] so the cleanup is reapplied here. This also acts as a regression test for [2]. [1]: rust-lang#128691 (comment) [2]: rust-lang#135278
The change between 0.1.143 and 0.1.144 includes refactoring that was in compiler-builtins before, but had to be reverted before landing in rust-lang/rust because the traits were leaking into diagnostics [1]. Recently a fix for this issue was merged [2] so the cleanup is reapplied here. This also acts as a regression test for [2]. [1]: rust-lang#128691 (comment) [2]: rust-lang#135278
…, r=<try> Resolve `compiler_builtins` not being treated as private; clean up rust-lang#135278 Follow up of rust-lang#135278 Do the following (one per commit): * Do not make dependencies of `std` private by default * Update remaining sysroot crates to use `public-dependencies` * Force `compiler_builtins` to be private, since it is an injected `extern crate` * Ensure that marking a dependency private makes its dependents private by default as well * Do the `compiler_builtins` update that has been blocked on this Based on top of rust-lang#136226 so there are a few preceding commits. try-job: test-various try-job: x86_64-msvc-1
The change between 0.1.143 and 0.1.144 includes refactoring that was in compiler-builtins before, but had to be reverted before landing in rust-lang/rust because the traits were leaking into diagnostics [1]. Recently a fix for this issue was merged [2] so the cleanup is reapplied here. This also acts as a regression test for [2]. [1]: rust-lang#128691 (comment) [2]: rust-lang#135278
…, r=<try> Resolve `compiler_builtins` not being treated as private; clean up rust-lang#135278 Follow up of rust-lang#135278 Do the following (one per commit): * Do not make dependencies of `std` private by default * Update remaining sysroot crates to use `public-dependencies` * Ensure that marking a dependency private makes its dependents private by default as well * Do the `compiler_builtins` update that has been blocked on this Based on top of rust-lang#136226 so there are a few preceding commits. try-job: test-various try-job: x86_64-msvc-1
Replace `public_test_dep!` by placing optionally public items into new modules, then controlling what is exported with the `public-test-deps` feature. This is nicer for automatic formatting and diagnostics. This is a reland of 2e2a925 ("Eliminate the use of `public_test_dep!`"), which was reverted in 47e50fd ('Revert "Eliminate the use of..."') due to a bug exposed at [1]. This was fixed in [2], so the cleanup should be able to be applied again. [1]: rust-lang/rust#128691 [2]: rust-lang/rust#135278 (cherry picked from commit d4abaf4)
Currently crates in the sysroot can show up in diagnostic suggestions, such as in #135232. To prevent this, duplicate
all_traitsintovisible_traitswhich only shows traits in non-private crates.Setting
#![feature(rustc_private)]overrides this and makes items in private crates visible as well, sincerustc_privateenables use ofstd's private dependencies.This may be reviewed per-commit.
Fixes: #135232