Closed
Description
fn foo() {
let result = Some(1i32);
match result {
Some(r) if r != 0 => {}
None => {}
}
}
The current output is:
Checking mystery v0.1.0 (/home/jsha/learnrust/mystery)
error[E0004]: non-exhaustive patterns: `Some(_)` not covered
--> src/lib.rs:3:11
|
3 | match result {
| ^^^^^^ pattern `Some(_)` not covered
|
::: /home/jsha/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs:518:5
|
518 | Some(#[stable(feature = "rust1", since = "1.0.0")] T),
| ---- not covered
|
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
= note: the matched value is of type `Option<i32>`
For more information about this error, try `rustc --explain E0004`.
Ideally the output should look like:
Checking mystery v0.1.0 (/home/jsha/learnrust/mystery)
error[E0004]: non-exhaustive patterns: `Some(_)` not covered
--> src/lib.rs:3:11
|
3 | match result {
| ^^^^^^ pattern `Some(_)` not covered
|
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
= note: the matched value is of type `Option<i32>`
For more information about this error, try `rustc --explain E0004`.
error: could not compile `mystery` due to previous error
The #[stable(...)]
tag is a directive for documentation, but should not be included in this diagnostic.
This bug exists for me locally in stable and nightly, installed via rustup. Oddly, it does not reproduce on the playground.
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
meithecatte commentedon Nov 20, 2021
Perhaps you have the
rust-src
component installed while the playground doesn't?estebank commentedon Nov 24, 2021
It's pointing at the
enum
variant, not at thestable
annotation. That annotation is for the inner fieldT
onSome
.jsha commentedon Nov 24, 2021
Ah, @NieDzejkob, you're right I have rust-src installed:
Is that not installed by default for most people?
Yep, that makes sense to me. So if I'm understanding right: when rust-src is installed, some extra diagnostics will show up that point to specific lines in Rust stdlib source files, and those lines will naturally contain stability annotations. I had previously been under the impression that stability annotations would be hidden in output like this, but I think that was incorrect.
estebank commentedon Nov 24, 2021
Your understanding is correct. The attributes aren't hidden, just not included in the span when they are outer attributes, but in this case it is the outer attribute of a field inside of the thing being displayed. This would be solved by this old PR of mine, but it needs some fixes to the underlying machinery on its previous PR.
jsha commentedon Nov 24, 2021
Thanks for the explanations! I'll consider this working as intended, then.