-
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 inline suggestions no longer be the default #127282
base: master
Are you sure you want to change the base?
Make inline suggestions no longer be the default #127282
Conversation
8ef3d49
to
1791206
Compare
Some changes occurred in src/tools/clippy cc @rust-lang/clippy |
This comment has been minimized.
This comment has been minimized.
1791206
to
ba252ed
Compare
I noticed a bunch of mistakes in current suggestions thanks to the new output, but all of those can go on other PRs. |
help: use an inclusive range | ||
| | ||
LL | 'a'...'z' => 1, | ||
| ~~~ |
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.
This clippy suggestions are just plain wrong, right?
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.
It's the old pattern syntax for when MSRV is set to the ancient times
rust/src/tools/clippy/tests/ui/almost_complete_range.rs
Lines 70 to 78 in 2b90614
#[clippy::msrv = "1.25"] | |
fn _under_msrv() { | |
let _ = match 'a' { | |
'a'..'z' => 1, | |
'A'..'Z' => 2, | |
'0'..'9' => 3, | |
_ => 4, | |
}; | |
} |
LL | CustomFutureType.await | ||
| |
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.
Interesting, we're missing an underline here.
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.
Does this happen, because we're replacing the entire line? The clippy suggestion probably doesn't add the .await
, but suggests to remove the CustomFutureType
and add CustomFutureType.await
.
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `x.map(|o| o + 1)` | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
help: try |
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.
Clippyy needs to have better messages for these suggestions
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.
Tweak some structured suggestions to be more verbose and accurate Addressing some issues I found while working on rust-lang#127282. ``` error: this URL is not a hyperlink --> $DIR/auxiliary/include-str-bare-urls.md:1:11 | LL | HEADS UP! https://example.com MUST SHOW UP IN THE STDERR FILE! | ^^^^^^^^^^^^^^^^^^^ | = note: bare URLs are not automatically turned into clickable links note: the lint level is defined here --> $DIR/include-str-bare-urls.rs:14:9 | LL | #![deny(rustdoc::bare_urls)] | ^^^^^^^^^^^^^^^^^^ help: use an automatic link instead | LL | HEADS UP! <https://example.com> MUST SHOW UP IN THE STDERR FILE! | + + ``` ``` error[E0384]: cannot assign twice to immutable variable `v` --> $DIR/assign-imm-local-twice.rs:7:5 | LL | v = 1; | ----- first assignment to `v` LL | println!("v={}", v); LL | v = 2; | ^^^^^ cannot assign twice to immutable variable | help: consider making this binding mutable | LL | let mut v: isize; | +++ ``` ``` error[E0393]: the type parameter `Rhs` must be explicitly specified --> $DIR/issue-22560.rs:9:23 | LL | trait Sub<Rhs=Self> { | ------------------- type parameter `Rhs` must be specified for this ... LL | type Test = dyn Add + Sub; | ^^^ | = note: because of the default `Self` reference, type parameters must be specified on object types help: set the type parameter to the desired type | LL | type Test = dyn Add + Sub<Rhs>; | +++++ ``` ``` error[E0596]: cannot borrow `v` as mutable, as it is not declared as mutable --> $DIR/issue-33819.rs:4:34 | LL | Some(ref v) => { let a = &mut v; }, | ^^^^^^ cannot borrow as mutable | help: try removing `&mut` here | LL - Some(ref v) => { let a = &mut v; }, LL + Some(ref v) => { let a = v; }, | ``` ``` help: remove the invocation before committing it to a version control system | LL - dbg!(); | ``` ``` error[E0308]: mismatched types --> $DIR/issue-39974.rs:1:21 | LL | const LENGTH: f64 = 2; | ^ expected `f64`, found integer | help: use a float literal | LL | const LENGTH: f64 = 2.0; | ++ ``` ``` error[E0529]: expected an array or slice, found `Vec<i32>` --> $DIR/match-ergonomics.rs:8:9 | LL | [&v] => {}, | ^^^^ pattern cannot match with input type `Vec<i32>` | help: consider slicing here | LL | match x[..] { | ++++ ``` ``` error[E0609]: no field `0` on type `[u32; 1]` --> $DIR/parenthesized-deref-suggestion.rs:10:21 | LL | (x as [u32; 1]).0; | ^ unknown field | help: instead of using tuple indexing, use array indexing | LL | (x as [u32; 1])[0]; | ~ + ```
Rollup merge of rust-lang#127301 - estebank:fix-suggestions, r=Urgau Tweak some structured suggestions to be more verbose and accurate Addressing some issues I found while working on rust-lang#127282. ``` error: this URL is not a hyperlink --> $DIR/auxiliary/include-str-bare-urls.md:1:11 | LL | HEADS UP! https://example.com MUST SHOW UP IN THE STDERR FILE! | ^^^^^^^^^^^^^^^^^^^ | = note: bare URLs are not automatically turned into clickable links note: the lint level is defined here --> $DIR/include-str-bare-urls.rs:14:9 | LL | #![deny(rustdoc::bare_urls)] | ^^^^^^^^^^^^^^^^^^ help: use an automatic link instead | LL | HEADS UP! <https://example.com> MUST SHOW UP IN THE STDERR FILE! | + + ``` ``` error[E0384]: cannot assign twice to immutable variable `v` --> $DIR/assign-imm-local-twice.rs:7:5 | LL | v = 1; | ----- first assignment to `v` LL | println!("v={}", v); LL | v = 2; | ^^^^^ cannot assign twice to immutable variable | help: consider making this binding mutable | LL | let mut v: isize; | +++ ``` ``` error[E0393]: the type parameter `Rhs` must be explicitly specified --> $DIR/issue-22560.rs:9:23 | LL | trait Sub<Rhs=Self> { | ------------------- type parameter `Rhs` must be specified for this ... LL | type Test = dyn Add + Sub; | ^^^ | = note: because of the default `Self` reference, type parameters must be specified on object types help: set the type parameter to the desired type | LL | type Test = dyn Add + Sub<Rhs>; | +++++ ``` ``` error[E0596]: cannot borrow `v` as mutable, as it is not declared as mutable --> $DIR/issue-33819.rs:4:34 | LL | Some(ref v) => { let a = &mut v; }, | ^^^^^^ cannot borrow as mutable | help: try removing `&mut` here | LL - Some(ref v) => { let a = &mut v; }, LL + Some(ref v) => { let a = v; }, | ``` ``` help: remove the invocation before committing it to a version control system | LL - dbg!(); | ``` ``` error[E0308]: mismatched types --> $DIR/issue-39974.rs:1:21 | LL | const LENGTH: f64 = 2; | ^ expected `f64`, found integer | help: use a float literal | LL | const LENGTH: f64 = 2.0; | ++ ``` ``` error[E0529]: expected an array or slice, found `Vec<i32>` --> $DIR/match-ergonomics.rs:8:9 | LL | [&v] => {}, | ^^^^ pattern cannot match with input type `Vec<i32>` | help: consider slicing here | LL | match x[..] { | ++++ ``` ``` error[E0609]: no field `0` on type `[u32; 1]` --> $DIR/parenthesized-deref-suggestion.rs:10:21 | LL | (x as [u32; 1]).0; | ^ unknown field | help: instead of using tuple indexing, use array indexing | LL | (x as [u32; 1])[0]; | ~ + ```
☔ The latest upstream changes (presumably #127326) made this pull request unmergeable. Please resolve the merge conflicts. |
Before ``` error: almost complete ascii range --> tests/ui/almost_complete_range.rs:17:17 | LL | let _ = ('a') ..'z'; | ^^^^^^--^^^ | | | help: use an inclusive range: `..=` | = note: `-D clippy::almost-complete-range` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::almost_complete_range)]` ``` After ``` error: almost complete ascii range --> tests/ui/almost_complete_range.rs:17:17 | LL | let _ = ('a') ..'z'; | ^^^^^^^^^^^ | = note: `-D clippy::almost-complete-range` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::almost_complete_range)]` help: use an inclusive range | LL | let _ = ('a') ..='z'; | ~~~ ```
20bf5b1
to
eb6c593
Compare
HIR ty lowering was modified cc @fmease Some changes occurred in cc @BoxyUwU Some changes occurred in tests/ui/check-cfg cc @Urgau Some changes occurred in tests/ui/sanitizer cc @rust-lang/project-exploit-mitigations, @rcvalle
cc @davidtwco, @compiler-errors, @TaKO8Ki Some changes occurred in match checking cc @Nadrieril |
This PR is too big as is, but the diff helps identify specific suggestions that are currently not-perfect, or flat-out wrong. I'll try to fix those things one at a time in separate PRs, making this PR smaller and smaller over time. |
☔ The latest upstream changes (presumably #127008) made this pull request unmergeable. Please resolve the merge conflicts. |
Tweak some structured suggestions to be more verbose and accurate Addressing some issues I found while working on rust-lang#127282. ``` error: this URL is not a hyperlink --> $DIR/auxiliary/include-str-bare-urls.md:1:11 | LL | HEADS UP! https://example.com MUST SHOW UP IN THE STDERR FILE! | ^^^^^^^^^^^^^^^^^^^ | = note: bare URLs are not automatically turned into clickable links note: the lint level is defined here --> $DIR/include-str-bare-urls.rs:14:9 | LL | #![deny(rustdoc::bare_urls)] | ^^^^^^^^^^^^^^^^^^ help: use an automatic link instead | LL | HEADS UP! <https://example.com> MUST SHOW UP IN THE STDERR FILE! | + + ``` ``` error[E0384]: cannot assign twice to immutable variable `v` --> $DIR/assign-imm-local-twice.rs:7:5 | LL | v = 1; | ----- first assignment to `v` LL | println!("v={}", v); LL | v = 2; | ^^^^^ cannot assign twice to immutable variable | help: consider making this binding mutable | LL | let mut v: isize; | +++ ``` ``` error[E0393]: the type parameter `Rhs` must be explicitly specified --> $DIR/issue-22560.rs:9:23 | LL | trait Sub<Rhs=Self> { | ------------------- type parameter `Rhs` must be specified for this ... LL | type Test = dyn Add + Sub; | ^^^ | = note: because of the default `Self` reference, type parameters must be specified on object types help: set the type parameter to the desired type | LL | type Test = dyn Add + Sub<Rhs>; | +++++ ``` ``` error[E0596]: cannot borrow `v` as mutable, as it is not declared as mutable --> $DIR/issue-33819.rs:4:34 | LL | Some(ref v) => { let a = &mut v; }, | ^^^^^^ cannot borrow as mutable | help: try removing `&mut` here | LL - Some(ref v) => { let a = &mut v; }, LL + Some(ref v) => { let a = v; }, | ``` ``` help: remove the invocation before committing it to a version control system | LL - dbg!(); | ``` ``` error[E0308]: mismatched types --> $DIR/issue-39974.rs:1:21 | LL | const LENGTH: f64 = 2; | ^ expected `f64`, found integer | help: use a float literal | LL | const LENGTH: f64 = 2.0; | ++ ``` ``` error[E0529]: expected an array or slice, found `Vec<i32>` --> $DIR/match-ergonomics.rs:8:9 | LL | [&v] => {}, | ^^^^ pattern cannot match with input type `Vec<i32>` | help: consider slicing here | LL | match x[..] { | ++++ ``` ``` error[E0609]: no field `0` on type `[u32; 1]` --> $DIR/parenthesized-deref-suggestion.rs:10:21 | LL | (x as [u32; 1]).0; | ^ unknown field | help: instead of using tuple indexing, use array indexing | LL | (x as [u32; 1])[0]; | ~ + ```
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
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
Make the default suggestions show the full patch output instead of trying to render inline.
Before
After
The inline suggestions output has worse readability than the "verbose" output, and it also (as evidenced in the diff of this PR) tends to hide when the suggestion span is slightly off. Backing off of the inline suggestions will also make it easier to migrate to annotate-snippets, as it will be one fewer special case to handle.