Skip to content

Commit 8e0141b

Browse files
committed
Stabilize unrestricted_attribute_tokens
1 parent f1586ba commit 8e0141b

16 files changed

+63
-112
lines changed

src/libsyntax/feature_gate.rs

+3-11
Original file line numberDiff line numberDiff line change
@@ -440,9 +440,6 @@ declare_features! (
440440
// Added for testing E0705; perma-unstable.
441441
(active, test_2018_feature, "1.31.0", Some(0), Some(Edition::Edition2018)),
442442

443-
// support for arbitrary delimited token streams in non-macro attributes
444-
(active, unrestricted_attribute_tokens, "1.30.0", Some(55208), None),
445-
446443
// Allows `use x::y;` to resolve through `self::x`, not just `::x`.
447444
(active, uniform_paths, "1.30.0", Some(53130), None),
448445

@@ -686,6 +683,8 @@ declare_features! (
686683
(accepted, repr_packed, "1.33.0", Some(33158), None),
687684
// Allows calling `const unsafe fn` inside `unsafe` blocks in `const fn` functions.
688685
(accepted, min_const_unsafe_fn, "1.33.0", Some(55607), None),
686+
// support for arbitrary delimited token streams in non-macro attributes
687+
(accepted, unrestricted_attribute_tokens, "1.33.0", Some(55208), None),
689688
);
690689

691690
// If you change this, please modify `src/doc/unstable-book` as well. You must
@@ -1558,14 +1557,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
15581557
}
15591558
Err(mut err) => err.emit(),
15601559
}
1561-
None => if !self.context.features.unrestricted_attribute_tokens {
1562-
// Unfortunately, `parse_meta` cannot be called speculatively
1563-
// because it can report errors by itself, so we have to call it
1564-
// only if the feature is disabled.
1565-
if let Err(mut err) = attr.parse_meta(self.context.parse_sess) {
1566-
err.help("try enabling `#![feature(unrestricted_attribute_tokens)]`").emit()
1567-
}
1568-
}
1560+
None => {}
15691561
}
15701562
}
15711563

src/test/run-pass/proc-macro/derive-b.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// aux-build:derive-b.rs
22

3-
#![feature(unrestricted_attribute_tokens)]
4-
53
extern crate derive_b;
64

75
#[derive(Debug, PartialEq, derive_b::B, Eq, Copy, Clone)]

src/test/ui/attr-eq-token-tree.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// compile-pass
22

3-
#![feature(custom_attribute, unrestricted_attribute_tokens)]
3+
#![feature(custom_attribute)]
44

55
#[my_attr = !] // OK under feature gate
66
fn main() {}

src/test/ui/feature-gates/feature-gate-unrestricted-attribute-tokens.rs

-7
This file was deleted.

src/test/ui/feature-gates/feature-gate-unrestricted-attribute-tokens.stderr

-20
This file was deleted.

src/test/ui/macros/macro-attribute.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
#![feature(unrestricted_attribute_tokens)]
2-
31
#[doc = $not_there] //~ ERROR expected `]`, found `not_there`
42
fn main() { }

src/test/ui/macros/macro-attribute.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: expected `]`, found `not_there`
2-
--> $DIR/macro-attribute.rs:3:10
2+
--> $DIR/macro-attribute.rs:1:10
33
|
44
LL | #[doc = $not_there] //~ ERROR expected `]`, found `not_there`
55
| ^^^^^^^^^ expected `]`

src/test/ui/marker_trait_attr/marker-attribute-with-values.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![feature(marker_trait_attr)]
2-
#![feature(unrestricted_attribute_tokens)]
32

43
#[marker(always)]
54
trait Marker1 {}

src/test/ui/marker_trait_attr/marker-attribute-with-values.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
error: attribute must be of the form `#[marker]`
2-
--> $DIR/marker-attribute-with-values.rs:4:1
2+
--> $DIR/marker-attribute-with-values.rs:3:1
33
|
44
LL | #[marker(always)]
55
| ^^^^^^^^^^^^^^^^^
66

77
error: attribute must be of the form `#[marker]`
8-
--> $DIR/marker-attribute-with-values.rs:8:1
8+
--> $DIR/marker-attribute-with-values.rs:7:1
99
|
1010
LL | #[marker("never")]
1111
| ^^^^^^^^^^^^^^^^^^
1212

1313
error: expected unsuffixed literal or identifier, found value
14-
--> $DIR/marker-attribute-with-values.rs:12:10
14+
--> $DIR/marker-attribute-with-values.rs:11:10
1515
|
1616
LL | #[marker(key = value)]
1717
| ^^^

src/test/ui/parser/attr-bad-meta.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
// compile-flags: -Z parse-only
22

3-
#![feature(unrestricted_attribute_tokens)]
4-
53
#[path*] //~ ERROR expected one of `(`, `::`, `=`, `[`, `]`, or `{`, found `*`
64
mod m {}

src/test/ui/parser/attr-bad-meta.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: expected one of `(`, `::`, `=`, `[`, `]`, or `{`, found `*`
2-
--> $DIR/attr-bad-meta.rs:5:7
2+
--> $DIR/attr-bad-meta.rs:3:7
33
|
44
LL | #[path*] //~ ERROR expected one of `(`, `::`, `=`, `[`, `]`, or `{`, found `*`
55
| ^ expected one of `(`, `::`, `=`, `[`, `]`, or `{` here

src/test/ui/proc-macro/proc-macro-attributes.rs

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ extern crate derive_b;
88
#[B(D)] //~ ERROR `B` is ambiguous
99
#[B(E = "foo")] //~ ERROR `B` is ambiguous
1010
#[B(arbitrary tokens)] //~ ERROR `B` is ambiguous
11-
//~^ ERROR expected one of `(`, `)`, `,`, `::`, or `=`, found `tokens`
1211
#[derive(B)]
1312
struct B;
1413

src/test/ui/proc-macro/proc-macro-attributes.stderr

+5-11
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ LL | #[B] //~ ERROR `B` is ambiguous
1313
| ^ ambiguous name
1414
|
1515
note: `B` could refer to the derive helper attribute defined here
16-
--> $DIR/proc-macro-attributes.rs:12:10
16+
--> $DIR/proc-macro-attributes.rs:11:10
1717
|
1818
LL | #[derive(B)]
1919
| ^
@@ -30,7 +30,7 @@ LL | #[B(D)] //~ ERROR `B` is ambiguous
3030
| ^ ambiguous name
3131
|
3232
note: `B` could refer to the derive helper attribute defined here
33-
--> $DIR/proc-macro-attributes.rs:12:10
33+
--> $DIR/proc-macro-attributes.rs:11:10
3434
|
3535
LL | #[derive(B)]
3636
| ^
@@ -47,7 +47,7 @@ LL | #[B(E = "foo")] //~ ERROR `B` is ambiguous
4747
| ^ ambiguous name
4848
|
4949
note: `B` could refer to the derive helper attribute defined here
50-
--> $DIR/proc-macro-attributes.rs:12:10
50+
--> $DIR/proc-macro-attributes.rs:11:10
5151
|
5252
LL | #[derive(B)]
5353
| ^
@@ -64,7 +64,7 @@ LL | #[B(arbitrary tokens)] //~ ERROR `B` is ambiguous
6464
| ^ ambiguous name
6565
|
6666
note: `B` could refer to the derive helper attribute defined here
67-
--> $DIR/proc-macro-attributes.rs:12:10
67+
--> $DIR/proc-macro-attributes.rs:11:10
6868
|
6969
LL | #[derive(B)]
7070
| ^
@@ -74,13 +74,7 @@ note: `B` could also refer to the derive macro imported here
7474
LL | #[macro_use]
7575
| ^^^^^^^^^^^^
7676

77-
error: expected one of `(`, `)`, `,`, `::`, or `=`, found `tokens`
78-
--> $DIR/proc-macro-attributes.rs:10:15
79-
|
80-
LL | #[B(arbitrary tokens)] //~ ERROR `B` is ambiguous
81-
| ^^^^^^ expected one of `(`, `)`, `,`, `::`, or `=` here
82-
83-
error: aborting due to 6 previous errors
77+
error: aborting due to 5 previous errors
8478

8579
Some errors occurred: E0658, E0659.
8680
For more information about an error, try `rustc --explain E0658`.

src/test/ui/suffixed-literal-meta.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#![feature(custom_attribute)]
22

3-
#[my_attr = 1usize] //~ ERROR: suffixed literals are not allowed in attributes
4-
#[my_attr = 1u8] //~ ERROR: suffixed literals are not allowed in attributes
5-
#[my_attr = 1u16] //~ ERROR: suffixed literals are not allowed in attributes
6-
#[my_attr = 1u32] //~ ERROR: suffixed literals are not allowed in attributes
7-
#[my_attr = 1u64] //~ ERROR: suffixed literals are not allowed in attributes
8-
#[my_attr = 1isize] //~ ERROR: suffixed literals are not allowed in attributes
9-
#[my_attr = 1i8] //~ ERROR: suffixed literals are not allowed in attributes
10-
#[my_attr = 1i16] //~ ERROR: suffixed literals are not allowed in attributes
11-
#[my_attr = 1i32] //~ ERROR: suffixed literals are not allowed in attributes
12-
#[my_attr = 1i64] //~ ERROR: suffixed literals are not allowed in attributes
13-
#[my_attr = 1.0f32] //~ ERROR: suffixed literals are not allowed in attributes
14-
#[my_attr = 1.0f64] //~ ERROR: suffixed literals are not allowed in attributes
3+
#[macro_use(x = 1usize)] //~ ERROR: suffixed literals are not allowed in attributes
4+
#[macro_use(x = 1u8)] //~ ERROR: suffixed literals are not allowed in attributes
5+
#[macro_use(x = 1u16)] //~ ERROR: suffixed literals are not allowed in attributes
6+
#[macro_use(x = 1u32)] //~ ERROR: suffixed literals are not allowed in attributes
7+
#[macro_use(x = 1u64)] //~ ERROR: suffixed literals are not allowed in attributes
8+
#[macro_use(x = 1isize)] //~ ERROR: suffixed literals are not allowed in attributes
9+
#[macro_use(x = 1i8)] //~ ERROR: suffixed literals are not allowed in attributes
10+
#[macro_use(x = 1i16)] //~ ERROR: suffixed literals are not allowed in attributes
11+
#[macro_use(x = 1i32)] //~ ERROR: suffixed literals are not allowed in attributes
12+
#[macro_use(x = 1i64)] //~ ERROR: suffixed literals are not allowed in attributes
13+
#[macro_use(x = 1.0f32)] //~ ERROR: suffixed literals are not allowed in attributes
14+
#[macro_use(x = 1.0f64)] //~ ERROR: suffixed literals are not allowed in attributes
1515
fn main() { }

src/test/ui/suffixed-literal-meta.stderr

+36-36
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,96 @@
11
error: suffixed literals are not allowed in attributes
2-
--> $DIR/suffixed-literal-meta.rs:3:13
2+
--> $DIR/suffixed-literal-meta.rs:3:17
33
|
4-
LL | #[my_attr = 1usize] //~ ERROR: suffixed literals are not allowed in attributes
5-
| ^^^^^^
4+
LL | #[macro_use(x = 1usize)] //~ ERROR: suffixed literals are not allowed in attributes
5+
| ^^^^^^
66
|
77
= help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.).
88

99
error: suffixed literals are not allowed in attributes
10-
--> $DIR/suffixed-literal-meta.rs:4:13
10+
--> $DIR/suffixed-literal-meta.rs:4:17
1111
|
12-
LL | #[my_attr = 1u8] //~ ERROR: suffixed literals are not allowed in attributes
13-
| ^^^
12+
LL | #[macro_use(x = 1u8)] //~ ERROR: suffixed literals are not allowed in attributes
13+
| ^^^
1414
|
1515
= help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.).
1616

1717
error: suffixed literals are not allowed in attributes
18-
--> $DIR/suffixed-literal-meta.rs:5:13
18+
--> $DIR/suffixed-literal-meta.rs:5:17
1919
|
20-
LL | #[my_attr = 1u16] //~ ERROR: suffixed literals are not allowed in attributes
21-
| ^^^^
20+
LL | #[macro_use(x = 1u16)] //~ ERROR: suffixed literals are not allowed in attributes
21+
| ^^^^
2222
|
2323
= help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.).
2424

2525
error: suffixed literals are not allowed in attributes
26-
--> $DIR/suffixed-literal-meta.rs:6:13
26+
--> $DIR/suffixed-literal-meta.rs:6:17
2727
|
28-
LL | #[my_attr = 1u32] //~ ERROR: suffixed literals are not allowed in attributes
29-
| ^^^^
28+
LL | #[macro_use(x = 1u32)] //~ ERROR: suffixed literals are not allowed in attributes
29+
| ^^^^
3030
|
3131
= help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.).
3232

3333
error: suffixed literals are not allowed in attributes
34-
--> $DIR/suffixed-literal-meta.rs:7:13
34+
--> $DIR/suffixed-literal-meta.rs:7:17
3535
|
36-
LL | #[my_attr = 1u64] //~ ERROR: suffixed literals are not allowed in attributes
37-
| ^^^^
36+
LL | #[macro_use(x = 1u64)] //~ ERROR: suffixed literals are not allowed in attributes
37+
| ^^^^
3838
|
3939
= help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.).
4040

4141
error: suffixed literals are not allowed in attributes
42-
--> $DIR/suffixed-literal-meta.rs:8:13
42+
--> $DIR/suffixed-literal-meta.rs:8:17
4343
|
44-
LL | #[my_attr = 1isize] //~ ERROR: suffixed literals are not allowed in attributes
45-
| ^^^^^^
44+
LL | #[macro_use(x = 1isize)] //~ ERROR: suffixed literals are not allowed in attributes
45+
| ^^^^^^
4646
|
4747
= help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.).
4848

4949
error: suffixed literals are not allowed in attributes
50-
--> $DIR/suffixed-literal-meta.rs:9:13
50+
--> $DIR/suffixed-literal-meta.rs:9:17
5151
|
52-
LL | #[my_attr = 1i8] //~ ERROR: suffixed literals are not allowed in attributes
53-
| ^^^
52+
LL | #[macro_use(x = 1i8)] //~ ERROR: suffixed literals are not allowed in attributes
53+
| ^^^
5454
|
5555
= help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.).
5656

5757
error: suffixed literals are not allowed in attributes
58-
--> $DIR/suffixed-literal-meta.rs:10:13
58+
--> $DIR/suffixed-literal-meta.rs:10:17
5959
|
60-
LL | #[my_attr = 1i16] //~ ERROR: suffixed literals are not allowed in attributes
61-
| ^^^^
60+
LL | #[macro_use(x = 1i16)] //~ ERROR: suffixed literals are not allowed in attributes
61+
| ^^^^
6262
|
6363
= help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.).
6464

6565
error: suffixed literals are not allowed in attributes
66-
--> $DIR/suffixed-literal-meta.rs:11:13
66+
--> $DIR/suffixed-literal-meta.rs:11:17
6767
|
68-
LL | #[my_attr = 1i32] //~ ERROR: suffixed literals are not allowed in attributes
69-
| ^^^^
68+
LL | #[macro_use(x = 1i32)] //~ ERROR: suffixed literals are not allowed in attributes
69+
| ^^^^
7070
|
7171
= help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.).
7272

7373
error: suffixed literals are not allowed in attributes
74-
--> $DIR/suffixed-literal-meta.rs:12:13
74+
--> $DIR/suffixed-literal-meta.rs:12:17
7575
|
76-
LL | #[my_attr = 1i64] //~ ERROR: suffixed literals are not allowed in attributes
77-
| ^^^^
76+
LL | #[macro_use(x = 1i64)] //~ ERROR: suffixed literals are not allowed in attributes
77+
| ^^^^
7878
|
7979
= help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.).
8080

8181
error: suffixed literals are not allowed in attributes
82-
--> $DIR/suffixed-literal-meta.rs:13:13
82+
--> $DIR/suffixed-literal-meta.rs:13:17
8383
|
84-
LL | #[my_attr = 1.0f32] //~ ERROR: suffixed literals are not allowed in attributes
85-
| ^^^^^^
84+
LL | #[macro_use(x = 1.0f32)] //~ ERROR: suffixed literals are not allowed in attributes
85+
| ^^^^^^
8686
|
8787
= help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.).
8888

8989
error: suffixed literals are not allowed in attributes
90-
--> $DIR/suffixed-literal-meta.rs:14:13
90+
--> $DIR/suffixed-literal-meta.rs:14:17
9191
|
92-
LL | #[my_attr = 1.0f64] //~ ERROR: suffixed literals are not allowed in attributes
93-
| ^^^^^^
92+
LL | #[macro_use(x = 1.0f64)] //~ ERROR: suffixed literals are not allowed in attributes
93+
| ^^^^^^
9494
|
9595
= help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.).
9696

Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// compile-pass
22

3-
#![feature(custom_attribute, unrestricted_attribute_tokens)]
3+
#![feature(custom_attribute)]
44

55
#[my_attr(a b c d)]
66
fn main() {}

0 commit comments

Comments
 (0)