avoid suggesting traits from private dependencies#143038
avoid suggesting traits from private dependencies#143038bors merged 3 commits intorust-lang:masterfrom
Conversation
8dd63b7 to
2f3d599
Compare
|
Oh that's a wonderfully small fix. Were you able to reproduce this with something other than Just make sure it actually fails without the fix since I know this is a bit touchy. |
| mut valid_out_of_scope_traits: Vec<DefId>, | ||
| explain: bool, | ||
| ) -> bool { | ||
| valid_out_of_scope_traits.retain(|id| !self.tcx.is_private_dep(id.krate)); |
There was a problem hiding this comment.
I think it might be better to rename all_traits to all_visible_traits (and update its usage) here https://github.com/rust-lang/rust/blob/2f3d599989883d0be932df3dceed65a6ec3274f8/compiler/rustc_hir_typeck/src/method/suggest.rs#L4387C15-L4389, then have that function call visible_traits
rust/compiler/rustc_middle/src/ty/context.rs
Lines 2320 to 2335 in bc4376f
suggest_valid_traits.
@estebank any opinions here?
There was a problem hiding this comment.
Maybe renaming all_traits to all_traits_inclusing_private or something else verbose? visible_traits is what most people want/need so it should have the shorter, more findable name.
There was a problem hiding this comment.
The actual tcx methods you mean? That seems reasonable to me to avoid the footgun. It's only named in ~10 places so @Qelxiros feel free to either do that in a second commit in this PR, or as a separate PR.
There was a problem hiding this comment.
I'm happy to add it here. As a side note, visible_traits above uses TyCtxt::is_user_visible_dep, which allows imports from direct private dependencies. Using that instead of is_private_dep still removes the erroneous suggestions, is more in line with my mental model of what I'm trying to do here, and aligns with the documentation of is_user_visible_dep:
rust/compiler/rustc_middle/src/ty/util.rs
Lines 838 to 839 in bc4376f
|
HIR ty lowering was modified cc @fmease |
|
I'm assuming that ping is due to the function rename, see #143038 (comment) for context |
This comment has been minimized.
This comment has been minimized.
1ac98c8 to
a9d5951
Compare
tgross35
left a comment
There was a problem hiding this comment.
LGTM as well, thank you for the changes!
One request if possible, are you able to adjust the history a bit? Split commits like:
- Add the tests and run+bless it so we have the current failures in history (this is purely nice to have, feel free to disregard this if it's tricky)
- Make
compiler-builtinsa private dep - Add the fix and update the test (everything else)
This is so we will be able to backport only the library changes (second commit) to beta, which should fix #143215.
0bd4396 to
92e5103
Compare
Awesome to see the failure reproduced in the first commit since I was having trouble getting it to work locally. Thank you for all the work here! @bors r+ |
|
@bors r- |
|
Since // By default, the `read` diagnostic suggests `std::os::unix::fs::FileExt::read_at`. Add
// something more likely to be recommended to make the diagnostic cross-platform.
trait DecoyRead {
fn read1(&self) {}
}
impl<T> DecoyRead for Vec<T> {} |
51aa76f to
6b824e8
Compare
|
@bors2 try jobs=test-various |
…<try>
avoid suggesting traits from private dependencies
<!-- homu-ignore:start -->
<!--
If this PR is related to an unstable feature or an otherwise tracked effort,
please link to the relevant tracking issue here. If you don't know of a related
tracking issue or there are none, feel free to ignore this.
This PR will get automatically assigned to a reviewer. In case you would like
a specific user to review your work, you can assign it to them by using
r? <reviewer name>
-->
<!-- homu-ignore:end -->
fixes #142676
fixes #138191
r? `@tgross35`
try-job: test-various
|
@bors r+ |
…-traits, r=tgross35 avoid suggesting traits from private dependencies fixes rust-lang#142676 fixes rust-lang#138191 r? `@tgross35`
Rollup of 6 pull requests Successful merges: - #134006 (setup typos check in CI) - #142876 (Port `#[target_feature]` to new attribute parsing infrastructure) - #143038 (avoid suggesting traits from private dependencies) - #143083 (Fix rustdoc not correctly showing attributes on re-exports) - #143283 (document optional jobs) - #143329 (minicore: use core's `diagnostic::on_unimplemented` messages) Failed merges: - #143237 (Port `#[no_implicit_prelude]` to the new attribute parsing infrastructure) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 6 pull requests Successful merges: - rust-lang/rust#134006 (setup typos check in CI) - rust-lang/rust#142876 (Port `#[target_feature]` to new attribute parsing infrastructure) - rust-lang/rust#143038 (avoid suggesting traits from private dependencies) - rust-lang/rust#143083 (Fix rustdoc not correctly showing attributes on re-exports) - rust-lang/rust#143283 (document optional jobs) - rust-lang/rust#143329 (minicore: use core's `diagnostic::on_unimplemented` messages) Failed merges: - rust-lang/rust#143237 (Port `#[no_implicit_prelude]` to the new attribute parsing infrastructure) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 6 pull requests Successful merges: - rust-lang/rust#134006 (setup typos check in CI) - rust-lang/rust#142876 (Port `#[target_feature]` to new attribute parsing infrastructure) - rust-lang/rust#143038 (avoid suggesting traits from private dependencies) - rust-lang/rust#143083 (Fix rustdoc not correctly showing attributes on re-exports) - rust-lang/rust#143283 (document optional jobs) - rust-lang/rust#143329 (minicore: use core's `diagnostic::on_unimplemented` messages) Failed merges: - rust-lang/rust#143237 (Port `#[no_implicit_prelude]` to the new attribute parsing infrastructure) r? `@ghost` `@rustbot` modify labels: rollup
|
Removing the nomination since #143660 fixes it instead |
…-traits, r=tgross35 avoid suggesting traits from private dependencies fixes rust-lang#142676 fixes rust-lang#138191 r? ``@tgross35``
fixes #142676
fixes #138191
r? @tgross35