Skip to content
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

Merged
merged 1 commit into from
May 2, 2022

Conversation

petrochenkov
Copy link
Contributor

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.

@rust-highfive
Copy link
Collaborator

Some changes occurred in src/tools/clippy.

cc @rust-lang/clippy

@rustbot rustbot added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Apr 26, 2022
@rust-highfive
Copy link
Collaborator

r? @fee1-dead

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 26, 2022
@@ -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]
Copy link
Member

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?

Copy link
Member

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.

Copy link
Contributor Author

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.

@petrochenkov
Copy link
Contributor Author

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Apr 26, 2022
@bors
Copy link
Contributor

bors commented Apr 26, 2022

⌛ Trying commit 74cd66d8a52cd4368ae5bb7b5ab49f589094cfdf with merge 014631e3348b61e1086e3923458a7225d9663b97...

@bors
Copy link
Contributor

bors commented Apr 26, 2022

☀️ Try build successful - checks-actions
Build commit: 014631e3348b61e1086e3923458a7225d9663b97 (014631e3348b61e1086e3923458a7225d9663b97)

@rust-timer
Copy link
Collaborator

Queued 014631e3348b61e1086e3923458a7225d9663b97 with parent d6a57d3, future comparison URL.

@rust-timer
Copy link
Collaborator

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
@rustbot label: +S-waiting-on-review -S-waiting-on-perf -perf-regression

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Apr 26, 2022
// 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
Copy link
Member

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..

@fee1-dead
Copy link
Member

r? rust-lang/compiler

rust-lang/highfive#399

@fee1-dead
Copy link
Member

r? rust-lang/compiler

@rust-highfive rust-highfive assigned nagisa and unassigned fee1-dead Apr 28, 2022
@cjgillot
Copy link
Contributor

cjgillot commented May 1, 2022

r? @cjgillot
r=me after rebase

@rust-highfive rust-highfive assigned cjgillot and unassigned nagisa May 1, 2022
@nagisa
Copy link
Member

nagisa commented May 1, 2022

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`.
@petrochenkov
Copy link
Contributor Author

@bors r=cjgillot

@bors
Copy link
Contributor

bors commented May 1, 2022

📌 Commit 5b5964f has been approved by cjgillot

@bors bors removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 1, 2022
@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label May 1, 2022
@bors
Copy link
Contributor

bors commented May 2, 2022

⌛ Testing commit 5b5964f with merge f1e60edc527525412e3fcb9f58916f8e22bc8cfc...

@rust-log-analyzer
Copy link
Collaborator

A job failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

@bors
Copy link
Contributor

bors commented May 2, 2022

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels May 2, 2022
@petrochenkov
Copy link
Contributor Author

Timeout on dist-aarch64-apple.
@bors retry

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 2, 2022
@petrochenkov
Copy link
Contributor Author

@bors rollup=maybe

@bors
Copy link
Contributor

bors commented May 2, 2022

⌛ Testing commit 5b5964f with merge 879fb42...

@bors
Copy link
Contributor

bors commented May 2, 2022

☀️ Test successful - checks-actions
Approved by: cjgillot
Pushing 879fb42 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label May 2, 2022
@bors bors merged commit 879fb42 into rust-lang:master May 2, 2022
@rustbot rustbot added this to the 1.62.0 milestone May 2, 2022
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (879fb42): comparison url.

Summary:

  • Primary benchmarks: 🎉 relevant improvement found
  • Secondary benchmarks: no relevant changes found
Regressions 😿
(primary)
Regressions 😿
(secondary)
Improvements 🎉
(primary)
Improvements 🎉
(secondary)
All 😿 🎉
(primary)
count1 0 0 1 0 1
mean2 N/A N/A -0.8% N/A -0.8%
max N/A N/A -0.8% N/A -0.8%

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

@rustbot label: -perf-regression

Footnotes

  1. number of relevant changes

  2. the arithmetic mean of the percent change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants