-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Point at enum definition when match patterns are not exhaustive #58380
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,17 @@ | ||
error[E0004]: non-exhaustive patterns: `HastaLaVistaBaby` not covered | ||
--> $DIR/E0004.rs:9:11 | ||
| | ||
LL | match x { //~ ERROR E0004 | ||
| ^ pattern `HastaLaVistaBaby` not covered | ||
LL | / enum Terminator { | ||
LL | | HastaLaVistaBaby, | ||
| | ---------------- not covered | ||
LL | | TalkToMyHand, | ||
LL | | } | ||
| |_- `Terminator` defined here | ||
... | ||
LL | match x { //~ ERROR E0004 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (possibly a bad idea, probably out of scope for this PR) I find it counterintuitive for the primary span of a "non-exaustive patterns" error to point to the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have the same thoughts you do, but I lay on the side of using the smallest possible primary span, for VSCode's sake. |
||
| ^ pattern `HastaLaVistaBaby` not covered | ||
| | ||
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms | ||
|
||
error: aborting due to previous error | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I usually write empty vectors as
Vec::new()
(thinking, "no need to the macro sugar when there aren't any elements to initialize"), butrustfmt
doesn't seem to have an opinion. (I guess you could argue that it's technically a semantic change.)