diff --git a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs index 74e2b157dd0a4..83a9fa76323ab 100644 --- a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs +++ b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs @@ -2328,6 +2328,7 @@ pub(super) fn check_type_bounds<'tcx>( let obligations: Vec<_> = tcx .explicit_item_bounds(trait_ty.def_id) .iter_instantiated_copied(tcx, rebased_args) + .chain(tcx.predicates_of(trait_ty.def_id).instantiate_own(tcx, rebased_args)) .map(|(concrete_ty_bound, span)| { debug!("check_type_bounds: concrete_ty_bound = {:?}", concrete_ty_bound); traits::Obligation::new(tcx, mk_cause(span), param_env, concrete_ty_bound) diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs index af30d9121d1a8..db859652d41be 100644 --- a/compiler/rustc_trait_selection/src/traits/project.rs +++ b/compiler/rustc_trait_selection/src/traits/project.rs @@ -2314,7 +2314,6 @@ fn confirm_param_env_candidate<'cx, 'tcx>( ) { Ok(InferOk { value: _, obligations }) => { nested_obligations.extend(obligations); - assoc_ty_own_obligations(selcx, obligation, &mut nested_obligations); // FIXME(associated_const_equality): Handle consts here as well? Maybe this progress type should just take // a term instead. Progress { term: cache_entry.term, obligations: nested_obligations } @@ -2337,7 +2336,7 @@ fn confirm_impl_candidate<'cx, 'tcx>( ) -> Progress<'tcx> { let tcx = selcx.tcx(); - let ImplSourceUserDefinedData { impl_def_id, args, mut nested } = impl_impl_source; + let ImplSourceUserDefinedData { impl_def_id, args, nested } = impl_impl_source; let assoc_item_id = obligation.predicate.def_id; let trait_def_id = tcx.trait_id_of_impl(impl_def_id).unwrap(); @@ -2384,62 +2383,10 @@ fn confirm_impl_candidate<'cx, 'tcx>( ); Progress { term: err.into(), obligations: nested } } else { - assoc_ty_own_obligations(selcx, obligation, &mut nested); Progress { term: term.instantiate(tcx, args), obligations: nested } } } -// Get obligations corresponding to the predicates from the where-clause of the -// associated type itself. -fn assoc_ty_own_obligations<'cx, 'tcx>( - selcx: &mut SelectionContext<'cx, 'tcx>, - obligation: &ProjectionTyObligation<'tcx>, - nested: &mut Vec>, -) { - let tcx = selcx.tcx(); - let predicates = tcx - .predicates_of(obligation.predicate.def_id) - .instantiate_own(tcx, obligation.predicate.args); - for (predicate, span) in predicates { - let normalized = normalize_with_depth_to( - selcx, - obligation.param_env, - obligation.cause.clone(), - obligation.recursion_depth + 1, - predicate, - nested, - ); - - let nested_cause = if matches!( - obligation.cause.code(), - super::CompareImplItemObligation { .. } - | super::CheckAssociatedTypeBounds { .. } - | super::AscribeUserTypeProvePredicate(..) - ) { - obligation.cause.clone() - } else if span.is_dummy() { - ObligationCause::new( - obligation.cause.span, - obligation.cause.body_id, - super::ItemObligation(obligation.predicate.def_id), - ) - } else { - ObligationCause::new( - obligation.cause.span, - obligation.cause.body_id, - super::BindingObligation(obligation.predicate.def_id, span), - ) - }; - nested.push(Obligation::with_depth( - tcx, - nested_cause, - obligation.recursion_depth + 1, - obligation.param_env, - normalized, - )); - } -} - pub(crate) trait ProjectionCacheKeyExt<'cx, 'tcx>: Sized { fn from_poly_projection_predicate( selcx: &mut SelectionContext<'cx, 'tcx>, diff --git a/tests/ui/generic-associated-types/bugs/hrtb-implied-1.rs b/tests/ui/generic-associated-types/bugs/hrtb-implied-1.rs index 5101de19d3cb6..7e511f297cd31 100644 --- a/tests/ui/generic-associated-types/bugs/hrtb-implied-1.rs +++ b/tests/ui/generic-associated-types/bugs/hrtb-implied-1.rs @@ -1,5 +1,4 @@ -// check-fail -// known-bug: unknown +// check-pass // This gives us problems because `for<'a> I::Item<'a>: Debug` should mean "for // all 'a where I::Item<'a> is WF", but really means "for all 'a possible" diff --git a/tests/ui/generic-associated-types/bugs/hrtb-implied-1.stderr b/tests/ui/generic-associated-types/bugs/hrtb-implied-1.stderr deleted file mode 100644 index 362aeae23614f..0000000000000 --- a/tests/ui/generic-associated-types/bugs/hrtb-implied-1.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/hrtb-implied-1.rs:31:22 - | -LL | let slice = &mut (); - | ^^ creates a temporary value which is freed while still in use -LL | let windows = WindowsMut { slice }; -LL | print_items::>(windows); - | -------------------------------------- argument requires that borrow lasts for `'static` -LL | } - | - temporary value is freed at the end of this statement - | -note: due to current limitations in the borrow checker, this implies a `'static` lifetime - --> $DIR/hrtb-implied-1.rs:26:26 - | -LL | for<'a> I::Item<'a>: Debug, - | ^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0716`. diff --git a/tests/ui/generic-associated-types/bugs/hrtb-implied-2.rs b/tests/ui/generic-associated-types/bugs/hrtb-implied-2.rs index 3174227a7a1e1..5bac6011bb234 100644 --- a/tests/ui/generic-associated-types/bugs/hrtb-implied-2.rs +++ b/tests/ui/generic-associated-types/bugs/hrtb-implied-2.rs @@ -1,5 +1,4 @@ -// check-fail -// known-bug: unknown +// check-pass // This gives us problems because `for<'a> I::Item<'a>: Debug` should mean "for // all 'a where I::Item<'a> is WF", but really means "for all 'a possible" diff --git a/tests/ui/generic-associated-types/bugs/hrtb-implied-2.stderr b/tests/ui/generic-associated-types/bugs/hrtb-implied-2.stderr deleted file mode 100644 index 1ee270398de4d..0000000000000 --- a/tests/ui/generic-associated-types/bugs/hrtb-implied-2.stderr +++ /dev/null @@ -1,22 +0,0 @@ -error[E0521]: borrowed data escapes outside of function - --> $DIR/hrtb-implied-2.rs:18:17 - | -LL | fn fails(iter: &mut I, f: F) -> bool - | ---- - let's call the lifetime of this reference `'1` - | | - | `iter` is a reference that is only valid in the function body -... -LL | let _next = iter2.next(); - | ^^^^^^^^^^^^ - | | - | `iter` escapes the function body here - | argument requires that `'1` must outlive `'static` - | - = note: requirement occurs because of a mutable reference to `Eat<&mut I, F>` - = note: mutable references are invariant over their type parameter - = help: see for more information about variance - = note: due to current limitations in the borrow checker, this implies a `'static` lifetime - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0521`. diff --git a/tests/ui/generic-associated-types/bugs/hrtb-implied-3.rs b/tests/ui/generic-associated-types/bugs/hrtb-implied-3.rs index bc9e6c8aea85e..13ad5d3f6016c 100644 --- a/tests/ui/generic-associated-types/bugs/hrtb-implied-3.rs +++ b/tests/ui/generic-associated-types/bugs/hrtb-implied-3.rs @@ -1,3 +1,5 @@ +// check-pass + trait LendingIterator { type Item<'a> where @@ -17,7 +19,6 @@ where fn fails(iter: &str) { trivial_bound(iter); - //~^ borrowed data escapes } fn main() {} diff --git a/tests/ui/generic-associated-types/bugs/hrtb-implied-3.stderr b/tests/ui/generic-associated-types/bugs/hrtb-implied-3.stderr deleted file mode 100644 index c67e02437cd8d..0000000000000 --- a/tests/ui/generic-associated-types/bugs/hrtb-implied-3.stderr +++ /dev/null @@ -1,22 +0,0 @@ -error[E0521]: borrowed data escapes outside of function - --> $DIR/hrtb-implied-3.rs:19:5 - | -LL | fn fails(iter: &str) { - | ---- - let's call the lifetime of this reference `'1` - | | - | `iter` is a reference that is only valid in the function body -LL | trivial_bound(iter); - | ^^^^^^^^^^^^^^^^^^^ - | | - | `iter` escapes the function body here - | argument requires that `'1` must outlive `'static` - | -note: due to current limitations in the borrow checker, this implies a `'static` lifetime - --> $DIR/hrtb-implied-3.rs:14:26 - | -LL | for<'a> I::Item<'a>: Sized, - | ^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0521`. diff --git a/tests/ui/generic-associated-types/bugs/issue-87755.rs b/tests/ui/generic-associated-types/bugs/issue-87755.rs index cda722d2f0c72..cbd5ca82aaf15 100644 --- a/tests/ui/generic-associated-types/bugs/issue-87755.rs +++ b/tests/ui/generic-associated-types/bugs/issue-87755.rs @@ -1,7 +1,5 @@ -// check-fail -// known-bug: #87755 - -// This should pass. +// issue: #87755 +// check-pass use std::fmt::Debug; diff --git a/tests/ui/generic-associated-types/bugs/issue-87755.stderr b/tests/ui/generic-associated-types/bugs/issue-87755.stderr deleted file mode 100644 index 5e94db9b0c00f..0000000000000 --- a/tests/ui/generic-associated-types/bugs/issue-87755.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0275]: overflow evaluating the requirement `::Ass == _` - --> $DIR/issue-87755.rs:16:16 - | -LL | type Ass = Bar; - | ^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0275`. diff --git a/tests/ui/generic-associated-types/collectivity-regression.rs b/tests/ui/generic-associated-types/collectivity-regression.rs index 54154f9d1fc8d..b8782f10b66e6 100644 --- a/tests/ui/generic-associated-types/collectivity-regression.rs +++ b/tests/ui/generic-associated-types/collectivity-regression.rs @@ -1,4 +1,5 @@ // Regression test from https://github.com/rust-lang/rust/pull/98109 +// check-pass pub trait Get { type Value<'a> @@ -11,10 +12,6 @@ where for<'a> T: Get = ()>, { || { - //~^ `T` does not live long enough - // - // FIXME(#98437). This regressed at some point and - // probably should work. let _x = x; }; } diff --git a/tests/ui/generic-associated-types/collectivity-regression.stderr b/tests/ui/generic-associated-types/collectivity-regression.stderr deleted file mode 100644 index a085096e1f8c5..0000000000000 --- a/tests/ui/generic-associated-types/collectivity-regression.stderr +++ /dev/null @@ -1,24 +0,0 @@ -error: `T` does not live long enough - --> $DIR/collectivity-regression.rs:13:5 - | -LL | / || { -LL | | -LL | | // -LL | | // FIXME(#98437). This regressed at some point and -LL | | // probably should work. -LL | | let _x = x; -LL | | }; - | |_____^ - | -note: due to current limitations in the borrow checker, this implies a `'static` lifetime - --> $DIR/collectivity-regression.rs:11:16 - | -LL | for<'a> T: Get = ()>, - | ^^^^^^^^^^^^^^^^^^^ -help: consider restricting the type parameter to the `'static` lifetime - | -LL | for<'a> T: Get = ()> + 'static, - | +++++++++ - -error: aborting due to previous error - diff --git a/tests/ui/generic-associated-types/extended/lending_iterator.base.stderr b/tests/ui/generic-associated-types/extended/lending_iterator.base.stderr deleted file mode 100644 index 614c4a34c187d..0000000000000 --- a/tests/ui/generic-associated-types/extended/lending_iterator.base.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0276]: impl has stricter requirements than trait - --> $DIR/lending_iterator.rs:13:45 - | -LL | fn from_iter LendingIterator = A>>(iter: T) -> Self; - | ------------------------------------------------------------------------ definition of `from_iter` from trait -... -LL | fn from_iter LendingIterator = A>>(mut iter: I) -> Self { - | ^^^^^^^^^^^^ impl has extra requirement `I: 'x` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0276`. diff --git a/tests/ui/generic-associated-types/extended/lending_iterator.rs b/tests/ui/generic-associated-types/extended/lending_iterator.rs index 247761dd04bf4..507b9ecbad9c5 100644 --- a/tests/ui/generic-associated-types/extended/lending_iterator.rs +++ b/tests/ui/generic-associated-types/extended/lending_iterator.rs @@ -1,5 +1,5 @@ // revisions: base extended -//[base] check-fail +//[base] check-pass //[extended] check-pass #![cfg_attr(extended, feature(generic_associated_types_extended))] @@ -11,7 +11,6 @@ pub trait FromLendingIterator: Sized { impl FromLendingIterator for Vec { fn from_iter LendingIterator = A>>(mut iter: I) -> Self { - //[base]~^ impl has stricter let mut v = vec![]; while let Some(item) = iter.next() { v.push(item); diff --git a/tests/ui/generic-associated-types/extended/lending_iterator_2.base.stderr b/tests/ui/generic-associated-types/extended/lending_iterator_2.base.stderr deleted file mode 100644 index f6b0b644e4064..0000000000000 --- a/tests/ui/generic-associated-types/extended/lending_iterator_2.base.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0276]: impl has stricter requirements than trait - --> $DIR/lending_iterator_2.rs:13:45 - | -LL | fn from_iter LendingIterator = A>>(iter: T) -> Self; - | ------------------------------------------------------------------------ definition of `from_iter` from trait -... -LL | fn from_iter LendingIterator = A>>(mut iter: I) -> Self { - | ^^^^^^^^^^^^ impl has extra requirement `I: 'x` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0276`. diff --git a/tests/ui/generic-associated-types/extended/lending_iterator_2.rs b/tests/ui/generic-associated-types/extended/lending_iterator_2.rs index eb9c0456a1eed..3d94cd829813d 100644 --- a/tests/ui/generic-associated-types/extended/lending_iterator_2.rs +++ b/tests/ui/generic-associated-types/extended/lending_iterator_2.rs @@ -1,5 +1,5 @@ // revisions: base extended -//[base] check-fail +//[base] check-pass //[extended] check-pass #![cfg_attr(extended, feature(generic_associated_types_extended))] @@ -11,7 +11,6 @@ pub trait FromLendingIterator: Sized { impl FromLendingIterator for Vec { fn from_iter LendingIterator = A>>(mut iter: I) -> Self { - //[base]~^ impl has stricter let mut v = vec![]; while let Some(item) = iter.next() { v.push(item); diff --git a/tests/ui/generic-associated-types/generic-associated-types-where.stderr b/tests/ui/generic-associated-types/generic-associated-types-where.stderr index 9a745c099c0ed..a3662d1a8d8ba 100644 --- a/tests/ui/generic-associated-types/generic-associated-types-where.stderr +++ b/tests/ui/generic-associated-types/generic-associated-types-where.stderr @@ -5,6 +5,11 @@ LL | type Assoc2 = Vec; | ^^^^^^ `T` cannot be formatted with the default formatter | = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead +note: required by a bound in `Foo::Assoc2` + --> $DIR/generic-associated-types-where.rs:8:29 + | +LL | type Assoc2 where T: Display; + | ^^^^^^^ required by this bound in `Foo::Assoc2` help: consider restricting type parameter `T` | LL | type Assoc2 = Vec; diff --git a/tests/ui/generic-associated-types/issue-84931.rs b/tests/ui/generic-associated-types/issue-84931.rs index 2ef990a7a9072..5074064d7cf59 100644 --- a/tests/ui/generic-associated-types/issue-84931.rs +++ b/tests/ui/generic-associated-types/issue-84931.rs @@ -13,7 +13,7 @@ struct StreamingSliceIter<'a, T> { impl<'b, T: 'b> StreamingIter for StreamingSliceIter<'b, T> { type Item<'a> = &'a mut T; //~^ ERROR: the parameter type - //~| ERROR: does not fulfill the required lifetime + //~| ERROR lifetime bound not satisfied fn next(&mut self) -> Option<&mut T> { loop {} } diff --git a/tests/ui/generic-associated-types/issue-84931.stderr b/tests/ui/generic-associated-types/issue-84931.stderr index 04e14b9c746f3..fd8da18c4b7b9 100644 --- a/tests/ui/generic-associated-types/issue-84931.stderr +++ b/tests/ui/generic-associated-types/issue-84931.stderr @@ -11,26 +11,24 @@ help: consider adding an explicit lifetime bound LL | type Item<'a> = &'a mut T where T: 'a; | +++++++++++ -error[E0477]: the type `StreamingSliceIter<'b, T>` does not fulfill the required lifetime +error[E0478]: lifetime bound not satisfied --> $DIR/issue-84931.rs:14:21 | -LL | type Item<'a> where Self: 'a; - | ------------- definition of `Item` from trait -... LL | type Item<'a> = &'a mut T; | ^^^^^^^^^ | -note: type must outlive the lifetime `'a` as defined here +note: lifetime parameter instantiated with the lifetime `'b` as defined here + --> $DIR/issue-84931.rs:13:6 + | +LL | impl<'b, T: 'b> StreamingIter for StreamingSliceIter<'b, T> { + | ^^ +note: but lifetime parameter must outlive the lifetime `'a` as defined here --> $DIR/issue-84931.rs:14:15 | LL | type Item<'a> = &'a mut T; | ^^ -help: copy the `where` clause predicates from the trait - | -LL | type Item<'a> = &'a mut T where Self: 'a; - | ++++++++++++++ error: aborting due to 2 previous errors -Some errors have detailed explanations: E0309, E0477. +Some errors have detailed explanations: E0309, E0478. For more information about an error, try `rustc --explain E0309`. diff --git a/tests/ui/generic-associated-types/issue-90014.rs b/tests/ui/generic-associated-types/issue-90014.rs index c4d762796e2de..8c1a7a4804dbf 100644 --- a/tests/ui/generic-associated-types/issue-90014.rs +++ b/tests/ui/generic-associated-types/issue-90014.rs @@ -13,7 +13,7 @@ trait MakeFut { impl MakeFut for &'_ mut () { type Fut<'a> = impl Future; - //~^ ERROR: the type `&mut ()` does not fulfill the required lifetime + //~^ ERROR lifetime bound not satisfied fn make_fut<'a>(&'a self) -> Self::Fut<'a> { async { () } diff --git a/tests/ui/generic-associated-types/issue-90014.stderr b/tests/ui/generic-associated-types/issue-90014.stderr index 0d49398cac94a..de15ae5955802 100644 --- a/tests/ui/generic-associated-types/issue-90014.stderr +++ b/tests/ui/generic-associated-types/issue-90014.stderr @@ -1,22 +1,20 @@ -error[E0477]: the type `&mut ()` does not fulfill the required lifetime +error[E0478]: lifetime bound not satisfied --> $DIR/issue-90014.rs:15:20 | -LL | type Fut<'a> - | ------------ definition of `Fut` from trait -... LL | type Fut<'a> = impl Future; | ^^^^^^^^^^^^^^^^^^^^^^^^ | -note: type must outlive the lifetime `'a` as defined here +note: lifetime parameter instantiated with the anonymous lifetime as defined here + --> $DIR/issue-90014.rs:14:19 + | +LL | impl MakeFut for &'_ mut () { + | ^^ +note: but lifetime parameter must outlive the lifetime `'a` as defined here --> $DIR/issue-90014.rs:15:14 | LL | type Fut<'a> = impl Future; | ^^ -help: copy the `where` clause predicates from the trait - | -LL | type Fut<'a> = impl Future where Self: 'a; - | ++++++++++++++ error: aborting due to previous error -For more information about this error, try `rustc --explain E0477`. +For more information about this error, try `rustc --explain E0478`. diff --git a/tests/ui/generic-associated-types/issue-91139.rs b/tests/ui/generic-associated-types/issue-91139.rs index adc0cb4e0423f..4e972244c7cd1 100644 --- a/tests/ui/generic-associated-types/issue-91139.rs +++ b/tests/ui/generic-associated-types/issue-91139.rs @@ -1,3 +1,5 @@ +// check-pass + trait Foo { type Type<'a> where @@ -12,16 +14,6 @@ impl Foo for () { fn foo() { let _: for<'a> fn(<() as Foo>::Type<'a>, &'a T) = |_, _| (); - //~^ ERROR `T` does not live long enough - //~| ERROR `T` does not live long enough - // - // FIXME: This error is bogus, but it arises because we try to validate - // that `<() as Foo>::Type<'a>` is valid, which requires proving - // that `T: 'a`. Since `'a` is higher-ranked, this becomes - // `for<'a> T: 'a`, which is not true. Of course, the error is bogus - // because there *ought* to be an implied bound stating that `'a` is - // not any lifetime but specifically - // "some `'a` such that `<() as Foo>::Type<'a>" is valid". } pub fn main() {} diff --git a/tests/ui/generic-associated-types/issue-91139.stderr b/tests/ui/generic-associated-types/issue-91139.stderr deleted file mode 100644 index 89a4ba77e4e79..0000000000000 --- a/tests/ui/generic-associated-types/issue-91139.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error: `T` does not live long enough - --> $DIR/issue-91139.rs:14:12 - | -LL | let _: for<'a> fn(<() as Foo>::Type<'a>, &'a T) = |_, _| (); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: `T` does not live long enough - --> $DIR/issue-91139.rs:14:12 - | -LL | let _: for<'a> fn(<() as Foo>::Type<'a>, &'a T) = |_, _| (); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: aborting due to 2 previous errors - diff --git a/tests/ui/generic-associated-types/issue-91883.stderr b/tests/ui/generic-associated-types/issue-91883.stderr index d5db962094ce9..2e7c01c4fcede 100644 --- a/tests/ui/generic-associated-types/issue-91883.stderr +++ b/tests/ui/generic-associated-types/issue-91883.stderr @@ -1,9 +1,6 @@ error[E0478]: lifetime bound not satisfied --> $DIR/issue-91883.rs:30:24 | -LL | type Cursor<'tx>: Cursor<'tx> - | ----------------------------- definition of `Cursor` from trait -... LL | type Cursor<'tx> = CursorImpl<'tx>; | ^^^^^^^^^^^^^^^ | @@ -17,10 +14,6 @@ note: but lifetime parameter must outlive the lifetime `'tx` as defined here | LL | type Cursor<'tx> = CursorImpl<'tx>; | ^^^ -help: copy the `where` clause predicates from the trait - | -LL | type Cursor<'tx> = CursorImpl<'tx> where 'db: 'tx, Self: 'tx; - | +++++++++++++++++++++++++ error: aborting due to previous error diff --git a/tests/ui/generic-associated-types/issue-92033.rs b/tests/ui/generic-associated-types/issue-92033.rs index d111580b860aa..29bbd9c619a92 100644 --- a/tests/ui/generic-associated-types/issue-92033.rs +++ b/tests/ui/generic-associated-types/issue-92033.rs @@ -18,7 +18,7 @@ trait Swapchain { impl<'s> Surface for &'s Texture { type TextureIter<'a> = std::option::IntoIter<&'a Texture>; - //~^ ERROR the type + //~^ ERROR lifetime bound not satisfied fn get_texture(&self) -> Self::TextureIter<'_> { let option: Option<&Texture> = Some(self); diff --git a/tests/ui/generic-associated-types/issue-92033.stderr b/tests/ui/generic-associated-types/issue-92033.stderr index ddc420a7b4e61..9e3450045e719 100644 --- a/tests/ui/generic-associated-types/issue-92033.stderr +++ b/tests/ui/generic-associated-types/issue-92033.stderr @@ -1,22 +1,20 @@ -error[E0477]: the type `&'s Texture` does not fulfill the required lifetime +error[E0478]: lifetime bound not satisfied --> $DIR/issue-92033.rs:20:28 | -LL | type TextureIter<'a>: Iterator - | -------------------------------------------------- definition of `TextureIter` from trait -... LL | type TextureIter<'a> = std::option::IntoIter<&'a Texture>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -note: type must outlive the lifetime `'a` as defined here +note: lifetime parameter instantiated with the lifetime `'s` as defined here + --> $DIR/issue-92033.rs:19:6 + | +LL | impl<'s> Surface for &'s Texture { + | ^^ +note: but lifetime parameter must outlive the lifetime `'a` as defined here --> $DIR/issue-92033.rs:20:22 | LL | type TextureIter<'a> = std::option::IntoIter<&'a Texture>; | ^^ -help: copy the `where` clause predicates from the trait - | -LL | type TextureIter<'a> = std::option::IntoIter<&'a Texture> where Self: 'a; - | ++++++++++++++ error: aborting due to previous error -For more information about this error, try `rustc --explain E0477`. +For more information about this error, try `rustc --explain E0478`. diff --git a/tests/ui/generic-associated-types/projection-bound-cycle-generic.rs b/tests/ui/generic-associated-types/projection-bound-cycle-generic.rs index ecf6f69c9fa7e..74a89ab066580 100644 --- a/tests/ui/generic-associated-types/projection-bound-cycle-generic.rs +++ b/tests/ui/generic-associated-types/projection-bound-cycle-generic.rs @@ -1,6 +1,9 @@ // Like `projection-bound-cycle.rs` but this avoids using // `feature(trivial_bounds)`. +// FIXME(aliemjay): this should not pass. +// check-pass + trait Print { fn print(); } @@ -21,7 +24,6 @@ impl Foo for Number { // ``` // which it is :) type Item = [T] where [T]: Sized; - //~^ ERROR overflow evaluating the requirement ` as Foo>::Item == _` } struct OnlySized where T: Sized { f: T } diff --git a/tests/ui/generic-associated-types/projection-bound-cycle-generic.stderr b/tests/ui/generic-associated-types/projection-bound-cycle-generic.stderr deleted file mode 100644 index aae9a56bb6128..0000000000000 --- a/tests/ui/generic-associated-types/projection-bound-cycle-generic.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0275]: overflow evaluating the requirement ` as Foo>::Item == _` - --> $DIR/projection-bound-cycle-generic.rs:23:5 - | -LL | type Item = [T] where [T]: Sized; - | ^^^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0275`. diff --git a/tests/ui/generic-associated-types/projection-bound-cycle.rs b/tests/ui/generic-associated-types/projection-bound-cycle.rs index b51ae7ef20186..287688d226892 100644 --- a/tests/ui/generic-associated-types/projection-bound-cycle.rs +++ b/tests/ui/generic-associated-types/projection-bound-cycle.rs @@ -2,6 +2,9 @@ // Make sure that we make sure that we don't allow arbitrary bounds to be // proven when a bound and a where clause of an associated type are the same. +// FIXME(aliemjay): this should not pass. +// check-pass + #![feature(trivial_bounds)] trait Print { @@ -24,7 +27,6 @@ impl Foo for Number { // ``` // which it is :) type Item = str where str: Sized; - //~^ ERROR overflow evaluating the requirement `::Item == _` } struct OnlySized where T: Sized { f: T } diff --git a/tests/ui/generic-associated-types/projection-bound-cycle.stderr b/tests/ui/generic-associated-types/projection-bound-cycle.stderr deleted file mode 100644 index b1b8afeecd02f..0000000000000 --- a/tests/ui/generic-associated-types/projection-bound-cycle.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0275]: overflow evaluating the requirement `::Item == _` - --> $DIR/projection-bound-cycle.rs:26:5 - | -LL | type Item = str where str: Sized; - | ^^^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0275`. diff --git a/tests/ui/generic-associated-types/trait-objects.base.stderr b/tests/ui/generic-associated-types/trait-objects.base.stderr index 556422c272cf6..1df76a21bf9b4 100644 --- a/tests/ui/generic-associated-types/trait-objects.base.stderr +++ b/tests/ui/generic-associated-types/trait-objects.base.stderr @@ -1,11 +1,11 @@ error[E0038]: the trait `StreamingIterator` cannot be made into an object - --> $DIR/trait-objects.rs:13:21 + --> $DIR/trait-objects.rs:14:21 | LL | fn min_size(x: &mut dyn for<'a> StreamingIterator = &'a i32>) -> usize { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `StreamingIterator` cannot be made into an object | note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit - --> $DIR/trait-objects.rs:7:10 + --> $DIR/trait-objects.rs:8:10 | LL | trait StreamingIterator { | ----------------- this trait cannot be made into an object... diff --git a/tests/ui/generic-associated-types/trait-objects.extended.stderr b/tests/ui/generic-associated-types/trait-objects.extended.stderr deleted file mode 100644 index 45b64d2b02483..0000000000000 --- a/tests/ui/generic-associated-types/trait-objects.extended.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0521]: borrowed data escapes outside of function - --> $DIR/trait-objects.rs:15:5 - | -LL | fn min_size(x: &mut dyn for<'a> StreamingIterator = &'a i32>) -> usize { - | - - let's call the lifetime of this reference `'1` - | | - | `x` is a reference that is only valid in the function body -LL | -LL | x.size_hint().0 - | ^^^^^^^^^^^^^ - | | - | `x` escapes the function body here - | argument requires that `'1` must outlive `'static` - | - = note: due to current limitations in the borrow checker, this implies a `'static` lifetime - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0521`. diff --git a/tests/ui/generic-associated-types/trait-objects.rs b/tests/ui/generic-associated-types/trait-objects.rs index 17fed11bac360..707137b9d2b41 100644 --- a/tests/ui/generic-associated-types/trait-objects.rs +++ b/tests/ui/generic-associated-types/trait-objects.rs @@ -1,4 +1,5 @@ // revisions: base extended +//[extended] check-pass #![cfg_attr(extended, feature(generic_associated_types_extended))] #![cfg_attr(extended, allow(incomplete_features))] @@ -11,9 +12,8 @@ trait StreamingIterator { } fn min_size(x: &mut dyn for<'a> StreamingIterator = &'a i32>) -> usize { - //[base]~^ the trait `StreamingIterator` cannot be made into an object + //[base]~^ ERROR cannot be made into an object x.size_hint().0 - //[extended]~^ borrowed data escapes } fn main() {} diff --git a/tests/ui/generic-associated-types/unsatisfied-body-lifetime-bound.rs b/tests/ui/generic-associated-types/unsatisfied-body-lifetime-bound.rs new file mode 100644 index 0000000000000..dd9c0f5b55d2c --- /dev/null +++ b/tests/ui/generic-associated-types/unsatisfied-body-lifetime-bound.rs @@ -0,0 +1,17 @@ +// FIXME(aliemjay): this should not pass. +// check-pass + +trait Trait { + type Ty<'a> where Self: 'a; +} + +impl Trait for () { + type Ty<'a> = () where Self: 'a; +} + +pub fn body<'a>() { + // ill-formed projection.. + let _: Option<<() as Trait>::Ty::<'a>> = None; +} + +fn main() {} diff --git a/tests/ui/generic-associated-types/unsatisfied-item-lifetime-bound.rs b/tests/ui/generic-associated-types/unsatisfied-item-lifetime-bound.rs index a3f3b1a6d4d9a..75d78b4e85136 100644 --- a/tests/ui/generic-associated-types/unsatisfied-item-lifetime-bound.rs +++ b/tests/ui/generic-associated-types/unsatisfied-item-lifetime-bound.rs @@ -10,9 +10,9 @@ impl X for () { //~^ ERROR lifetime bound not satisfied } +// FIXME(aliemjay): this field type should be an error. struct B<'a, T: for<'r> X = &'r ()>> { f: ::Y<'a>, - //~^ ERROR lifetime bound not satisfied } struct C<'a, T: X> { @@ -20,9 +20,9 @@ struct C<'a, T: X> { //~^ ERROR lifetime bound not satisfied } +// FIXME(aliemjay): this field type should be an error. struct D<'a> { f: <() as X>::Y<'a>, - //~^ ERROR lifetime bound not satisfied } fn main() {} diff --git a/tests/ui/generic-associated-types/unsatisfied-item-lifetime-bound.stderr b/tests/ui/generic-associated-types/unsatisfied-item-lifetime-bound.stderr index f73ed5956da21..d506acde96b7d 100644 --- a/tests/ui/generic-associated-types/unsatisfied-item-lifetime-bound.stderr +++ b/tests/ui/generic-associated-types/unsatisfied-item-lifetime-bound.stderr @@ -11,19 +11,6 @@ note: the lint level is defined here LL | #![warn(unused_lifetimes)] | ^^^^^^^^^^^^^^^^ -error[E0478]: lifetime bound not satisfied - --> $DIR/unsatisfied-item-lifetime-bound.rs:14:8 - | -LL | f: ::Y<'a>, - | ^^^^^^^^^^^^^^^ - | -note: lifetime parameter instantiated with the lifetime `'a` as defined here - --> $DIR/unsatisfied-item-lifetime-bound.rs:13:10 - | -LL | struct B<'a, T: for<'r> X = &'r ()>> { - | ^^ - = note: but lifetime parameter must outlive the static lifetime - error[E0478]: lifetime bound not satisfied --> $DIR/unsatisfied-item-lifetime-bound.rs:19:8 | @@ -37,25 +24,9 @@ LL | struct C<'a, T: X> { | ^^ = note: but lifetime parameter must outlive the static lifetime -error[E0478]: lifetime bound not satisfied - --> $DIR/unsatisfied-item-lifetime-bound.rs:24:8 - | -LL | f: <() as X>::Y<'a>, - | ^^^^^^^^^^^^^^^^ - | -note: lifetime parameter instantiated with the lifetime `'a` as defined here - --> $DIR/unsatisfied-item-lifetime-bound.rs:23:10 - | -LL | struct D<'a> { - | ^^ - = note: but lifetime parameter must outlive the static lifetime - error[E0478]: lifetime bound not satisfied --> $DIR/unsatisfied-item-lifetime-bound.rs:9:18 | -LL | type Y<'a: 'static>; - | ------------------- definition of `Y` from trait -... LL | type Y<'a> = &'a (); | ^^^^^^ | @@ -65,11 +36,7 @@ note: lifetime parameter instantiated with the lifetime `'a` as defined here LL | type Y<'a> = &'a (); | ^^ = note: but lifetime parameter must outlive the static lifetime -help: copy the `where` clause predicates from the trait - | -LL | type Y<'a> = &'a () where 'a: 'static; - | +++++++++++++++++ -error: aborting due to 4 previous errors; 1 warning emitted +error: aborting due to 2 previous errors; 1 warning emitted For more information about this error, try `rustc --explain E0478`. diff --git a/tests/ui/lifetimes/issue-105507.fixed b/tests/ui/lifetimes/issue-105507.fixed deleted file mode 100644 index 277ce8a77e974..0000000000000 --- a/tests/ui/lifetimes/issue-105507.fixed +++ /dev/null @@ -1,43 +0,0 @@ -// run-rustfix -// -#![allow(warnings)] -struct Wrapper<'a, T: ?Sized>(&'a T); - -trait Project { - type Projected<'a> where Self: 'a; - fn project(this: Wrapper<'_, Self>) -> Self::Projected<'_>; -} -trait MyTrait {} -trait ProjectedMyTrait {} - -impl Project for Option { - type Projected<'a> = Option> where T: 'a; - fn project(this: Wrapper<'_, Self>) -> Self::Projected<'_> { - this.0.as_ref().map(Wrapper) - } -} - -impl MyTrait for Option> {} - -impl MyTrait for Wrapper<'_, T> {} - -impl ProjectedMyTrait for T - where - T: Project, - for<'a> T::Projected<'a>: MyTrait, - //~^ NOTE due to current limitations in the borrow checker, this implies a `'static` lifetime - //~| NOTE due to current limitations in the borrow checker, this implies a `'static` lifetime -{} - -fn require_trait(_: T) {} - -fn foo(wrap: Wrapper<'_, Option>, wrap1: Wrapper<'_, Option>) { - //~^ HELP consider restricting the type parameter to the `'static` lifetime - //~| HELP consider restricting the type parameter to the `'static` lifetime - require_trait(wrap); - //~^ ERROR `T` does not live long enough - require_trait(wrap1); - //~^ ERROR `U` does not live long enough -} - -fn main() {} diff --git a/tests/ui/lifetimes/issue-105507.rs b/tests/ui/lifetimes/issue-105507.rs index f46c6b6f21e86..401c3fd55a264 100644 --- a/tests/ui/lifetimes/issue-105507.rs +++ b/tests/ui/lifetimes/issue-105507.rs @@ -1,5 +1,5 @@ -// run-rustfix -// +// check-pass + #![allow(warnings)] struct Wrapper<'a, T: ?Sized>(&'a T); @@ -25,19 +25,13 @@ impl ProjectedMyTrait for T where T: Project, for<'a> T::Projected<'a>: MyTrait, - //~^ NOTE due to current limitations in the borrow checker, this implies a `'static` lifetime - //~| NOTE due to current limitations in the borrow checker, this implies a `'static` lifetime {} fn require_trait(_: T) {} fn foo(wrap: Wrapper<'_, Option>, wrap1: Wrapper<'_, Option>) { - //~^ HELP consider restricting the type parameter to the `'static` lifetime - //~| HELP consider restricting the type parameter to the `'static` lifetime require_trait(wrap); - //~^ ERROR `T` does not live long enough require_trait(wrap1); - //~^ ERROR `U` does not live long enough } fn main() {} diff --git a/tests/ui/lifetimes/issue-105507.stderr b/tests/ui/lifetimes/issue-105507.stderr deleted file mode 100644 index 44d3a7eb9a420..0000000000000 --- a/tests/ui/lifetimes/issue-105507.stderr +++ /dev/null @@ -1,34 +0,0 @@ -error: `T` does not live long enough - --> $DIR/issue-105507.rs:37:5 - | -LL | require_trait(wrap); - | ^^^^^^^^^^^^^^^^^^^ - | -note: due to current limitations in the borrow checker, this implies a `'static` lifetime - --> $DIR/issue-105507.rs:27:35 - | -LL | for<'a> T::Projected<'a>: MyTrait, - | ^^^^^^^ -help: consider restricting the type parameter to the `'static` lifetime - | -LL | fn foo(wrap: Wrapper<'_, Option>, wrap1: Wrapper<'_, Option>) { - | +++++++++ +++++++++ - -error: `U` does not live long enough - --> $DIR/issue-105507.rs:39:5 - | -LL | require_trait(wrap1); - | ^^^^^^^^^^^^^^^^^^^^ - | -note: due to current limitations in the borrow checker, this implies a `'static` lifetime - --> $DIR/issue-105507.rs:27:35 - | -LL | for<'a> T::Projected<'a>: MyTrait, - | ^^^^^^^ -help: consider restricting the type parameter to the `'static` lifetime - | -LL | fn foo(wrap: Wrapper<'_, Option>, wrap1: Wrapper<'_, Option>) { - | +++++++++ +++++++++ - -error: aborting due to 2 previous errors - diff --git a/tests/ui/object-safety/object-safety-supertrait-mentions-GAT.rs b/tests/ui/object-safety/object-safety-supertrait-mentions-GAT.rs index 14e00d2ef321d..d163d3abfe2e4 100644 --- a/tests/ui/object-safety/object-safety-supertrait-mentions-GAT.rs +++ b/tests/ui/object-safety/object-safety-supertrait-mentions-GAT.rs @@ -1,5 +1,3 @@ -//~ ERROR the parameter type `Self` may not live long enough - trait GatTrait { type Gat<'a> where diff --git a/tests/ui/object-safety/object-safety-supertrait-mentions-GAT.stderr b/tests/ui/object-safety/object-safety-supertrait-mentions-GAT.stderr index 2d2bb27b8f39a..8a4c039f06d3a 100644 --- a/tests/ui/object-safety/object-safety-supertrait-mentions-GAT.stderr +++ b/tests/ui/object-safety/object-safety-supertrait-mentions-GAT.stderr @@ -1,14 +1,5 @@ -error[E0311]: the parameter type `Self` may not live long enough - | -note: ...that is required by this bound - --> $DIR/object-safety-supertrait-mentions-GAT.rs:6:15 - | -LL | Self: 'a; - | ^^ - = help: consider adding an explicit lifetime bound `Self: 'a`... - error: associated item referring to unboxed trait object for its own trait - --> $DIR/object-safety-supertrait-mentions-GAT.rs:10:20 + --> $DIR/object-safety-supertrait-mentions-GAT.rs:8:20 | LL | trait SuperTrait: for<'a> GatTrait = T> { | ---------- in this trait @@ -21,13 +12,13 @@ LL | fn c(&self) -> Self; | ~~~~ error[E0038]: the trait `SuperTrait` cannot be made into an object - --> $DIR/object-safety-supertrait-mentions-GAT.rs:10:20 + --> $DIR/object-safety-supertrait-mentions-GAT.rs:8:20 | LL | fn c(&self) -> dyn SuperTrait; | ^^^^^^^^^^^^^^^^^ `SuperTrait` cannot be made into an object | note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit - --> $DIR/object-safety-supertrait-mentions-GAT.rs:4:10 + --> $DIR/object-safety-supertrait-mentions-GAT.rs:2:10 | LL | type Gat<'a> | ^^^ ...because it contains the generic associated type `Gat` @@ -36,7 +27,6 @@ LL | trait SuperTrait: for<'a> GatTrait = T> { | ---------- this trait cannot be made into an object... = help: consider moving `Gat` to another trait -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0038, E0311. -For more information about an error, try `rustc --explain E0038`. +For more information about this error, try `rustc --explain E0038`.