Skip to content

Commit e1ef833

Browse files
committed
Remove hack, fix fmt and tests
1 parent a6301ca commit e1ef833

File tree

9 files changed

+72
-47
lines changed

9 files changed

+72
-47
lines changed

compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -1756,7 +1756,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
17561756
trait_ref: ty::PolyTraitRef<'tcx>,
17571757
err: &mut Diagnostic,
17581758
) -> bool {
1759-
let report = |mut candidates: Vec<TraitRef<'_>>, err: &mut Diagnostic| {
1759+
let report = |mut candidates: Vec<TraitRef<'tcx>>, err: &mut Diagnostic| {
17601760
candidates.sort();
17611761
candidates.dedup();
17621762
let len = candidates.len();
@@ -1778,11 +1778,8 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
17781778
}
17791779
let trait_ref = TraitRef::identity(self.tcx, candidates[0].def_id);
17801780
// Check if the trait is the same in all cases. If so, we'll only show the type.
1781-
// FIXME: there *has* to be a better way!
1782-
let mut traits: Vec<_> = candidates
1783-
.iter()
1784-
.map(|c| format!("{}", c).split(" as ").last().unwrap().to_string())
1785-
.collect();
1781+
let mut traits: Vec<_> =
1782+
candidates.iter().map(|c| c.print_only_trait_path().to_string()).collect();
17861783
traits.sort();
17871784
traits.dedup();
17881785

src/test/ui/const-generics/defaults/rp_impl_trait_fail.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ LL | | 1_u32
4040
LL | | }
4141
| |_^ the trait `Traitor<N, N>` is not implemented for `u32`
4242
|
43-
= help: the following implementations were found:
43+
= help: the following other types implement trait `Traitor<N, M>`:
4444
<u32 as Traitor<N, 2_u8>>
4545
<u64 as Traitor<1_u8, 2_u8>>
4646

@@ -65,9 +65,9 @@ LL | | 1_u64
6565
LL | | }
6666
| |_^ the trait `Traitor<1_u8, 1_u8>` is not implemented for `u64`
6767
|
68-
= help: the following implementations were found:
69-
<u64 as Traitor<1_u8, 2_u8>>
68+
= help: the following other types implement trait `Traitor<N, M>`:
7069
<u32 as Traitor<N, 2_u8>>
70+
<u64 as Traitor<1_u8, 2_u8>>
7171

7272
error: aborting due to 6 previous errors
7373

src/test/ui/kindck/kindck-impl-type-params.nll.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ error[E0277]: the trait bound `String: Copy` is not satisfied
7272
LL | let a = t as Box<dyn Gettable<String>>;
7373
| ^ the trait `Copy` is not implemented for `String`
7474
|
75+
= help: the trait `Gettable<T>` is implemented for `S<T>`
7576
note: required because of the requirements on the impl of `Gettable<String>` for `S<String>`
7677
--> $DIR/kindck-impl-type-params.rs:14:32
7778
|
@@ -85,6 +86,7 @@ error[E0277]: the trait bound `Foo: Copy` is not satisfied
8586
LL | let a: Box<dyn Gettable<Foo>> = t;
8687
| ^ the trait `Copy` is not implemented for `Foo`
8788
|
89+
= help: the trait `Gettable<T>` is implemented for `S<T>`
8890
note: required because of the requirements on the impl of `Gettable<Foo>` for `S<Foo>`
8991
--> $DIR/kindck-impl-type-params.rs:14:32
9092
|

src/test/ui/traits/suggest-deferences/root-obligation.fixed

-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,3 @@ fn get_vowel_count(string: &str) -> usize {
1111
fn main() {
1212
let _ = get_vowel_count("asdf");
1313
}
14-

src/test/ui/traits/suggest-deferences/root-obligation.rs

-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,3 @@ fn get_vowel_count(string: &str) -> usize {
1111
fn main() {
1212
let _ = get_vowel_count("asdf");
1313
}
14-

src/test/ui/type-alias-impl-trait/nested-tait-inference2.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ LL | | ()
1919
LL | | }
2020
| |_^ the trait `Foo<FooX>` is not implemented for `()`
2121
|
22-
= help: the following implementations were found:
22+
= help: the following other types implement trait `Foo<A>`:
2323
<() as Foo<()>>
2424
<() as Foo<u32>>
2525

src/test/ui/type-alias-impl-trait/self-referential-2.stderr

+9-5
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@ LL | 42_i32
55
| ^^^^^^ no implementation for `i32 == Foo`
66
|
77
= help: the trait `PartialEq<Foo>` is not implemented for `i32`
8-
= help: the following implementations were found:
9-
<i32 as PartialEq>
10-
<f32 as PartialEq>
11-
<f64 as PartialEq>
12-
<i128 as PartialEq>
8+
= help: the following other types implement trait `PartialEq<Rhs>`:
9+
f32
10+
f64
11+
i128
12+
i16
13+
i32
14+
i64
15+
i8
16+
isize
1317
and 6 others
1418

1519
error: aborting due to previous error

src/test/ui/type-alias-impl-trait/self-referential-4.stderr

+27-15
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@ LL | i
55
| ^ no implementation for `&i32 == Bar<'b, 'static>`
66
|
77
= help: the trait `PartialEq<Bar<'b, 'static>>` is not implemented for `&i32`
8-
= help: the following implementations were found:
9-
<i32 as PartialEq>
10-
<f32 as PartialEq>
11-
<f64 as PartialEq>
12-
<i128 as PartialEq>
8+
= help: the following other types implement trait `PartialEq<Rhs>`:
9+
f32
10+
f64
11+
i128
12+
i16
13+
i32
14+
i64
15+
i8
16+
isize
1317
and 6 others
1418

1519
error[E0277]: can't compare `&i32` with `Foo<'static, 'b>`
@@ -19,11 +23,15 @@ LL | i
1923
| ^ no implementation for `&i32 == Foo<'static, 'b>`
2024
|
2125
= help: the trait `PartialEq<Foo<'static, 'b>>` is not implemented for `&i32`
22-
= help: the following implementations were found:
23-
<i32 as PartialEq>
24-
<f32 as PartialEq>
25-
<f64 as PartialEq>
26-
<i128 as PartialEq>
26+
= help: the following other types implement trait `PartialEq<Rhs>`:
27+
f32
28+
f64
29+
i128
30+
i16
31+
i32
32+
i64
33+
i8
34+
isize
2735
and 6 others
2836

2937
error[E0277]: can't compare `&i32` with `Moo<'static, 'a>`
@@ -33,11 +41,15 @@ LL | i
3341
| ^ no implementation for `&i32 == Moo<'static, 'a>`
3442
|
3543
= help: the trait `PartialEq<Moo<'static, 'a>>` is not implemented for `&i32`
36-
= help: the following implementations were found:
37-
<i32 as PartialEq>
38-
<f32 as PartialEq>
39-
<f64 as PartialEq>
40-
<i128 as PartialEq>
44+
= help: the following other types implement trait `PartialEq<Rhs>`:
45+
f32
46+
f64
47+
i128
48+
i16
49+
i32
50+
i64
51+
i8
52+
isize
4153
and 6 others
4254

4355
error: aborting due to 3 previous errors

src/test/ui/type-alias-impl-trait/self-referential.stderr

+27-15
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@ LL | i
55
| ^ no implementation for `&i32 == Bar<'b, 'a>`
66
|
77
= help: the trait `PartialEq<Bar<'b, 'a>>` is not implemented for `&i32`
8-
= help: the following implementations were found:
9-
<i32 as PartialEq>
10-
<f32 as PartialEq>
11-
<f64 as PartialEq>
12-
<i128 as PartialEq>
8+
= help: the following other types implement trait `PartialEq<Rhs>`:
9+
f32
10+
f64
11+
i128
12+
i16
13+
i32
14+
i64
15+
i8
16+
isize
1317
and 6 others
1418

1519
error[E0277]: can't compare `&i32` with `(i32, &i32)`
@@ -19,11 +23,15 @@ LL | (42, i)
1923
| ^ no implementation for `&i32 == (i32, &i32)`
2024
|
2125
= help: the trait `PartialEq<(i32, &i32)>` is not implemented for `&i32`
22-
= help: the following implementations were found:
23-
<i32 as PartialEq>
24-
<f32 as PartialEq>
25-
<f64 as PartialEq>
26-
<i128 as PartialEq>
26+
= help: the following other types implement trait `PartialEq<Rhs>`:
27+
f32
28+
f64
29+
i128
30+
i16
31+
i32
32+
i64
33+
i8
34+
isize
2735
and 6 others
2836

2937
error[E0277]: can't compare `&i32` with `(i32, Moo<'b, 'a>::{opaque#0})`
@@ -33,11 +41,15 @@ LL | (42, i)
3341
| ^ no implementation for `&i32 == (i32, Moo<'b, 'a>::{opaque#0})`
3442
|
3543
= help: the trait `PartialEq<(i32, Moo<'b, 'a>::{opaque#0})>` is not implemented for `&i32`
36-
= help: the following implementations were found:
37-
<i32 as PartialEq>
38-
<f32 as PartialEq>
39-
<f64 as PartialEq>
40-
<i128 as PartialEq>
44+
= help: the following other types implement trait `PartialEq<Rhs>`:
45+
f32
46+
f64
47+
i128
48+
i16
49+
i32
50+
i64
51+
i8
52+
isize
4153
and 6 others
4254

4355
error: aborting due to 3 previous errors

0 commit comments

Comments
 (0)