Commit graph

35 commits

Author SHA1 Message Date
Nilstrieb 41e8d152dc Show number in error message even for one error
Co-authored-by: Adrian <adrian.iosdev@gmail.com>
2023-11-24 19:15:52 +01:00
Esteban Küber 289ce572b3 tweak logic of "unknown field" label 2023-11-18 00:40:11 +00:00
Esteban Küber 4f7dddd4a1 recover primary span label 2023-11-16 17:00:23 +00:00
Esteban Küber 8bd8f3b090 Suggest unwrap() on field not found for Result/Option
When encountering a `Result<T, _>` or `Option<T>` where `T` has a field
that's being accessed, suggest calling `.unwrap()` to get to the field.
2023-11-16 17:00:23 +00:00
Esteban Küber dfa75391f8 Suggest field typo through derefs
Take into account implicit dereferences when suggesting fields.

```
error[E0609]: no field `longname` on type `Arc<S>`
  --> $DIR/suggest-field-through-deref.rs:10:15
   |
LL |     let _ = x.longname;
   |               ^^^^^^^^ help: a field with a similar name exists: `long_name`
```

CC https://github.com/rust-lang/rust/issues/78374#issuecomment-719564114
2023-11-16 17:00:23 +00:00
bors 111adde7ed Auto merge of #115324 - francorbacho:master, r=davidtwco
Suggest removing redundant arguments in format!()

Closes #105225. This is also a follow-up to #105635, which seems to have become stale.

r? `@estebank`
2023-10-23 00:51:35 +00:00
Esteban Küber 890e92feed Unify suggestion wording 2023-10-17 17:33:55 +00:00
francorbacho c8ee7db6ea Only give autofix suggestion when no named args are present 2023-10-05 16:11:31 +02:00
francorbacho 38b0182832 Add suggestion test 2023-10-05 16:11:31 +02:00
francorbacho 905bace904 Highlight redundant arguments instead of the whole format string 2023-10-05 16:11:31 +02:00
francorbacho fcdd5c0b2d Plurals in format redundant arguments suggestion 2023-10-05 16:11:31 +02:00
francorbacho 04fc051a34 Use diagnostic impls and add suggestions in redundant format!() args 2023-10-05 16:09:57 +02:00
francorbacho 93df9e6d7d Suggest removing redundant arguments in format!() 2023-10-05 16:05:42 +02:00
León Orell Valerian Liehr 867cc41b5b
clean up struct field suggestions 2023-10-04 21:36:04 +02:00
Esteban Küber 3848ffcee7 Tweak wording of missing angle backets in qualified path 2023-09-28 00:37:20 +00:00
Esteban Küber 55f8c66a60 Point at return type when it influences non-first match arm
When encountering code like

```rust
fn foo() -> i32 {
    match 0 {
        1 => return 0,
        2 => "",
        _ => 1,
    }
}
```

Point at the return type and not at the prior arm, as that arm has type
`!` which isn't influencing the arm corresponding to arm `2`.

Fix #78124.
2023-08-14 21:43:56 +00:00
Mu001999 049c728c60 Suggests turbofish in patterns 2023-08-01 23:30:40 +08:00
Michael Goulet fe870424a7 Do not set up wrong span for adjustments 2023-07-10 20:09:26 +00:00
Michael Goulet 2c33dfea76 Don't sort strings right after we just sorted by types 2023-06-27 23:31:06 +00:00
Michael Goulet 140c011ca6 Don't mention already set fields 2023-06-05 21:00:08 +00:00
Ezra Shaw 57c6a3183c
tweak "make mut" spans (No. 3) 2023-05-05 22:40:05 +12:00
Ezra Shaw 9624d2b08e
tweak "make mut" spans (No. 2) 2023-05-05 22:40:05 +12:00
Ezra Shaw fd8aa5ec7d
tweak "make mut" spans when assigning to locals 2023-05-05 22:40:04 +12:00
Nilstrieb c63b6a437e Rip it out
My type ascription
Oh rip it out
Ah
If you think we live too much then
You can sacrifice diagnostics
Don't mix your garbage
Into my syntax
So many weird hacks keep diagnostics alive
Yet I don't even step outside
So many bad diagnostics keep tyasc alive
Yet tyasc doesn't even bother to survive!
2023-05-01 16:15:13 +08:00
Deadbeef 4c6ddc036b fix library and rustdoc tests 2023-04-16 11:38:52 +00:00
Esteban Küber 9fadcc143a Special-case item attributes in the suggestion output 2023-04-12 22:50:10 +00:00
Esteban Küber 5b40aa5eb4 Tweak output for 'add line' suggestion 2023-04-12 22:50:10 +00:00
bohan d8a4e7cf51 fix(middle): emit error rather than delay bug when reaching limit 2023-04-03 11:08:14 +08:00
lcnr c63861b9d5 evaluate: improve and fix recursion depth handling 2023-03-21 09:57:22 +01:00
Jacob Pratt c2f2a3cff2
Add test for println! typo 2023-02-19 03:46:03 +00:00
Michael Goulet 9dd5d3e8e4 Recover _ as .. in field pattern 2023-02-02 06:10:02 +00:00
Esteban Küber 62ba3e70a1 Modify primary span label for E0308
The previous output was unintuitive to users.
2023-01-30 20:12:19 +00:00
Esteban Küber c6f322bf30 review comments: account for generics 2023-01-11 21:30:32 +00:00
Esteban Küber 12ddf77811 When suggesting writing a fully qualified path probe for appropriate types
Fix #46585.
2023-01-11 21:30:10 +00:00
Albert Larsan cf2dff2b1e
Move /src/test to /tests 2023-01-11 09:32:08 +00:00