Skip to content

Commit 26bd86d

Browse files
committed
fix(test): improve sensitivity of hygene tests
The change in 07f855d introduced a trailing numeral of some kind after the `extern crate compiler_builtins`, which appears to have caused at least two false negatives (654b924 and 657fd24). Instead, this change normalizes the test output to ignore the number (of symbols rustc recognizes?) to avoid needing to re-`--bless` these two tests for unrelated changes.
1 parent d88ab22 commit 26bd86d

File tree

4 files changed

+17
-11
lines changed

4 files changed

+17
-11
lines changed

tests/ui/proc-macro/meta-macro-hygiene.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
// edition:2018
44
// compile-flags: -Z span-debug -Z macro-backtrace -Z unpretty=expanded,hygiene -Z trim-diagnostic-paths=no
55
// check-pass
6+
// ignore-tidy-linelength
67
// normalize-stdout-test "\d+#" -> "0#"
78
// normalize-stdout-test "expn\d{3,}" -> "expnNNN"
9+
// normalize-stdout-test "extern crate compiler_builtins /\* \d+ \*/" -> "extern crate compiler_builtins /* NNN */"
810
//
911
// We don't care about symbol ids, so we set them all to 0
1012
// in the stdout
@@ -22,7 +24,7 @@ macro_rules! produce_it {
2224
// the fact that `print_def_site` is produced by a
2325
// `macro_rules!` macro in `make_macro`).
2426
meta_macro::print_def_site!($crate::dummy!());
25-
}
27+
};
2628
}
2729

2830
fn main() {

tests/ui/proc-macro/meta-macro-hygiene.stdout

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
Def site: $DIR/auxiliary/make-macro.rs:7:9: 7:56 (#4)
2-
Input: TokenStream [Ident { ident: "$crate", span: $DIR/meta-macro-hygiene.rs:24:37: 24:43 (#3) }, Punct { ch: ':', spacing: Joint, span: $DIR/meta-macro-hygiene.rs:24:43: 24:44 (#3) }, Punct { ch: ':', spacing: Alone, span: $DIR/meta-macro-hygiene.rs:24:44: 24:45 (#3) }, Ident { ident: "dummy", span: $DIR/meta-macro-hygiene.rs:24:45: 24:50 (#3) }, Punct { ch: '!', spacing: Alone, span: $DIR/meta-macro-hygiene.rs:24:50: 24:51 (#3) }, Group { delimiter: Parenthesis, stream: TokenStream [], span: $DIR/meta-macro-hygiene.rs:24:51: 24:53 (#3) }]
2+
Input: TokenStream [Ident { ident: "$crate", span: $DIR/meta-macro-hygiene.rs:26:37: 26:43 (#3) }, Punct { ch: ':', spacing: Joint, span: $DIR/meta-macro-hygiene.rs:26:43: 26:44 (#3) }, Punct { ch: ':', spacing: Alone, span: $DIR/meta-macro-hygiene.rs:26:44: 26:45 (#3) }, Ident { ident: "dummy", span: $DIR/meta-macro-hygiene.rs:26:45: 26:50 (#3) }, Punct { ch: '!', spacing: Alone, span: $DIR/meta-macro-hygiene.rs:26:50: 26:51 (#3) }, Group { delimiter: Parenthesis, stream: TokenStream [], span: $DIR/meta-macro-hygiene.rs:26:51: 26:53 (#3) }]
33
Respanned: TokenStream [Ident { ident: "$crate", span: $DIR/auxiliary/make-macro.rs:7:9: 7:56 (#4) }, Punct { ch: ':', spacing: Joint, span: $DIR/auxiliary/make-macro.rs:7:9: 7:56 (#4) }, Punct { ch: ':', spacing: Alone, span: $DIR/auxiliary/make-macro.rs:7:9: 7:56 (#4) }, Ident { ident: "dummy", span: $DIR/auxiliary/make-macro.rs:7:9: 7:56 (#4) }, Punct { ch: '!', spacing: Alone, span: $DIR/auxiliary/make-macro.rs:7:9: 7:56 (#4) }, Group { delimiter: Parenthesis, stream: TokenStream [], span: $DIR/auxiliary/make-macro.rs:7:9: 7:56 (#4) }]
44
#![feature /* 0#0 */(prelude_import)]
55
// aux-build:make-macro.rs
66
// aux-build:meta-macro.rs
77
// edition:2018
88
// compile-flags: -Z span-debug -Z macro-backtrace -Z unpretty=expanded,hygiene -Z trim-diagnostic-paths=no
99
// check-pass
10+
// ignore-tidy-linelength
1011
// normalize-stdout-test "\d+#" -> "0#"
1112
// normalize-stdout-test "expn\d{3,}" -> "expnNNN"
13+
// normalize-stdout-test "extern crate compiler_builtins /\* \d+ \*/" -> "extern crate compiler_builtins /* NNN */"
1214
//
1315
// We don't care about symbol ids, so we set them all to 0
1416
// in the stdout
@@ -18,7 +20,7 @@ Respanned: TokenStream [Ident { ident: "$crate", span: $DIR/auxiliary/make-macro
1820
use core /* 0#1 */::prelude /* 0#1 */::rust_2018 /* 0#1 */::*;
1921
#[macro_use /* 0#1 */]
2022
extern crate core /* 0#1 */;
21-
extern crate compiler_builtins /* 445 */ as _ /* 0#1 */;
23+
extern crate compiler_builtins /* NNN */ as _ /* 0#1 */;
2224
// Don't load unnecessary hygiene information from std
2325
extern crate std /* 0#0 */;
2426

@@ -36,7 +38,7 @@ macro_rules! produce_it
3638
// relative to `meta_macro`, *not* `make_macro` (despite
3739
// the fact that `print_def_site` is produced by a
3840
// `macro_rules!` macro in `make_macro`).
39-
}
41+
} ;
4042
}
4143

4244
fn main /* 0#0 */() { ; }

tests/ui/proc-macro/nonterminal-token-hygiene.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
// check-pass
44
// compile-flags: -Z span-debug -Z macro-backtrace -Z unpretty=expanded,hygiene
55
// compile-flags: -Z trim-diagnostic-paths=no
6+
// ignore-tidy-linelength
67
// normalize-stdout-test "\d+#" -> "0#"
78
// normalize-stdout-test "expn\d{3,}" -> "expnNNN"
9+
// normalize-stdout-test "extern crate compiler_builtins /\* \d+ \*/" -> "extern crate compiler_builtins /* NNN */"
810
// aux-build:test-macros.rs
911

1012
#![feature(decl_macro)]
11-
1213
#![no_std] // Don't load unnecessary hygiene information from std
1314
extern crate std;
1415

tests/ui/proc-macro/nonterminal-token-hygiene.stdout

+7-6
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ PRINT-BANG INPUT (DEBUG): TokenStream [
66
stream: TokenStream [
77
Ident {
88
ident: "struct",
9-
span: $DIR/nonterminal-token-hygiene.rs:31:5: 31:11 (#4),
9+
span: $DIR/nonterminal-token-hygiene.rs:32:5: 32:11 (#4),
1010
},
1111
Ident {
1212
ident: "S",
13-
span: $DIR/nonterminal-token-hygiene.rs:31:12: 31:13 (#4),
13+
span: $DIR/nonterminal-token-hygiene.rs:32:12: 32:13 (#4),
1414
},
1515
Punct {
1616
ch: ';',
1717
spacing: Alone,
18-
span: $DIR/nonterminal-token-hygiene.rs:31:13: 31:14 (#4),
18+
span: $DIR/nonterminal-token-hygiene.rs:32:13: 32:14 (#4),
1919
},
2020
],
21-
span: $DIR/nonterminal-token-hygiene.rs:21:27: 21:32 (#5),
21+
span: $DIR/nonterminal-token-hygiene.rs:22:27: 22:32 (#5),
2222
},
2323
]
2424
#![feature /* 0#0 */(prelude_import)]
@@ -28,18 +28,19 @@ PRINT-BANG INPUT (DEBUG): TokenStream [
2828
// check-pass
2929
// compile-flags: -Z span-debug -Z macro-backtrace -Z unpretty=expanded,hygiene
3030
// compile-flags: -Z trim-diagnostic-paths=no
31+
// ignore-tidy-linelength
3132
// normalize-stdout-test "\d+#" -> "0#"
3233
// normalize-stdout-test "expn\d{3,}" -> "expnNNN"
34+
// normalize-stdout-test "extern crate compiler_builtins /\* \d+ \*/" -> "extern crate compiler_builtins /* NNN */"
3335
// aux-build:test-macros.rs
3436

3537
#![feature /* 0#0 */(decl_macro)]
36-
3738
#![no_std /* 0#0 */]
3839
#[prelude_import /* 0#1 */]
3940
use ::core /* 0#1 */::prelude /* 0#1 */::rust_2015 /* 0#1 */::*;
4041
#[macro_use /* 0#1 */]
4142
extern crate core /* 0#2 */;
42-
extern crate compiler_builtins /* 445 */ as _ /* 0#2 */;
43+
extern crate compiler_builtins /* NNN */ as _ /* 0#2 */;
4344
// Don't load unnecessary hygiene information from std
4445
extern crate std /* 0#0 */;
4546

0 commit comments

Comments
 (0)