More accurately point at arguments

This commit is contained in:
Esteban Küber 2023-08-26 19:25:46 +00:00
parent bac0e556f0
commit b6494a7bb4
24 changed files with 124 additions and 136 deletions

View File

@ -43,6 +43,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
_ => return false,
};
let direct_param = if let ty::ClauseKind::Trait(pred) = unsubstituted_pred.kind().skip_binder()
&& let ty = pred.trait_ref.self_ty()
&& let ty::Param(_param) = ty.kind()
&& let Some(arg) = predicate_args.get(0)
&& let ty::GenericArgKind::Type(arg_ty) = arg.unpack()
&& arg_ty == ty
{
Some(*arg)
} else {
None
};
let find_param_matching = |matches: &dyn Fn(ty::ParamTerm) -> bool| {
predicate_args.iter().find_map(|arg| {
arg.walk().find_map(|arg| {
@ -63,32 +74,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
})
};
// Account for enum variant constructors, where the type param corresponds to the enum
// itself.
let enum_def_id =
if let DefKind::Ctor(hir::def::CtorOf::Variant, _) = self.tcx.def_kind(def_id) {
// `def_id` corresponds to a constructor, and its parent is the variant, and we want
// the enum.
Some(self.tcx.parent(self.tcx.parent(def_id)))
} else {
None
};
let variant_param_to_point_at = find_param_matching(&|param_term| {
// FIXME: It would be nice to make this not use string manipulation,
// but it's pretty hard to do this, since `ty::ParamTy` is missing
// sufficient info to determine if it is synthetic, and we don't
// always have a convenient way of getting `ty::Generics` at the call
// sites we invoke `IsSuggestable::is_suggestable`.
let include = match param_term {
ty::ParamTerm::Ty(param_ty) => !param_ty.name.as_str().starts_with("impl "),
_ => true,
};
// Account for enum variant constructors, where the type param corresponds to the enum
// itself.
let def_id = if let Some(def_id) = enum_def_id { def_id } else { def_id };
self.tcx.parent(generics.param_at(param_term.index(), self.tcx).def_id) == def_id
&& include
});
// Prefer generics that are local to the fn item, since these are likely
// to be the cause of the unsatisfied predicate.
let mut param_to_point_at = find_param_matching(&|param_term| {
@ -134,20 +119,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
};
if let Some(qpath) = qpath {
let def_id = if let Some(def_id) = enum_def_id { def_id } else { def_id };
if let hir::QPath::Resolved(None, path) = qpath {
for segment in path.segments {
if let Some(param) = variant_param_to_point_at
&& self.point_at_generic_if_possible(error, def_id, param, segment)
{
return true;
}
}
}
if let hir::QPath::TypeRelative(_ty, segment) = qpath {
if let Some(param) = variant_param_to_point_at
&& self.point_at_generic_if_possible(error, def_id, param, segment)
{
if let Some(param) = direct_param {
if self.point_at_path_if_possible(error, def_id, param, &qpath) {
return true;
}
}
@ -195,6 +168,18 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
match expr.map(|e| e.kind) {
Some(hir::ExprKind::MethodCall(segment, receiver, args, ..)) => {
if let Some(param) = direct_param
&& self.point_at_generic_if_possible(error, def_id, param, segment)
{
error.obligation.cause.map_code(|parent_code| {
ObligationCauseCode::FunctionArgumentObligation {
arg_hir_id: receiver.hir_id,
call_hir_id: hir_id,
parent_code,
}
});
return true;
}
for param in [param_to_point_at, fallback_param_to_point_at, self_param_to_point_at]
.into_iter()
.flatten()
@ -251,9 +236,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}
for param in [param_to_point_at, fallback_param_to_point_at, self_param_to_point_at]
.into_iter()
.flatten()
for param in [
direct_param,
param_to_point_at,
fallback_param_to_point_at,
self_param_to_point_at,
]
.into_iter()
.flatten()
{
if self.point_at_path_if_possible(error, def_id, param, qpath) {
return true;
@ -485,7 +475,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
/**
* Recursively searches for the most-specific blamable expression.
* Recursively searches for the most-specific blameable expression.
* For example, if you have a chain of constraints like:
* - want `Vec<i32>: Copy`
* - because `Option<Vec<i32>>: Copy` needs `Vec<i32>: Copy` because `impl <T: Copy> Copy for Option<T>`

View File

@ -14,12 +14,10 @@ LL | fn foo(i: impl std::fmt::Display) {}
= note: `impl Trait` cannot be explicitly specified as a generic argument
error[E0277]: `()` doesn't implement `std::fmt::Display`
--> $DIR/issue-100154.rs:4:15
--> $DIR/issue-100154.rs:4:11
|
LL | foo::<()>(());
| --------- ^^ `()` cannot be formatted with the default formatter
| |
| required by a bound introduced by this call
| ^^ `()` cannot be formatted with the default formatter
|
= help: the trait `std::fmt::Display` is not implemented for `()`
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead

View File

@ -1,8 +1,8 @@
error[E0277]: the trait bound `T: Foo<usize>` is not satisfied
--> $DIR/associated-types-invalid-trait-ref-issue-18865.rs:10:22
--> $DIR/associated-types-invalid-trait-ref-issue-18865.rs:10:13
|
LL | let u: <T as Foo<usize>>::Bar = t.get_bar();
| ^^^^^ the trait `Foo<usize>` is not implemented for `T`
| ^ the trait `Foo<usize>` is not implemented for `T`
|
help: consider further restricting this bound
|

View File

@ -1,11 +1,13 @@
error[E0271]: type mismatch resolving `<Adapter<I> as Iterator>::Item == Option<T>`
--> $DIR/associated-types-issue-20346.rs:34:33
--> $DIR/associated-types-issue-20346.rs:34:36
|
LL | fn test_adapter<T, I: Iterator<Item=Option<T>>>(it: I) {
| - this type parameter
...
LL | is_iterator_of::<Option<T>, _>(&adapter);
| ^ type mismatch resolving `<Adapter<I> as Iterator>::Item == Option<T>`
| ------------------------------ ^^^^^^^^ type mismatch resolving `<Adapter<I> as Iterator>::Item == Option<T>`
| |
| required by a bound introduced by this call
|
note: expected this to be `Option<T>`
--> $DIR/associated-types-issue-20346.rs:23:17

View File

@ -1,8 +1,8 @@
error[E0277]: the trait bound `(): Foo<N>` is not satisfied
--> $DIR/exhaustive-value.rs:262:16
--> $DIR/exhaustive-value.rs:262:6
|
LL | <() as Foo<N>>::test()
| ^ the trait `Foo<N>` is not implemented for `()`
| ^^ the trait `Foo<N>` is not implemented for `()`
|
= help: the following other types implement trait `Foo<N>`:
<() as Foo<0>>

View File

@ -2,7 +2,7 @@ error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:7:5
|
LL | String::from("x".as_ref());
| ^^^^^^^^^^^^ cannot infer type for reference `&_`
| ^^^^^^ cannot infer type for reference `&_`
|
= note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate:
- impl<> From<&String> for String;
@ -71,7 +71,7 @@ error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:21:5
|
LL | String::from("x".as_ref());
| ^^^^^^^^^^^^ cannot infer type for reference `&_`
| ^^^^^^ cannot infer type for reference `&_`
|
= note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate:
- impl<> From<&String> for String;
@ -97,7 +97,7 @@ error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:28:5
|
LL | String::from("x".as_ref());
| ^^^^^^^^^^^^ cannot infer type for reference `&_`
| ^^^^^^ cannot infer type for reference `&_`
|
= note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate:
- impl<> From<&String> for String;
@ -123,7 +123,7 @@ error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:37:5
|
LL | String::from("x".as_ref());
| ^^^^^^^^^^^^ cannot infer type for reference `&_`
| ^^^^^^ cannot infer type for reference `&_`
|
= note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate:
- impl<> From<&String> for String;
@ -149,7 +149,7 @@ error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:46:5
|
LL | String::from("x".as_ref());
| ^^^^^^^^^^^^ cannot infer type for reference `&_`
| ^^^^^^ cannot infer type for reference `&_`
|
= note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate:
- impl<> From<&String> for String;
@ -175,7 +175,7 @@ error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:53:5
|
LL | String::from("x".as_ref());
| ^^^^^^^^^^^^ cannot infer type for reference `&_`
| ^^^^^^ cannot infer type for reference `&_`
|
= note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate:
- impl<> From<&String> for String;
@ -201,7 +201,7 @@ error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:62:5
|
LL | String::from("x".as_ref());
| ^^^^^^^^^^^^ cannot infer type for reference `&_`
| ^^^^^^ cannot infer type for reference `&_`
|
= note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate:
- impl<> From<&String> for String;

View File

@ -1,8 +1,8 @@
error[E0283]: type annotations needed
--> $DIR/issue-29147.rs:22:13
--> $DIR/issue-29147.rs:22:14
|
LL | let _ = <S5<_>>::xxx;
| ^^^^^^^^^^^^ cannot infer type for struct `S5<_>`
| ^^^^^ cannot infer type for struct `S5<_>`
|
note: multiple `impl`s satisfying `S5<_>: Foo` found
--> $DIR/issue-29147.rs:18:1

View File

@ -17,10 +17,12 @@ note: required by a bound in `collect`
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
error[E0277]: a value of type `Vec<f64>` cannot be built from an iterator over elements of type `&f64`
--> $DIR/issue-66923-show-error-for-correct-call.rs:12:29
--> $DIR/issue-66923-show-error-for-correct-call.rs:12:39
|
LL | let x3 = x1.into_iter().collect::<Vec<f64>>();
| ^^^^^^^ value of type `Vec<f64>` cannot be built from `std::iter::Iterator<Item=&f64>`
| ------- ^^^^^^^^ value of type `Vec<f64>` cannot be built from `std::iter::Iterator<Item=&f64>`
| |
| required by a bound introduced by this call
|
= help: the trait `FromIterator<&f64>` is not implemented for `Vec<f64>`
= help: the trait `FromIterator<T>` is implemented for `Vec<T>`

View File

@ -1,8 +1,10 @@
error[E0277]: a value of type `f32` cannot be made by summing an iterator over elements of type `{integer}`
--> $DIR/invalid-iterator-chain-with-int-infer.rs:2:41
--> $DIR/invalid-iterator-chain-with-int-infer.rs:2:47
|
LL | let x = Some(()).iter().map(|()| 1).sum::<f32>();
| ^^^ value of type `f32` cannot be made by summing a `std::iter::Iterator<Item={integer}>`
| --- ^^^ value of type `f32` cannot be made by summing a `std::iter::Iterator<Item={integer}>`
| |
| required by a bound introduced by this call
|
= help: the trait `Sum<{integer}>` is not implemented for `f32`
= help: the following other types implement trait `Sum<A>`:

View File

@ -17,10 +17,12 @@ note: required by a bound in `collect`
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `()`
--> $DIR/invalid-iterator-chain.rs:15:27
--> $DIR/invalid-iterator-chain.rs:15:33
|
LL | println!("{}", scores.sum::<i32>());
| ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=()>`
| --- ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=()>`
| |
| required by a bound introduced by this call
|
= help: the trait `Sum<()>` is not implemented for `i32`
= help: the following other types implement trait `Sum<A>`:
@ -42,10 +44,12 @@ note: required by a bound in `std::iter::Iterator::sum`
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `()`
--> $DIR/invalid-iterator-chain.rs:26:14
--> $DIR/invalid-iterator-chain.rs:26:20
|
LL | .sum::<i32>(),
| ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=()>`
| --- ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=()>`
| |
| required by a bound introduced by this call
|
= help: the trait `Sum<()>` is not implemented for `i32`
= help: the following other types implement trait `Sum<A>`:
@ -74,10 +78,12 @@ note: required by a bound in `std::iter::Iterator::sum`
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `f64`
--> $DIR/invalid-iterator-chain.rs:36:14
--> $DIR/invalid-iterator-chain.rs:36:20
|
LL | .sum::<i32>(),
| ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=f64>`
| --- ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=f64>`
| |
| required by a bound introduced by this call
|
= help: the trait `Sum<f64>` is not implemented for `i32`
= help: the following other types implement trait `Sum<A>`:
@ -102,10 +108,12 @@ note: required by a bound in `std::iter::Iterator::sum`
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `()`
--> $DIR/invalid-iterator-chain.rs:38:54
--> $DIR/invalid-iterator-chain.rs:38:60
|
LL | println!("{}", vec![0, 1].iter().map(|x| { x; }).sum::<i32>());
| ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=()>`
| --- ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=()>`
| |
| required by a bound introduced by this call
|
= help: the trait `Sum<()>` is not implemented for `i32`
= help: the following other types implement trait `Sum<A>`:
@ -123,10 +131,12 @@ note: required by a bound in `std::iter::Iterator::sum`
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `&()`
--> $DIR/invalid-iterator-chain.rs:39:40
--> $DIR/invalid-iterator-chain.rs:39:46
|
LL | println!("{}", vec![(), ()].iter().sum::<i32>());
| ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=&()>`
| --- ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=&()>`
| |
| required by a bound introduced by this call
|
= help: the trait `Sum<&()>` is not implemented for `i32`
= help: the following other types implement trait `Sum<A>`:

View File

@ -1,8 +1,8 @@
error[E0277]: the size for values of type `dyn ToString` cannot be known at compilation time
--> $DIR/issue-61525.rs:14:33
--> $DIR/issue-61525.rs:14:19
|
LL | 1.query::<dyn ToString>("")
| ----- ^^ doesn't have a size known at compile-time
| ----- ^^^^^^^^^^^^ doesn't have a size known at compile-time
| |
| required by a bound introduced by this call
|

View File

@ -1,10 +1,8 @@
error[E0277]: the trait bound `E: From<()>` is not satisfied
--> $DIR/never-value-fallback-issue-66757.rs:28:26
--> $DIR/never-value-fallback-issue-66757.rs:28:6
|
LL | <E as From<_>>::from(never);
| -------------------- ^^^^^ the trait `From<()>` is not implemented for `E`
| |
| required by a bound introduced by this call
| ^ the trait `From<()>` is not implemented for `E`
|
= help: the trait `From<!>` is implemented for `E`

View File

@ -1,8 +1,10 @@
error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `&()`
--> $DIR/sum.rs:4:25
--> $DIR/sum.rs:4:31
|
LL | vec![(), ()].iter().sum::<i32>();
| ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=&()>`
| --- ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=&()>`
| |
| required by a bound introduced by this call
|
= help: the trait `Sum<&()>` is not implemented for `i32`
= help: the following other types implement trait `Sum<A>`:
@ -19,10 +21,12 @@ note: required by a bound in `std::iter::Iterator::sum`
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
error[E0277]: a value of type `i32` cannot be made by multiplying all elements of type `&()` from an iterator
--> $DIR/sum.rs:7:25
--> $DIR/sum.rs:7:35
|
LL | vec![(), ()].iter().product::<i32>();
| ^^^^^^^ value of type `i32` cannot be made by multiplying all elements from a `std::iter::Iterator<Item=&()>`
| ------- ^^^ value of type `i32` cannot be made by multiplying all elements from a `std::iter::Iterator<Item=&()>`
| |
| required by a bound introduced by this call
|
= help: the trait `Product<&()>` is not implemented for `i32`
= help: the following other types implement trait `Product<A>`:

View File

@ -1,10 +1,8 @@
error[E0277]: the trait bound `T: GlUniformScalar` is not satisfied
--> $DIR/assoc-const-as-fn.rs:14:40
--> $DIR/assoc-const-as-fn.rs:14:6
|
LL | <T as GlUniformScalar>::FACTORY(1, value);
| ------------------------------- ^^^^^ the trait `GlUniformScalar` is not implemented for `T`
| |
| required by a bound introduced by this call
| ^ the trait `GlUniformScalar` is not implemented for `T`
|
help: consider further restricting this bound
|

View File

@ -1,8 +1,10 @@
error[E0277]: the trait bound `for<'b> &'b S: Trait` is not satisfied
--> $DIR/imm-ref-trait-object-literal-bound-regions.rs:17:11
--> $DIR/imm-ref-trait-object-literal-bound-regions.rs:17:14
|
LL | foo::<S>(s);
| ^ the trait `for<'b> Trait` is not implemented for `&'b S`
| -------- ^ the trait `for<'b> Trait` is not implemented for `&'b S`
| |
| required by a bound introduced by this call
|
= help: the trait `Trait` is implemented for `&'a mut S`
= note: `for<'b> Trait` is implemented for `&'b mut S`, but not for `&'b S`

View File

@ -2,7 +2,9 @@ error[E0277]: `T` cannot be sent between threads safely
--> $DIR/bad-method-typaram-kind.rs:2:13
|
LL | 1.bar::<T>();
| ^ `T` cannot be sent between threads safely
| --- ^ `T` cannot be sent between threads safely
| |
| required by a bound introduced by this call
|
= note: consider using `std::sync::Arc<T>`; for more information visit <https://doc.rust-lang.org/book/ch16-03-shared-state.html>
note: required by a bound in `Bar::bar`

View File

@ -5,12 +5,10 @@ LL | <i32 as RefFoo<i32>>::ref_foo(unknown);
| ^^^^^^^ not found in this scope
error[E0277]: the trait bound `for<'a> &'a mut Vec<&'a u32>: Foo<'static, i32>` is not satisfied
--> $DIR/dont-autoderef-ty-with-escaping-var.rs:17:35
--> $DIR/dont-autoderef-ty-with-escaping-var.rs:17:6
|
LL | <i32 as RefFoo<i32>>::ref_foo(unknown);
| ----------------------------- ^^^^^^^ the trait `for<'a> Foo<'static, i32>` is not implemented for `&'a mut Vec<&'a u32>`
| |
| required by a bound introduced by this call
| ^^^ the trait `for<'a> Foo<'static, i32>` is not implemented for `&'a mut Vec<&'a u32>`
|
note: required for `i32` to implement `RefFoo<i32>`
--> $DIR/dont-autoderef-ty-with-escaping-var.rs:9:9

View File

@ -24,12 +24,10 @@ LL | fn with_trait<C:CompareToInts + CompareTo<i32>>(c: &C) -> bool {
| ++++++++++++++++
error[E0277]: the trait bound `dyn CompareToInts: CompareTo<i32>` is not satisfied
--> $DIR/repeated-supertrait-ambig.rs:34:37
--> $DIR/repeated-supertrait-ambig.rs:34:6
|
LL | <dyn CompareToInts>::same_as(c, 22)
| ---------------------------- ^^ the trait `CompareTo<i32>` is not implemented for `dyn CompareToInts`
| |
| required by a bound introduced by this call
| ^^^^^^^^^^^^^^^^^ the trait `CompareTo<i32>` is not implemented for `dyn CompareToInts`
|
= help: the following other types implement trait `CompareTo<T>`:
<i64 as CompareTo<i64>>

View File

@ -35,23 +35,12 @@ help: consider specifying the generic argument
LL | opts.get::<Q>(opt.as_ref());
| +++++
error[E0283]: type annotations needed
error[E0282]: type annotations needed
--> $DIR/issue-77982.rs:13:59
|
LL | let ips: Vec<_> = (0..100_000).map(|_| u32::from(0u32.into())).collect();
| --------- ^^^^
| |
| required by a bound introduced by this call
| ^^^^
|
= note: multiple `impl`s satisfying `u32: From<_>` found in the `core` crate:
- impl From<Ipv4Addr> for u32;
- impl From<NonZeroU32> for u32;
- impl From<bool> for u32;
- impl From<char> for u32;
- impl From<u16> for u32;
- impl From<u8> for u32;
- impl<T> From<!> for T;
- impl<T> From<T> for T;
help: try using a fully qualified path to specify the expected types
|
LL | let ips: Vec<_> = (0..100_000).map(|_| u32::from(<u32 as Into<T>>::into(0u32))).collect();
@ -95,4 +84,5 @@ LL | let _: Box<T> = (&()).bar();
error: aborting due to 5 previous errors
For more information about this error, try `rustc --explain E0283`.
Some errors have detailed explanations: E0282, E0283.
For more information about an error, try `rustc --explain E0282`.

View File

@ -15,10 +15,10 @@ LL | default type Id = T;
| ^ cannot infer type for associated type `<T as Default>::Id`
error[E0284]: type annotations needed: cannot satisfy `<u32 as Default>::Id == ()`
--> $DIR/specialization-unconstrained.rs:20:12
--> $DIR/specialization-unconstrained.rs:20:5
|
LL | test::<u32, ()>();
| ^^^ cannot satisfy `<u32 as Default>::Id == ()`
| ^^^^^^^^^^^^^^^ cannot satisfy `<u32 as Default>::Id == ()`
|
note: required by a bound in `test`
--> $DIR/specialization-unconstrained.rs:17:20

View File

@ -1,10 +1,8 @@
error[E0277]: the trait bound `(): MyTrait` is not satisfied
--> $DIR/no-use.rs:11:26
--> $DIR/no-use.rs:11:6
|
LL | <() as MyTrait>::foo(&());
| -------------------- ^^^ the trait `MyTrait` is not implemented for `()`
| |
| required by a bound introduced by this call
| ^^ the trait `MyTrait` is not implemented for `()`
|
= help: the trait `MyTrait` is implemented for `()`

View File

@ -1,10 +1,8 @@
error[E0277]: the trait bound `(): MyTrait` is not satisfied
--> $DIR/no-use.rs:11:26
--> $DIR/no-use.rs:11:6
|
LL | <() as MyTrait>::foo(&());
| -------------------- ^^^ the trait `MyTrait` is not implemented for `()`
| |
| required by a bound introduced by this call
| ^^ the trait `MyTrait` is not implemented for `()`
|
= help: the trait `MyTrait` is implemented for `()`

View File

@ -38,10 +38,10 @@ LL + fn check<T: Iterator, U>() {
|
error[E0277]: the trait bound `u64: From<T>` is not satisfied
--> $DIR/suggest-where-clause.rs:15:18
--> $DIR/suggest-where-clause.rs:15:6
|
LL | <u64 as From<T>>::from;
| ^ the trait `From<T>` is not implemented for `u64`
| ^^^ the trait `From<T>` is not implemented for `u64`
|
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
|
@ -49,10 +49,10 @@ LL | fn check<T: Iterator, U: ?Sized>() where u64: From<T> {
| ++++++++++++++++++
error[E0277]: the trait bound `u64: From<<T as Iterator>::Item>` is not satisfied
--> $DIR/suggest-where-clause.rs:18:18
--> $DIR/suggest-where-clause.rs:18:6
|
LL | <u64 as From<<T as Iterator>::Item>>::from;
| ^^^^^^^^^^^^^^^^^^^^^ the trait `From<<T as Iterator>::Item>` is not implemented for `u64`
| ^^^ the trait `From<<T as Iterator>::Item>` is not implemented for `u64`
|
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
|
@ -60,10 +60,10 @@ LL | fn check<T: Iterator, U: ?Sized>() where u64: From<<T as Iterator>::Item> {
| ++++++++++++++++++++++++++++++++++++++
error[E0277]: the trait bound `Misc<_>: From<T>` is not satisfied
--> $DIR/suggest-where-clause.rs:23:22
--> $DIR/suggest-where-clause.rs:23:6
|
LL | <Misc<_> as From<T>>::from;
| ^ the trait `From<T>` is not implemented for `Misc<_>`
| ^^^^^^^ the trait `From<T>` is not implemented for `Misc<_>`
error[E0277]: the size for values of type `[T]` cannot be known at compilation time
--> $DIR/suggest-where-clause.rs:28:20

View File

@ -1,10 +1,8 @@
error[E0277]: cannot add `u32` to `i32`
--> $DIR/ufcs-qpath-self-mismatch.rs:4:31
--> $DIR/ufcs-qpath-self-mismatch.rs:4:6
|
LL | <i32 as Add<u32>>::add(1, 2);
| ---------------------- ^ no implementation for `i32 + u32`
| |
| required by a bound introduced by this call
| ^^^ no implementation for `i32 + u32`
|
= help: the trait `Add<u32>` is not implemented for `i32`
= help: the following other types implement trait `Add<Rhs>`: