-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Fix several ICEs related to malformed #[repr(...)]
attributes
#87013
Conversation
r? @estebank (rust-highfive has picked a reviewer for you, use r? to override) |
let mut err = struct_span_err!( | ||
diagnostic, | ||
item.span(), | ||
E0589, | ||
"invalid `repr(align)` attribute: `align` needs an argument" | ||
); | ||
err.span_suggestion( | ||
item.span(), | ||
"supply an argument here", | ||
"align(...)".to_string(), | ||
Applicability::HasPlaceholders, | ||
); | ||
err.emit(); |
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.
Because you have no conditional changes on the diagnostic, you can rely on chaining instead:
let mut err = struct_span_err!( | |
diagnostic, | |
item.span(), | |
E0589, | |
"invalid `repr(align)` attribute: `align` needs an argument" | |
); | |
err.span_suggestion( | |
item.span(), | |
"supply an argument here", | |
"align(...)".to_string(), | |
Applicability::HasPlaceholders, | |
); | |
err.emit(); | |
struct_span_err!( | |
diagnostic, | |
item.span(), | |
E0589, | |
"invalid `repr(align)` attribute: `align` needs an argument" | |
).span_suggestion( | |
item.span(), | |
"supply an argument here", | |
"align(...)".to_string(), | |
Applicability::HasPlaceholders, | |
).emit(); |
(Might need to run ./x.py fmt
to fix the formatting here)
@bors r+ |
📌 Commit a7bfd35 has been approved by |
Rollup of 5 pull requests Successful merges: - rust-lang#87006 (Revert the revert of renaming traits::VTable to ImplSource) - rust-lang#87011 (avoid reentrant lock acquire when ThreadIds run out) - rust-lang#87013 (Fix several ICEs related to malformed `#[repr(...)]` attributes) - rust-lang#87020 (remove const_raw_ptr_to_usize_cast feature) - rust-lang#87028 (Fix type: `'satic` -> `'static`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This PR fixes #83921. #83921 actually contains two related but distinct issues (one of them incorrectly reported as a duplicate in #83921 (comment)):
In the first, a call to
delay_span_bug
leads to an ICE when compiling with-Zunpretty=everybody_loops
(and some other pretty-printing modes), because the corresponding error is emitted in a later pass, which does not run when only pretty-printing is requested.The second issue is about parsing
#[repr(...)]
attributes. Currently, all of the following cause an ICE when applied to a struct/enum:I have fixed this by expanding the well-formedness checks in
find_repr_attrs()
.