Skip to content

Commit 15e0627

Browse files
committed
Reorder fields to visit NodeId first.
1 parent 7b8def0 commit 15e0627

File tree

12 files changed

+130
-127
lines changed

12 files changed

+130
-127
lines changed

compiler/rustc_ast/src/ast.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -554,12 +554,12 @@ pub struct WhereEqPredicate {
554554

555555
#[derive(Clone, Encodable, Decodable, Debug, Walkable)]
556556
pub struct Crate {
557-
pub attrs: AttrVec,
558-
pub items: ThinVec<P<Item>>,
559-
pub spans: ModSpans,
560557
/// Must be equal to `CRATE_NODE_ID` after the crate root is expanded, but may hold
561558
/// expansion placeholders or an unassigned value (`DUMMY_NODE_ID`) before that.
562559
pub id: NodeId,
560+
pub attrs: AttrVec,
561+
pub items: ThinVec<P<Item>>,
562+
pub spans: ModSpans,
563563
pub is_placeholder: bool,
564564
}
565565

@@ -2278,7 +2278,7 @@ pub struct MutTy {
22782278

22792279
/// Represents a function's signature in a trait declaration,
22802280
/// trait implementation, or free function.
2281-
#[derive(Clone, Encodable, Decodable, Debug, Walkable)]
2281+
#[derive(Clone, Encodable, Decodable, Debug)]
22822282
pub struct FnSig {
22832283
pub header: FnHeader,
22842284
pub decl: P<FnDecl>,
@@ -3778,7 +3778,7 @@ pub struct FnContract {
37783778
pub ensures: Option<P<Expr>>,
37793779
}
37803780

3781-
#[derive(Clone, Encodable, Decodable, Debug, Walkable)]
3781+
#[derive(Clone, Encodable, Decodable, Debug)]
37823782
pub struct Fn {
37833783
pub defaultness: Defaultness,
37843784
pub ident: Ident,

compiler/rustc_ast/src/visit.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -521,8 +521,6 @@ macro_rules! common_visitor_and_walkers {
521521
DelimSpan,
522522
EnumDef,
523523
Extern,
524-
Fn,
525-
FnSig,
526524
ForLoopKind,
527525
FormatArgPosition,
528526
FormatArgsPiece,
@@ -1005,8 +1003,13 @@ macro_rules! common_visitor_and_walkers {
10051003
// Visibility is visited as a part of the item.
10061004
_vis,
10071005
Fn { defaultness, ident, sig, generics, contract, body, define_opaque },
1008-
) =>
1009-
visit_visitable!($($mut)? vis, defaultness, ident, sig, generics, contract, body, define_opaque),
1006+
) => {
1007+
let FnSig { header, decl, span } = sig;
1008+
visit_visitable!($($mut)? vis,
1009+
defaultness, ident, header, generics, decl,
1010+
contract, body, span, define_opaque
1011+
)
1012+
}
10101013
FnKind::Closure(binder, coroutine_kind, decl, body) =>
10111014
visit_visitable!($($mut)? vis, binder, coroutine_kind, decl, body),
10121015
}

tests/ui/asm/inline-syntax.x86_64.stderr

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1+
warning: avoid using `.intel_syntax`, Intel syntax is the default
2+
--> $DIR/inline-syntax.rs:47:14
3+
|
4+
LL | global_asm!(".intel_syntax noprefix", "nop");
5+
| ^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: `#[warn(bad_asm_style)]` on by default
8+
19
warning: avoid using `.intel_syntax`, Intel syntax is the default
210
--> $DIR/inline-syntax.rs:21:15
311
|
412
LL | asm!(".intel_syntax noprefix", "nop");
513
| ^^^^^^^^^^^^^^^^^^^^^^
6-
|
7-
= note: `#[warn(bad_asm_style)]` on by default
814

915
warning: avoid using `.intel_syntax`, Intel syntax is the default
1016
--> $DIR/inline-syntax.rs:24:15
@@ -36,11 +42,5 @@ warning: avoid using `.intel_syntax`, Intel syntax is the default
3642
LL | .intel_syntax noprefix
3743
| ^^^^^^^^^^^^^^^^^^^^^^
3844

39-
warning: avoid using `.intel_syntax`, Intel syntax is the default
40-
--> $DIR/inline-syntax.rs:47:14
41-
|
42-
LL | global_asm!(".intel_syntax noprefix", "nop");
43-
| ^^^^^^^^^^^^^^^^^^^^^^
44-
4545
warning: 7 warnings emitted
4646

tests/ui/attributes/key-value-expansion-scope.stderr

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,27 @@ LL | #![doc = in_block!()]
126126
|
127127
= help: have you added the `#[macro_use]` on the module/import?
128128

129+
warning: cannot find macro `in_root` in the current scope when looking from the crate root
130+
--> $DIR/key-value-expansion-scope.rs:1:10
131+
|
132+
LL | #![doc = in_root!()]
133+
| ^^^^^^^ not found from the crate root
134+
|
135+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
136+
= note: for more information, see issue #124535 <https://github.com/rust-lang/rust/issues/124535>
137+
= help: import `macro_rules` with `use` to make it callable above its definition
138+
= note: `#[warn(out_of_scope_macro_calls)]` on by default
139+
140+
warning: cannot find macro `in_mod_escape` in the current scope when looking from the crate root
141+
--> $DIR/key-value-expansion-scope.rs:4:10
142+
|
143+
LL | #![doc = in_mod_escape!()]
144+
| ^^^^^^^^^^^^^ not found from the crate root
145+
|
146+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
147+
= note: for more information, see issue #124535 <https://github.com/rust-lang/rust/issues/124535>
148+
= help: import `macro_rules` with `use` to make it callable above its definition
149+
129150
warning: cannot find macro `in_mod` in the current scope when looking from module `macros_stay`
130151
--> $DIR/key-value-expansion-scope.rs:21:9
131152
|
@@ -135,7 +156,6 @@ LL | #[doc = in_mod!()]
135156
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
136157
= note: for more information, see issue #124535 <https://github.com/rust-lang/rust/issues/124535>
137158
= help: import `macro_rules` with `use` to make it callable above its definition
138-
= note: `#[warn(out_of_scope_macro_calls)]` on by default
139159

140160
warning: cannot find macro `in_mod` in the current scope when looking from module `macros_stay`
141161
--> $DIR/key-value-expansion-scope.rs:24:14
@@ -167,25 +187,5 @@ LL | #![doc = in_mod_escape!()]
167187
= note: for more information, see issue #124535 <https://github.com/rust-lang/rust/issues/124535>
168188
= help: import `macro_rules` with `use` to make it callable above its definition
169189

170-
warning: cannot find macro `in_root` in the current scope when looking from the crate root
171-
--> $DIR/key-value-expansion-scope.rs:1:10
172-
|
173-
LL | #![doc = in_root!()]
174-
| ^^^^^^^ not found from the crate root
175-
|
176-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
177-
= note: for more information, see issue #124535 <https://github.com/rust-lang/rust/issues/124535>
178-
= help: import `macro_rules` with `use` to make it callable above its definition
179-
180-
warning: cannot find macro `in_mod_escape` in the current scope when looking from the crate root
181-
--> $DIR/key-value-expansion-scope.rs:4:10
182-
|
183-
LL | #![doc = in_mod_escape!()]
184-
| ^^^^^^^^^^^^^ not found from the crate root
185-
|
186-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
187-
= note: for more information, see issue #124535 <https://github.com/rust-lang/rust/issues/124535>
188-
= help: import `macro_rules` with `use` to make it callable above its definition
189-
190190
error: aborting due to 16 previous errors; 6 warnings emitted
191191

tests/ui/cfg/cfg-version/syntax.stderr

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -95,32 +95,32 @@ LL | assert!(cfg!(version("1.20.0-stable")));
9595
| ^^^^^^^^^^^^^^^
9696

9797
warning: unexpected `cfg` condition name: `version`
98-
--> $DIR/syntax.rs:130:18
98+
--> $DIR/syntax.rs:30:7
9999
|
100-
LL | assert!(cfg!(version = "1.43"));
101-
| ^^^^^^^^^^^^^^^^
100+
LL | #[cfg(version = "1.43")]
101+
| ^^^^^^^^^^^^^^^^
102102
|
103103
= help: to expect this configuration use `--check-cfg=cfg(version, values("1.43"))`
104104
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
105105
= note: `#[warn(unexpected_cfgs)]` on by default
106106
help: there is a similar config predicate: `version("..")`
107107
|
108-
LL - assert!(cfg!(version = "1.43"));
109-
LL + assert!(cfg!(version("1.43")));
108+
LL - #[cfg(version = "1.43")]
109+
LL + #[cfg(version("1.43"))]
110110
|
111111

112112
warning: unexpected `cfg` condition name: `version`
113-
--> $DIR/syntax.rs:30:7
113+
--> $DIR/syntax.rs:130:18
114114
|
115-
LL | #[cfg(version = "1.43")]
116-
| ^^^^^^^^^^^^^^^^
115+
LL | assert!(cfg!(version = "1.43"));
116+
| ^^^^^^^^^^^^^^^^
117117
|
118118
= help: to expect this configuration use `--check-cfg=cfg(version, values("1.43"))`
119119
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
120120
help: there is a similar config predicate: `version("..")`
121121
|
122-
LL - #[cfg(version = "1.43")]
123-
LL + #[cfg(version("1.43"))]
122+
LL - assert!(cfg!(version = "1.43"));
123+
LL + assert!(cfg!(version("1.43")));
124124
|
125125

126126
error[E0425]: cannot find function `key_value_form` in this scope

tests/ui/check-cfg/mix.stderr

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,53 @@
1+
warning: unexpected `cfg` condition name: `widnows`
2+
--> $DIR/mix.rs:13:7
3+
|
4+
LL | #[cfg(widnows)]
5+
| ^^^^^^^ help: there is a config with a similar name: `windows`
6+
|
7+
= help: to expect this configuration use `--check-cfg=cfg(widnows)`
8+
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
9+
= note: `#[warn(unexpected_cfgs)]` on by default
10+
11+
warning: unexpected `cfg` condition value: (none)
12+
--> $DIR/mix.rs:17:7
13+
|
14+
LL | #[cfg(feature)]
15+
| ^^^^^^^- help: specify a config value: `= "foo"`
16+
|
17+
= note: expected values for `feature` are: `foo`
18+
= help: to expect this configuration use `--check-cfg=cfg(feature)`
19+
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
20+
21+
warning: unexpected `cfg` condition value: `bar`
22+
--> $DIR/mix.rs:24:7
23+
|
24+
LL | #[cfg(feature = "bar")]
25+
| ^^^^^^^^^^^^^^^
26+
|
27+
= note: expected values for `feature` are: `foo`
28+
= help: to expect this configuration use `--check-cfg=cfg(feature, values("bar"))`
29+
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
30+
31+
warning: unexpected `cfg` condition value: `zebra`
32+
--> $DIR/mix.rs:28:7
33+
|
34+
LL | #[cfg(feature = "zebra")]
35+
| ^^^^^^^^^^^^^^^^^
36+
|
37+
= note: expected values for `feature` are: `foo`
38+
= help: to expect this configuration use `--check-cfg=cfg(feature, values("zebra"))`
39+
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
40+
41+
warning: unexpected `cfg` condition name: `uu`
42+
--> $DIR/mix.rs:32:12
43+
|
44+
LL | #[cfg_attr(uu, unix)]
45+
| ^^
46+
|
47+
= help: expected names are: `feature` and 31 more
48+
= help: to expect this configuration use `--check-cfg=cfg(uu)`
49+
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
50+
151
warning: unexpected `cfg` condition name: `widnows`
252
--> $DIR/mix.rs:41:10
353
|
@@ -6,7 +56,6 @@ LL | cfg!(widnows);
656
|
757
= help: to expect this configuration use `--check-cfg=cfg(widnows)`
858
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
9-
= note: `#[warn(unexpected_cfgs)]` on by default
1059

1160
warning: unexpected `cfg` condition value: `bar`
1261
--> $DIR/mix.rs:44:10
@@ -34,7 +83,6 @@ warning: unexpected `cfg` condition name: `xxx`
3483
LL | cfg!(xxx = "foo");
3584
| ^^^^^^^^^^^
3685
|
37-
= help: expected names are: `feature` and 31 more
3886
= help: to expect this configuration use `--check-cfg=cfg(xxx, values("foo"))`
3987
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
4088

@@ -197,53 +245,5 @@ LL | cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra"));
197245
= help: to expect this configuration use `--check-cfg=cfg(feature, values("zebra"))`
198246
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
199247

200-
warning: unexpected `cfg` condition name: `widnows`
201-
--> $DIR/mix.rs:13:7
202-
|
203-
LL | #[cfg(widnows)]
204-
| ^^^^^^^ help: there is a config with a similar name: `windows`
205-
|
206-
= help: to expect this configuration use `--check-cfg=cfg(widnows)`
207-
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
208-
209-
warning: unexpected `cfg` condition value: (none)
210-
--> $DIR/mix.rs:17:7
211-
|
212-
LL | #[cfg(feature)]
213-
| ^^^^^^^- help: specify a config value: `= "foo"`
214-
|
215-
= note: expected values for `feature` are: `foo`
216-
= help: to expect this configuration use `--check-cfg=cfg(feature)`
217-
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
218-
219-
warning: unexpected `cfg` condition value: `bar`
220-
--> $DIR/mix.rs:24:7
221-
|
222-
LL | #[cfg(feature = "bar")]
223-
| ^^^^^^^^^^^^^^^
224-
|
225-
= note: expected values for `feature` are: `foo`
226-
= help: to expect this configuration use `--check-cfg=cfg(feature, values("bar"))`
227-
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
228-
229-
warning: unexpected `cfg` condition value: `zebra`
230-
--> $DIR/mix.rs:28:7
231-
|
232-
LL | #[cfg(feature = "zebra")]
233-
| ^^^^^^^^^^^^^^^^^
234-
|
235-
= note: expected values for `feature` are: `foo`
236-
= help: to expect this configuration use `--check-cfg=cfg(feature, values("zebra"))`
237-
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
238-
239-
warning: unexpected `cfg` condition name: `uu`
240-
--> $DIR/mix.rs:32:12
241-
|
242-
LL | #[cfg_attr(uu, unix)]
243-
| ^^
244-
|
245-
= help: to expect this configuration use `--check-cfg=cfg(uu)`
246-
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
247-
248248
warning: 26 warnings emitted
249249

tests/ui/coroutine/print/coroutine-print-verbose-1.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ note: required because it's used within this coroutine
3333
|
3434
LL | #[coroutine] || {
3535
| ^^
36-
note: required because it appears within the type `Opaque(DefId(0:28 ~ coroutine_print_verbose_1[75fb]::make_gen2::{opaque#0}), [Arc<RefCell<i32>>])`
36+
note: required because it appears within the type `Opaque(DefId(0:29 ~ coroutine_print_verbose_1[75fb]::make_gen2::{opaque#0}), [Arc<RefCell<i32>>])`
3737
--> $DIR/coroutine-print-verbose-1.rs:41:30
3838
|
3939
LL | pub fn make_gen2<T>(t: T) -> impl Coroutine<Return = T> {

tests/ui/impl-trait/precise-capturing/illegal-positions.real.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@ error: `use<...>` precise capturing syntax not allowed in bounds
1616
LL | type Assoc: use<> where (): use<>;
1717
| ^^^^^
1818

19-
error: at least one trait must be specified
20-
--> $DIR/illegal-positions.rs:14:21
21-
|
22-
LL | fn fun<T: use<>>(_: impl use<>) where (): use<> {}
23-
| ^^^^^^^^^^
24-
2519
error: `use<...>` precise capturing syntax not allowed in bounds
2620
--> $DIR/illegal-positions.rs:14:11
2721
|
@@ -34,6 +28,12 @@ error: `use<...>` precise capturing syntax not allowed in bounds
3428
LL | fn fun<T: use<>>(_: impl use<>) where (): use<> {}
3529
| ^^^^^
3630

31+
error: at least one trait must be specified
32+
--> $DIR/illegal-positions.rs:14:21
33+
|
34+
LL | fn fun<T: use<>>(_: impl use<>) where (): use<> {}
35+
| ^^^^^^^^^^
36+
3737
error: `use<...>` precise capturing syntax not allowed in `dyn` trait object bounds
3838
--> $DIR/illegal-positions.rs:21:25
3939
|

tests/ui/lint/unused/useless-comment.stderr

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
error: unused doc comment
2+
--> $DIR/useless-comment.rs:9:1
3+
|
4+
LL | /// foo
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ rustdoc does not generate documentation for macro invocations
6+
|
7+
= help: to document an item produced by a macro, the macro must produce the documentation as part of its expansion
8+
note: the lint level is defined here
9+
--> $DIR/useless-comment.rs:3:9
10+
|
11+
LL | #![deny(unused_doc_comments)]
12+
| ^^^^^^^^^^^^^^^^^^^
13+
114
error: unused doc comment
215
--> $DIR/useless-comment.rs:12:1
316
|
@@ -8,11 +21,6 @@ LL | unsafe extern "C" { }
821
| --------------------- rustdoc does not generate documentation for extern blocks
922
|
1023
= help: use `//` for a plain comment
11-
note: the lint level is defined here
12-
--> $DIR/useless-comment.rs:3:9
13-
|
14-
LL | #![deny(unused_doc_comments)]
15-
| ^^^^^^^^^^^^^^^^^^^
1624

1725
error: unused doc comment
1826
--> $DIR/useless-comment.rs:13:1
@@ -151,13 +159,5 @@ LL | | }
151159
|
152160
= help: use `//` for a plain comment
153161

154-
error: unused doc comment
155-
--> $DIR/useless-comment.rs:9:1
156-
|
157-
LL | /// foo
158-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ rustdoc does not generate documentation for macro invocations
159-
|
160-
= help: to document an item produced by a macro, the macro must produce the documentation as part of its expansion
161-
162162
error: aborting due to 15 previous errors
163163

0 commit comments

Comments
 (0)