Repository navigation
Move #[naked] attribute check to attribute parsing stage - #162530
RichardTjokroutomo wants to merge 13 commits into
Conversation
|
Some changes occurred in compiler/rustc_passes/src/check_attr.rs cc @jdonszelmann, @JonathanBrouwer Some changes occurred in compiler/rustc_attr_parsing |
|
Thanks for the pull request, and welcome! The Rust Project has assigned @nnethercote (or someone else) to review your changes, you should hear from them (or someone else) within the next two weeks. Please see the contribution instructions and our LLM policy for more information. Why was this reviewer chosen?The reviewer was selected based on:
|
57ae8f4 to
c65aa6f
Compare
This comment has been minimized.
This comment has been minimized.
c65aa6f to
4c2e629
Compare
This comment has been minimized.
This comment has been minimized.
4c2e629 to
ee7a87a
Compare
ee7a87a to
9d144c2
Compare
This comment has been minimized.
This comment has been minimized.
|
Reminder, once the PR becomes ready for a review, use |
9d144c2 to
7e93b9a
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
7e93b9a to
cdc980c
Compare
This comment has been minimized.
This comment has been minimized.
cdc980c to
4fbadae
Compare
2d331a2 to
566fa74
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. |
|
I just read the LLM guidelines and found out disclosure is needed only if a part of the PR (code, PR desc, etc) is generated by LLM. Since I only use it to learn the codebase, I'll remove the disclosure. |
| WherePredicate(&'a WherePredicate), | ||
|
|
||
| /// Used when it is not possible to get detailed information about the target. | ||
| None, |
There was a problem hiding this comment.
Yeah that makes sense, we can have a 'AstTarget::None` for this case then to keep things simple
Yeah as long as reviewers are not seeing any AI generated output you don't need to disclose. |
Signed-off-by: Richard Tjokroutomo <richard.tjokro2@gmail.com>
566fa74 to
f12bf6b
Compare
| &l.attrs, | ||
| l.span, | ||
| Target::Statement, | ||
| rustc_attr_ir::target::AstTarget::None, |
There was a problem hiding this comment.
Why can't this be AstTarget::Statement?
There was a problem hiding this comment.
Sorry... should've checked the caller function
| &attrs, | ||
| span, | ||
| Target::Expression, | ||
| rustc_attr_ir::target::AstTarget::None, |
There was a problem hiding this comment.
Why can't this be AstTarget::Expression?
There was a problem hiding this comment.
I didn't check caller functions, sorry....
| ¶m.attrs, | ||
| param.span, | ||
| Target::Param, | ||
| AstTarget::None, |
There was a problem hiding this comment.
Why can't this be AstTarget::Pram?
There was a problem hiding this comment.
Sorry... I was being careless..
| &f.attrs, | ||
| f.span, | ||
| Target::ExprField, | ||
| AstTarget::Expression(expr), |
There was a problem hiding this comment.
I don't think this is correct
| #[derive(Clone, Copy, Debug)] | ||
| pub enum AstTarget<'a> { | ||
| // Target types that may correspond to different kinds of items. | ||
| Delegation { target: DelegationAstTarget<'a>, mac: bool }, |
There was a problem hiding this comment.
Also here I'm leaning towards that we don't need the fields of this, and it adds a lot of complexity
| pub fn from_ast_item(kind: &'a ast::ItemKind) -> Self { | ||
| match kind { | ||
| ast::ItemKind::ExternCrate(..) => AstTarget::ExternCrate(kind), | ||
| ast::ItemKind::Use(..) => AstTarget::Use(kind), |
There was a problem hiding this comment.
I'd prefer if we map each ItemKind to its field where reasonable.
Like have AstTarget::Use take a UseTree rather than a ast::ItemKind.
| Union(&'a ItemKind), | ||
| Trait(&'a ItemKind), | ||
| TraitAlias(&'a ItemKind), | ||
| Impl { item: &'a ItemKind, of_trait: bool }, |
There was a problem hiding this comment.
Do we need this of_trait field? That should already be stored in the Impl right?
There was a problem hiding this comment.
yeah. It's irrelevant now after the most recent commit
f12bf6b to
4280fe0
Compare
Signed-off-by: Richard Tjokroutomo <richard.tjokro2@gmail.com>
4280fe0 to
b567ca0
Compare
Signed-off-by: Richard Tjokroutomo <richard.tjokro2@gmail.com>
|
@JonathanBrouwer I think everything is correct now. Let's just wait for CI results... Previously there were a lot of changes when making |
|
@rustbot ready |
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| Closure(&'a Closure), | ||
| Expression(&'a Expr), | ||
| ForLoop(&'a ForLoop), | ||
| Loop, |
There was a problem hiding this comment.
Are these targets (ForLoop, Loop, While, Break) ever produced?
If not lets remove them, and accept that this is a mismatch with Target
There was a problem hiding this comment.
Could you also check for the other AstTargets if they're used?
There was a problem hiding this comment.
If not lets remove them, and accept that this is a mismatch with
Target
So we won't be replacing Target with AstTarget?
For now, there's only one case where we absolutely need AstTarget::None, and I think it is possible to replace it since AstTarget::MacroCall no longer carry detailed info of the AST target.
I also think that we can remove the fields of the enum types that we don't need (e.g. ForLoop), so we can still replace Target with AstTarget in the future. Just my thoughts though. I'm fine with removing them.
Could you also check for the other
AstTargets if they're used?
Most are unused. They were only added since we wanted to make AstTarget map 1-1 with Target.
Edit: turns out not that many.
There was a problem hiding this comment.
For now, I'm gonna go ahead with your suggestion and remove all unused AstTarget types on a new commit. If you have different thoughts we can always hard reset to previous commit :)
| Field(&'a FieldDef), | ||
| GenericParam(&'a GenericParam), | ||
| LifetimeParam(&'a GenericParam), | ||
| Local(&'a Local), |
There was a problem hiding this comment.
Is Local still used?
There was a problem hiding this comment.
No. It's only there to make 1-1 matching
| ExternAbi::Rust | ||
| }) | ||
| }); | ||
| abi.symbol_unescaped.as_str().parse().unwrap_or_else(|_| { |
There was a problem hiding this comment.
What happened to the indent here?
It would be nice if you could self-review (go through the diff of the PR) your changes to at least catch these kind of things, before submitting it for review
There was a problem hiding this comment.
Oops.
Sorry, I thought the CI tests everything including tidiness, so I assumed if all checks pass then everything is good.
| target_span, | ||
| target, | ||
| None, | ||
| rustc_attr_ir::target::AstTarget::None, |
There was a problem hiding this comment.
nit: I'd prefer if everywhere (not just here) we could import AstTarget and make this AstTarget::None
(don't import the variants)
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (b2e91b7): comparison URL. Overall result: no relevant changes - no action neededBenchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up. @rustbot label: -S-waiting-on-perf -perf-regression Instruction countThis perf run didn't have relevant results for this metric. Max RSS (memory usage)This perf run didn't have relevant results for this metric. CyclesResults (secondary 2.7%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: 490.84s -> 489.964s (-0.18%) |
Signed-off-by: Richard Tjokroutomo <richard.tjokro2@gmail.com>
Signed-off-by: Richard Tjokroutomo <richard.tjokro2@gmail.com>
|
@rustbot ready |
View all comments
Following #161482's idea to add
target_itemfield toFinalizeCheckContext, replacetarget_itemwithast_target, which is anenumthat contains all possible types of target Item (obtained by grepping all functions that calllower_attrs()).This change is needed as methods defined under
traits &impls are represented asast::AssocItem. Lastly, movecheck_nakedto the callback returned byNakedParser::deferred_finalize_check().Part of #153101. r?@JonathanBrouwer