add list of recognized repr attributes to the unrecognized repr error
This commit is contained in:
parent
9ba169a73a
commit
ad275f5096
5 changed files with 67 additions and 12 deletions
|
@ -1040,18 +1040,16 @@ pub fn parse_repr_attr(sess: &Session, attr: &Attribute) -> Vec<ReprAttr> {
|
||||||
&name,
|
&name,
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
} else {
|
} else if matches!(
|
||||||
if matches!(
|
meta_item.name_or_empty(),
|
||||||
meta_item.name_or_empty(),
|
sym::C | sym::simd | sym::transparent
|
||||||
sym::C | sym::simd | sym::transparent
|
) || int_type_of_word(meta_item.name_or_empty()).is_some()
|
||||||
) || int_type_of_word(meta_item.name_or_empty()).is_some()
|
{
|
||||||
{
|
recognised = true;
|
||||||
recognised = true;
|
sess.emit_err(session_diagnostics::InvalidReprHintNoValue {
|
||||||
sess.emit_err(session_diagnostics::InvalidReprHintNoValue {
|
span: meta_item.span,
|
||||||
span: meta_item.span,
|
name: meta_item.name_or_empty().to_ident_string(),
|
||||||
name: meta_item.name_or_empty().to_ident_string(),
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if let MetaItemKind::List(_) = meta_item.kind {
|
} else if let MetaItemKind::List(_) = meta_item.kind {
|
||||||
if meta_item.has_name(sym::align) {
|
if meta_item.has_name(sym::align) {
|
||||||
|
|
|
@ -1658,6 +1658,7 @@ impl CheckAttrVisitor<'_> {
|
||||||
E0552,
|
E0552,
|
||||||
"unrecognized representation hint"
|
"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();
|
.emit();
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -31,12 +31,16 @@ error[E0552]: unrecognized representation hint
|
||||||
|
|
|
|
||||||
LL | #[repr(nothing)]
|
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
|
error[E0552]: unrecognized representation hint
|
||||||
--> $DIR/issue-43988.rs:18:12
|
--> $DIR/issue-43988.rs:18:12
|
||||||
|
|
|
|
||||||
LL | #[repr(something_not_real)]
|
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
|
error[E0518]: attribute should be applied to function or closure
|
||||||
--> $DIR/issue-43988.rs:30:5
|
--> $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…
Add table
Add a link
Reference in a new issue