Move #[naked] attribute check to attribute parsing stage - #162530
Move #[naked] attribute check to attribute parsing stage#162530RichardTjokroutomo wants to merge 2 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.
| }; | ||
|
|
||
| let ItemKind::Fn(fn_item) = &item.kind else { | ||
| return; |
There was a problem hiding this comment.
This should never fail right? So please make this panic
There was a problem hiding this comment.
After implementing panic, through the failing CI I just found out that methods defined under traits & impls are represented as associated item instead of normal item.... lucky...
| MethodKind::Trait { body: true } | MethodKind::TraitImpl | MethodKind::Inherent, | ||
| ) => { | ||
| let Some(item) = cx.target_item else { | ||
| return; |
There was a problem hiding this comment.
same with this
| /// - support unwinding with `-Cpanic=unwind`, unlike `extern "C"` | ||
| /// - often diverge from the C ABI | ||
| /// - are subject to change between compiler versions | ||
| pub fn is_rustic_abi(self) -> bool { |
There was a problem hiding this comment.
Can we avoid duplicating this logic?
Perhaps by parsing the abi into a ExternAbi instead?
There was a problem hiding this comment.
I don't think we can. I originally tried to convert it to ExternAbi, but I couldn't compile as it creates circular dependency (haven't checked deeper as to why, though).
Then I saw similar check for CanonAbi, and I thought since the logic is already duplicated elsewhere, perhaps I can also add similar method to Extern.
| target_span: Span, | ||
| target_hir_id: HirId, | ||
| target: Target, | ||
| target_item: Option<&ast::Item>, |
|
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.
Signed-off-by: Richard Tjokroutomo <richard.tjokro2@gmail.com>
7e93b9a to
cdc980c
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. |
cdc980c to
4fbadae
Compare
This comment has been minimized.
This comment has been minimized.
4fbadae to
f731dff
Compare
This comment has been minimized.
This comment has been minimized.
f731dff to
43761f2
Compare
This comment has been minimized.
This comment has been minimized.
7afc73b to
07f3466
Compare
This comment has been minimized.
This comment has been minimized.
Signed-off-by: Richard Tjokroutomo <richard.tjokro2@gmail.com>
07f3466 to
404d6fd
Compare
|
@rustbot ready |
View all comments
Following #161482's idea to add
target_itemfield toFinalizeCheckContext, addtarget_associated_itemas an additional field. Lastly, movecheck_nakedto the callback returned byNakedParser::deferred_finalize_check().Part of #153101. r?@JonathanBrouwer
LLM disclosure: I wrote the code by hand & took inspiration from #161482. However, I did use LLM to learn how attribute checking is done in Rustc.