-
Notifications
You must be signed in to change notification settings - Fork 13.4k
2021 disjoint capture suggestion breaks macro_rules macro #88440
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Some of my thought process: My initial thoughts were we can just issue warnings for any closure that has a precise capture given it was defined within a macro. Something like: Drop order/Trait might be affected, please check the edition guide on how to migrate. Without any specific suggestion and maybe we highlight macro a bit more in the edition guide. But we can have a case where Hmm I suppose we will see this as precise capture. I guess during typechk can we tell that a piece of code is with a macro? And can issue a warning that's worded appropriately. |
Maybe related to: #87955 |
The invalid syntax there is already fixed by #87958 |
…ck-fragment, r=estebank Improve closure dummy capture suggestion in macros. Fixes some cases of rust-lang#88440 Fixes https://crater-reports.s3.amazonaws.com/pr-87190-3/try%23a7a572ce3edd6d476191fbfe92c9c1986e009b34/reg/rcodec-1.0.1/log.txt
…ck-fragment, r=estebank Improve closure dummy capture suggestion in macros. Fixes some cases of rust-lang#88440 Fixes https://crater-reports.s3.amazonaws.com/pr-87190-3/try%23a7a572ce3edd6d476191fbfe92c9c1986e009b34/reg/rcodec-1.0.1/log.txt
…ck-fragment, r=estebank Improve closure dummy capture suggestion in macros. Fixes some cases of rust-lang#88440 Fixes https://crater-reports.s3.amazonaws.com/pr-87190-3/try%23a7a572ce3edd6d476191fbfe92c9c1986e009b34/reg/rcodec-1.0.1/log.txt
…ck-fragment, r=estebank Improve closure dummy capture suggestion in macros. Fixes some cases of rust-lang#88440 Fixes https://crater-reports.s3.amazonaws.com/pr-87190-3/try%23a7a572ce3edd6d476191fbfe92c9c1986e009b34/reg/rcodec-1.0.1/log.txt
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_captures
lint, 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_rules
definition?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
The text was updated successfully, but these errors were encountered: