You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Diagnostics sometimes suggest items from rustc_private crates #135232
This requires a compiler_builtins that includes a public or possibly public (i.e. feature gated) trait. The most recent v0.1.142 has this on Windows only (attempted update in #135180), I have a patched branch that makes this trait available on all platforms https://github.com/tgross35/rust/tree/experiment-builtins-math.
--> foo.rs:6:22
|
6 | type Foo = dyn Trait<F = i32, Bar = i32>;
| ^ there is a similarly named associated type `H` in the trait `compiler_builtins::math::libm::support::int_traits::DInt`
Desired output
Don't suggest using compiler_builtins unless the crate is #![feature(rustc_private)]
The context is that compiler_builtins has a lot of traits that are usually private but are public with a feature for testing. Currently everything is wrapped in a cfged macro so the traits don't even make it to AST unless the relevant config is enabled. It would be much nicer to instead just make the relevant module conditionally private/public, but since diagnostics ignore module visibility, that means they can show up in diagnostics if the crate is accessible.
I did try making that change before rust-lang/compiler-builtins#656, which had to be reverted because of the failure at #128691 (comment). Didn't look into the cause too much at that time. But in any case, the current situation isn't very robust, and finding problems only at sync time is inconvenient.
I can try to figure this out but I'm not sure where to start. @compiler-errors this seems like your territory, any suggestions?
error[E0220]: associated type `Buf` not found for `Trait`
--> src/lib.rs:2:22
|
2 | type Foo = dyn Trait<Buf = i32, Bar = i32>;
| ^^^ there is an associated type `Buf` in the trait `addr2line::LookupContinuation`
Activity
tgross35 commentedon Jan 8, 2025
The context is that
compiler_builtinshas a lot of traits that are usually private but are public with a feature for testing. Currently everything is wrapped in acfged macro so the traits don't even make it to AST unless the relevant config is enabled. It would be much nicer to instead just make the relevant module conditionally private/public, but since diagnostics ignore module visibility, that means they can show up in diagnostics if the crate is accessible.I did try making that change before rust-lang/compiler-builtins#656, which had to be reverted because of the failure at #128691 (comment). Didn't look into the cause too much at that time. But in any case, the current situation isn't very robust, and finding problems only at sync time is inconvenient.
I can try to figure this out but I'm not sure where to start. @compiler-errors this seems like your territory, any suggestions?
tgross35 commentedon Jan 8, 2025
Also this only seems to apply to trait-related diagnostics, e.g. calling a function from
compiler_builtinsdoesn't suggest anything.tgross35 commentedon Jan 8, 2025
More reliable repro that works on stable and refers to
addr2linefrom the sysroothttps://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=f137a5a714aff5759deb28283947f9c6
Looks like this might be easier than expected if this is the only kind of error, maybe just a filter at
rust/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs
Lines 201 to 209 in 0707499
Use `visible_crates` rather than `crates` for solving and diagnostics
Use `visible_crates` rather than `crates` for solving and diagnostics
Use `visible_crates` rather than `crates` for solving and diagnostics
Use `visible_crates` rather than `crates` for solving and diagnostics
Auto merge of rust-lang#135278 - tgross35:ignore-std-dep-crates, r=<try>
Use `visible_crates` rather than `crates` for solving and diagnostics
Add `tcx.visible_traits()` and use it for producing diagnostics
Add `tcx.visible_traits()` and use it for producing diagnostics
Auto merge of rust-lang#135278 - tgross35:ignore-std-dep-crates, r=<try>
Add `tcx.visible_traits()` and use it for producing diagnostics
Add `tcx.visible_traits()` and use it for producing diagnostics
Mark dependencies of the standard library as private by default
Add `tcx.visible_traits()` and use it for producing diagnostics
Mark dependencies of the standard library as private by default
Add `tcx.visible_traits()` and use it for producing diagnostics
Mark dependencies of the standard library as private by default
Auto merge of rust-lang#135278 - tgross35:ignore-std-dep-crates, r=Sp…
Auto merge of #135278 - tgross35:ignore-std-dep-crates, r=SparrowLii
Auto merge of #135278 - tgross35:ignore-std-dep-crates, r=SparrowLii