Repository navigation
Move check_rustc_must_implement_one_of validation to attribute parser - #163980
darkraider01 wants to merge 1 commit into
Conversation
2828fd1 to
5792ac6
Compare
5792ac6 to
ab04b05
Compare
|
Some changes occurred in compiler/rustc_passes/src/check_attr.rs cc @jdonszelmann, @JonathanBrouwer Some changes occurred in compiler/rustc_attr_parsing |
|
r? @wesleywiser rustbot has assigned @wesleywiser. Use Why was this reviewer chosen?The reviewer was selected based on:
|
| match ctxt { | ||
| visit::AssocCtxt::Trait => { | ||
| self.replace_with_dummy(item, AssocItemKind::MacCall, AstOwner::TraitItem) | ||
| self.insert(item.id, AstOwner::TraitItem(Box::new(item.clone()))); |
There was a problem hiding this comment.
The old replace_with_dummy was replacing the trait items with MacCall placeholders, so finalize_check couldn't actually inspect them through target_item.
This keeps the original items in the trait while still indexing the cloned ones separately for lowering.
The downside is that we're cloning trait items even when the attribute isn't used. I couldn't find a simpler way to reuse the existing infrastructure here, but I'm open to suggestions.
There was a problem hiding this comment.
Edit: (This approach is suggested by llm, since i couldn't come with a better/simplied solution) Maybe another option could be to keep the original trait items only for traits with #[rustc_must_implement_one_of] , and use the existing placeholders everywhere else. That would still involve cloning, but limit it to traits that actually need the check. Not sure how neatly it would fit into the indexer, especially with nested traits, but it might be worth exploring.
There was a problem hiding this comment.
I think both options might be terrible for performance, let's check.
It also just doesn't feel like a great solution, it might be better to just keep the check in rustc_passes if this is needed
There was a problem hiding this comment.
I've started a small experiment here that might make this code nice if perf allows: #164980
I'm not expecting that PR to be accepted tho
There was a problem hiding this comment.
Tried this with #163980 locally and it works without cloning the trait items. I just dropped the cloning hunk and kept your indexer as-is. Thank you!!!
Edit: heres the branch if you'd like to inspect https://github.com/darkraider01/rust/tree/experiment-ast-retention-164980
| _ => { | ||
| cx.emit_err(diagnostics::MustImplementNotFunction { | ||
| span: item.span, | ||
| span_note: diagnostics::MustImplementNotFunctionSpanNote { |
There was a problem hiding this comment.
Keeping delegation as a valid case here since it lowers to TraitFn::Provided, which the old check already accepted.
I added tests for both normal and renamed delegation as well.
| panic!("expected trait AST target item for Target::Trait"); | ||
| }; | ||
|
|
||
| let fn_names = |
There was a problem hiding this comment.
Kept the full Ident comparison here rather than just matching names, since the old check did the same.
Added a couple of macro tests to make sure the hygiene behavior stays the same.
This comment was marked as outdated.
This comment was marked as outdated.
|
r? me |
This comment has been minimized.
This comment has been minimized.
ab04b05 to
73ccfeb
Compare
This comment has been minimized.
This comment has been minimized.
|
(Sorry for taking so long to review this, I've been away for a bit due to conferences and illness, I should get to this in a day or two) |
This comment has been minimized.
This comment has been minimized.
73ccfeb to
46ce4af
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
@bors try @rust-timer queuee |
|
Unknown rust-timer command: queuee |
|
@rust-timer queue |
This comment has been minimized.
This comment has been minimized.
…oundary, r=<try> Move check_rustc_must_implement_one_of validation to attribute parser
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (b1e6bae): comparison URL. Overall result: ❌✅ regressions and improvements - please read:Benchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up. Next, please: If you can, justify the regressions found in this try perf run in writing along with @bors rollup=iffy rustc-perf Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 0.3%, secondary 0.5%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary -0.5%, secondary -0.5%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary 0.1%, secondary 0.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 488.092s -> 488.8s (0.15%) |
|
The |
View all comments
Part of #153101 and #131229.
Moves the remaining
rustc_must_implement_one_ofvalidation fromrustc_passes::check_attrintoRustcMustImplementOneOfParser::finalize_checkusing AST trait information available throughFinalizeCheckContext::target_item.The duplicate-name validation was already migrated in #160412. This completes the remaining associated-item and default-implementation checks.
Related: #153101, #131229, #160412