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
| 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
|
|
||
| use super::prelude::*; | ||
| use crate::session_diagnostics::{self, IncorrectReprFormatGenericCause}; | ||
| use crate::session_diagnostics::{self}; |
There was a problem hiding this comment.
| use crate::session_diagnostics::{self}; | |
| use crate::session_diagnostics; |
| /// Parse #[repr(...)] forms. | ||
| /// | ||
| /// Valid repr contents: any of the primitive integral type names (see | ||
| /// `int_type_of_word`, below) to specify enum discriminant type; `C`, to use |
There was a problem hiding this comment.
int_type_of_word is dangling.
| @@ -1,8 +1,10 @@ | |||
| #### Note: this error code is no longer emitted by the compiler | |||
There was a problem hiding this comment.
Please mention how this now emits another code. Same for the align error code.
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