Skip to content

Commit 9381d9c

Browse files
committed
Revert "Remove hack, fix fmt and tests"
This reverts commit e1ef833.
1 parent 949b98c commit 9381d9c

File tree

9 files changed

+47
-72
lines changed

9 files changed

+47
-72
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1762,7 +1762,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
17621762
trait_ref: ty::PolyTraitRef<'tcx>,
17631763
err: &mut Diagnostic,
17641764
) -> bool {
1765-
let report = |mut candidates: Vec<TraitRef<'tcx>>, err: &mut Diagnostic| {
1765+
let report = |mut candidates: Vec<TraitRef<'_>>, err: &mut Diagnostic| {
17661766
candidates.sort();
17671767
candidates.dedup();
17681768
let len = candidates.len();
@@ -1784,8 +1784,11 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
17841784
}
17851785
let trait_ref = TraitRef::identity(self.tcx, candidates[0].def_id);
17861786
// Check if the trait is the same in all cases. If so, we'll only show the type.
1787-
let mut traits: Vec<_> =
1788-
candidates.iter().map(|c| c.print_only_trait_path().to_string()).collect();
1787+
// FIXME: there *has* to be a better way!
1788+
let mut traits: Vec<_> = candidates
1789+
.iter()
1790+
.map(|c| format!("{}", c).split(" as ").last().unwrap().to_string())
1791+
.collect();
17891792
traits.sort();
17901793
traits.dedup();
17911794

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

Lines changed: 3 additions & 3 deletions
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 other types implement trait `Traitor<N, M>`:
43+
= help: the following implementations were found:
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 other types implement trait `Traitor<N, M>`:
69-
<u32 as Traitor<N, 2_u8>>
68+
= help: the following implementations were found:
7069
<u64 as Traitor<1_u8, 2_u8>>
70+
<u32 as Traitor<N, 2_u8>>
7171

7272
error: aborting due to 6 previous errors
7373

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ 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>`
7675
note: required because of the requirements on the impl of `Gettable<String>` for `S<String>`
7776
--> $DIR/kindck-impl-type-params.rs:14:32
7877
|
@@ -86,7 +85,6 @@ error[E0277]: the trait bound `Foo: Copy` is not satisfied
8685
LL | let a: Box<dyn Gettable<Foo>> = t;
8786
| ^ the trait `Copy` is not implemented for `Foo`
8887
|
89-
= help: the trait `Gettable<T>` is implemented for `S<T>`
9088
note: required because of the requirements on the impl of `Gettable<Foo>` for `S<Foo>`
9189
--> $DIR/kindck-impl-type-params.rs:14:32
9290
|

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ 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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ 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

Lines changed: 1 addition & 1 deletion
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 other types implement trait `Foo<A>`:
22+
= help: the following implementations were found:
2323
<() as Foo<()>>
2424
<() as Foo<u32>>
2525

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

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,11 @@ 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 other types implement trait `PartialEq<Rhs>`:
9-
f32
10-
f64
11-
i128
12-
i16
13-
i32
14-
i64
15-
i8
16-
isize
8+
= help: the following implementations were found:
9+
<i32 as PartialEq>
10+
<f32 as PartialEq>
11+
<f64 as PartialEq>
12+
<i128 as PartialEq>
1713
and 6 others
1814

1915
error: aborting due to previous error

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

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,11 @@ 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 other types implement trait `PartialEq<Rhs>`:
9-
f32
10-
f64
11-
i128
12-
i16
13-
i32
14-
i64
15-
i8
16-
isize
8+
= help: the following implementations were found:
9+
<i32 as PartialEq>
10+
<f32 as PartialEq>
11+
<f64 as PartialEq>
12+
<i128 as PartialEq>
1713
and 6 others
1814

1915
error[E0277]: can't compare `&i32` with `Foo<'static, 'b>`
@@ -23,15 +19,11 @@ LL | i
2319
| ^ no implementation for `&i32 == Foo<'static, 'b>`
2420
|
2521
= help: the trait `PartialEq<Foo<'static, 'b>>` is not implemented for `&i32`
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
22+
= help: the following implementations were found:
23+
<i32 as PartialEq>
24+
<f32 as PartialEq>
25+
<f64 as PartialEq>
26+
<i128 as PartialEq>
3527
and 6 others
3628

3729
error[E0277]: can't compare `&i32` with `Moo<'static, 'a>`
@@ -41,15 +33,11 @@ LL | i
4133
| ^ no implementation for `&i32 == Moo<'static, 'a>`
4234
|
4335
= help: the trait `PartialEq<Moo<'static, 'a>>` is not implemented for `&i32`
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
36+
= help: the following implementations were found:
37+
<i32 as PartialEq>
38+
<f32 as PartialEq>
39+
<f64 as PartialEq>
40+
<i128 as PartialEq>
5341
and 6 others
5442

5543
error: aborting due to 3 previous errors

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

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,11 @@ 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 other types implement trait `PartialEq<Rhs>`:
9-
f32
10-
f64
11-
i128
12-
i16
13-
i32
14-
i64
15-
i8
16-
isize
8+
= help: the following implementations were found:
9+
<i32 as PartialEq>
10+
<f32 as PartialEq>
11+
<f64 as PartialEq>
12+
<i128 as PartialEq>
1713
and 6 others
1814

1915
error[E0277]: can't compare `&i32` with `(i32, &i32)`
@@ -23,15 +19,11 @@ LL | (42, i)
2319
| ^ no implementation for `&i32 == (i32, &i32)`
2420
|
2521
= help: the trait `PartialEq<(i32, &i32)>` is not implemented for `&i32`
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
22+
= help: the following implementations were found:
23+
<i32 as PartialEq>
24+
<f32 as PartialEq>
25+
<f64 as PartialEq>
26+
<i128 as PartialEq>
3527
and 6 others
3628

3729
error[E0277]: can't compare `&i32` with `(i32, Moo<'b, 'a>::{opaque#0})`
@@ -41,15 +33,11 @@ LL | (42, i)
4133
| ^ no implementation for `&i32 == (i32, Moo<'b, 'a>::{opaque#0})`
4234
|
4335
= help: the trait `PartialEq<(i32, Moo<'b, 'a>::{opaque#0})>` is not implemented for `&i32`
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
36+
= help: the following implementations were found:
37+
<i32 as PartialEq>
38+
<f32 as PartialEq>
39+
<f64 as PartialEq>
40+
<i128 as PartialEq>
5341
and 6 others
5442

5543
error: aborting due to 3 previous errors

0 commit comments

Comments
 (0)