Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exclusive_range_pattern error is unhelpful #120047

Closed
ilyvion opened this issue Jan 17, 2024 · 1 comment · Fixed by #120152
Closed

exclusive_range_pattern error is unhelpful #120047

ilyvion opened this issue Jan 17, 2024 · 1 comment · Fixed by #120152
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. D-terse Diagnostics: An error or lint that doesn't give enough information about the problem at hand. F-exclusive_range_pattern `#![feature(exclusive_range_pattern)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@ilyvion
Copy link

ilyvion commented Jan 17, 2024

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

@ilyvion ilyvion added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 17, 2024
@rustbot rustbot added needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. C-enhancement Category: An issue proposing an enhancement or a PR with one. D-terse Diagnostics: An error or lint that doesn't give enough information about the problem at hand. F-exclusive_range_pattern `#![feature(exclusive_range_pattern)]` labels Jan 17, 2024
@Noratrieb Noratrieb removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 19, 2024
@rowan-sl
Copy link
Contributor

@rustbot claim

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 22, 2024
…ttern, r=oli-obk

add help message for `exclusive_range_pattern` error

Fixes rust-lang#120047

this error
```
error[E0658]: exclusive range pattern syntax is experimental
 --> src/lib.rs:3:9
  |
3 |         0..42 => {},
  |         ^^^^^
  |
  = note: see issue rust-lang#37854 <rust-lang#37854> for more information
  = help: use an inclusive range pattern, like N..=M
  ```
now includes a help message

Not sure of proper procedure here but this seemed like a good help message (used the one suggested in the original issue), if you have a idea for one that is better or something I missed please comment!
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 22, 2024
…ttern, r=oli-obk

add help message for `exclusive_range_pattern` error

Fixes rust-lang#120047

this error
```
error[E0658]: exclusive range pattern syntax is experimental
 --> src/lib.rs:3:9
  |
3 |         0..42 => {},
  |         ^^^^^
  |
  = note: see issue rust-lang#37854 <rust-lang#37854> for more information
  = help: use an inclusive range pattern, like N..=M
  ```
now includes a help message

Not sure of proper procedure here but this seemed like a good help message (used the one suggested in the original issue), if you have a idea for one that is better or something I missed please comment!
@bors bors closed this as completed in 2346647 Jan 22, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jan 22, 2024
Rollup merge of rust-lang#120152 - rowan-sl:help-message-for-range-pattern, r=oli-obk

add help message for `exclusive_range_pattern` error

Fixes rust-lang#120047

this error
```
error[E0658]: exclusive range pattern syntax is experimental
 --> src/lib.rs:3:9
  |
3 |         0..42 => {},
  |         ^^^^^
  |
  = note: see issue rust-lang#37854 <rust-lang#37854> for more information
  = help: use an inclusive range pattern, like N..=M
  ```
now includes a help message

Not sure of proper procedure here but this seemed like a good help message (used the one suggested in the original issue), if you have a idea for one that is better or something I missed please comment!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. D-terse Diagnostics: An error or lint that doesn't give enough information about the problem at hand. F-exclusive_range_pattern `#![feature(exclusive_range_pattern)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants