Skip to content

Commit 129fe9a

Browse files
committed
Add a comment to tests/ui/proc-macro/issue-75930-derive-cfg.rs.
Explaining something in the output that surprised me.
1 parent becf494 commit 129fe9a

File tree

3 files changed

+416
-386
lines changed

3 files changed

+416
-386
lines changed

tests/ui/proc-macro/issue-75930-derive-cfg.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,36 @@ extern crate std;
1616
#[macro_use]
1717
extern crate test_macros;
1818

19+
// Note: the expected output contains this sequence:
20+
// ```
21+
// Punct {
22+
// ch: '<',
23+
// spacing: Joint,
24+
// span: $DIR/issue-75930-derive-cfg.rs:25:11: 25:12 (#0),
25+
// },
26+
// Ident {
27+
// ident: "B",
28+
// span: $DIR/issue-75930-derive-cfg.rs:25:29: 25:30 (#0),
29+
// },
30+
// ```
31+
// It's surprising to see a `Joint` token tree followed by an `Ident` token
32+
// tree, because `Joint` is supposed to only be used if the following token is
33+
// `Punct`.
34+
//
35+
// It is because of this code from below:
36+
// ```
37+
// struct Foo<#[cfg(FALSE)] A, B>
38+
// ```
39+
// When the token stream is formed during parsing, `<` is followed immediately
40+
// by `#`, which is punctuation, so it is marked `Joint`. But before being
41+
// passed to the proc macro it is rewritten to this:
42+
// ```
43+
// struct Foo<B>
44+
// ```
45+
// But the `Joint` marker on the `<` is not updated. Perhaps it should be
46+
// corrected before being passed to the proc macro? But a prior attempt to do
47+
// that kind of correction caused the problem seen in #76399, so maybe not.
48+
1949
#[print_helper(a)] //~ WARN derive helper attribute is used before it is introduced
2050
//~| WARN this was previously accepted
2151
#[cfg_attr(not(FALSE), allow(dead_code))]

tests/ui/proc-macro/issue-75930-derive-cfg.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: derive helper attribute is used before it is introduced
2-
--> $DIR/issue-75930-derive-cfg.rs:19:3
2+
--> $DIR/issue-75930-derive-cfg.rs:49:3
33
|
44
LL | #[print_helper(a)]
55
| ^^^^^^^^^^^^
@@ -12,7 +12,7 @@ LL | #[derive(Print)]
1212
= note: `#[warn(legacy_derive_helpers)]` on by default
1313

1414
warning: derive helper attribute is used before it is introduced
15-
--> $DIR/issue-75930-derive-cfg.rs:19:3
15+
--> $DIR/issue-75930-derive-cfg.rs:49:3
1616
|
1717
LL | #[print_helper(a)]
1818
| ^^^^^^^^^^^^

0 commit comments

Comments
 (0)