edition-2024-expr-fragment-specifier requires feature to work (on stable...)
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
I tried this code:
#![allow(irrefutable_let_patterns)]
#![warn(edition_2024_expr_fragment_specifier)]
enum Enum<T> { TSVariant(#[allow(dead_code)] T), SVariant { _v: T }, UVariant }
macro_rules! is_variant {
(@check $variant:ident, $matcher:tt, $expr:expr) => (
assert!(if let Enum::$variant::<()> $matcher = $expr { true } else { false },
"expr does not have correct type");
);
}
fn main() {}
I expected to see this happen: lint applies successfully
Instead, this happened: lint breaks your build in almost all cases
warning: the `expr` fragment specifier will accept more expressions in the 2024 edition
--> ./tests/ui/type-alias-enum-variants/enum-variant-generic-args-pass.rs:8:48
|
8 | (@check $variant:ident, $matcher:tt, $expr:expr) => (
| ^^^^
|
= warning: this changes meaning in Rust 2024
= note: for more information, see Migration Guide <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/macro-fragment-specifiers.html>
note: the lint level is defined here
--> ./tests/ui/type-alias-enum-variants/enum-variant-generic-args-pass.rs:3:9
|
3 | #![warn(edition_2024_expr_fragment_specifier)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: to keep the existing behavior, use the `expr_2021` fragment specifier
|
8 | (@check $variant:ident, $matcher:tt, $expr:expr_2021) => (
| ~~~~~~~~~
when changed to (@check $variant:ident, $matcher:tt, $expr:expr_2021) => (, the code suddenly requires a feature which was never opted into, even on beta or stable 🤔
This is weird since the lint is machine applicable.
Meta
rustc --version --verbose:
rustc 1.83.0-nightly (2bd1e894e 2024-09-26)
binary: rustc
commit-hash: 2bd1e894efde3b6be857ad345914a3b1cea51def
commit-date: 2024-09-26
host: x86_64-unknown-linux-gnu
release: 1.83.0-nightly
LLVM version: 19.1.0
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the diagnostic in tests/ui/type-alias-enum-variants/enum-variant-generic-args-pass.rs with the shown nightly compiler context. Inspect the edition_2024_expr_fragment_specifier lint and its machine-applicable suggestion, then verify behavior on stable and beta. Done means the suggested change does not unexpectedly require an unsupported feature, with a regression test covering the case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100