Skip to content

Commit 759df5f

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 547abe0 commit 759df5f

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
@@ -937,6 +937,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
937937
bounds,
938938
speculative,
939939
&mut dup_bindings,
940+
span,
940941
);
941942
// Okay to ignore `Err` because of `ErrorReported` (see above).
942943
}
@@ -1189,6 +1190,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
11891190
bounds: &mut Bounds<'tcx>,
11901191
speculative: bool,
11911192
dup_bindings: &mut FxHashMap<DefId, Span>,
1193+
path_span: Span,
11921194
) -> Result<(), ErrorReported> {
11931195
let tcx = self.tcx();
11941196

@@ -1259,7 +1261,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
12591261
|| traits::supertraits(tcx, trait_ref),
12601262
&trait_ref.print_only_trait_path().to_string(),
12611263
binding.item_name,
1262-
binding.span,
1264+
path_span,
12631265
)
12641266
}?;
12651267

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)