Closed
Description
Code
match x {
0..42 => {},
_ => {},
}
Current output
error[E0658]: exclusive range pattern syntax is experimental
--> src/lib.rs:3:9
|
3 | 0..42 => {},
| ^^^^^
|
= note: see issue #37854 <https://github.com/rust-lang/rust/issues/37854> for more information
Desired output
error[E0658]: exclusive range pattern syntax is experimental
--> src/lib.rs:3:9
|
3 | 0..42 => {},
| ^^^^^
|
= note: see issue #37854 <https://github.com/rust-lang/rust/issues/37854> for more information
= help: use an inclusive range pattern, like 0..=41
Rationale and extra context
Came across this when a beginner was very confused about what was wrong with their match
; the words "is experimental" and the link to the issue was not sufficient for their discovering what the problem/solution was.
The suggested inclusive range pattern doesn't need to contain the actual matching value if producing it is hard or impossible, printing something like use an inclusive range pattern, like N..=M
is still better than nothing.
This issue may of course be ignored/closed if this nightly feature is just about ready to be stabilized or something.
Other cases
No response
Rust Version
❯ rustc --version --verbose
rustc 1.75.0 (82e1608df 2023-12-21)
binary: rustc
commit-hash: 82e1608dfa6e0b5569232559e3d385fea5a93112
commit-date: 2023-12-21
host: x86_64-pc-windows-msvc
release: 1.75.0
LLVM version: 17.0.6
Anything else?
@rustbot label +D-terse +C-enhancement +F-exclusive_range_pattern
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsCategory: An issue proposing an enhancement or a PR with one.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.`#![feature(exclusive_range_pattern)]`Relevant to the compiler team, which will review and decide on the PR/issue.