-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
2021 disjoint capture suggestion breaks macro_rules macro #88440
Copy link
Copy link
Open
Labels
A-closuresArea: Closures (`|…| { … }`)Area: Closures (`|…| { … }`)A-edition-2021Area: The 2021 editionArea: The 2021 editionA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-bugCategory: This is a bug.Category: This is a bug.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.
Metadata
Metadata
Assignees
Labels
A-closuresArea: Closures (`|…| { … }`)Area: Closures (`|…| { … }`)A-edition-2021Area: The 2021 editionArea: The 2021 editionA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-bugCategory: This is a bug.Category: This is a bug.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.
Type
Fields
Give feedbackNo fields configured for issues without a type.
I tried this code:
The rust_2021_incompatible_closure_captures lint generates a suggestion which causes this to fail to compile:
I'm not exactly sure what this should do. In this particular case, the suggestion is not required. However, that's a fundamental problem with the
rust_2021_incompatible_closure_captureslint, as it does not know when it is required.In general, modifying macros can be prone to failure, so maybe an alternative is to issue a warning with a non-machine-applicable fix when inside a
macro_rulesdefinition?This was found in the 2021 crater run for rcodec 1.0.1: https://crater-reports.s3.amazonaws.com/pr-87190-3/try%23a7a572ce3edd6d476191fbfe92c9c1986e009b34/reg/rcodec-1.0.1/log.txt
Note that this has even worse behavior than the example above. The sample macro:
rewrites the map call to:
which is invalid syntax.
Meta
rustc --version --verbose:cc @rust-lang/wg-rfc-2229