Skip to content

Commit 6cd44a4

Browse files
committed
Make typo in field and name suggestions verbose
1 parent 5bc3450 commit 6cd44a4

File tree

74 files changed

+1165
-241
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+1165
-241
lines changed

compiler/rustc_hir_typeck/src/pat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2296,7 +2296,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
22962296
let suggested_name =
22972297
find_best_match_for_name(&[field.name], pat_field.ident.name, None);
22982298
if let Some(suggested_name) = suggested_name {
2299-
err.span_suggestion(
2299+
err.span_suggestion_verbose(
23002300
pat_field.ident.span,
23012301
"a field with a similar name exists",
23022302
suggested_name,

compiler/rustc_resolve/src/diagnostics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1963,7 +1963,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
19631963
};
19641964
(span, msg, suggestion.candidate.to_ident_string())
19651965
};
1966-
err.span_suggestion(span, msg, sugg, Applicability::MaybeIncorrect);
1966+
err.span_suggestion_verbose(span, msg, sugg, Applicability::MaybeIncorrect);
19671967
true
19681968
}
19691969

tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -570,19 +570,37 @@ error: cannot find attribute `warn_` in this scope
570570
--> $DIR/diagnostic-derive.rs:590:3
571571
|
572572
LL | #[warn_(no_crate_example, code = E0123)]
573-
| ^^^^^ help: a built-in attribute with a similar name exists: `warn`
573+
| ^^^^^
574+
|
575+
help: a built-in attribute with a similar name exists
576+
|
577+
LL - #[warn_(no_crate_example, code = E0123)]
578+
LL + #[warn(no_crate_example, code = E0123)]
579+
|
574580

575581
error: cannot find attribute `lint` in this scope
576582
--> $DIR/diagnostic-derive.rs:597:3
577583
|
578584
LL | #[lint(no_crate_example, code = E0123)]
579-
| ^^^^ help: a built-in attribute with a similar name exists: `link`
585+
| ^^^^
586+
|
587+
help: a built-in attribute with a similar name exists
588+
|
589+
LL - #[lint(no_crate_example, code = E0123)]
590+
LL + #[link(no_crate_example, code = E0123)]
591+
|
580592

581593
error: cannot find attribute `lint` in this scope
582594
--> $DIR/diagnostic-derive.rs:604:3
583595
|
584596
LL | #[lint(no_crate_example, code = E0123)]
585-
| ^^^^ help: a built-in attribute with a similar name exists: `link`
597+
| ^^^^
598+
|
599+
help: a built-in attribute with a similar name exists
600+
|
601+
LL - #[lint(no_crate_example, code = E0123)]
602+
LL + #[link(no_crate_example, code = E0123)]
603+
|
586604

587605
error: cannot find attribute `multipart_suggestion` in this scope
588606
--> $DIR/diagnostic-derive.rs:644:3

tests/ui/argument-suggestions/issue-109831.stderr

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,13 @@ LL | struct A;
2424
| --------- similarly named unit struct `A` defined here
2525
...
2626
LL | f(A, A, B, C);
27-
| ^ help: a unit struct with a similar name exists: `A`
27+
| ^
28+
|
29+
help: a unit struct with a similar name exists
30+
|
31+
LL - f(A, A, B, C);
32+
LL + f(A, A, B, A);
33+
|
2834

2935
error[E0061]: this function takes 3 arguments but 4 arguments were supplied
3036
--> $DIR/issue-109831.rs:7:5

tests/ui/associated-item/issue-87638.stderr

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ LL | type Target;
55
| ------------ associated type `Target` defined here
66
...
77
LL | let _: <S as Trait>::Output;
8-
| ^^^^^^
9-
| |
10-
| not found in `Trait`
11-
| help: maybe you meant this associated type: `Target`
8+
| ^^^^^^ not found in `Trait`
9+
|
10+
help: maybe you meant this associated type
11+
|
12+
LL - let _: <S as Trait>::Output;
13+
LL + let _: <S as Trait>::Target;
14+
|
1215

1316
error[E0576]: cannot find method or associated constant `BAR` in trait `Trait`
1417
--> $DIR/issue-87638.rs:20:27
@@ -17,10 +20,13 @@ LL | const FOO: usize;
1720
| ----------------- associated constant `FOO` defined here
1821
...
1922
LL | let _ = <S as Trait>::BAR;
20-
| ^^^
21-
| |
22-
| not found in `Trait`
23-
| help: maybe you meant this associated constant: `FOO`
23+
| ^^^ not found in `Trait`
24+
|
25+
help: maybe you meant this associated constant
26+
|
27+
LL - let _ = <S as Trait>::BAR;
28+
LL + let _ = <S as Trait>::FOO;
29+
|
2430

2531
error: aborting due to 2 previous errors
2632

tests/ui/associated-types/issue-19883.stderr

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ LL | type Output;
55
| ------------ associated type `Output` defined here
66
...
77
LL | <Dst as From<Self>>::Dst
8-
| ^^^
9-
| |
10-
| not found in `From`
11-
| help: maybe you meant this associated type: `Output`
8+
| ^^^ not found in `From`
9+
|
10+
help: maybe you meant this associated type
11+
|
12+
LL - <Dst as From<Self>>::Dst
13+
LL + <Dst as From<Self>>::Output
14+
|
1215

1316
error: aborting due to 1 previous error
1417

tests/ui/associated-types/issue-22037.stderr

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@ error[E0576]: cannot find associated type `X` in trait `A`
44
LL | type Output;
55
| ------------ associated type `Output` defined here
66
LL | fn a(&self) -> <Self as A>::X;
7-
| ^
8-
| |
9-
| not found in `A`
10-
| help: maybe you meant this associated type: `Output`
7+
| ^ not found in `A`
8+
|
9+
help: maybe you meant this associated type
10+
|
11+
LL - fn a(&self) -> <Self as A>::X;
12+
LL + fn a(&self) -> <Self as A>::Output;
13+
|
1114

1215
error: aborting due to 1 previous error
1316

tests/ui/attributes/align-on-fields-143987.stderr

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@ error[E0425]: cannot find type `usize8` in this scope
22
--> $DIR/align-on-fields-143987.rs:17:8
33
|
44
LL | x: usize8,
5-
| ^^^^^^ help: a builtin type with a similar name exists: `usize`
5+
| ^^^^^^
6+
|
7+
help: a builtin type with a similar name exists
8+
|
9+
LL - x: usize8,
10+
LL + x: usize,
11+
|
612

713
error: `#[rustc_align]` attribute cannot be used on struct fields
814
--> $DIR/align-on-fields-143987.rs:10:5

tests/ui/borrowck/non-ADT-struct-pattern-box-pattern-ice-121463.stderr

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,23 @@ error[E0433]: failed to resolve: use of undeclared type `E`
22
--> $DIR/non-ADT-struct-pattern-box-pattern-ice-121463.rs:6:17
33
|
44
LL | let mut a = E::StructVar { boxed: Box::new(5_i32) };
5-
| ^
6-
| |
7-
| use of undeclared type `E`
8-
| help: a trait with a similar name exists: `Eq`
5+
| ^ use of undeclared type `E`
6+
|
7+
help: a trait with a similar name exists
8+
|
9+
LL | let mut a = Eq::StructVar { boxed: Box::new(5_i32) };
10+
| +
911

1012
error[E0433]: failed to resolve: use of undeclared type `E`
1113
--> $DIR/non-ADT-struct-pattern-box-pattern-ice-121463.rs:9:9
1214
|
1315
LL | E::StructVar { box boxed } => { }
14-
| ^
15-
| |
16-
| use of undeclared type `E`
17-
| help: a trait with a similar name exists: `Eq`
16+
| ^ use of undeclared type `E`
17+
|
18+
help: a trait with a similar name exists
19+
|
20+
LL | Eq::StructVar { box boxed } => { }
21+
| +
1822

1923
error: aborting due to 2 previous errors
2024

tests/ui/closures/issue-90871.stderr

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@ error[E0425]: cannot find type `n` in this scope
22
--> $DIR/issue-90871.rs:4:22
33
|
44
LL | type_ascribe!(2, n([u8; || 1]))
5-
| ^ help: a trait with a similar name exists: `Fn`
5+
| ^
66
|
77
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
88
|
99
= note: similarly named trait `Fn` defined here
10+
help: a trait with a similar name exists
11+
|
12+
LL | type_ascribe!(2, Fn([u8; || 1]))
13+
| +
1014

1115
error[E0308]: mismatched types
1216
--> $DIR/issue-90871.rs:4:29

0 commit comments

Comments
 (0)