Point out the actual mismatch error
This commit is contained in:
parent
8be12f4ed7
commit
07851679cd
@ -1,3 +1,5 @@
|
||||
// ignore-tidy-filelength :(
|
||||
|
||||
mod ambiguity;
|
||||
pub mod on_unimplemented;
|
||||
pub mod suggestions;
|
||||
@ -1943,6 +1945,8 @@ fn report_similar_impl_candidates(
|
||||
other: bool,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
) -> bool {
|
||||
// If we have a single implementation, try to unify it with the trait ref
|
||||
// that failed. This should uncover a better hint for what *is* implemented.
|
||||
if let [single] = &impl_candidates {
|
||||
if self.probe(|_| {
|
||||
let ocx = ObligationCtxt::new(self);
|
||||
@ -1972,7 +1976,7 @@ fn report_similar_impl_candidates(
|
||||
std::iter::zip(obligation_trait_ref.args, impl_trait_ref.args)
|
||||
{
|
||||
if let Err(terr) =
|
||||
ocx.eq(&ObligationCause::dummy(), param_env, obligation_arg, impl_arg)
|
||||
ocx.eq(&ObligationCause::dummy(), param_env, impl_arg, obligation_arg)
|
||||
{
|
||||
terrs.push(terr);
|
||||
}
|
||||
@ -2000,6 +2004,15 @@ fn report_similar_impl_candidates(
|
||||
(cand.self_ty().to_string(), Style::Highlight),
|
||||
("`".to_string(), Style::NoStyle),
|
||||
]);
|
||||
|
||||
if let [TypeError::Sorts(exp_found)] = &terrs[..] {
|
||||
let exp_found = self.resolve_vars_if_possible(*exp_found);
|
||||
err.help(format!(
|
||||
"for that trait implementation, expected `{}`, found `{}`",
|
||||
exp_found.expected, exp_found.found
|
||||
));
|
||||
}
|
||||
|
||||
true
|
||||
}) {
|
||||
return true;
|
||||
|
@ -17,6 +17,7 @@ LL | let () = K::<()>;
|
||||
| ^^ the trait `From<()>` is not implemented for `Infallible`
|
||||
|
|
||||
= help: the trait `From<!>` is implemented for `Infallible`
|
||||
= help: for that trait implementation, expected `!`, found `()`
|
||||
note: required by a bound in `K`
|
||||
--> $DIR/unsatisfied-bounds.rs:12:17
|
||||
|
|
||||
@ -48,6 +49,7 @@ LL | let _ = <() as Trait<&'static str>>::B::<()>;
|
||||
| ^^ the trait `From<()>` is not implemented for `Infallible`
|
||||
|
|
||||
= help: the trait `From<!>` is implemented for `Infallible`
|
||||
= help: for that trait implementation, expected `!`, found `()`
|
||||
note: required by a bound in `Trait::B`
|
||||
--> $DIR/unsatisfied-bounds.rs:21:21
|
||||
|
|
||||
|
@ -43,6 +43,7 @@ LL | WrongImpl::<()>::foo(0i32);
|
||||
| ^^^^^^^^^^^^^^^ the trait `Raw<()>` is not implemented for `RawImpl<()>`
|
||||
|
|
||||
= help: the trait `Raw<[()]>` is implemented for `RawImpl<()>`
|
||||
= help: for that trait implementation, expected `[()]`, found `()`
|
||||
note: required by a bound in `SafeImpl`
|
||||
--> $DIR/issue-62742.rs:26:35
|
||||
|
|
||||
|
@ -6,6 +6,7 @@ LL | x[0i32];
|
||||
|
|
||||
= help: the trait `SliceIndex<[{integer}]>` is not implemented for `i32`
|
||||
= help: the trait `SliceIndex<[{integer}]>` is implemented for `usize`
|
||||
= help: for that trait implementation, expected `usize`, found `i32`
|
||||
= note: required for `Vec<{integer}>` to implement `Index<i32>`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
@ -6,6 +6,7 @@ LL | [0][0u8];
|
||||
|
|
||||
= help: the trait `SliceIndex<[{integer}]>` is not implemented for `u8`
|
||||
= help: the trait `SliceIndex<[{integer}]>` is implemented for `usize`
|
||||
= help: for that trait implementation, expected `usize`, found `u8`
|
||||
= note: required for `[{integer}]` to implement `Index<u8>`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
|
@ -6,6 +6,7 @@ LL | v[3u8];
|
||||
|
|
||||
= help: the trait `SliceIndex<[isize]>` is not implemented for `u8`
|
||||
= help: the trait `SliceIndex<[isize]>` is implemented for `usize`
|
||||
= help: for that trait implementation, expected `usize`, found `u8`
|
||||
= note: required for `Vec<isize>` to implement `Index<u8>`
|
||||
|
||||
error[E0277]: the type `[isize]` cannot be indexed by `i8`
|
||||
@ -16,6 +17,7 @@ LL | v[3i8];
|
||||
|
|
||||
= help: the trait `SliceIndex<[isize]>` is not implemented for `i8`
|
||||
= help: the trait `SliceIndex<[isize]>` is implemented for `usize`
|
||||
= help: for that trait implementation, expected `usize`, found `i8`
|
||||
= note: required for `Vec<isize>` to implement `Index<i8>`
|
||||
|
||||
error[E0277]: the type `[isize]` cannot be indexed by `u32`
|
||||
@ -26,6 +28,7 @@ LL | v[3u32];
|
||||
|
|
||||
= help: the trait `SliceIndex<[isize]>` is not implemented for `u32`
|
||||
= help: the trait `SliceIndex<[isize]>` is implemented for `usize`
|
||||
= help: for that trait implementation, expected `usize`, found `u32`
|
||||
= note: required for `Vec<isize>` to implement `Index<u32>`
|
||||
|
||||
error[E0277]: the type `[isize]` cannot be indexed by `i32`
|
||||
@ -36,6 +39,7 @@ LL | v[3i32];
|
||||
|
|
||||
= help: the trait `SliceIndex<[isize]>` is not implemented for `i32`
|
||||
= help: the trait `SliceIndex<[isize]>` is implemented for `usize`
|
||||
= help: for that trait implementation, expected `usize`, found `i32`
|
||||
= note: required for `Vec<isize>` to implement `Index<i32>`
|
||||
|
||||
error[E0277]: the type `[u8]` cannot be indexed by `u8`
|
||||
@ -46,6 +50,7 @@ LL | s.as_bytes()[3u8];
|
||||
|
|
||||
= help: the trait `SliceIndex<[u8]>` is not implemented for `u8`
|
||||
= help: the trait `SliceIndex<[u8]>` is implemented for `usize`
|
||||
= help: for that trait implementation, expected `usize`, found `u8`
|
||||
= note: required for `[u8]` to implement `Index<u8>`
|
||||
|
||||
error[E0277]: the type `[u8]` cannot be indexed by `i8`
|
||||
@ -56,6 +61,7 @@ LL | s.as_bytes()[3i8];
|
||||
|
|
||||
= help: the trait `SliceIndex<[u8]>` is not implemented for `i8`
|
||||
= help: the trait `SliceIndex<[u8]>` is implemented for `usize`
|
||||
= help: for that trait implementation, expected `usize`, found `i8`
|
||||
= note: required for `[u8]` to implement `Index<i8>`
|
||||
|
||||
error[E0277]: the type `[u8]` cannot be indexed by `u32`
|
||||
@ -66,6 +72,7 @@ LL | s.as_bytes()[3u32];
|
||||
|
|
||||
= help: the trait `SliceIndex<[u8]>` is not implemented for `u32`
|
||||
= help: the trait `SliceIndex<[u8]>` is implemented for `usize`
|
||||
= help: for that trait implementation, expected `usize`, found `u32`
|
||||
= note: required for `[u8]` to implement `Index<u32>`
|
||||
|
||||
error[E0277]: the type `[u8]` cannot be indexed by `i32`
|
||||
@ -76,6 +83,7 @@ LL | s.as_bytes()[3i32];
|
||||
|
|
||||
= help: the trait `SliceIndex<[u8]>` is not implemented for `i32`
|
||||
= help: the trait `SliceIndex<[u8]>` is implemented for `usize`
|
||||
= help: for that trait implementation, expected `usize`, found `i32`
|
||||
= note: required for `[u8]` to implement `Index<i32>`
|
||||
|
||||
error: aborting due to 8 previous errors
|
||||
|
@ -20,6 +20,7 @@ LL | let sr2: Vec<(u32, _, _)> = sr.iter().map(|(faction, th_sender, th_rece
|
||||
|
|
||||
= help: the trait `FromIterator<()>` is not implemented for `Vec<(u32, _, _)>`
|
||||
= help: the trait `FromIterator<(u32, _, _)>` is implemented for `Vec<(u32, _, _)>`
|
||||
= help: for that trait implementation, expected `(u32, _, _)`, found `()`
|
||||
note: the method call chain might not have had the expected associated types
|
||||
--> $DIR/issue-34334.rs:5:43
|
||||
|
|
||||
|
@ -5,6 +5,7 @@ LL | req.get_ref::<Params>();
|
||||
| ^^^^^^^ the trait `Plugin<i32>` is not implemented for `Params`
|
||||
|
|
||||
= help: the trait `Plugin<Foo>` is implemented for `Params`
|
||||
= help: for that trait implementation, expected `Foo`, found `i32`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -6,6 +6,7 @@ LL | let x2: Vec<f64> = x1.into_iter().collect();
|
||||
|
|
||||
= help: the trait `FromIterator<&f64>` is not implemented for `Vec<f64>`
|
||||
= help: the trait `FromIterator<f64>` is implemented for `Vec<f64>`
|
||||
= help: for that trait implementation, expected `f64`, found `&f64`
|
||||
note: the method call chain might not have had the expected associated types
|
||||
--> $DIR/issue-66923-show-error-for-correct-call.rs:8:27
|
||||
|
|
||||
@ -26,6 +27,7 @@ LL | let x3 = x1.into_iter().collect::<Vec<f64>>();
|
||||
|
|
||||
= help: the trait `FromIterator<&f64>` is not implemented for `Vec<f64>`
|
||||
= help: the trait `FromIterator<f64>` is implemented for `Vec<f64>`
|
||||
= help: for that trait implementation, expected `f64`, found `&f64`
|
||||
note: the method call chain might not have had the expected associated types
|
||||
--> $DIR/issue-66923-show-error-for-correct-call.rs:12:17
|
||||
|
|
||||
|
@ -6,6 +6,7 @@ LL | i.collect()
|
||||
|
|
||||
= help: the trait `FromIterator<&X>` is not implemented for `Vec<X>`
|
||||
= help: the trait `FromIterator<X>` is implemented for `Vec<X>`
|
||||
= help: for that trait implementation, expected `X`, found `&X`
|
||||
note: the method call chain might not have had the expected associated types
|
||||
--> $DIR/invalid-iterator-chain.rs:4:26
|
||||
|
|
||||
@ -160,6 +161,7 @@ LL | let g: Vec<i32> = f.collect();
|
||||
|
|
||||
= help: the trait `FromIterator<()>` is not implemented for `Vec<i32>`
|
||||
= help: the trait `FromIterator<i32>` is implemented for `Vec<i32>`
|
||||
= help: for that trait implementation, expected `i32`, found `()`
|
||||
note: the method call chain might not have had the expected associated types
|
||||
--> $DIR/invalid-iterator-chain.rs:44:15
|
||||
|
|
||||
|
@ -5,6 +5,7 @@ LL | <E as From<_>>::from(never);
|
||||
| ^ the trait `From<()>` is not implemented for `E`
|
||||
|
|
||||
= help: the trait `From<!>` is implemented for `E`
|
||||
= help: for that trait implementation, expected `!`, found `()`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -8,6 +8,7 @@ LL | Foo::<usize>::foo((1i32, 1i32, 1i32));
|
||||
|
|
||||
= help: the trait `Foo<usize>` is not implemented for `(i32, i32, i32)`
|
||||
= help: the trait `Foo<i32>` is implemented for `(i32, i32, i32)`
|
||||
= help: for that trait implementation, expected `i32`, found `usize`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -8,6 +8,7 @@ LL | Index::<u32>::index(&[1, 2, 3] as &[i32], 2u32);
|
||||
|
|
||||
= help: the trait `Index<u32>` is not implemented for `[i32]`
|
||||
= help: the trait `Index<usize>` is implemented for `[i32]`
|
||||
= help: for that trait implementation, expected `usize`, found `u32`
|
||||
|
||||
error[E0277]: the trait bound `[i32]: Index<u32>` is not satisfied
|
||||
--> $DIR/on-impl.rs:22:5
|
||||
@ -17,6 +18,7 @@ LL | Index::<u32>::index(&[1, 2, 3] as &[i32], 2u32);
|
||||
|
|
||||
= help: the trait `Index<u32>` is not implemented for `[i32]`
|
||||
= help: the trait `Index<usize>` is implemented for `[i32]`
|
||||
= help: for that trait implementation, expected `usize`, found `u32`
|
||||
|
||||
error[E0277]: the trait bound `[i32]: Index<u32>` is not satisfied
|
||||
--> $DIR/on-impl.rs:22:5
|
||||
@ -26,6 +28,7 @@ LL | Index::<u32>::index(&[1, 2, 3] as &[i32], 2u32);
|
||||
|
|
||||
= help: the trait `Index<u32>` is not implemented for `[i32]`
|
||||
= help: the trait `Index<usize>` is implemented for `[i32]`
|
||||
= help: for that trait implementation, expected `usize`, found `u32`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
@ -6,6 +6,7 @@ LL | x[1i32];
|
||||
|
|
||||
= help: the trait `SliceIndex<[i32]>` is not implemented for `i32`
|
||||
= help: the trait `SliceIndex<[i32]>` is implemented for `usize`
|
||||
= help: for that trait implementation, expected `usize`, found `i32`
|
||||
= note: required for `[i32]` to implement `Index<i32>`
|
||||
|
||||
error[E0277]: the type `[i32]` cannot be indexed by `RangeTo<i32>`
|
||||
|
@ -8,6 +8,7 @@ LL | let _: u8 = s[4];
|
||||
= note: you can use `.chars().nth()` or `.bytes().nth()`
|
||||
for more information, see chapter 8 in The Book: <https://doc.rust-lang.org/book/ch08-02-strings.html#indexing-into-strings>
|
||||
= help: the trait `SliceIndex<[_]>` is implemented for `usize`
|
||||
= help: for that trait implementation, expected `[_]`, found `str`
|
||||
= note: required for `str` to implement `Index<{integer}>`
|
||||
|
||||
error[E0277]: the type `str` cannot be indexed by `{integer}`
|
||||
@ -22,6 +23,7 @@ LL | let _ = s.get(4);
|
||||
= note: you can use `.chars().nth()` or `.bytes().nth()`
|
||||
for more information, see chapter 8 in The Book: <https://doc.rust-lang.org/book/ch08-02-strings.html#indexing-into-strings>
|
||||
= help: the trait `SliceIndex<[_]>` is implemented for `usize`
|
||||
= help: for that trait implementation, expected `[_]`, found `str`
|
||||
note: required by a bound in `core::str::<impl str>::get`
|
||||
--> $SRC_DIR/core/src/str/mod.rs:LL:COL
|
||||
|
||||
@ -37,6 +39,7 @@ LL | let _ = s.get_unchecked(4);
|
||||
= note: you can use `.chars().nth()` or `.bytes().nth()`
|
||||
for more information, see chapter 8 in The Book: <https://doc.rust-lang.org/book/ch08-02-strings.html#indexing-into-strings>
|
||||
= help: the trait `SliceIndex<[_]>` is implemented for `usize`
|
||||
= help: for that trait implementation, expected `[_]`, found `str`
|
||||
note: required by a bound in `core::str::<impl str>::get_unchecked`
|
||||
--> $SRC_DIR/core/src/str/mod.rs:LL:COL
|
||||
|
||||
|
@ -32,6 +32,7 @@ LL | s[1usize] = bot();
|
||||
|
|
||||
= help: the trait `SliceIndex<str>` is not implemented for `usize`
|
||||
= help: the trait `SliceIndex<[_]>` is implemented for `usize`
|
||||
= help: for that trait implementation, expected `[_]`, found `str`
|
||||
= note: required for `str` to implement `Index<usize>`
|
||||
|
||||
error[E0277]: the type `str` cannot be indexed by `{integer}`
|
||||
@ -46,6 +47,7 @@ LL | s.get_mut(1);
|
||||
= note: you can use `.chars().nth()` or `.bytes().nth()`
|
||||
for more information, see chapter 8 in The Book: <https://doc.rust-lang.org/book/ch08-02-strings.html#indexing-into-strings>
|
||||
= help: the trait `SliceIndex<[_]>` is implemented for `usize`
|
||||
= help: for that trait implementation, expected `[_]`, found `str`
|
||||
note: required by a bound in `core::str::<impl str>::get_mut`
|
||||
--> $SRC_DIR/core/src/str/mod.rs:LL:COL
|
||||
|
||||
@ -61,6 +63,7 @@ LL | s.get_unchecked_mut(1);
|
||||
= note: you can use `.chars().nth()` or `.bytes().nth()`
|
||||
for more information, see chapter 8 in The Book: <https://doc.rust-lang.org/book/ch08-02-strings.html#indexing-into-strings>
|
||||
= help: the trait `SliceIndex<[_]>` is implemented for `usize`
|
||||
= help: for that trait implementation, expected `[_]`, found `str`
|
||||
note: required by a bound in `core::str::<impl str>::get_unchecked_mut`
|
||||
--> $SRC_DIR/core/src/str/mod.rs:LL:COL
|
||||
|
||||
|
@ -8,6 +8,7 @@ LL | Trait::do_stuff({ fun(&mut *inner) });
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
= help: the trait `Trait<'_>` is implemented for `()`
|
||||
= help: for that trait implementation, expected `()`, found `*mut ()`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -6,6 +6,7 @@ LL | let one_item_please: i32 = [1, 2, 3][i];
|
||||
|
|
||||
= help: the trait `SliceIndex<[{integer}]>` is not implemented for `&usize`
|
||||
= help: the trait `SliceIndex<[{integer}]>` is implemented for `usize`
|
||||
= help: for that trait implementation, expected `usize`, found `&usize`
|
||||
= note: required for `[{integer}]` to implement `Index<&usize>`
|
||||
help: dereference this index
|
||||
|
|
||||
|
@ -5,6 +5,7 @@ LL | let s: Box<dyn Trait<isize>> = Box::new(Struct { person: "Fred" });
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait<isize>` is not implemented for `Struct`
|
||||
|
|
||||
= help: the trait `Trait<&'static str>` is implemented for `Struct`
|
||||
= help: for that trait implementation, expected `&'static str`, found `isize`
|
||||
= note: required for the cast from `Box<Struct>` to `Box<dyn Trait<isize>>`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
@ -6,6 +6,7 @@ LL | Err("")?;
|
||||
|
|
||||
= note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
|
||||
= help: the trait `From<Infallible>` is implemented for `TryFromSliceError`
|
||||
= help: for that trait implementation, expected `Infallible`, found `&str`
|
||||
= note: required for `Result<u32, TryFromSliceError>` to implement `FromResidual<Result<Infallible, &str>>`
|
||||
|
||||
error[E0271]: type mismatch resolving `<Result<i32, i32> as Try>::Output == &str`
|
||||
|
@ -74,6 +74,7 @@ LL | ControlFlow::Continue(Err("hello")?)
|
||||
|
|
||||
= help: the trait `FromResidual<Result<Infallible, &str>>` is not implemented for `ControlFlow<String>`
|
||||
= help: the trait `FromResidual<ControlFlow<String, Infallible>>` is implemented for `ControlFlow<String>`
|
||||
= help: for that trait implementation, expected `ControlFlow<String, Infallible>`, found `Result<Infallible, &str>`
|
||||
|
||||
error[E0277]: the `?` operator can only be used on `ControlFlow`s in a function that returns `ControlFlow`
|
||||
--> $DIR/bad-interconversion.rs:37:12
|
||||
@ -85,6 +86,7 @@ LL | Some(3)?;
|
||||
|
|
||||
= help: the trait `FromResidual<Option<Infallible>>` is not implemented for `ControlFlow<u64>`
|
||||
= help: the trait `FromResidual<ControlFlow<u64, Infallible>>` is implemented for `ControlFlow<u64>`
|
||||
= help: for that trait implementation, expected `ControlFlow<u64, Infallible>`, found `Option<Infallible>`
|
||||
|
||||
error[E0277]: the `?` operator in a function that returns `ControlFlow<B, _>` can only be used on other `ControlFlow<B, _>`s (with the same Break type)
|
||||
--> $DIR/bad-interconversion.rs:43:29
|
||||
@ -97,6 +99,7 @@ LL | ControlFlow::Break(4_u8)?;
|
||||
= help: the trait `FromResidual<ControlFlow<u8, Infallible>>` is not implemented for `ControlFlow<i64>`
|
||||
= note: unlike `Result`, there's no `From`-conversion performed for `ControlFlow`
|
||||
= help: the trait `FromResidual<ControlFlow<i64, Infallible>>` is implemented for `ControlFlow<i64>`
|
||||
= help: for that trait implementation, expected `i64`, found `u8`
|
||||
|
||||
error: aborting due to 8 previous errors
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user