add list of recognized repr attributes to the unrecognized repr error
This commit is contained in:
parent
9ba169a73a
commit
ad275f5096
@ -1040,18 +1040,16 @@ pub fn parse_repr_attr(sess: &Session, attr: &Attribute) -> Vec<ReprAttr> {
|
||||
&name,
|
||||
),
|
||||
});
|
||||
} else {
|
||||
if matches!(
|
||||
meta_item.name_or_empty(),
|
||||
sym::C | sym::simd | sym::transparent
|
||||
) || int_type_of_word(meta_item.name_or_empty()).is_some()
|
||||
{
|
||||
recognised = true;
|
||||
sess.emit_err(session_diagnostics::InvalidReprHintNoValue {
|
||||
span: meta_item.span,
|
||||
name: meta_item.name_or_empty().to_ident_string(),
|
||||
});
|
||||
}
|
||||
} else if matches!(
|
||||
meta_item.name_or_empty(),
|
||||
sym::C | sym::simd | sym::transparent
|
||||
) || int_type_of_word(meta_item.name_or_empty()).is_some()
|
||||
{
|
||||
recognised = true;
|
||||
sess.emit_err(session_diagnostics::InvalidReprHintNoValue {
|
||||
span: meta_item.span,
|
||||
name: meta_item.name_or_empty().to_ident_string(),
|
||||
});
|
||||
}
|
||||
} else if let MetaItemKind::List(_) = meta_item.kind {
|
||||
if meta_item.has_name(sym::align) {
|
||||
|
@ -1658,6 +1658,7 @@ impl CheckAttrVisitor<'_> {
|
||||
E0552,
|
||||
"unrecognized representation hint"
|
||||
)
|
||||
.help("valid reprs are `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize`")
|
||||
.emit();
|
||||
|
||||
continue;
|
||||
|
@ -31,12 +31,16 @@ error[E0552]: unrecognized representation hint
|
||||
|
|
||||
LL | #[repr(nothing)]
|
||||
| ^^^^^^^
|
||||
|
|
||||
= help: valid reprs are `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize`
|
||||
|
||||
error[E0552]: unrecognized representation hint
|
||||
--> $DIR/issue-43988.rs:18:12
|
||||
|
|
||||
LL | #[repr(something_not_real)]
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: valid reprs are `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize`
|
||||
|
||||
error[E0518]: attribute should be applied to function or closure
|
||||
--> $DIR/issue-43988.rs:30:5
|
||||
|
17
src/test/ui/repr/invalid_repr_list_help.rs
Normal file
17
src/test/ui/repr/invalid_repr_list_help.rs
Normal file
@ -0,0 +1,17 @@
|
||||
#![crate_type = "lib"]
|
||||
|
||||
#[repr(uwu)] //~ERROR: unrecognized representation hint
|
||||
pub struct OwO;
|
||||
|
||||
#[repr(uwu = "a")] //~ERROR: unrecognized representation hint
|
||||
pub struct OwO2(i32);
|
||||
|
||||
#[repr(uwu(4))] //~ERROR: unrecognized representation hint
|
||||
pub struct OwO3 {
|
||||
x: i32,
|
||||
}
|
||||
|
||||
#[repr(uwu, u8)] //~ERROR: unrecognized representation hint
|
||||
pub enum OwO4 {
|
||||
UwU = 1,
|
||||
}
|
35
src/test/ui/repr/invalid_repr_list_help.stderr
Normal file
35
src/test/ui/repr/invalid_repr_list_help.stderr
Normal file
@ -0,0 +1,35 @@
|
||||
error[E0552]: unrecognized representation hint
|
||||
--> $DIR/invalid_repr_list_help.rs:3:8
|
||||
|
|
||||
LL | #[repr(uwu)]
|
||||
| ^^^
|
||||
|
|
||||
= help: valid reprs are `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize`
|
||||
|
||||
error[E0552]: unrecognized representation hint
|
||||
--> $DIR/invalid_repr_list_help.rs:6:8
|
||||
|
|
||||
LL | #[repr(uwu = "a")]
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= help: valid reprs are `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize`
|
||||
|
||||
error[E0552]: unrecognized representation hint
|
||||
--> $DIR/invalid_repr_list_help.rs:9:8
|
||||
|
|
||||
LL | #[repr(uwu(4))]
|
||||
| ^^^^^^
|
||||
|
|
||||
= help: valid reprs are `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize`
|
||||
|
||||
error[E0552]: unrecognized representation hint
|
||||
--> $DIR/invalid_repr_list_help.rs:14:8
|
||||
|
|
||||
LL | #[repr(uwu, u8)]
|
||||
| ^^^
|
||||
|
|
||||
= help: valid reprs are `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0552`.
|
Loading…
x
Reference in New Issue
Block a user