-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Mark span parent in def_collector. #127241
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
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Mark span parent in def_collector. The current device of marking spans with a parent def-id during lowering has been frustrating me for quite some time, as it's very easy to forget marking some spans. This PR moves such marking to the def_collector, which is responsible for creating def-ids on partially expanded AST. This is much more robust as long as visitors are exhaustive. r? ghost
This comment has been minimized.
This comment has been minimized.
95dc7f7
to
585fe45
Compare
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Mark span parent in def_collector. The current device of marking spans with a parent def-id during lowering has been frustrating me for quite some time, as it's very easy to forget marking some spans. This PR moves such marking to the def_collector, which is responsible for creating def-ids on partially expanded AST. This is much more robust as long as visitors are exhaustive. r? ghost
This comment has been minimized.
This comment has been minimized.
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (04122fb): comparison URL. Overall result: ❌✅ regressions and improvements - 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. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @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)Results (primary 0.3%, secondary -0.7%)This 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.
CyclesResults (primary 0.6%, secondary 3.2%)This 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.
Binary sizeResults (primary -0.2%, secondary -0.2%)This 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.
Bootstrap: 695.108s -> 697.834s (0.39%) |
), | ||
span: p.segments[..proj_start] | ||
.last() | ||
.map_or(path_span_lo, |segment| path_span_lo.to(segment.span())), |
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.
It would appear that half the regression in incr-unchecked comes from Span::to
in this line. The other half comes from using a MutVisitor in DefCollector, which had to be expected.
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 other half comes from using a MutVisitor in DefCollector
I tried to address this in #127371, not sure if it will help.
This comment has been minimized.
This comment has been minimized.
@petrochenkov do I need to add something to this PR to handle metavar spans, or is this pass enough? |
9b82411
to
928d08d
Compare
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Def collector also doesn't enable It would generally make sense to parent token spans in macro definitions, but that's sort of an offtopic for this PR. It would also make sense to parent token spans in macro arguments as well (which we don't do due to #127241 (comment), in addition to |
Due to the comments above, I think both key and value spans in the So probably nothing to do right now. |
Once this work is generally ready it's probably better to split it into multiple parts (in any order)
|
Finished benchmarking commit (83cb4f9): comparison URL. Overall result: ❌✅ regressions and improvements - 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. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @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)Results (primary -1.8%, secondary -3.3%)This 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.
CyclesResults (primary 0.1%, secondary -1.2%)This 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.
Binary sizeResults (primary -0.1%, secondary -0.1%)This 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.
Bootstrap: 697.439s -> 698.541s (0.16%) |
I wonder if it would be possible to assign span parents even earlier, during parsing. That way we'd automatically "visit" everything including tokens in macros, and also avoided mutating AST (if immutable arena-allocated AST is a goal). We'd keep a current parent id in the parser state and update it when recusing into things like items. Upd: if we do this and remove nonterminals (AST pieces inside tokens), then we'd be able to remove |
I don't see how: that would need to assign a parent even before the parent def-id is created. |
Do not call source_span when not tracking dependencies. Split from rust-lang#127241
…enkov Do not call source_span when not tracking dependencies. Split from rust-lang#127241
…enkov Do not call source_span when not tracking dependencies. Split from rust-lang#127241
…enkov Do not call source_span when not tracking dependencies. Split from rust-lang#127241
…enkov Do not call source_span when not tracking dependencies. Split from rust-lang#127241
…enkov Do not call source_span when not tracking dependencies. Split from rust-lang#127241
…enkov Do not call source_span when not tracking dependencies. Split from rust-lang#127241
Do not call source_span when not tracking dependencies. Split from rust-lang/rust#127241
928d08d
to
9159cc6
Compare
@cjgillot do you plan to return to this? |
completely deduplicate `Visitor` and `MutVisitor` r? oli-obk This closes #127615. ### Discussion > * Give every `MutVisitor::visit_*` method a corresponding `flat_map_*` method. Not every AST node exists in a location where they can be mapped to multiple instances of themselves. Not every AST node exists in a location where they can be removed from existence (e.g. `filter_map_expr`). I don't think this is doable. > * Give every `MutVisitor::visit_*` method a corresponding `Visitor` method and vice versa The only three remaining method-level asymmetries after this PR are `visit_stmt` and `visit_nested_use_tree` (only on `Visitor`) and `visit_span` (only on `MutVisitor`). `visit_stmt` doesn't seem applicable to `MutVisitor` because `walk_flat_map_stmt_kind` will ask `flat_map_item` / `filter_map_expr` to potentially turn a single `Stmt` to multiple based on what a visitor wants. So only using `flat_map_stmt` seems appropriate. `visit_nested_use_tree` is used for `rustc_resolve` to track stuff. Not useful for `MutVisitor` for now. `visit_span` is currently not used for `MutVisitor` already, it was just kept in case we want to revive #127241. cc `@cjgillot` maybe we could remove for now and re-insert later if we find a use-case? It does involve some extra effort to maintain. * Remaining FIXMEs `visit_lifetime` has an extra param for `Visitor` that's not in `MutVisitor`. This is again something only used by `rustc_resolve`. I think we can keep that symmetry for now.
The current device of marking spans with a parent def-id during lowering has been frustrating me for quite some time, as it's very easy to forget marking some spans.
This PR moves such marking to the def_collector, which is responsible for creating def-ids on partially expanded AST. This is much more robust as long as visitors are exhaustive.
r? ghost