Move the foreign module #[link] ABI check to attribute parsing - #162373
Move the foreign module #[link] ABI check to attribute parsing#162373hizyyo wants to merge 1 commit into
Conversation
|
Some changes occurred in compiler/rustc_attr_parsing cc @jdonszelmann, @JonathanBrouwer Some changes occurred in compiler/rustc_passes/src/check_attr.rs |
|
Thanks for the pull request, and welcome! The Rust Project has assigned @jieyouxu (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:
|
|
r? me |
|
Hi there, thanks for your contributions and thanks for the LLM disclosure! |
| attrs: &[Attribute], | ||
| target_span: Span, | ||
| target: Target, | ||
| foreign_mod_abi: Option<ExternAbi>, |
There was a problem hiding this comment.
I'm not sure how I like the approach of this approach of passing such specific information into this function. Specifically, I think that approach that this PR takes might also work for this attribute and this doesn't require that. It might make more sense to wait to see for what happens to that PR first
|
@rustbot author |
|
Reminder, once the PR becomes ready for a review, use |
|
I wrote the PR description myself. I made it so detailed because I take this work very seriously, and I wanted to accurately document the behavior. The llm was used only to the extent specified in the disclosure. |
|
I'd prefer if you shortened the PR description a bit, for example the "Validation" is not necessary as we have CI, and it's not really relevant to me how you tested your PR locally. I asked about your AI usage since this is a section that AI models tend to include. More generally, try to limit PR descriptions to a few sentences of "what are you changing", and focus mostly on "why did you take this approach". Anything that I could easily see from reading the code does not need to be in the PR description. I just did some review on #161482 in order to get it moving again, it's your choice whether you change the implementation of this PR now or wait for #161482 to be merged, but I will wait with reviewing this further until #161482 is merged regardless. @rustbot label +S-blocked |
Addresses #153101.
This moves the
#[link]check forextern "Rust"blocks from the late HIR pass inrustc_passesto attribute finalization.The check belongs to attribute validation, but it previously had to wait until HIR because the attribute parser did not know the foreign module's ABI. Instead of storing additional state in the parser or HIR, this change passes the ABI as local context for the current item. The authoritative ABI lowering remains unchanged, including invalid-ABI diagnostics, target validation, and feature gates.
This preserves the existing lint behavior while removing the separate HIR-side check. Regression tests cover the relevant ABI cases, lint levels, multiple
#[link]attributes, and invalid-ABI recovery.LLM disclosure
I proposed the initial approach and developed the main solution collaboratively with an LLM. The LLM helped evaluate the approach against the compiler architecture and review my understanding of the completed changes and their test coverage.
I wrote the implementation and tests myself and independently reviewed the final diff.