Skip to content

Commit

Permalink
Remove hack, fix fmt and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
estebank committed Apr 4, 2022
1 parent a6301ca commit e1ef833
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1756,7 +1756,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
trait_ref: ty::PolyTraitRef<'tcx>,
err: &mut Diagnostic,
) -> bool {
let report = |mut candidates: Vec<TraitRef<'_>>, err: &mut Diagnostic| {
let report = |mut candidates: Vec<TraitRef<'tcx>>, err: &mut Diagnostic| {
candidates.sort();
candidates.dedup();
let len = candidates.len();
Expand All @@ -1778,11 +1778,8 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
}
let trait_ref = TraitRef::identity(self.tcx, candidates[0].def_id);
// Check if the trait is the same in all cases. If so, we'll only show the type.
// FIXME: there *has* to be a better way!
let mut traits: Vec<_> = candidates
.iter()
.map(|c| format!("{}", c).split(" as ").last().unwrap().to_string())
.collect();
let mut traits: Vec<_> =
candidates.iter().map(|c| c.print_only_trait_path().to_string()).collect();
traits.sort();
traits.dedup();

Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/const-generics/defaults/rp_impl_trait_fail.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ LL | | 1_u32
LL | | }
| |_^ the trait `Traitor<N, N>` is not implemented for `u32`
|
= help: the following implementations were found:
= help: the following other types implement trait `Traitor<N, M>`:
<u32 as Traitor<N, 2_u8>>
<u64 as Traitor<1_u8, 2_u8>>

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

error: aborting due to 6 previous errors

Expand Down
2 changes: 2 additions & 0 deletions src/test/ui/kindck/kindck-impl-type-params.nll.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ error[E0277]: the trait bound `String: Copy` is not satisfied
LL | let a = t as Box<dyn Gettable<String>>;
| ^ the trait `Copy` is not implemented for `String`
|
= help: the trait `Gettable<T>` is implemented for `S<T>`
note: required because of the requirements on the impl of `Gettable<String>` for `S<String>`
--> $DIR/kindck-impl-type-params.rs:14:32
|
Expand All @@ -85,6 +86,7 @@ error[E0277]: the trait bound `Foo: Copy` is not satisfied
LL | let a: Box<dyn Gettable<Foo>> = t;
| ^ the trait `Copy` is not implemented for `Foo`
|
= help: the trait `Gettable<T>` is implemented for `S<T>`
note: required because of the requirements on the impl of `Gettable<Foo>` for `S<Foo>`
--> $DIR/kindck-impl-type-params.rs:14:32
|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ fn get_vowel_count(string: &str) -> usize {
fn main() {
let _ = get_vowel_count("asdf");
}

1 change: 0 additions & 1 deletion src/test/ui/traits/suggest-deferences/root-obligation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ fn get_vowel_count(string: &str) -> usize {
fn main() {
let _ = get_vowel_count("asdf");
}

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ LL | | ()
LL | | }
| |_^ the trait `Foo<FooX>` is not implemented for `()`
|
= help: the following implementations were found:
= help: the following other types implement trait `Foo<A>`:
<() as Foo<()>>
<() as Foo<u32>>

Expand Down
14 changes: 9 additions & 5 deletions src/test/ui/type-alias-impl-trait/self-referential-2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ LL | 42_i32
| ^^^^^^ no implementation for `i32 == Foo`
|
= help: the trait `PartialEq<Foo>` is not implemented for `i32`
= help: the following implementations were found:
<i32 as PartialEq>
<f32 as PartialEq>
<f64 as PartialEq>
<i128 as PartialEq>
= help: the following other types implement trait `PartialEq<Rhs>`:
f32
f64
i128
i16
i32
i64
i8
isize
and 6 others

error: aborting due to previous error
Expand Down
42 changes: 27 additions & 15 deletions src/test/ui/type-alias-impl-trait/self-referential-4.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ LL | i
| ^ no implementation for `&i32 == Bar<'b, 'static>`
|
= help: the trait `PartialEq<Bar<'b, 'static>>` is not implemented for `&i32`
= help: the following implementations were found:
<i32 as PartialEq>
<f32 as PartialEq>
<f64 as PartialEq>
<i128 as PartialEq>
= help: the following other types implement trait `PartialEq<Rhs>`:
f32
f64
i128
i16
i32
i64
i8
isize
and 6 others

error[E0277]: can't compare `&i32` with `Foo<'static, 'b>`
Expand All @@ -19,11 +23,15 @@ LL | i
| ^ no implementation for `&i32 == Foo<'static, 'b>`
|
= help: the trait `PartialEq<Foo<'static, 'b>>` is not implemented for `&i32`
= help: the following implementations were found:
<i32 as PartialEq>
<f32 as PartialEq>
<f64 as PartialEq>
<i128 as PartialEq>
= help: the following other types implement trait `PartialEq<Rhs>`:
f32
f64
i128
i16
i32
i64
i8
isize
and 6 others

error[E0277]: can't compare `&i32` with `Moo<'static, 'a>`
Expand All @@ -33,11 +41,15 @@ LL | i
| ^ no implementation for `&i32 == Moo<'static, 'a>`
|
= help: the trait `PartialEq<Moo<'static, 'a>>` is not implemented for `&i32`
= help: the following implementations were found:
<i32 as PartialEq>
<f32 as PartialEq>
<f64 as PartialEq>
<i128 as PartialEq>
= help: the following other types implement trait `PartialEq<Rhs>`:
f32
f64
i128
i16
i32
i64
i8
isize
and 6 others

error: aborting due to 3 previous errors
Expand Down
42 changes: 27 additions & 15 deletions src/test/ui/type-alias-impl-trait/self-referential.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ LL | i
| ^ no implementation for `&i32 == Bar<'b, 'a>`
|
= help: the trait `PartialEq<Bar<'b, 'a>>` is not implemented for `&i32`
= help: the following implementations were found:
<i32 as PartialEq>
<f32 as PartialEq>
<f64 as PartialEq>
<i128 as PartialEq>
= help: the following other types implement trait `PartialEq<Rhs>`:
f32
f64
i128
i16
i32
i64
i8
isize
and 6 others

error[E0277]: can't compare `&i32` with `(i32, &i32)`
Expand All @@ -19,11 +23,15 @@ LL | (42, i)
| ^ no implementation for `&i32 == (i32, &i32)`
|
= help: the trait `PartialEq<(i32, &i32)>` is not implemented for `&i32`
= help: the following implementations were found:
<i32 as PartialEq>
<f32 as PartialEq>
<f64 as PartialEq>
<i128 as PartialEq>
= help: the following other types implement trait `PartialEq<Rhs>`:
f32
f64
i128
i16
i32
i64
i8
isize
and 6 others

error[E0277]: can't compare `&i32` with `(i32, Moo<'b, 'a>::{opaque#0})`
Expand All @@ -33,11 +41,15 @@ LL | (42, i)
| ^ no implementation for `&i32 == (i32, Moo<'b, 'a>::{opaque#0})`
|
= help: the trait `PartialEq<(i32, Moo<'b, 'a>::{opaque#0})>` is not implemented for `&i32`
= help: the following implementations were found:
<i32 as PartialEq>
<f32 as PartialEq>
<f64 as PartialEq>
<i128 as PartialEq>
= help: the following other types implement trait `PartialEq<Rhs>`:
f32
f64
i128
i16
i32
i64
i8
isize
and 6 others

error: aborting due to 3 previous errors
Expand Down

0 comments on commit e1ef833

Please sign in to comment.