Skip to content

Commit 998d332

Browse files
committed
Add stability attribute eager expansion test
error: expected unsuffixed literal or identifier, found `stable_feature` --> tests/ui/stability-attribute/eager-expansion.rs:37:32 | LL | #[stable(feature = stable_feature!($signedness), since = stable_since!($signedness))] | ^^^^^^^^^^^^^^ ... LL | / nonzero_integers! { LL | | unsigned NonZeroU8(u8) LL | | unsigned NonZeroU16(u16) LL | | unsigned NonZeroU32(u32) ... | LL | | signed NonZeroI64(u64) LL | | } | |_- in this macro invocation | = note: this error originates in the macro `nonzero_integers` (in Nightly builds, run with -Z macro-backtrace for more info)
1 parent 2730354 commit 998d332

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// check-pass
2+
3+
#![crate_type = "lib"]
4+
#![feature(staged_api)]
5+
#![stable(feature = "stable_test_feature", since = "3.3.3")]
6+
7+
macro_rules! sign_dependent_expr {
8+
(unsigned ? if unsigned { $unsigned_case:expr } if signed { $signed_case:expr }) => {
9+
$unsigned_case
10+
};
11+
(signed ? if unsigned { $unsigned_case:expr } if signed { $signed_case:expr }) => {
12+
$signed_case
13+
};
14+
}
15+
16+
macro_rules! stable_feature {
17+
($signedness:ident) => {
18+
sign_dependent_expr! {
19+
$signedness ?
20+
if unsigned { "nonzero" }
21+
if signed { "signed_nonzero" }
22+
}
23+
};
24+
}
25+
26+
macro_rules! stable_since {
27+
($signedness:ident) => {
28+
sign_dependent_expr! {
29+
$signedness ?
30+
if unsigned { "1.28.0" }
31+
if signed { "1.34.0" }
32+
}
33+
};
34+
}
35+
36+
macro_rules! nonzero_integers {
37+
($($signedness:ident $NonZero:ident($primitive:ty))*) => {
38+
$(
39+
#[stable(feature = stable_feature!($signedness), since = stable_since!($signedness))]
40+
pub struct $NonZero($primitive);
41+
)*
42+
};
43+
}
44+
45+
nonzero_integers! {
46+
unsigned NonZeroU8(u8)
47+
unsigned NonZeroU16(u16)
48+
unsigned NonZeroU32(u32)
49+
unsigned NonZeroU64(u64)
50+
signed NonZeroI8(i8)
51+
signed NonZeroI16(i16)
52+
signed NonZeroI32(i32)
53+
signed NonZeroI64(i64)
54+
}

0 commit comments

Comments
 (0)