Add a comment to `tests/ui/proc-macro/issue-75930-derive-cfg.rs`.

Explaining something in the output that surprised me.
This commit is contained in:
Nicholas Nethercote 2023-08-08 11:28:29 +10:00
parent becf4942a2
commit 129fe9a998
3 changed files with 1006 additions and 976 deletions

View File

@ -16,6 +16,36 @@ extern crate std;
#[macro_use]
extern crate test_macros;
// Note: the expected output contains this sequence:
// ```
// Punct {
// ch: '<',
// spacing: Joint,
// span: $DIR/issue-75930-derive-cfg.rs:25:11: 25:12 (#0),
// },
// Ident {
// ident: "B",
// span: $DIR/issue-75930-derive-cfg.rs:25:29: 25:30 (#0),
// },
// ```
// It's surprising to see a `Joint` token tree followed by an `Ident` token
// tree, because `Joint` is supposed to only be used if the following token is
// `Punct`.
//
// It is because of this code from below:
// ```
// struct Foo<#[cfg(FALSE)] A, B>
// ```
// When the token stream is formed during parsing, `<` is followed immediately
// by `#`, which is punctuation, so it is marked `Joint`. But before being
// passed to the proc macro it is rewritten to this:
// ```
// struct Foo<B>
// ```
// But the `Joint` marker on the `<` is not updated. Perhaps it should be
// corrected before being passed to the proc macro? But a prior attempt to do
// that kind of correction caused the problem seen in #76399, so maybe not.
#[print_helper(a)] //~ WARN derive helper attribute is used before it is introduced
//~| WARN this was previously accepted
#[cfg_attr(not(FALSE), allow(dead_code))]

View File

@ -1,5 +1,5 @@
warning: derive helper attribute is used before it is introduced
--> $DIR/issue-75930-derive-cfg.rs:19:3
--> $DIR/issue-75930-derive-cfg.rs:49:3
|
LL | #[print_helper(a)]
| ^^^^^^^^^^^^
@ -12,7 +12,7 @@ LL | #[derive(Print)]
= note: `#[warn(legacy_derive_helpers)]` on by default
warning: derive helper attribute is used before it is introduced
--> $DIR/issue-75930-derive-cfg.rs:19:3
--> $DIR/issue-75930-derive-cfg.rs:49:3
|
LL | #[print_helper(a)]
| ^^^^^^^^^^^^

File diff suppressed because it is too large Load Diff