Skip to content

Commit 49310ce

Browse files
committed
Add test for "const stability on macro"
1 parent 19806e4 commit 49310ce

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

compiler/rustc_expand/src/base.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -774,8 +774,11 @@ impl SyntaxExtension {
774774
sess.parse_sess
775775
.span_diagnostic
776776
.struct_span_err(sp, "macros cannot have const stability attributes")
777-
.span_label(sp, "invalid stability attribute")
778-
.span_label(span, "in this macro")
777+
.span_label(sp, "invalid const stability attribute")
778+
.span_label(
779+
sess.source_map().guess_head_span(span),
780+
"const stability attribute affects this macro",
781+
)
779782
.emit();
780783
}
781784

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#[rustc_const_stable(feature = "foo", since = "0")]
2+
//~^ ERROR macros cannot have const stability attributes
3+
macro_rules! foo {
4+
() => {};
5+
}
6+
7+
#[rustc_const_unstable(feature = "bar", issue="none")]
8+
//~^ ERROR macros cannot have const stability attributes
9+
macro_rules! bar {
10+
() => {};
11+
}
12+
13+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
error: macros cannot have const stability attributes
2+
--> $DIR/const-stability-on-macro.rs:1:1
3+
|
4+
LL | #[rustc_const_stable(feature = "foo", since = "0")]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid const stability attribute
6+
LL |
7+
LL | macro_rules! foo {
8+
| ---------------- const stability attribute affects this macro
9+
10+
error: macros cannot have const stability attributes
11+
--> $DIR/const-stability-on-macro.rs:7:1
12+
|
13+
LL | #[rustc_const_unstable(feature = "bar", issue="none")]
14+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid const stability attribute
15+
LL |
16+
LL | macro_rules! bar {
17+
| ---------------- const stability attribute affects this macro
18+
19+
error: aborting due to 2 previous errors
20+

0 commit comments

Comments
 (0)