Skip to content

Commit 7e1f2f9

Browse files
committed
Augment some tests involving attributes.
This shows places where the use of `name_or_empty` causes problems, i.e. we print empty identifiers in error messages: ``` error: unrecognized field name `` error: `` isn't a valid `#[macro_export]` argument `#[no_sanitize()]` should be applied to a function ``` (The last one is about an attribute `#[no_sanitize("address")]`.) The next commit will fix these.
1 parent 400e8e5 commit 7e1f2f9

6 files changed

+46
-3
lines changed

tests/ui/abi/debug.rs

+3
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,6 @@ type TestAbiNeSign = (fn(i32), fn(u32)); //~ ERROR: ABIs are not compatible
5252

5353
#[rustc_abi(assert_eq)]
5454
type TestAbiEqNonsense = (fn((str, str)), fn((str, str))); //~ ERROR: cannot be known at compilation time
55+
56+
#[rustc_abi("assert_eq")] //~ ERROR unrecognized field name ``
57+
type Bad = u32;

tests/ui/abi/debug.stderr

+7-1
Original file line numberDiff line numberDiff line change
@@ -906,6 +906,12 @@ LL | type TestAbiEqNonsense = (fn((str, str)), fn((str, str)));
906906
= help: the trait `Sized` is not implemented for `str`
907907
= note: only the last element of a tuple may have a dynamically sized type
908908

909+
error: unrecognized field name ``
910+
--> $DIR/debug.rs:56:13
911+
|
912+
LL | #[rustc_abi("assert_eq")]
913+
| ^^^^^^^^^^^
914+
909915
error: `#[rustc_abi]` can only be applied to function items, type aliases, and associated functions
910916
--> $DIR/debug.rs:29:5
911917
|
@@ -1004,6 +1010,6 @@ error: fn_abi_of(assoc_test) = FnAbi {
10041010
LL | fn assoc_test(&self) { }
10051011
| ^^^^^^^^^^^^^^^^^^^^
10061012

1007-
error: aborting due to 11 previous errors
1013+
error: aborting due to 12 previous errors
10081014

10091015
For more information about this error, try `rustc --explain E0277`.

tests/ui/attributes/invalid_macro_export_argument.deny.stderr

+7-1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,11 @@ error: `not_local_inner_macros` isn't a valid `#[macro_export]` argument
1616
LL | #[macro_export(not_local_inner_macros)]
1717
| ^^^^^^^^^^^^^^^^^^^^^^
1818

19-
error: aborting due to 2 previous errors
19+
error: `` isn't a valid `#[macro_export]` argument
20+
--> $DIR/invalid_macro_export_argument.rs:33:16
21+
|
22+
LL | #[macro_export("blah")]
23+
| ^^^^^^
24+
25+
error: aborting due to 3 previous errors
2026

tests/ui/attributes/invalid_macro_export_argument.rs

+6
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,10 @@ macro_rules! e {
3030
() => ()
3131
}
3232

33+
#[macro_export("blah")]
34+
//[deny]~^ ERROR `` isn't a valid `#[macro_export]` argument
35+
macro_rules! f {
36+
() => ()
37+
}
38+
3339
fn main() {}

tests/ui/attributes/no-sanitize.rs

+5
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,8 @@ fn valid() {}
3838

3939
#[no_sanitize(address)]
4040
static VALID : i32 = 0;
41+
42+
#[no_sanitize("address")]
43+
//~^ ERROR `#[no_sanitize()]` should be applied to a function
44+
//~| ERROR invalid argument for `no_sanitize`
45+
static VALID2 : i32 = 0;

tests/ui/attributes/no-sanitize.stderr

+18-1
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,22 @@ LL | #[no_sanitize(address, memory)]
5959
LL | static INVALID : i32 = 0;
6060
| ------------------------- not a function
6161

62-
error: aborting due to 7 previous errors
62+
error: `#[no_sanitize()]` should be applied to a function
63+
--> $DIR/no-sanitize.rs:42:15
64+
|
65+
LL | #[no_sanitize("address")]
66+
| ^^^^^^^^^
67+
...
68+
LL | static VALID2 : i32 = 0;
69+
| ------------------------ not a function
70+
71+
error: invalid argument for `no_sanitize`
72+
--> $DIR/no-sanitize.rs:42:15
73+
|
74+
LL | #[no_sanitize("address")]
75+
| ^^^^^^^^^
76+
|
77+
= note: expected one of: `address`, `cfi`, `hwaddress`, `kcfi`, `memory`, `memtag`, `shadow-call-stack`, or `thread`
78+
79+
error: aborting due to 9 previous errors
6380

0 commit comments

Comments
 (0)