Skip to content

Commit b6f4b29

Browse files
committed
Point at the associated type's def span
1 parent 286f7ae commit b6f4b29

13 files changed

+66
-0
lines changed

src/librustc_typeck/astconv.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,6 +1053,10 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o {
10531053
span,
10541054
format!("missing associated type `{}` value", assoc_item.ident),
10551055
);
1056+
err.span_label(
1057+
tcx.def_span(item_def_id),
1058+
format!("`{}` defined here", assoc_item.ident),
1059+
);
10561060
}
10571061
err.emit();
10581062
}

src/test/ui/associated-type/associated-type-projection-from-multiple-supertraits.stderr

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ LL | fn dent_object<COLOR>(c: BoxCar<Color=COLOR>) {
2525
error[E0191]: the value of the associated type `Color` (from the trait `Vehicle`) must be specified
2626
--> $DIR/associated-type-projection-from-multiple-supertraits.rs:33:26
2727
|
28+
LL | type Color;
29+
| ----------- `Color` defined here
30+
...
2831
LL | fn dent_object<COLOR>(c: BoxCar<Color=COLOR>) {
2932
| ^^^^^^^^^^^^^^^^^^^ missing associated type `Color` value
3033

src/test/ui/associated-types/associated-types-incomplete-object.stderr

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,29 @@
11
error[E0191]: the value of the associated type `B` (from the trait `Foo`) must be specified
22
--> $DIR/associated-types-incomplete-object.rs:33:26
33
|
4+
LL | type B;
5+
| ------- `B` defined here
6+
...
47
LL | let b = &42isize as &Foo<A=usize>;
58
| ^^^^^^^^^^^^ missing associated type `B` value
69

710
error[E0191]: the value of the associated type `A` (from the trait `Foo`) must be specified
811
--> $DIR/associated-types-incomplete-object.rs:36:26
912
|
13+
LL | type A;
14+
| ------- `A` defined here
15+
...
1016
LL | let c = &42isize as &Foo<B=char>;
1117
| ^^^^^^^^^^^ missing associated type `A` value
1218

1319
error[E0191]: the value of the associated types `A` (from the trait `Foo`), `B` (from the trait `Foo`) must be specified
1420
--> $DIR/associated-types-incomplete-object.rs:39:26
1521
|
22+
LL | type A;
23+
| ------- `A` defined here
24+
LL | type B;
25+
| ------- `B` defined here
26+
...
1627
LL | let d = &42isize as &Foo;
1728
| ^^^
1829
| |

src/test/ui/error-codes/E0107-b.stderr

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ LL | pub struct Foo { i: Box<T<usize, usize, usize, usize, B=usize>> }
99
error[E0191]: the value of the associated types `A` (from the trait `T`), `C` (from the trait `T`) must be specified
1010
--> $DIR/E0107-b.rs:6:26
1111
|
12+
LL | type A;
13+
| ------- `A` defined here
14+
LL | type B;
15+
LL | type C;
16+
| ------- `C` defined here
17+
LL | }
1218
LL | pub struct Foo { i: Box<T<usize, usize, usize, usize, B=usize>> }
1319
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1420
| |

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
error[E0191]: the value of the associated type `Bar` (from the trait `Trait`) must be specified
22
--> $DIR/E0191.rs:15:12
33
|
4+
LL | type Bar;
5+
| --------- `Bar` defined here
6+
...
47
LL | type Foo = Trait; //~ ERROR E0191
58
| ^^^^^ missing associated type `Bar` value
69

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ LL | type Foo = Trait<F=i32>; //~ ERROR E0220
77
error[E0191]: the value of the associated type `Bar` (from the trait `Trait`) must be specified
88
--> $DIR/E0220.rs:15:12
99
|
10+
LL | type Bar;
11+
| --------- `Bar` defined here
12+
...
1013
LL | type Foo = Trait<F=i32>; //~ ERROR E0220
1114
| ^^^^^^^^^^^^ missing associated type `Bar` value
1215

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
error[E0191]: the value of the associated type `A` (from the trait `Foo`) must be specified
22
--> $DIR/issue-19482.rs:20:12
33
|
4+
LL | type A;
5+
| ------- `A` defined here
6+
...
47
LL | fn bar(x: &Foo) {}
58
| ^^^ missing associated type `A` value
69

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ error[E0191]: the value of the associated type `Output` (from the trait `std::op
1111
|
1212
LL | &Add;
1313
| ^^^ missing associated type `Output` value
14+
|
15+
::: $SRC_DIR/libcore/ops/arith.rs:LL:COL
16+
|
17+
LL | type Output;
18+
| ------------ `Output` defined here
1419

1520
error: aborting due to 2 previous errors
1621

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
error[E0191]: the value of the associated type `A` (from the trait `Foo`) must be specified
22
--> $DIR/issue-22434.rs:15:19
33
|
4+
LL | type A;
5+
| ------- `A` defined here
6+
...
47
LL | type I<'a> = &'a (Foo + 'a);
58
| ^^^^^^^^ missing associated type `A` value
69

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ LL | | //~^ ERROR E0393
2929
LL | | //~| ERROR E0191
3030
LL | | Sub;
3131
| |_______________^ missing associated type `Output` value
32+
|
33+
::: $SRC_DIR/libcore/ops/arith.rs:LL:COL
34+
|
35+
LL | type Output;
36+
| ------------ `Output` defined here
3237

3338
error: aborting due to 4 previous errors
3439

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ error[E0191]: the value of the associated type `Output` (from the trait `std::op
1717
|
1818
LL | println!("{:?}",(vfnfer[0] as Fn)(3));
1919
| ^^ missing associated type `Output` value
20+
|
21+
::: $SRC_DIR/libcore/ops/function.rs:LL:COL
22+
|
23+
LL | type Output;
24+
| ------------ `Output` defined here
2025

2126
error: aborting due to 3 previous errors
2227

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ error[E0191]: the value of the associated type `Output` (from the trait `std::op
33
|
44
LL | let x: u8 = BitXor::bitor(0 as u8, 0 as u8);
55
| ^^^^^^^^^^^^^ missing associated type `Output` value
6+
|
7+
::: $SRC_DIR/libcore/ops/bit.rs:LL:COL
8+
|
9+
LL | type Output;
10+
| ------------ `Output` defined here
611

712
error[E0599]: no function or associated item named `bitor` found for type `dyn std::ops::BitXor<_>` in the current scope
813
--> $DIR/issue-28344.rs:14:17
@@ -17,6 +22,11 @@ error[E0191]: the value of the associated type `Output` (from the trait `std::op
1722
|
1823
LL | let g = BitXor::bitor;
1924
| ^^^^^^^^^^^^^ missing associated type `Output` value
25+
|
26+
::: $SRC_DIR/libcore/ops/bit.rs:LL:COL
27+
|
28+
LL | type Output;
29+
| ------------ `Output` defined here
2030

2131
error[E0599]: no function or associated item named `bitor` found for type `dyn std::ops::BitXor<_>` in the current scope
2232
--> $DIR/issue-28344.rs:18:13

src/test/ui/traits/trait-alias-object.stderr

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ error[E0191]: the value of the associated type `Item` (from the trait `std::iter
1111
|
1212
LL | let _: &dyn IteratorAlias = &vec![123].into_iter();
1313
| ^^^^^^^^^^^^^^^^^ missing associated type `Item` value
14+
|
15+
::: $SRC_DIR/libcore/iter/iterator.rs:LL:COL
16+
|
17+
LL | type Item;
18+
| ---------- `Item` defined here
1419

1520
error: aborting due to 2 previous errors
1621

0 commit comments

Comments
 (0)