Remove hack, fix fmt and tests

This commit is contained in:
Esteban Kuber 2022-03-27 02:14:54 +00:00
parent a6301cab5e
commit e1ef833bca
9 changed files with 72 additions and 47 deletions

View File

@ -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();
@ -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();

View File

@ -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>>
@ -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

View File

@ -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
|
@ -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
|

View File

@ -11,4 +11,3 @@ fn get_vowel_count(string: &str) -> usize {
fn main() {
let _ = get_vowel_count("asdf");
}

View File

@ -11,4 +11,3 @@ fn get_vowel_count(string: &str) -> usize {
fn main() {
let _ = get_vowel_count("asdf");
}

View File

@ -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>>

View File

@ -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

View File

@ -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>`
@ -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>`
@ -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

View File

@ -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)`
@ -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})`
@ -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