Add test for "const stability on macro"
This commit is contained in:
parent
19806e4514
commit
49310cee30
@ -774,8 +774,11 @@ impl SyntaxExtension {
|
||||
sess.parse_sess
|
||||
.span_diagnostic
|
||||
.struct_span_err(sp, "macros cannot have const stability attributes")
|
||||
.span_label(sp, "invalid stability attribute")
|
||||
.span_label(span, "in this macro")
|
||||
.span_label(sp, "invalid const stability attribute")
|
||||
.span_label(
|
||||
sess.source_map().guess_head_span(span),
|
||||
"const stability attribute affects this macro",
|
||||
)
|
||||
.emit();
|
||||
}
|
||||
|
||||
|
13
src/test/ui/attributes/const-stability-on-macro.rs
Normal file
13
src/test/ui/attributes/const-stability-on-macro.rs
Normal file
@ -0,0 +1,13 @@
|
||||
#[rustc_const_stable(feature = "foo", since = "0")]
|
||||
//~^ ERROR macros cannot have const stability attributes
|
||||
macro_rules! foo {
|
||||
() => {};
|
||||
}
|
||||
|
||||
#[rustc_const_unstable(feature = "bar", issue="none")]
|
||||
//~^ ERROR macros cannot have const stability attributes
|
||||
macro_rules! bar {
|
||||
() => {};
|
||||
}
|
||||
|
||||
fn main() {}
|
20
src/test/ui/attributes/const-stability-on-macro.stderr
Normal file
20
src/test/ui/attributes/const-stability-on-macro.stderr
Normal file
@ -0,0 +1,20 @@
|
||||
error: macros cannot have const stability attributes
|
||||
--> $DIR/const-stability-on-macro.rs:1:1
|
||||
|
|
||||
LL | #[rustc_const_stable(feature = "foo", since = "0")]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid const stability attribute
|
||||
LL |
|
||||
LL | macro_rules! foo {
|
||||
| ---------------- const stability attribute affects this macro
|
||||
|
||||
error: macros cannot have const stability attributes
|
||||
--> $DIR/const-stability-on-macro.rs:7:1
|
||||
|
|
||||
LL | #[rustc_const_unstable(feature = "bar", issue="none")]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid const stability attribute
|
||||
LL |
|
||||
LL | macro_rules! bar {
|
||||
| ---------------- const stability attribute affects this macro
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
Loading…
x
Reference in New Issue
Block a user