-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Limit impl_trait_header query to only trait impls #144607
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
base: master
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Limit impl_trait_header query to only trait impls
💔 Test failed (CI). Failed jobs:
|
c4b4025
to
35dbd1a
Compare
@bors try @rust-timer queue |
@camsteffen: 🔑 Insufficient privileges: not in try users |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Limit impl_trait_header query to only trait impls
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (60b45cb): comparison URL. Overall result: ❌✅ regressions and improvements - BENCHMARK(S) FAILEDBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @bors rollup=never ❗ ❗ ❗ ❗ ❗
❗ ❗ ❗ ❗ ❗ Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)This benchmark run did not return any relevant results for this metric. CyclesResults (secondary -2.6%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 469.046s -> 466.887s (-0.46%) |
Y'all think that's funny? 😤 Fixed the rustdoc issues from above. |
c6eaf7f
to
19fcf89
Compare
@rustbot ready -S-blocked |
@bors2 delegate=try |
✌️ @camsteffen, you can now perform try builds on this pull request! You can now post |
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Limit impl_trait_header query to only trait impls
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (f97840c): comparison URL. Overall result: ❌✅ regressions and improvements - please read the text belowBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (secondary 1.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary -4.3%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 473.894s -> 472.442s (-0.31%) |
Yay! Consistent wins for rustc and some smaller regressions for doc. I think the doc regressions can be won back by continuing with more refactors to avoid the def_kind lookups, but I think that can be a follow-up and this is worth landing as is. There are one or two things here that could be split out into smaller chunks if that is preferred but I'll leave it to the reviewer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
didn't quite look into clippy yet, but a few nits
I quite like this change and think it's a nice improvement
I do feel like it would have been nice to initially simply rename the query to opt_impl_trait_ref
and change impl_trait_ref
to simply call that query and unwrap so that this change can be separately reviewed and merged.
// Note: this cannot come from an inherent impl, | ||
// because the first probing succeeded. | ||
CandidateSource::Impl(def) => self.tcx.trait_id_of_impl(def), | ||
CandidateSource::Impl(def) => self.tcx.impl_opt_trait_id(def), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
given the note, this could just be impl_trait_id
, should it nor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't totally sure but I'll give it a try.
CandidateSource::Trait(def_id) => def_id != info.def_id, | ||
CandidateSource::Impl(def_id) => { | ||
self.tcx.trait_id_of_impl(def_id) != Some(info.def_id) | ||
self.tcx.impl_opt_trait_id(def_id) != Some(info.def_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why does this change from non-optional to optional
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trait_id_of_impl
is optional. I'm not sure if it's safe to be non-optional.
} | ||
|
||
fn trait_ref(&mut self) -> &mut Self { | ||
self.in_primary_interface = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... we set this to true
here and don't reset it to false
after... is this a bug?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seemed odd to me too. I'm not really sure but several functions above this one do the same. self
is unused after this function is called so I think I've preserved behavior.
compiler/rustc_privacy/src/lib.rs
Outdated
check.ty(); | ||
if of_trait { | ||
check.trait_ref(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this pattern could be something like check.impl_header(of_trait)
given that it's being repeated multiple times here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The patterns is repeated once but it's a different function being called. But I could do that to preserve the chaining?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pushed a commit with this.
Replied and added some fixup commits that can be squashed.
Yeah that's fair. I did kinda do that with separate commits except I lumped in some changes to not use opt along with the rename. It seemed silly to do a simple rename that would leave |
Changes
impl_trait_header
to panic on inherent impls intstead of returning None. A few downstream functions are split into option and non-option returning functions. This gets rid of a lot of unwraps where we know we have a trait impl, while there are still some cases where the Option is helpful.Summary of changes to tcx methods:
impl_is_of_trait
(new)impl_trait_header
->impl_trait_header
/impl_opt_trait_header
impl_trait_ref
->impl_trait_ref
/impl_opt_trait_ref
trait_id_of_impl
->impl_trait_id
/impl_opt_trait_id