-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Make some suggestions "verbose" #137343
base: master
Are you sure you want to change the base?
Make some suggestions "verbose" #137343
Conversation
Some changes occurred to the CTFE machinery cc @rust-lang/wg-const-eval |
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.
Going over the diff, the new output makes some mistakes in the existing suggestions more obvious. Annotated them to address them later.
tests/ui/rfcs/rfc-0000-never_patterns/ICE-130779-never-arm-no-oatherwise-block.stderr
Show resolved
Hide resolved
tests/ui/rfcs/rfc-0000-never_patterns/ICE-133063-never-arm-no-otherwise-block.stderr
Show resolved
Hide resolved
help: remove the qualifier | ||
| | ||
LL - pub(crate) Dove | ||
LL + Dove | ||
| |
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.
Leftover leading whitespace
help: remove this `where` | ||
| | ||
LL - pub type EmptyLeading1<T> where = T where T: Copy; | ||
LL + pub type EmptyLeading1<T> = T where T: Copy; | ||
| |
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.
Leftover whitespace
help: remove the `where` clause | ||
| | ||
LL - type E: where; | ||
LL + type E: ; | ||
| |
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.
Leftover whitespace and :
help: `Trait` has the following associated type | ||
| | ||
LL - type AssociatedTy = dyn Trait<ExpressionStack = i32, Bar = i32>; | ||
LL + type AssociatedTy = dyn Trait<Bar = i32, Bar = i32>; | ||
| |
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.
Suggesting associated type that is already there.
This comment has been minimized.
This comment has been minimized.
I feel like the justification here is still somewhat missing here 🤔
This seems like a limitation of annotate-snippets. I kinda don't think we should be doing major migrations of rustc diagnostics just because annotate-snippets is missing a functionality that rustc has. Especially without any justification for why annotate-snippets doesn't support inline suggestions. Can you please elaborate here? Also, what does this have to do with rust-lang/rust-playground#1117? While some of these diagnostics improvements are neutral, I think a lot of them make the error message quite a lot longer and harder to read. #137348 fixes some of them, but not sure how many still are a bit too verbose and what we need to do to fix them further. |
I'm happy to review any of the fixes called by all of the above inline comments as separate PR(s), prior to converting them being verbose. They're broken on the master branch after all. |
When encountering an unreachable match arm, (correctly) suggest removing the entire arm: ``` error: a never pattern is always unreachable --> $DIR/ICE-130779-never-arm-no-oatherwise-block.rs:10:20 | LL | ! if true => {} | ^^ this will never be executed | help: remove the unreachable match arm | LL - ! if true => {} | ``` Noticed in rust-lang#137343 (comment).
When encountering an unreachable match arm, (correctly) suggest removing the entire arm: ``` error: a never pattern is always unreachable --> $DIR/ICE-130779-never-arm-no-oatherwise-block.rs:10:20 | LL | Some(!) if true => {} | ^^ this will never be executed | help: remove the unreachable match arm | LL - Some(!) if true => {} LL + Some(!), | ``` Noticed in rust-lang#137343 (comment).
When encountering an unreachable match arm, (correctly) suggest removing the entire arm: ``` error: a never pattern is always unreachable --> $DIR/ICE-130779-never-arm-no-oatherwise-block.rs:10:20 | LL | Some(!) if true => {} | ^^ this will never be executed | help: remove the unreachable match arm | LL - Some(!) if true => {} LL + Some(!), | ``` Noticed in rust-lang#137343 (comment).
☔ The latest upstream changes (presumably #137466) made this pull request unmergeable. Please resolve the merge conflicts. |
When encountering an unreachable match arm, (correctly) suggest removing the entire arm: ``` error: a never pattern is always unreachable --> $DIR/ICE-130779-never-arm-no-oatherwise-block.rs:10:20 | LL | Some(!) if true => {} | ^^ this will never be executed | help: remove the unreachable match arm | LL - Some(!) if true => {} LL + Some(!), | ``` Noticed in rust-lang#137343 (comment).
The verbose "diff" suggestion format is easier to read, and the only one supported by annotate-snippets. Making verbose the default in one go would result in a huge PR that is too hard to land: rust-lang#127282. CC rust-lang/rust-playground#1117
b64979d
to
0af7fa2
Compare
Keep a span for the attribute *within* the square brackets as part of the `AttrKind`. ``` error: `cfg` is not followed by parentheses --> $DIR/cfg-attr-syntax-validation.rs:4:1 | LL | #[cfg = 10] | ^^^^^^^^^^^ | help: expected syntax is | LL - #[cfg = 10] LL + #[cfg(/* predicate */)] | ``` Noticed in rust-lang#137343 (comment).
Keep a span for the attribute *within* the square brackets as part of the `AttrKind`. ``` error: `cfg` is not followed by parentheses --> $DIR/cfg-attr-syntax-validation.rs:4:1 | LL | #[cfg = 10] | ^^^^^^^^^^^ | help: expected syntax is | LL - #[cfg = 10] LL + #[cfg(/* predicate */)] | ``` Noticed in rust-lang#137343 (comment).
When encountering an unreachable match arm, (correctly) suggest removing the entire arm: ``` error: a never pattern is always unreachable --> $DIR/ICE-130779-never-arm-no-oatherwise-block.rs:10:20 | LL | Some(!) if true => {} | ^^ this will never be executed | help: remove the unreachable match arm | LL - Some(!) if true => {} LL + Some(!), | ``` Noticed in rust-lang#137343 (comment).
Tweak comma handling of "missing match arm" suggestion and fix "remove this arm" suggestion, and make suggestion verbose Better track trailing commas in match arms. Do not suggest adding trailing comma to match arm with block body. Better heuristic for "is this match in one line". When encountering an unreachable match arm, (correctly) suggest removing the entire arm: ``` error: a never pattern is always unreachable --> $DIR/ICE-130779-never-arm-no-oatherwise-block.rs:10:20 | LL | ! if true => {} | ^^ this will never be executed | help: remove the unreachable match arm | LL - ! if true => {} | ``` Noticed in rust-lang#137343 (comment). r? `@compiler-errors` The first commit is independent of the second, but to make the second one produce accurate suggestions the span needs to include the trailing comma, hence the grouping of both changes in this PR.
When encountering an unreachable match arm, (correctly) suggest removing the entire arm: ``` error: a never pattern is always unreachable --> $DIR/ICE-130779-never-arm-no-oatherwise-block.rs:10:20 | LL | Some(!) if true => {} | ^^ this will never be executed | help: remove the unreachable match arm | LL - Some(!) if true => {} LL + Some(!), | ``` Noticed in rust-lang#137343 (comment).
The verbose "diff" suggestion format is easier to read (specially since #136958), and the only one supported by annotate-snippets (which we want to migrate to).
Making verbose the default in one go would result in a huge PR that is too hard to land: #127282.
CC rust-lang/rust-playground#1117