Skip to content

Commit 11f5309

Browse files
authored
Rollup merge of #70227 - LeSeulArtichaut:typo-def, r=Centril
Only display definition when suggesting a typo Closes #70206 r? @Centril
2 parents 675bdf6 + cb7a2c1 commit 11f5309

13 files changed

+69
-116
lines changed

src/librustc_resolve/diagnostics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ impl<'a> Resolver<'a> {
796796
});
797797
if let Some(span) = def_span {
798798
err.span_label(
799-
span,
799+
self.session.source_map().def_span(span),
800800
&format!(
801801
"similarly named {} `{}` defined here",
802802
suggestion.res.descr(),

src/test/ui/error-codes/E0423.stderr

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,17 @@ LL | for _ in (std::ops::Range { start: 0, end: 10 }) {}
2929
error[E0423]: expected function, tuple struct or tuple variant, found struct `Foo`
3030
--> $DIR/E0423.rs:4:13
3131
|
32-
LL | struct Foo { a: bool };
33-
| ---------------------- `Foo` defined here
32+
LL | struct Foo { a: bool };
33+
| ---------------------- `Foo` defined here
3434
LL |
35-
LL | let f = Foo();
36-
| ^^^
37-
| |
38-
| did you mean `Foo { /* fields */ }`?
39-
| help: a function with a similar name exists (notice the capitalization): `foo`
35+
LL | let f = Foo();
36+
| ^^^
37+
| |
38+
| did you mean `Foo { /* fields */ }`?
39+
| help: a function with a similar name exists (notice the capitalization): `foo`
4040
...
41-
LL | / fn foo() {
42-
LL | | for _ in std::ops::Range { start: 0, end: 10 } {}
43-
LL | |
44-
LL | | }
45-
| |_- similarly named function `foo` defined here
41+
LL | fn foo() {
42+
| -------- similarly named function `foo` defined here
4643

4744
error[E0423]: expected value, found struct `T`
4845
--> $DIR/E0423.rs:14:8

src/test/ui/glob-resolve1.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ error[E0412]: cannot find type `A` in this scope
4747
--> $DIR/glob-resolve1.rs:28:11
4848
|
4949
LL | pub enum B { B1 }
50-
| ----------------- similarly named enum `B` defined here
50+
| ---------- similarly named enum `B` defined here
5151
...
5252
LL | foo::<A>();
5353
| ^
@@ -65,7 +65,7 @@ error[E0412]: cannot find type `C` in this scope
6565
--> $DIR/glob-resolve1.rs:29:11
6666
|
6767
LL | pub enum B { B1 }
68-
| ----------------- similarly named enum `B` defined here
68+
| ---------- similarly named enum `B` defined here
6969
...
7070
LL | foo::<C>();
7171
| ^
@@ -83,7 +83,7 @@ error[E0412]: cannot find type `D` in this scope
8383
--> $DIR/glob-resolve1.rs:30:11
8484
|
8585
LL | pub enum B { B1 }
86-
| ----------------- similarly named enum `B` defined here
86+
| ---------- similarly named enum `B` defined here
8787
...
8888
LL | foo::<D>();
8989
| ^

src/test/ui/issues/issue-31845.stderr

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
error[E0425]: cannot find function `g` in this scope
22
--> $DIR/issue-31845.rs:7:12
33
|
4-
LL | / fn h() {
5-
LL | | g();
6-
| | ^ help: a function with a similar name exists: `h`
7-
LL | | }
8-
| |_________- similarly named function `h` defined here
4+
LL | fn h() {
5+
| ------ similarly named function `h` defined here
6+
LL | g();
7+
| ^ help: a function with a similar name exists: `h`
98

109
error: aborting due to previous error
1110

src/test/ui/issues/issue-46332.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0422]: cannot find struct, variant or union type `TyUInt` in this scope
22
--> $DIR/issue-46332.rs:9:5
33
|
44
LL | struct TyUint {}
5-
| ---------------- similarly named struct `TyUint` defined here
5+
| ------------- similarly named struct `TyUint` defined here
66
...
77
LL | TyUInt {};
88
| ^^^^^^ help: a struct with a similar name exists (notice the capitalization): `TyUint`
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
error: cannot find macro `k` in this scope
22
--> $DIR/macro_undefined.rs:11:5
33
|
4-
LL | / macro_rules! kl {
5-
LL | | () => ()
6-
LL | | }
7-
| |_____- similarly named macro `kl` defined here
4+
LL | macro_rules! kl {
5+
| --------------- similarly named macro `kl` defined here
86
...
9-
LL | k!();
10-
| ^ help: a macro with a similar name exists: `kl`
7+
LL | k!();
8+
| ^ help: a macro with a similar name exists: `kl`
119

1210
error: aborting due to previous error
1311

src/test/ui/privacy/legacy-ctor-visibility.stderr

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
error[E0423]: expected function, tuple struct or tuple variant, found struct `S`
22
--> $DIR/legacy-ctor-visibility.rs:9:13
33
|
4-
LL | / fn f() {
5-
LL | | S(10);
6-
| | ^ help: a function with a similar name exists: `f`
7-
LL | |
8-
LL | | }
9-
| |_________- similarly named function `f` defined here
4+
LL | fn f() {
5+
| ------ similarly named function `f` defined here
6+
LL | S(10);
7+
| ^ help: a function with a similar name exists: `f`
108

119
error: aborting due to previous error
1210

src/test/ui/proc-macro/resolve-error.stderr

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,20 @@ LL | Dlona!();
1818
error: cannot find macro `attr_proc_macra` in this scope
1919
--> $DIR/resolve-error.rs:58:5
2020
|
21-
LL | / macro_rules! attr_proc_mac {
22-
LL | | () => {}
23-
LL | | }
24-
| |_- similarly named macro `attr_proc_mac` defined here
21+
LL | macro_rules! attr_proc_mac {
22+
| -------------------------- similarly named macro `attr_proc_mac` defined here
2523
...
26-
LL | attr_proc_macra!();
27-
| ^^^^^^^^^^^^^^^ help: a macro with a similar name exists: `attr_proc_mac`
24+
LL | attr_proc_macra!();
25+
| ^^^^^^^^^^^^^^^ help: a macro with a similar name exists: `attr_proc_mac`
2826

2927
error: cannot find macro `FooWithLongNama` in this scope
3028
--> $DIR/resolve-error.rs:55:5
3129
|
32-
LL | / macro_rules! FooWithLongNam {
33-
LL | | () => {}
34-
LL | | }
35-
| |_- similarly named macro `FooWithLongNam` defined here
30+
LL | macro_rules! FooWithLongNam {
31+
| --------------------------- similarly named macro `FooWithLongNam` defined here
3632
...
37-
LL | FooWithLongNama!();
38-
| ^^^^^^^^^^^^^^^ help: a macro with a similar name exists: `FooWithLongNam`
33+
LL | FooWithLongNama!();
34+
| ^^^^^^^^^^^^^^^ help: a macro with a similar name exists: `FooWithLongNam`
3935

4036
error: cannot find derive macro `attr_proc_macra` in this scope
4137
--> $DIR/resolve-error.rs:49:10

src/test/ui/resolve/issue-5035.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ error[E0404]: expected trait, found type alias `K`
88
--> $DIR/issue-5035.rs:3:6
99
|
1010
LL | trait I {}
11-
| ---------- similarly named trait `I` defined here
11+
| ------- similarly named trait `I` defined here
1212
LL | type K = dyn I;
1313
LL | impl K for isize {}
1414
| ^

src/test/ui/resolve/levenshtein.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ error[E0412]: cannot find type `Baz` in this scope
88
--> $DIR/levenshtein.rs:14:10
99
|
1010
LL | enum Bar { }
11-
| ------------ similarly named enum `Bar` defined here
11+
| -------- similarly named enum `Bar` defined here
1212
LL |
1313
LL | type A = Baz; // Misspelled type name.
1414
| ^^^ help: an enum with a similar name exists: `Bar`
@@ -43,7 +43,7 @@ error[E0425]: cannot find function `foobar` in this scope
4343
--> $DIR/levenshtein.rs:30:5
4444
|
4545
LL | fn foo_bar() {}
46-
| --------------- similarly named function `foo_bar` defined here
46+
| ------------ similarly named function `foo_bar` defined here
4747
...
4848
LL | foobar(); // Misspelled function name.
4949
| ^^^^^^ help: a function with a similar name exists: `foo_bar`

0 commit comments

Comments
 (0)