Skip to content

Commit fdfffc0

Browse files
authored
Rollup merge of #125734 - petrochenkov:macinattr, r=wesleywiser
ast: Revert a breaking attribute visiting order change Fixes #124535 Fixes #125201
2 parents 1ae1388 + 6e67eaa commit fdfffc0

7 files changed

+233
-47
lines changed

compiler/rustc_ast/src/visit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -852,10 +852,10 @@ pub fn walk_assoc_item<'a, V: Visitor<'a>>(
852852
ctxt: AssocCtxt,
853853
) -> V::Result {
854854
let &Item { id: _, span: _, ident, ref vis, ref attrs, ref kind, tokens: _ } = item;
855-
walk_list!(visitor, visit_attribute, attrs);
856855
try_visit!(visitor.visit_vis(vis));
857856
try_visit!(visitor.visit_ident(ident));
858857
try_visit!(kind.walk(item, ctxt, visitor));
858+
walk_list!(visitor, visit_attribute, attrs);
859859
V::Result::output()
860860
}
861861

Original file line numberDiff line numberDiff line change
@@ -1,53 +1,53 @@
11
error: using tabs in doc comments is not recommended
2-
--> tests/ui/tabs_in_doc_comments.rs:6:5
2+
--> tests/ui/tabs_in_doc_comments.rs:10:9
33
|
4-
LL | /// - first one
5-
| ^^^^ help: consider using four spaces per tab
4+
LL | /// - First String:
5+
| ^^^^ help: consider using four spaces per tab
66
|
77
= note: `-D clippy::tabs-in-doc-comments` implied by `-D warnings`
88
= help: to override `-D warnings` add `#[allow(clippy::tabs_in_doc_comments)]`
99

1010
error: using tabs in doc comments is not recommended
11-
--> tests/ui/tabs_in_doc_comments.rs:6:13
11+
--> tests/ui/tabs_in_doc_comments.rs:11:9
1212
|
13-
LL | /// - first one
14-
| ^^^^^^^^ help: consider using four spaces per tab
13+
LL | /// - needs to be inside here
14+
| ^^^^^^^^ help: consider using four spaces per tab
1515

1616
error: using tabs in doc comments is not recommended
17-
--> tests/ui/tabs_in_doc_comments.rs:7:5
17+
--> tests/ui/tabs_in_doc_comments.rs:14:9
1818
|
19-
LL | /// - second one
20-
| ^^^^ help: consider using four spaces per tab
19+
LL | /// - Second String:
20+
| ^^^^ help: consider using four spaces per tab
2121

2222
error: using tabs in doc comments is not recommended
23-
--> tests/ui/tabs_in_doc_comments.rs:7:14
23+
--> tests/ui/tabs_in_doc_comments.rs:15:9
2424
|
25-
LL | /// - second one
26-
| ^^^^ help: consider using four spaces per tab
25+
LL | /// - needs to be inside here
26+
| ^^^^^^^^ help: consider using four spaces per tab
2727

2828
error: using tabs in doc comments is not recommended
29-
--> tests/ui/tabs_in_doc_comments.rs:10:9
29+
--> tests/ui/tabs_in_doc_comments.rs:6:5
3030
|
31-
LL | /// - First String:
32-
| ^^^^ help: consider using four spaces per tab
31+
LL | /// - first one
32+
| ^^^^ help: consider using four spaces per tab
3333

3434
error: using tabs in doc comments is not recommended
35-
--> tests/ui/tabs_in_doc_comments.rs:11:9
35+
--> tests/ui/tabs_in_doc_comments.rs:6:13
3636
|
37-
LL | /// - needs to be inside here
38-
| ^^^^^^^^ help: consider using four spaces per tab
37+
LL | /// - first one
38+
| ^^^^^^^^ help: consider using four spaces per tab
3939

4040
error: using tabs in doc comments is not recommended
41-
--> tests/ui/tabs_in_doc_comments.rs:14:9
41+
--> tests/ui/tabs_in_doc_comments.rs:7:5
4242
|
43-
LL | /// - Second String:
44-
| ^^^^ help: consider using four spaces per tab
43+
LL | /// - second one
44+
| ^^^^ help: consider using four spaces per tab
4545

4646
error: using tabs in doc comments is not recommended
47-
--> tests/ui/tabs_in_doc_comments.rs:15:9
47+
--> tests/ui/tabs_in_doc_comments.rs:7:14
4848
|
49-
LL | /// - needs to be inside here
50-
| ^^^^^^^^ help: consider using four spaces per tab
49+
LL | /// - second one
50+
| ^^^^ help: consider using four spaces per tab
5151

5252
error: aborting due to 8 previous errors
5353

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#![doc = in_root!()] // FIXME, this is a bug
2+
#![doc = in_mod!()] //~ ERROR cannot find macro `in_mod` in this scope
3+
#![doc = in_mod_escape!()] // FIXME, this is a bug
4+
#![doc = in_block!()] //~ ERROR cannot find macro `in_block` in this scope
5+
6+
#[doc = in_root!()] //~ ERROR cannot find macro `in_root` in this scope
7+
#[doc = in_mod!()] //~ ERROR cannot find macro `in_mod` in this scope
8+
#[doc = in_mod_escape!()] //~ ERROR cannot find macro `in_mod_escape` in this scope
9+
#[doc = in_block!()] //~ ERROR cannot find macro `in_block` in this scope
10+
fn before() {
11+
#![doc = in_root!()] //~ ERROR cannot find macro `in_root` in this scope
12+
#![doc = in_mod!()] //~ ERROR cannot find macro `in_mod` in this scope
13+
#![doc = in_mod_escape!()] //~ ERROR cannot find macro `in_mod_escape` in this scope
14+
#![doc = in_block!()] //~ ERROR cannot find macro `in_block` in this scope
15+
}
16+
17+
macro_rules! in_root { () => { "" } }
18+
19+
mod macros_stay {
20+
#![doc = in_mod!()] // FIXME, this is a bug
21+
22+
macro_rules! in_mod { () => { "" } }
23+
24+
#[doc = in_mod!()] // OK
25+
fn f() {
26+
#![doc = in_mod!()] // OK
27+
}
28+
}
29+
30+
#[macro_use]
31+
mod macros_escape {
32+
#![doc = in_mod_escape!()] // FIXME, this is a bug
33+
34+
macro_rules! in_mod_escape { () => { "" } }
35+
36+
#[doc = in_mod_escape!()] // OK
37+
fn f() {
38+
#![doc = in_mod_escape!()] // OK
39+
}
40+
}
41+
42+
fn block() {
43+
#![doc = in_block!()] //~ ERROR cannot find macro `in_block` in this scope
44+
45+
macro_rules! in_block { () => { "" } }
46+
47+
#[doc = in_block!()] // OK
48+
fn f() {
49+
#![doc = in_block!()] // OK
50+
}
51+
}
52+
53+
#[doc = in_root!()] // OK
54+
#[doc = in_mod!()] //~ ERROR cannot find macro `in_mod` in this scope
55+
#[doc = in_mod_escape!()] // OK
56+
#[doc = in_block!()] //~ ERROR cannot find macro `in_block` in this scope
57+
fn after() {
58+
#![doc = in_root!()] // OK
59+
#![doc = in_mod!()] //~ ERROR cannot find macro `in_mod` in this scope
60+
#![doc = in_mod_escape!()] // OK
61+
#![doc = in_block!()] //~ ERROR cannot find macro `in_block` in this scope
62+
}
63+
64+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
error: cannot find macro `in_mod` in this scope
2+
--> $DIR/key-value-expansion-scope.rs:2:10
3+
|
4+
LL | #![doc = in_mod!()]
5+
| ^^^^^^
6+
|
7+
= help: have you added the `#[macro_use]` on the module/import?
8+
9+
error: cannot find macro `in_block` in this scope
10+
--> $DIR/key-value-expansion-scope.rs:4:10
11+
|
12+
LL | #![doc = in_block!()]
13+
| ^^^^^^^^
14+
|
15+
= help: have you added the `#[macro_use]` on the module/import?
16+
17+
error: cannot find macro `in_root` in this scope
18+
--> $DIR/key-value-expansion-scope.rs:6:9
19+
|
20+
LL | #[doc = in_root!()]
21+
| ^^^^^^^
22+
|
23+
= help: have you added the `#[macro_use]` on the module/import?
24+
25+
error: cannot find macro `in_mod` in this scope
26+
--> $DIR/key-value-expansion-scope.rs:7:9
27+
|
28+
LL | #[doc = in_mod!()]
29+
| ^^^^^^
30+
|
31+
= help: have you added the `#[macro_use]` on the module/import?
32+
33+
error: cannot find macro `in_mod_escape` in this scope
34+
--> $DIR/key-value-expansion-scope.rs:8:9
35+
|
36+
LL | #[doc = in_mod_escape!()]
37+
| ^^^^^^^^^^^^^
38+
|
39+
= help: have you added the `#[macro_use]` on the module/import?
40+
41+
error: cannot find macro `in_block` in this scope
42+
--> $DIR/key-value-expansion-scope.rs:9:9
43+
|
44+
LL | #[doc = in_block!()]
45+
| ^^^^^^^^
46+
|
47+
= help: have you added the `#[macro_use]` on the module/import?
48+
49+
error: cannot find macro `in_root` in this scope
50+
--> $DIR/key-value-expansion-scope.rs:11:14
51+
|
52+
LL | #![doc = in_root!()]
53+
| ^^^^^^^
54+
|
55+
= help: have you added the `#[macro_use]` on the module/import?
56+
57+
error: cannot find macro `in_mod` in this scope
58+
--> $DIR/key-value-expansion-scope.rs:12:14
59+
|
60+
LL | #![doc = in_mod!()]
61+
| ^^^^^^
62+
|
63+
= help: have you added the `#[macro_use]` on the module/import?
64+
65+
error: cannot find macro `in_mod_escape` in this scope
66+
--> $DIR/key-value-expansion-scope.rs:13:14
67+
|
68+
LL | #![doc = in_mod_escape!()]
69+
| ^^^^^^^^^^^^^
70+
|
71+
= help: have you added the `#[macro_use]` on the module/import?
72+
73+
error: cannot find macro `in_block` in this scope
74+
--> $DIR/key-value-expansion-scope.rs:14:14
75+
|
76+
LL | #![doc = in_block!()]
77+
| ^^^^^^^^
78+
|
79+
= help: have you added the `#[macro_use]` on the module/import?
80+
81+
error: cannot find macro `in_block` in this scope
82+
--> $DIR/key-value-expansion-scope.rs:43:14
83+
|
84+
LL | #![doc = in_block!()]
85+
| ^^^^^^^^
86+
|
87+
= help: have you added the `#[macro_use]` on the module/import?
88+
89+
error: cannot find macro `in_mod` in this scope
90+
--> $DIR/key-value-expansion-scope.rs:54:9
91+
|
92+
LL | #[doc = in_mod!()]
93+
| ^^^^^^
94+
|
95+
= help: have you added the `#[macro_use]` on the module/import?
96+
97+
error: cannot find macro `in_block` in this scope
98+
--> $DIR/key-value-expansion-scope.rs:56:9
99+
|
100+
LL | #[doc = in_block!()]
101+
| ^^^^^^^^
102+
|
103+
= help: have you added the `#[macro_use]` on the module/import?
104+
105+
error: cannot find macro `in_mod` in this scope
106+
--> $DIR/key-value-expansion-scope.rs:59:14
107+
|
108+
LL | #![doc = in_mod!()]
109+
| ^^^^^^
110+
|
111+
= help: have you added the `#[macro_use]` on the module/import?
112+
113+
error: cannot find macro `in_block` in this scope
114+
--> $DIR/key-value-expansion-scope.rs:61:14
115+
|
116+
LL | #![doc = in_block!()]
117+
| ^^^^^^^^
118+
|
119+
= help: have you added the `#[macro_use]` on the module/import?
120+
121+
error: aborting due to 15 previous errors
122+

tests/ui/feature-gates/feature-gate-optimize_attribute.stderr

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
1-
error[E0658]: the `#[optimize]` attribute is an experimental feature
2-
--> $DIR/feature-gate-optimize_attribute.rs:4:1
3-
|
4-
LL | #[optimize(size)]
5-
| ^^^^^^^^^^^^^^^^^
6-
|
7-
= note: see issue #54882 <https://github.com/rust-lang/rust/issues/54882> for more information
8-
= help: add `#![feature(optimize_attribute)]` to the crate attributes to enable
9-
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
10-
111
error[E0658]: the `#[optimize]` attribute is an experimental feature
122
--> $DIR/feature-gate-optimize_attribute.rs:7:1
133
|
@@ -38,6 +28,16 @@ LL | #[optimize(banana)]
3828
= help: add `#![feature(optimize_attribute)]` to the crate attributes to enable
3929
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
4030

31+
error[E0658]: the `#[optimize]` attribute is an experimental feature
32+
--> $DIR/feature-gate-optimize_attribute.rs:4:1
33+
|
34+
LL | #[optimize(size)]
35+
| ^^^^^^^^^^^^^^^^^
36+
|
37+
= note: see issue #54882 <https://github.com/rust-lang/rust/issues/54882> for more information
38+
= help: add `#![feature(optimize_attribute)]` to the crate attributes to enable
39+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
40+
4141
error[E0658]: the `#[optimize]` attribute is an experimental feature
4242
--> $DIR/feature-gate-optimize_attribute.rs:2:1
4343
|

tests/ui/feature-gates/issue-43106-gating-of-stable.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
error[E0734]: stability attributes may not be used outside of the standard library
2-
--> $DIR/issue-43106-gating-of-stable.rs:10:1
3-
|
4-
LL | #[stable()]
5-
| ^^^^^^^^^^^
6-
71
error[E0734]: stability attributes may not be used outside of the standard library
82
--> $DIR/issue-43106-gating-of-stable.rs:14:9
93
|
@@ -34,6 +28,12 @@ error[E0734]: stability attributes may not be used outside of the standard libra
3428
LL | #[stable()]
3529
| ^^^^^^^^^^^
3630

31+
error[E0734]: stability attributes may not be used outside of the standard library
32+
--> $DIR/issue-43106-gating-of-stable.rs:10:1
33+
|
34+
LL | #[stable()]
35+
| ^^^^^^^^^^^
36+
3737
error[E0734]: stability attributes may not be used outside of the standard library
3838
--> $DIR/issue-43106-gating-of-stable.rs:7:1
3939
|

tests/ui/feature-gates/issue-43106-gating-of-unstable.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
error[E0734]: stability attributes may not be used outside of the standard library
2-
--> $DIR/issue-43106-gating-of-unstable.rs:10:1
3-
|
4-
LL | #[unstable()]
5-
| ^^^^^^^^^^^^^
6-
71
error[E0734]: stability attributes may not be used outside of the standard library
82
--> $DIR/issue-43106-gating-of-unstable.rs:14:9
93
|
@@ -34,6 +28,12 @@ error[E0734]: stability attributes may not be used outside of the standard libra
3428
LL | #[unstable()]
3529
| ^^^^^^^^^^^^^
3630

31+
error[E0734]: stability attributes may not be used outside of the standard library
32+
--> $DIR/issue-43106-gating-of-unstable.rs:10:1
33+
|
34+
LL | #[unstable()]
35+
| ^^^^^^^^^^^^^
36+
3737
error[E0734]: stability attributes may not be used outside of the standard library
3838
--> $DIR/issue-43106-gating-of-unstable.rs:7:1
3939
|

0 commit comments

Comments
 (0)