-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
rustc: Panic by default in DefIdTree::parent
#96431
Conversation
Some changes occurred in src/tools/clippy. cc @rust-lang/clippy |
r? @fee1-dead (rust-highfive has picked a reviewer for you, use r? to override) |
@@ -1105,7 +1105,8 @@ impl<'a> AsMut<Resolver<'a>> for Resolver<'a> { | |||
} | |||
|
|||
impl<'a, 'b> DefIdTree for &'a Resolver<'b> { | |||
fn parent(self, id: DefId) -> Option<DefId> { | |||
#[inline] |
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.
Does the use of #[inline]
here actually improve perf?
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 guess we could start with a perf run on this PR first. I don't know if I would be available when CI passes. Could you initiate a perf run? Thanks.
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.
Looks like it does not - #96431 (comment).
I added these mostly for completeness, together with the default methods on DefIdTree
.
All of these functions may convert DefId
to LocalDefId
and back multiple times, so it would be good if all of these conversions disappeared in the end.
@bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit 74cd66d8a52cd4368ae5bb7b5ab49f589094cfdf with merge 014631e3348b61e1086e3923458a7225d9663b97... |
☀️ Try build successful - checks-actions |
Queued 014631e3348b61e1086e3923458a7225d9663b97 with parent d6a57d3, future comparison URL. |
Finished benchmarking commit (014631e3348b61e1086e3923458a7225d9663b97): comparison url. Summary: This benchmark run did not return any relevant results. If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. @bors rollup=never |
// needed in case this is a ctor, not a variant | ||
|| parent.map_or(false, |parent| tcx.parent(parent) == atomic_ordering) | ||
|| tcx.opt_parent(parent) == atomic_ordering |
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 is a bit weird since atomic_ordering could be None
, which could return true
accidentally I think? Anyways this is an existing logic bug. I hope no_core
has an actual purpose otherwise fixing this feels useless..
r? rust-lang/compiler |
r? rust-lang/compiler |
r? @cjgillot |
Heh, I was just about to take a look. Thanks for taking over @cjgillot! |
Only crate root def-ids don't have a parent, and in majority of cases the argument of `DefIdTree::parent` cannot be a crate root. So we now panic by default in `parent` and introduce a new non-panicing function `opt_parent` for cases where the argument can be a crate root. Same applies to `local_parent`/`opt_local_parent`.
@bors r=cjgillot |
📌 Commit 5b5964f has been approved by |
⌛ Testing commit 5b5964f with merge f1e60edc527525412e3fcb9f58916f8e22bc8cfc... |
💔 Test failed - checks-actions |
Timeout on dist-aarch64-apple. |
@bors rollup=maybe |
☀️ Test successful - checks-actions |
Finished benchmarking commit (879fb42): comparison url. Summary:
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. @rustbot label: -perf-regression Footnotes |
Only crate root def-ids don't have a parent, and in majority of cases the argument of
DefIdTree::parent
cannot be a crate root.So we now panic by default in
parent
and introduce a new non-panicing functionopt_parent
for cases where the argument can be a crate root.Same applies to
local_parent
/opt_local_parent
.