-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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: Make def_kind
mandatory for all DefId
s
#118250
Conversation
r? @TaKO8Ki (rustbot has picked a reviewer for you, use r? to override) |
Some changes occurred in src/tools/clippy cc @rust-lang/clippy |
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
rustc: Make `def_kind` mandatory for all `DefId`s Prerequisite for rust-lang#118188.
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
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.
👍 like this a lot. a few comments (and i know perf is running)
@@ -895,7 +891,7 @@ impl<'hir> Map<'hir> { | |||
|
|||
#[inline] | |||
fn opt_ident(self, id: HirId) -> Option<Ident> { | |||
match self.get(id) { | |||
match self.find(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.
What codepath triggers this specifically? Just curious.
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.
def_span
for anonymous constants without HIR.
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.
Should we keep a FIXME here too?
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.
HirId
s do not always have HIR nodes or Ident
s, so the new behavior looks reasonable to me, we just didn't hit this case before.
Finished benchmarking commit (f86037d): comparison URL. Overall result: ✅ improvements - no action neededBenchmarking 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 Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 674.644s -> 675.592s (0.14%) |
@@ -1393,7 +1392,13 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { | |||
if should_encode_fn_sig(def_kind) { | |||
record!(self.tables.fn_sig[def_id] <- tcx.fn_sig(def_id)); | |||
} | |||
if should_encode_generics(def_kind) { | |||
// FIXME: Some anonymous constants produced by `#[rustc_legacy_const_generics]` |
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.
Should we give them a dummy hir node to avoid those ices?
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.
Maybe, I just didn't want to get into that in this PR, #118188 is not blocked on it.
I tried to look what exactly happens with rustc_legacy_const_generics
, but it's still not clear to me.
There seems to be some mismatch between what def collector and AST lowering do.
@@ -895,7 +891,7 @@ impl<'hir> Map<'hir> { | |||
|
|||
#[inline] | |||
fn opt_ident(self, id: HirId) -> Option<Ident> { | |||
match self.get(id) { | |||
match self.find(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.
Should we keep a FIXME here too?
331df84
to
2c23386
Compare
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.
r=me unless you want another round of review from cjgillot
@bors r=compiler-errors |
☀️ Test successful - checks-actions |
Finished benchmarking commit (5c97719): comparison URL. Overall result: ❌✅ regressions and improvements - ACTION NEEDEDNext Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 674.797s -> 672.47s (-0.34%) |
If anything, this looks like a tiny performance win. @rustbot label: +perf-regression-triaged |
resolve: Feed the `def_kind` query immediately on `DefId` creation Before this PR the def kind query required building HIR for no good reason, with this PR def kinds are instead assigned immediately when `DefId`s are created. Some PRs previously refactored things to make all def kinds to be available early enough - rust-lang#118250, rust-lang#118272, rust-lang#118311.
…errors rustc: Make `def_kind` mandatory for all `DefId`s Prerequisite for rust-lang#118188.
Prerequisite for #118188.