Skip to content

Commit a89f03d

Browse files
committed
Fix case in associated-type-projection-from-multiple-supertraits.rs
This still doesn't handle the case entirely correctly, requiring a more targeted approach with a better suggestion, but at least now the suggested syntax makes *some* sense.
1 parent 43fc934 commit a89f03d

File tree

5 files changed

+14
-12
lines changed

5 files changed

+14
-12
lines changed

src/librustc_typeck/astconv.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -890,6 +890,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
890890
bounds,
891891
speculative,
892892
&mut dup_bindings,
893+
span,
893894
);
894895
// Okay to ignore `Err` because of `ErrorReported` (see above).
895896
}
@@ -1146,6 +1147,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
11461147
bounds: &mut Bounds<'tcx>,
11471148
speculative: bool,
11481149
dup_bindings: &mut FxHashMap<DefId, Span>,
1150+
path_span: Span,
11491151
) -> Result<(), ErrorReported> {
11501152
let tcx = self.tcx();
11511153

@@ -1212,7 +1214,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
12121214
|| traits::supertraits(tcx, trait_ref),
12131215
&trait_ref.print_only_trait_path().to_string(),
12141216
binding.item_name,
1215-
binding.span
1217+
path_span,
12161218
)
12171219
}?;
12181220

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ LL | fn dent<C:BoxCar>(c: C, color: <C as Vehicle>::Color) {
2626
| ^^^^^^^^^^^^^^^^^^^^^
2727

2828
error[E0221]: ambiguous associated type `Color` in bounds of `BoxCar`
29-
--> $DIR/associated-type-projection-from-multiple-supertraits.rs:25:37
29+
--> $DIR/associated-type-projection-from-multiple-supertraits.rs:25:30
3030
|
3131
LL | type Color;
3232
| ----------- ambiguous `Color` from `Vehicle`
@@ -35,16 +35,16 @@ LL | type Color;
3535
| ----------- ambiguous `Color` from `Box`
3636
...
3737
LL | fn dent_object<COLOR>(c: dyn BoxCar<Color=COLOR>) {
38-
| ^^^^^^^^^^^ ambiguous associated type `Color`
38+
| ^^^^^^^^^^^^^^^^^^^ ambiguous associated type `Color`
3939
|
4040
help: use fully qualified syntax to disambiguate
4141
|
42-
LL | fn dent_object<COLOR>(c: dyn BoxCar<<BoxCar as Box>::Color>) {
43-
| ^^^^^^^^^^^^^^^^^^^^^^
42+
LL | fn dent_object<COLOR>(c: dyn <BoxCar as Box>::Color) {
43+
| ^^^^^^^^^^^^^^^^^^^^^^
4444
help: use fully qualified syntax to disambiguate
4545
|
46-
LL | fn dent_object<COLOR>(c: dyn BoxCar<<BoxCar as Vehicle>::Color>) {
47-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
46+
LL | fn dent_object<COLOR>(c: dyn <BoxCar as Vehicle>::Color) {
47+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
4848

4949
error[E0191]: the value of the associated type `Color` (from trait `Vehicle`) must be specified
5050
--> $DIR/associated-type-projection-from-multiple-supertraits.rs:25:30

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error[E0220]: associated type `F` not found for `Trait`
2-
--> $DIR/E0220.rs:5:22
2+
--> $DIR/E0220.rs:5:16
33
|
44
LL | type Foo = dyn Trait<F=i32>;
5-
| ^^^^^ associated type `F` not found
5+
| ^^^^^^^^^^^^ associated type `F` not found
66

77
error[E0191]: the value of the associated type `Bar` (from trait `Trait`) must be specified
88
--> $DIR/E0220.rs:5:16

src/test/ui/span/type-binding.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0220]: associated type `Trget` not found for `std::ops::Deref`
2-
--> $DIR/type-binding.rs:6:20
2+
--> $DIR/type-binding.rs:6:14
33
|
44
LL | fn homura<T: Deref<Trget = i32>>(_: T) {}
55
| ^^^^^^^^^^^ help: there is an associated type with a similar name: `Target`

src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-trait.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ LL | fn f<F:Trait(isize) -> isize>(x: F) {}
55
| ^^^^^^^^^^^^ unexpected type argument
66

77
error[E0220]: associated type `Output` not found for `Trait`
8-
--> $DIR/unboxed-closure-sugar-wrong-trait.rs:5:24
8+
--> $DIR/unboxed-closure-sugar-wrong-trait.rs:5:8
99
|
1010
LL | fn f<F:Trait(isize) -> isize>(x: F) {}
11-
| ^^^^^ associated type `Output` not found
11+
| ^^^^^^^^^^^^^^^^^^^^^ associated type `Output` not found
1212

1313
error: aborting due to 2 previous errors
1414

0 commit comments

Comments
 (0)