File tree Expand file tree Collapse file tree
compiler/rustc_attr_parsing/src/attributes Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ use super::prelude::*;
44pub ( crate ) struct CfiEncodingParser ;
55impl SingleAttributeParser for CfiEncodingParser {
66 const PATH : & [ Symbol ] = & [ sym:: cfi_encoding] ;
7- const ALLOWED_TARGETS : AllowedTargets < ' _ > = AllowedTargets :: AllowListWarnRest ( & [
7+ const ALLOWED_TARGETS : AllowedTargets < ' _ > = AllowedTargets :: AllowList ( & [
88 Allow ( Target :: Struct ) ,
99 Allow ( Target :: ForeignTy ) ,
1010 Allow ( Target :: Enum ) ,
Original file line number Diff line number Diff line change 1- // Verifies that invalid user-defined CFI encodings can't be used.
2- //
3- //@ needs-sanitizer-cfi
4- //@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi
1+ //! Checks for invalid uses of the `cfi_encoding` attribute
52
6- #![ feature( cfi_encoding, no_core) ]
7- #![ no_core]
8- #![ no_main]
3+ #![ feature( cfi_encoding) ]
4+ #![ crate_type = "lib" ]
95
106#[ cfi_encoding] //~ ERROR malformed `cfi_encoding` attribute input
117pub struct Type1 ( i32 ) ;
8+
9+ #[ cfi_encoding = "Foo" ] //~ ERROR the `cfi_encoding` attribute cannot be used on traits
10+ pub trait X { }
11+
12+ #[ cfi_encoding = "Bar" ] //~ ERROR the `cfi_encoding` attribute cannot be used on type aliases
13+ pub type Y = Type1 ;
Original file line number Diff line number Diff line change 11error[E0539]: malformed `cfi_encoding` attribute input
2- --> $DIR/invalid-attr-encoding.rs:10 :3
2+ --> $DIR/invalid-attr-encoding.rs:7 :3
33 |
44LL | #[cfi_encoding]
55 | ^^^^^^^^^^^^ expected this to be of the form `cfi_encoding = "..."`
@@ -9,6 +9,22 @@ help: must be of the form
99LL | #[cfi_encoding = "encoding"]
1010 | ++++++++++++
1111
12- error: aborting due to 1 previous error
12+ error: the `cfi_encoding` attribute cannot be used on traits
13+ --> $DIR/invalid-attr-encoding.rs:10:3
14+ |
15+ LL | #[cfi_encoding = "Foo"]
16+ | ^^^^^^^^^^^^
17+ |
18+ = help: the `cfi_encoding` attribute can only be applied to data types
19+
20+ error: the `cfi_encoding` attribute cannot be used on type aliases
21+ --> $DIR/invalid-attr-encoding.rs:13:3
22+ |
23+ LL | #[cfi_encoding = "Bar"]
24+ | ^^^^^^^^^^^^
25+ |
26+ = help: the `cfi_encoding` attribute can only be applied to data types
27+
28+ error: aborting due to 3 previous errors
1329
1430For more information about this error, try `rustc --explain E0539`.
You can’t perform that action at this time.
0 commit comments