Use more accurate failed predicate spans

This commit is contained in:
Esteban Küber 2020-01-29 16:55:37 -08:00
parent 8d48597b76
commit 6870f79e9c
40 changed files with 187 additions and 212 deletions

View File

@ -1015,6 +1015,7 @@ impl<'tcx> GenericPredicates<'tcx> {
) -> InstantiatedPredicates<'tcx> {
InstantiatedPredicates {
predicates: self.predicates.iter().map(|(p, _)| p.subst(tcx, substs)).collect(),
spans: self.predicates.iter().map(|(_, sp)| *sp).collect(),
}
}
@ -1028,6 +1029,7 @@ impl<'tcx> GenericPredicates<'tcx> {
tcx.predicates_of(def_id).instantiate_into(tcx, instantiated, substs);
}
instantiated.predicates.extend(self.predicates.iter().map(|(p, _)| p.subst(tcx, substs)));
instantiated.spans.extend(self.predicates.iter().map(|(_, sp)| *sp));
}
pub fn instantiate_identity(&self, tcx: TyCtxt<'tcx>) -> InstantiatedPredicates<'tcx> {
@ -1044,7 +1046,8 @@ impl<'tcx> GenericPredicates<'tcx> {
if let Some(def_id) = self.parent {
tcx.predicates_of(def_id).instantiate_identity_into(tcx, instantiated);
}
instantiated.predicates.extend(self.predicates.iter().map(|&(p, _)| p))
instantiated.predicates.extend(self.predicates.iter().map(|(p, _)| p));
instantiated.spans.extend(self.predicates.iter().map(|(_, s)| s));
}
pub fn instantiate_supertrait(
@ -1059,6 +1062,7 @@ impl<'tcx> GenericPredicates<'tcx> {
.iter()
.map(|(pred, _)| pred.subst_supertrait(tcx, poly_trait_ref))
.collect(),
spans: self.predicates.iter().map(|(_, sp)| *sp).collect(),
}
}
}
@ -1511,11 +1515,12 @@ impl<'tcx> Predicate<'tcx> {
#[derive(Clone, Debug, TypeFoldable)]
pub struct InstantiatedPredicates<'tcx> {
pub predicates: Vec<Predicate<'tcx>>,
pub spans: Vec<Span>,
}
impl<'tcx> InstantiatedPredicates<'tcx> {
pub fn empty() -> InstantiatedPredicates<'tcx> {
InstantiatedPredicates { predicates: vec![] }
InstantiatedPredicates { predicates: vec![], spans: vec![] }
}
pub fn is_empty(&self) -> bool {

View File

@ -161,7 +161,7 @@ crate fn environment(tcx: TyCtxt<'_>, def_id: DefId) -> Environment<'_> {
}
// Compute the bounds on `Self` and the type parameters.
let ty::InstantiatedPredicates { predicates } =
let ty::InstantiatedPredicates { predicates, .. } =
tcx.predicates_of(def_id).instantiate_identity(tcx);
let clauses = predicates

View File

@ -228,7 +228,7 @@ fn param_env(tcx: TyCtxt<'_>, def_id: DefId) -> ty::ParamEnv<'_> {
}
// Compute the bounds on Self and the type parameters.
let ty::InstantiatedPredicates { predicates } =
let ty::InstantiatedPredicates { predicates, .. } =
tcx.predicates_of(def_id).instantiate_identity(tcx);
// Finally, we have to normalize the bounds in the environment, in

View File

@ -665,16 +665,21 @@ fn check_where_clauses<'tcx, 'fcx>(
let mut predicates = predicates.instantiate_identity(fcx.tcx);
if let Some((return_ty, span)) = return_ty {
predicates.predicates.extend(check_opaque_types(tcx, fcx, def_id, span, return_ty));
let opaque_types = check_opaque_types(tcx, fcx, def_id, span, return_ty);
for _ in 0..opaque_types.len() {
predicates.spans.push(span);
}
predicates.predicates.extend(opaque_types);
}
let predicates = fcx.normalize_associated_types_in(span, &predicates);
debug!("check_where_clauses: predicates={:?}", predicates.predicates);
let wf_obligations = predicates
.predicates
.iter()
.flat_map(|p| traits::wf::predicate_obligations(fcx, fcx.param_env, fcx.body_id, p, span));
assert_eq!(predicates.predicates.len(), predicates.spans.len());
let wf_obligations =
predicates.predicates.iter().zip(predicates.spans.iter()).flat_map(|(p, sp)| {
traits::wf::predicate_obligations(fcx, fcx.param_env, fcx.body_id, p, *sp)
});
for obligation in wf_obligations.chain(default_obligations) {
debug!("next obligation cause: {:?}", obligation.cause);

View File

@ -10,7 +10,7 @@ error[E0277]: `<<T as Case1>::C as std::iter::Iterator>::Item` is not an iterato
--> $DIR/bad-bounds-on-assoc-in-trait.rs:36:1
|
LL | fn assume_case1<T: Case1>() {
| ^^^^^^^^^^^^ - help: consider further restricting the associated type: `where <<T as Case1>::C as std::iter::Iterator>::Item: std::iter::Iterator`
| ^^^^^ - help: consider further restricting the associated type: `where <<T as Case1>::C as std::iter::Iterator>::Item: std::iter::Iterator`
| |
| `<<T as Case1>::C as std::iter::Iterator>::Item` is not an iterator
|
@ -23,7 +23,7 @@ LL | trait Case1 {
| ----------- required by `Case1`
...
LL | fn assume_case1<T: Case1>() {
| ^^^^^^^^^^^^ - help: consider further restricting the associated type: `where <<T as Case1>::C as std::iter::Iterator>::Item: std::marker::Send`
| ^^^^^ - help: consider further restricting the associated type: `where <<T as Case1>::C as std::iter::Iterator>::Item: std::marker::Send`
| |
| `<<T as Case1>::C as std::iter::Iterator>::Item` cannot be sent between threads safely
|
@ -36,7 +36,7 @@ LL | trait Case1 {
| ----------- required by `Case1`
...
LL | fn assume_case1<T: Case1>() {
| ^^^^^^^^^^^^ - help: consider further restricting the associated type: `where <<T as Case1>::C as std::iter::Iterator>::Item: std::marker::Sync`
| ^^^^^ - help: consider further restricting the associated type: `where <<T as Case1>::C as std::iter::Iterator>::Item: std::marker::Sync`
| |
| `<<T as Case1>::C as std::iter::Iterator>::Item` cannot be shared between threads safely
|
@ -49,7 +49,7 @@ LL | trait Case1 {
| ----------- required by `Case1`
...
LL | fn assume_case1<T: Case1>() {
| ^^^^^^^^^^^^ `<_ as Lam<&'a u8>>::App` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug`
| ^^^^^ `<_ as Lam<&'a u8>>::App` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug`
|
= help: the trait `for<'a> std::fmt::Debug` is not implemented for `<_ as Lam<&'a u8>>::App`

View File

@ -1,20 +1,20 @@
error[E0284]: type annotations needed
--> $DIR/associated-types-overridden-binding.rs:4:1
--> $DIR/associated-types-overridden-binding.rs:4:12
|
LL | trait Foo: Iterator<Item = i32> {}
| ------------------------------- required by `Foo`
LL | trait Bar: Foo<Item = u32> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `Self`
| ^^^^^^^^^^^^^^^ cannot infer type for type parameter `Self`
|
= note: cannot resolve `<Self as std::iter::Iterator>::Item == i32`
error[E0284]: type annotations needed
--> $DIR/associated-types-overridden-binding.rs:7:1
--> $DIR/associated-types-overridden-binding.rs:7:21
|
LL | trait I32Iterator = Iterator<Item = i32>;
| ----------------------------------------- required by `I32Iterator`
LL | trait U32Iterator = I32Iterator<Item = u32>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `Self`
| ^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `Self`
|
= note: cannot resolve `<Self as std::iter::Iterator>::Item == i32`

View File

@ -1,11 +1,11 @@
error[E0275]: overflow evaluating the requirement `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>: Foo`
--> $DIR/E0275.rs:5:1
--> $DIR/E0275.rs:5:33
|
LL | trait Foo {}
| --------- required by `Foo`
...
LL | impl<T> Foo for T where Bar<T>: Foo {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^
|
= help: consider adding a `#![recursion_limit="256"]` attribute to your crate
= note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`

View File

@ -4,8 +4,8 @@
// FIXME(generic-associated-types) Investigate why this doesn't compile.
trait Iterator {
//~^ ERROR the requirement `for<'a> <Self as Iterator>::Item<'a>: 'a` is not satisfied
type Item<'a>: 'a;
//~^ ERROR the requirement `for<'a> <Self as Iterator>::Item<'a>: 'a` is not satisfied
}
fn main() {}

View File

@ -1,15 +1,10 @@
error[E0280]: the requirement `for<'a> <Self as Iterator>::Item<'a>: 'a` is not satisfied
--> $DIR/issue-62326-parameter-out-of-range.rs:6:1
--> $DIR/issue-62326-parameter-out-of-range.rs:7:20
|
LL | trait Iterator {
| ^-------------
| |
| _required by `Iterator`
| |
LL | |
LL | | type Item<'a>: 'a;
LL | | }
| |_^
| -------------- required by `Iterator`
LL | type Item<'a>: 'a;
| ^^
error: aborting due to previous error

View File

@ -5,9 +5,9 @@ trait From<Src> {
}
trait To {
fn to<Dst>( //~ ERROR the size for values of type
fn to<Dst>(
self
) -> <Dst as From<Self>>::Result where Dst: From<Self> {
) -> <Dst as From<Self>>::Result where Dst: From<Self> { //~ ERROR the size for values of type
From::from(self)
}
}

View File

@ -1,14 +1,13 @@
error[E0277]: the size for values of type `Self` cannot be known at compilation time
--> $DIR/issue-20005.rs:8:8
--> $DIR/issue-20005.rs:10:49
|
LL | trait From<Src> {
| --------------- required by `From`
...
LL | fn to<Dst>(
| ^^ doesn't have a size known at compile-time
LL | self
LL | ) -> <Dst as From<Self>>::Result where Dst: From<Self> {
| - help: consider further restricting `Self`: `, Self: std::marker::Sized`
| ^^^^^^^^^^- help: consider further restricting `Self`: `, Self: std::marker::Sized`
| |
| doesn't have a size known at compile-time
|
= help: the trait `std::marker::Sized` is not implemented for `Self`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>

View File

@ -7,8 +7,8 @@ struct NoData<T>;
impl<T> Foo for T where NoData<T>: Foo {
//~^ ERROR: overflow evaluating the requirement
//~| ERROR: overflow evaluating the requirement
fn answer(self) {
//~^ ERROR: overflow evaluating the requirement
let val: NoData<T> = NoData;
}
}

View File

@ -7,19 +7,13 @@ LL | struct NoData<T>;
= help: consider removing `T`, referring to it in a field, or using a marker such as `std::marker::PhantomData`
error[E0275]: overflow evaluating the requirement `NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>: Foo`
--> $DIR/issue-20413.rs:8:1
--> $DIR/issue-20413.rs:8:36
|
LL | trait Foo {
| --------- required by `Foo`
...
LL | / impl<T> Foo for T where NoData<T>: Foo {
LL | |
LL | | fn answer(self) {
LL | |
LL | | let val: NoData<T> = NoData;
LL | | }
LL | | }
| |_^
LL | impl<T> Foo for T where NoData<T>: Foo {
| ^^^
|
= help: consider adding a `#![recursion_limit="256"]` attribute to your crate
= note: required because of the requirements on the impl of `Foo` for `NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
@ -151,13 +145,13 @@ LL | | }
= note: required because of the requirements on the impl of `Foo` for `NoData<T>`
error[E0275]: overflow evaluating the requirement `NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>: Foo`
--> $DIR/issue-20413.rs:10:6
--> $DIR/issue-20413.rs:8:36
|
LL | trait Foo {
| --------- required by `Foo`
...
LL | fn answer(self) {
| ^^^^^^
LL | impl<T> Foo for T where NoData<T>: Foo {
| ^^^
|
= help: consider adding a `#![recursion_limit="256"]` attribute to your crate
= note: required because of the requirements on the impl of `Foo` for `NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`

View File

@ -7,8 +7,8 @@ trait Foo {
fn foo(self);
}
fn foo<'a,'b,T>(x: &'a T, y: &'b T) //~ ERROR type annotations needed
where &'a T : Foo,
fn foo<'a,'b,T>(x: &'a T, y: &'b T)
where &'a T : Foo, //~ ERROR type annotations needed
&'b T : Foo
{
x.foo();

View File

@ -1,10 +1,10 @@
error[E0283]: type annotations needed
--> $DIR/issue-21974.rs:10:4
--> $DIR/issue-21974.rs:11:19
|
LL | trait Foo {
| --------- required by `Foo`
...
LL | fn foo<'a,'b,T>(x: &'a T, y: &'b T)
LL | where &'a T : Foo,
| ^^^ cannot infer type for reference `&'a T`
|
= note: cannot resolve `&'a T: Foo`

View File

@ -1,11 +1,11 @@
error[E0271]: type mismatch resolving `<<T as Trait>::A as MultiDispatch<i32>>::O == T`
--> $DIR/issue-24204.rs:14:4
--> $DIR/issue-24204.rs:14:12
|
LL | trait Trait: Sized {
| ------------------ required by `Trait`
...
LL | fn test<T: Trait<B=i32>>(b: i32) -> T where T::A: MultiDispatch<i32> { T::new(b) }
| ^^^^ expected type parameter `T`, found associated type
| ^^^^^^^^^^^^ expected type parameter `T`, found associated type
|
= note: expected type parameter `T`
found associated type `<<T as Trait>::A as MultiDispatch<i32>>::O`

View File

@ -1,11 +1,11 @@
error[E0283]: type annotations needed
--> $DIR/issue-24424.rs:4:1
--> $DIR/issue-24424.rs:4:57
|
LL | trait Trait0<'l0> {}
| ----------------- required by `Trait0`
LL |
LL | impl <'l0, 'l1, T0> Trait1<'l0, T0> for bool where T0 : Trait0<'l0>, T0 : Trait0<'l1> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `T0`
| ^^^^^^^^^^^ cannot infer type for type parameter `T0`
|
= note: cannot resolve `T0: Trait0<'l0>`

View File

@ -13,66 +13,68 @@ LL | foo: &'static T
| ^^^^^^^^^^^^^^^
error[E0309]: the parameter type `K` may not live long enough
--> $DIR/lifetime-doesnt-live-long-enough.rs:24:8
--> $DIR/lifetime-doesnt-live-long-enough.rs:24:19
|
LL | trait X<K>: Sized {
| - help: consider adding an explicit lifetime bound `K: 'a`...
LL | fn foo<'a, L: X<&'a Nested<K>>>();
| ^^^
| ^^^^^^^^^^^^^^^^
|
note: ...so that the reference type `&'a Nested<K>` does not outlive the data it points at
--> $DIR/lifetime-doesnt-live-long-enough.rs:24:8
--> $DIR/lifetime-doesnt-live-long-enough.rs:24:19
|
LL | fn foo<'a, L: X<&'a Nested<K>>>();
| ^^^
| ^^^^^^^^^^^^^^^^
error[E0309]: the parameter type `Self` may not live long enough
--> $DIR/lifetime-doesnt-live-long-enough.rs:28:8
--> $DIR/lifetime-doesnt-live-long-enough.rs:28:19
|
LL | fn bar<'a, L: X<&'a Nested<Self>>>();
| ^^^
| ^^^^^^^^^^^^^^^^^^^
|
= help: consider adding an explicit lifetime bound `Self: 'a`...
note: ...so that the reference type `&'a Nested<Self>` does not outlive the data it points at
--> $DIR/lifetime-doesnt-live-long-enough.rs:28:8
--> $DIR/lifetime-doesnt-live-long-enough.rs:28:19
|
LL | fn bar<'a, L: X<&'a Nested<Self>>>();
| ^^^
| ^^^^^^^^^^^^^^^^^^^
error[E0309]: the parameter type `L` may not live long enough
--> $DIR/lifetime-doesnt-live-long-enough.rs:32:8
--> $DIR/lifetime-doesnt-live-long-enough.rs:32:22
|
LL | fn baz<'a, L, M: X<&'a Nested<L>>>() {
| ^^^ - help: consider adding an explicit lifetime bound `L: 'a`...
| - ^^^^^^^^^^^^^^^^
| |
| help: consider adding an explicit lifetime bound `L: 'a`...
|
note: ...so that the reference type `&'a Nested<L>` does not outlive the data it points at
--> $DIR/lifetime-doesnt-live-long-enough.rs:32:8
--> $DIR/lifetime-doesnt-live-long-enough.rs:32:22
|
LL | fn baz<'a, L, M: X<&'a Nested<L>>>() {
| ^^^
| ^^^^^^^^^^^^^^^^
error[E0309]: the parameter type `K` may not live long enough
--> $DIR/lifetime-doesnt-live-long-enough.rs:41:8
--> $DIR/lifetime-doesnt-live-long-enough.rs:41:33
|
LL | impl<K> Nested<K> {
| - help: consider adding an explicit lifetime bound `K: 'a`...
LL | fn generic_in_parent<'a, L: X<&'a Nested<K>>>() {
| ^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^
|
note: ...so that the reference type `&'a Nested<K>` does not outlive the data it points at
--> $DIR/lifetime-doesnt-live-long-enough.rs:41:8
--> $DIR/lifetime-doesnt-live-long-enough.rs:41:33
|
LL | fn generic_in_parent<'a, L: X<&'a Nested<K>>>() {
| ^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^
error[E0309]: the parameter type `M` may not live long enough
--> $DIR/lifetime-doesnt-live-long-enough.rs:44:8
--> $DIR/lifetime-doesnt-live-long-enough.rs:44:36
|
LL | fn generic_in_child<'a, 'b, L: X<&'a Nested<M>>, M: 'b>() {
| ^^^^^^^^^^^^^^^^ -- help: consider adding an explicit lifetime bound `M: 'a`...
|
note: ...so that the reference type `&'a Nested<M>` does not outlive the data it points at
--> $DIR/lifetime-doesnt-live-long-enough.rs:44:8
--> $DIR/lifetime-doesnt-live-long-enough.rs:44:36
|
LL | fn generic_in_child<'a, 'b, L: X<&'a Nested<M>>, M: 'b>() {
| ^^^^^^^^^^^^^^^^

View File

@ -1,8 +1,8 @@
error[E0491]: in type `&'a &'b usize`, reference has a longer lifetime than the data it references
--> $DIR/regions-free-region-ordering-callee-4.rs:5:4
--> $DIR/regions-free-region-ordering-callee-4.rs:5:68
|
LL | fn ordering4<'a, 'b, F>(a: &'a usize, b: &'b usize, x: F) where F: FnOnce(&'a &'b usize) {
| ^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^
|
note: the pointer is valid for the lifetime `'a` as defined on the function body at 5:14
--> $DIR/regions-free-region-ordering-callee-4.rs:5:14

View File

@ -1,20 +1,13 @@
error[E0277]: the trait bound `<T as Parent>::Assoc: Child<A>` is not satisfied
--> $DIR/missing-assoc-type-bound-restriction.rs:17:1
--> $DIR/missing-assoc-type-bound-restriction.rs:17:19
|
LL | trait Parent {
| ------------ required by `Parent`
...
LL | impl<A, T: Parent<Ty = A>> Parent for ParentWrapper<T> {
| ^ - help: consider further restricting the associated type: `where <T as Parent>::Assoc: Child<A>`
| _|
| ^^^^^^ - help: consider further restricting the associated type: `where <T as Parent>::Assoc: Child<A>`
| |
LL | |
LL | | type Ty = A;
LL | | type Assoc = ChildWrapper<T::Assoc>;
LL | |
LL | |
LL | | }
| |_^ the trait `Child<A>` is not implemented for `<T as Parent>::Assoc`
| the trait `Child<A>` is not implemented for `<T as Parent>::Assoc`
error[E0277]: the trait bound `<T as Parent>::Assoc: Child<A>` is not satisfied
--> $DIR/missing-assoc-type-bound-restriction.rs:20:5

View File

@ -1,13 +1,12 @@
error[E0277]: the trait bound `T: Foo` is not satisfied
--> $DIR/trait-alias-wf.rs:5:1
--> $DIR/trait-alias-wf.rs:5:14
|
LL | trait A<T: Foo> {}
| --------------- required by `A`
LL | trait B<T> = A<T>;
| ^^^^^^^^-^^^^^^^^^
| | |
| | help: consider restricting this bound: `T: Foo`
| the trait `Foo` is not implemented for `T`
| - ^^^^ the trait `Foo` is not implemented for `T`
| |
| help: consider restricting this bound: `T: Foo`
error: aborting due to previous error

View File

@ -47,15 +47,14 @@ LL | trait TraitBound<T:Copy=String> {}
| required by `TraitBound`
error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied
--> $DIR/type-check-defaults.rs:21:1
--> $DIR/type-check-defaults.rs:21:25
|
LL | trait Super<T: Copy> { }
| -------------------- required by `Super`
LL | trait Base<T = String>: Super<T> { }
| ^^^^^^^^^^^-^^^^^^^^^^^^^^^^^^^^^^^^
| | |
| | help: consider restricting this bound: `T: std::marker::Copy`
| the trait `std::marker::Copy` is not implemented for `T`
| - ^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T`
| |
| help: consider restricting this bound: `T: std::marker::Copy`
error[E0277]: cannot add `u8` to `i32`
--> $DIR/type-check-defaults.rs:24:66

View File

@ -2,8 +2,8 @@ trait Foo: Sized {
fn foo(self);
}
fn foo<'a,'b,T>(x: &'a T, y: &'b T) //~ ERROR type annotations needed
where &'a T : Foo,
fn foo<'a,'b,T>(x: &'a T, y: &'b T)
where &'a T : Foo, //~ ERROR type annotations needed
&'b T : Foo
{
x.foo();

View File

@ -1,10 +1,10 @@
error[E0283]: type annotations needed
--> $DIR/issue-40294.rs:5:4
--> $DIR/issue-40294.rs:6:19
|
LL | trait Foo: Sized {
| ---------------- required by `Foo`
...
LL | fn foo<'a,'b,T>(x: &'a T, y: &'b T)
LL | where &'a T : Foo,
| ^^^ cannot infer type for reference `&'a T`
|
= note: cannot resolve `&'a T: Foo`

View File

@ -6,8 +6,8 @@
trait ExtraCopy<T:Copy> { }
enum SomeEnum<T,U> //~ ERROR E0277
where T: ExtraCopy<U>
enum SomeEnum<T,U>
where T: ExtraCopy<U> //~ ERROR E0277
{
SomeVariant(T,U)
}

View File

@ -1,16 +1,13 @@
error[E0277]: the trait bound `U: std::marker::Copy` is not satisfied
--> $DIR/wf-enum-bound.rs:9:1
--> $DIR/wf-enum-bound.rs:10:14
|
LL | trait ExtraCopy<T:Copy> { }
| ----------------------- required by `ExtraCopy`
LL |
LL | / enum SomeEnum<T,U>
LL | | where T: ExtraCopy<U>
| | - help: consider further restricting type parameter `U`: `, U: std::marker::Copy`
LL | | {
LL | | SomeVariant(T,U)
LL | | }
| |_^ the trait `std::marker::Copy` is not implemented for `U`
...
LL | where T: ExtraCopy<U>
| ^^^^^^^^^^^^- help: consider further restricting type parameter `U`: `, U: std::marker::Copy`
| |
| the trait `std::marker::Copy` is not implemented for `U`
error: aborting due to previous error

View File

@ -1,29 +1,29 @@
error[E0277]: the trait bound `U: std::marker::Copy` is not satisfied
--> $DIR/wf-fn-where-clause.rs:8:4
--> $DIR/wf-fn-where-clause.rs:8:24
|
LL | trait ExtraCopy<T:Copy> { }
| ----------------------- required by `ExtraCopy`
LL |
LL | fn foo<T,U>() where T: ExtraCopy<U>
| ^^^ - help: consider further restricting type parameter `U`: `, U: std::marker::Copy`
| ^^^^^^^^^^^^- help: consider further restricting type parameter `U`: `, U: std::marker::Copy`
| |
| the trait `std::marker::Copy` is not implemented for `U`
error[E0277]: the size for values of type `(dyn std::marker::Copy + 'static)` cannot be known at compilation time
--> $DIR/wf-fn-where-clause.rs:12:4
--> $DIR/wf-fn-where-clause.rs:12:16
|
LL | fn bar() where Vec<dyn Copy>:, {}
| ^^^ doesn't have a size known at compile-time
| ^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `std::marker::Sized` is not implemented for `(dyn std::marker::Copy + 'static)`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: required by `std::vec::Vec`
error[E0038]: the trait `std::marker::Copy` cannot be made into an object
--> $DIR/wf-fn-where-clause.rs:12:4
--> $DIR/wf-fn-where-clause.rs:12:16
|
LL | fn bar() where Vec<dyn Copy>:, {}
| ^^^ the trait `std::marker::Copy` cannot be made into an object
| ^^^^^^^^^^^^^ the trait `std::marker::Copy` cannot be made into an object
|
= note: the trait cannot require that `Self : Sized`

View File

@ -6,8 +6,8 @@
trait MustBeCopy<T:Copy> {
}
fn bar<T,U>() //~ ERROR E0277
where T: MustBeCopy<U>
fn bar<T,U>()
where T: MustBeCopy<U> //~ ERROR E0277
{
}

View File

@ -1,13 +1,13 @@
error[E0277]: the trait bound `U: std::marker::Copy` is not satisfied
--> $DIR/wf-in-fn-where-clause.rs:9:4
--> $DIR/wf-in-fn-where-clause.rs:10:14
|
LL | trait MustBeCopy<T:Copy> {
| ------------------------ required by `MustBeCopy`
...
LL | fn bar<T,U>()
| ^^^ the trait `std::marker::Copy` is not implemented for `U`
LL | where T: MustBeCopy<U>
| - help: consider further restricting type parameter `U`: `, U: std::marker::Copy`
| ^^^^^^^^^^^^^- help: consider further restricting type parameter `U`: `, U: std::marker::Copy`
| |
| the trait `std::marker::Copy` is not implemented for `U`
error: aborting due to previous error

View File

@ -1,5 +1,5 @@
error[E0277]: the trait bound `U: std::marker::Copy` is not satisfied
--> $DIR/wf-inherent-impl-method-where-clause.rs:12:8
--> $DIR/wf-inherent-impl-method-where-clause.rs:12:27
|
LL | trait ExtraCopy<T:Copy> { }
| ----------------------- required by `ExtraCopy`
@ -7,7 +7,7 @@ LL | trait ExtraCopy<T:Copy> { }
LL | impl<T,U> Foo<T,U> {
| - help: consider restricting this bound: `U: std::marker::Copy`
LL | fn foo(self) where T: ExtraCopy<U>
| ^^^ the trait `std::marker::Copy` is not implemented for `U`
| ^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `U`
error: aborting due to previous error

View File

@ -1,16 +1,13 @@
error[E0277]: the trait bound `U: std::marker::Copy` is not satisfied
--> $DIR/wf-inherent-impl-where-clause.rs:11:1
--> $DIR/wf-inherent-impl-where-clause.rs:11:29
|
LL | trait ExtraCopy<T:Copy> { }
| ----------------------- required by `ExtraCopy`
...
LL | impl<T,U> Foo<T,U> where T: ExtraCopy<U>
| ^ - help: consider further restricting type parameter `U`: `, U: std::marker::Copy`
| _|
| ^^^^^^^^^^^^- help: consider further restricting type parameter `U`: `, U: std::marker::Copy`
| |
LL | | {
LL | | }
| |_^ the trait `std::marker::Copy` is not implemented for `U`
| the trait `std::marker::Copy` is not implemented for `U`
error: aborting due to previous error

View File

@ -6,8 +6,8 @@
trait ExtraCopy<T:Copy> { }
struct SomeStruct<T,U> //~ ERROR E0277
where T: ExtraCopy<U>
struct SomeStruct<T,U>
where T: ExtraCopy<U> //~ ERROR E0277
{
data: (T,U)
}

View File

@ -1,16 +1,13 @@
error[E0277]: the trait bound `U: std::marker::Copy` is not satisfied
--> $DIR/wf-struct-bound.rs:9:1
--> $DIR/wf-struct-bound.rs:10:14
|
LL | trait ExtraCopy<T:Copy> { }
| ----------------------- required by `ExtraCopy`
LL |
LL | / struct SomeStruct<T,U>
LL | | where T: ExtraCopy<U>
| | - help: consider further restricting type parameter `U`: `, U: std::marker::Copy`
LL | | {
LL | | data: (T,U)
LL | | }
| |_^ the trait `std::marker::Copy` is not implemented for `U`
...
LL | where T: ExtraCopy<U>
| ^^^^^^^^^^^^- help: consider further restricting type parameter `U`: `, U: std::marker::Copy`
| |
| the trait `std::marker::Copy` is not implemented for `U`
error: aborting due to previous error

View File

@ -6,8 +6,8 @@
trait ExtraCopy<T:Copy> { }
trait SomeTrait<T> { //~ ERROR E0277
type Type1: ExtraCopy<T>;
trait SomeTrait<T> {
type Type1: ExtraCopy<T>; //~ ERROR E0277
}

View File

@ -1,16 +1,13 @@
error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied
--> $DIR/wf-trait-associated-type-bound.rs:9:1
--> $DIR/wf-trait-associated-type-bound.rs:10:17
|
LL | trait ExtraCopy<T:Copy> { }
| ----------------------- required by `ExtraCopy`
LL |
LL | trait SomeTrait<T> {
| ^ - help: consider restricting this bound: `T: std::marker::Copy`
| _|
| |
LL | | type Type1: ExtraCopy<T>;
LL | | }
| |_^ the trait `std::marker::Copy` is not implemented for `T`
| - help: consider restricting this bound: `T: std::marker::Copy`
LL | type Type1: ExtraCopy<T>;
| ^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T`
error: aborting due to previous error

View File

@ -6,8 +6,8 @@
trait ExtraCopy<T:Copy> { }
trait SomeTrait<T,U> //~ ERROR E0277
where T: ExtraCopy<U>
trait SomeTrait<T,U>
where T: ExtraCopy<U> //~ ERROR E0277
{
}

View File

@ -1,15 +1,13 @@
error[E0277]: the trait bound `U: std::marker::Copy` is not satisfied
--> $DIR/wf-trait-bound.rs:9:1
--> $DIR/wf-trait-bound.rs:10:14
|
LL | trait ExtraCopy<T:Copy> { }
| ----------------------- required by `ExtraCopy`
LL |
LL | / trait SomeTrait<T,U>
LL | | where T: ExtraCopy<U>
| | - help: consider further restricting type parameter `U`: `, U: std::marker::Copy`
LL | | {
LL | | }
| |_^ the trait `std::marker::Copy` is not implemented for `U`
...
LL | where T: ExtraCopy<U>
| ^^^^^^^^^^^^- help: consider further restricting type parameter `U`: `, U: std::marker::Copy`
| |
| the trait `std::marker::Copy` is not implemented for `U`
error: aborting due to previous error

View File

@ -1,11 +1,11 @@
error[E0277]: the trait bound `Self: std::cmp::Eq` is not satisfied
--> $DIR/wf-trait-default-fn-where-clause.rs:11:8
--> $DIR/wf-trait-default-fn-where-clause.rs:11:31
|
LL | trait Bar<T:Eq+?Sized> { }
| ---------------------- required by `Bar`
...
LL | fn bar<A>(&self) where A: Bar<Self> {
| ^^^ - help: consider further restricting `Self`: `, Self: std::cmp::Eq`
| ^^^^^^^^^- help: consider further restricting `Self`: `, Self: std::cmp::Eq`
| |
| the trait `std::cmp::Eq` is not implemented for `Self`

View File

@ -1,11 +1,11 @@
error[E0277]: the trait bound `Self: std::cmp::Eq` is not satisfied
--> $DIR/wf-trait-fn-where-clause.rs:10:8
--> $DIR/wf-trait-fn-where-clause.rs:10:49
|
LL | struct Bar<T:Eq+?Sized> { value: Box<T> }
| ----------------------- required by `Bar`
...
LL | fn bar(&self) where Self: Sized, Bar<Self>: Copy;
| ^^^ - help: consider further restricting `Self`: `, Self: std::cmp::Eq`
| ^^^^- help: consider further restricting `Self`: `, Self: std::cmp::Eq`
| |
| the trait `std::cmp::Eq` is not implemented for `Self`

View File

@ -1,15 +1,13 @@
error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied
--> $DIR/wf-trait-superbound.rs:9:1
--> $DIR/wf-trait-superbound.rs:9:21
|
LL | trait ExtraCopy<T:Copy> { }
| ----------------------- required by `ExtraCopy`
LL |
LL | trait SomeTrait<T>: ExtraCopy<T> {
| ^ - help: consider restricting this bound: `T: std::marker::Copy`
| _|
| - ^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T`
| |
LL | | }
| |_^ the trait `std::marker::Copy` is not implemented for `T`
| help: consider restricting this bound: `T: std::marker::Copy`
error: aborting due to previous error