-
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
Remove HirId -> LocalDefId map from HIR. #107206
Conversation
(rustbot has picked a reviewer for you, use r? to override) |
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt Some changes occurred in engine.rs, potentially modifying the public API of Some changes occurred in src/tools/clippy cc @rust-lang/clippy Some changes occurred in src/librustdoc/clean/types.rs cc @camelid |
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
⌛ Trying commit d67bc5ba7e09381171f0029586e4e5cae885132e with merge 2d52b6d10b72a07b2ac1932319805ec304591e33... |
This comment has been minimized.
This comment has been minimized.
☀️ Try build successful - checks-actions |
1 similar comment
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (2d52b6d10b72a07b2ac1932319805ec304591e33): 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.
CyclesResultsThis 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.
|
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'm not sure what the implications of using different IDs are, but generally looks good to me (especially the perf improvement 👀 ).
r=me after #103902 gets merged, this is rebased on top of master and associated type defaults are removed.
P.S. sorry for so many nits .-.
@@ -96,14 +96,14 @@ impl<'a, 'tcx> Autoderef<'a, 'tcx> { | |||
pub fn new( | |||
infcx: &'a InferCtxt<'tcx>, | |||
param_env: ty::ParamEnv<'tcx>, | |||
body_id: hir::HirId, | |||
body_def_id: LocalDefId, |
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 use the same name as the field (body_id
)?
let closure = expr_or_init(cx, map_arg); | ||
if let Some(def_id) = cx.tcx.hir().opt_local_def_id(closure.hir_id); | ||
if let Some(body_id) = cx.tcx.hir().maybe_body_owned_by(def_id); | ||
let closure_body = cx.tcx.hir().body(body_id); | ||
if let hir::ExprKind::Closure(closure) = closure.kind; |
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 merge this with the prev statement?
if let hir::ExprKind::Closure(closure) = expr_or_init(cx, map_arg).kind;
@@ -2305,10 +2300,12 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> { | |||
predicate.to_opt_poly_trait_pred().unwrap(), | |||
); | |||
if impl_candidates.len() < 10 { | |||
let 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.
hir_id
?
sym::ItemContext, | ||
self.describe_enclosure(obligation.cause.body_id).map(|s| s.to_owned()), | ||
)]; | ||
let body_hir = self.tcx.hir().local_def_id_to_hir_id(obligation.cause.body_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.
body_hir_id
?
@@ -535,8 +535,8 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { | |||
|
|||
// FIXME: Add check for trait bound that is already present, particularly `?Sized` so we | |||
// don't suggest `T: Sized + ?Sized`. | |||
let mut hir_id = body_id; | |||
while let Some(node) = self.tcx.hir().find(hir_id) { | |||
let mut body_id = body_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.
This can be removed in favor of mut body_id: LocalDefId
in the param list.
@@ -1593,7 +1590,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { | |||
else { return }; | |||
|
|||
let map = self.infcx.tcx.hir(); | |||
let body = map.body(rustc_hir::BodyId { hir_id: self.body_id }); | |||
let body_hir = self.tcx.hir().body_owned_by(self.body_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.
body_hir_id
?
// it's an actual definition. According to the comments (e.g. in | ||
// rustc_hir_analysis/check/compare_impl_item.rs:compare_predicate_entailment) the latter | ||
// is relied upon by some other code. This might (or might not) need cleanup. |
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.
Do the comments mentioned here need an update too?
if sig.header.abi != Abi::Rust && cx.sess().contains_name(attrs, sym::no_mangle) | ||
if sig.header.abi != Abi::Rust | ||
&& cx.tcx.has_attr(id.to_def_id(), sym::no_mangle) |
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.
Is has_attr
better than contains_name
?
compiler/rustc_privacy/src/lib.rs
Outdated
.into_iter() | ||
.filter_map(|hir_id| tcx.hir().opt_local_def_id(hir_id)) | ||
.collect(), | ||
old_error_set_ancestry: old_error_set_ancestry, |
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.
old_error_set_ancestry: old_error_set_ancestry, | |
old_error_set_ancestry, |
@@ -3,6 +3,7 @@ | |||
#![recursion_limit = "256"] | |||
#![allow(rustc::potential_query_instability)] | |||
#![feature(never_type)] | |||
#![feature(associated_type_defaults)] |
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.
Please do not use associated type defaults, r-a chokes on them, rust-lang/rust-analyzer#13693.
ac30163
to
b0fc662
Compare
@bors r=WaffleLapkin |
📌 Commit b0fc662bed3d016b200868b80c1d0cfecbc55dcd has been approved by It is now in the queue for this repository. |
☔ The latest upstream changes (presumably #107343) made this pull request unmergeable. Please resolve the merge conflicts. |
☔ The latest upstream changes (presumably #107386) made this pull request unmergeable. Please resolve the merge conflicts. |
@bors r=WaffleLapkin |
☀️ Test successful - checks-actions |
Finished benchmarking commit (d6f0642): 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. |
The (small) improvements outweigh the (small) regressions. @rustbot label: +perf-regression-triaged |
Upgrade the Rust toolchain to 'nightly-2023-02-01' <!-- Please describe your changes on the following line: --> This change should address the failing nightly [rustc test jobs](https://github.com/servo/servo/actions/workflows/nightly-rust.yml) For reference, these are the [relevant](rust-lang/rust#107206) [PRs](rust-lang/rust#104170) in rustc that I could find. Signed-off-by: Mukilan Thiyagarajan <mukilanthiagarajan@gmail.com> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [ ] These changes fix #___ (GitHub issue number if applicable) <!-- Either: --> - [ ] There are tests for these changes OR - [X] These changes do not require tests because there are existing unit tests for script_plugins that do pass. <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Upgrade the Rust toolchain to 'nightly-2023-02-01' <!-- Please describe your changes on the following line: --> This change should address the failing nightly [rustc test jobs](https://github.com/servo/servo/actions/workflows/nightly-rust.yml) For reference, these are the [relevant](rust-lang/rust#107206) [PRs](rust-lang/rust#104170) in rustc that I could find. Signed-off-by: Mukilan Thiyagarajan <mukilanthiagarajan@gmail.com> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [ ] These changes fix #___ (GitHub issue number if applicable) <!-- Either: --> - [ ] There are tests for these changes OR - [X] These changes do not require tests because there are existing unit tests for script_plugins that do pass. <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Remove HirId -> LocalDefId map from HIR. Having this map in HIR prevents the creating of new definitions after HIR has been built. Thankfully, we do not need it. Based on rust-lang#103902
Having this map in HIR prevents the creating of new definitions after HIR has been built.
Thankfully, we do not need it.
Based on #103902