Rewrite the #[repr] attribute parser#157125
Conversation
|
Some changes occurred in compiler/rustc_attr_parsing |
| cx.adcx().expected_specific_argument( | ||
| param.span(), | ||
| &[ | ||
| sym::align, |
There was a problem hiding this comment.
One thing that still annoys me is that in a lot of attribute parsers have these match statements, and then we need to list all branches of the match statement again for the expected_specific_argument error
There was a problem hiding this comment.
I'd like a solution where these symbols are only listed once.
Maybe make an array of [(Symbol, constructor); _] (or maybe [(Symbol, checker, constructor); _]) and if you don't find the symbol in the array, do something like array.iter().map(|x|x.0).collect() and pass that to expected_specific_argument.
See
rust/compiler/rustc_resolve/src/macros.rs
Line 716 in 6368fd5
There was a problem hiding this comment.
(let's leave this for a separate PR tho, since this affects more places that I'd like to fix at the same time)
| cx.adcx().expected_specific_argument( | ||
| param.span(), | ||
| &[ | ||
| sym::align, |
There was a problem hiding this comment.
I'd like a solution where these symbols are only listed once.
Maybe make an array of [(Symbol, constructor); _] (or maybe [(Symbol, checker, constructor); _]) and if you don't find the symbol in the array, do something like array.iter().map(|x|x.0).collect() and pass that to expected_specific_argument.
See
rust/compiler/rustc_resolve/src/macros.rs
Line 716 in 6368fd5
|
Does this conflict with #157036 ? |
f4e215b to
7aef596
Compare
The
#[repr]attribute parser was one of the first attribute parsers we made, and didn't use a lot of the awesome infra we have nowadays yet, so in preparation for a new approach I'm trying for #156569 I decided to clean it up.This PR should have no observable effect other than improved diagnostic messages.
r? @mejrs