diff --git a/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs b/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs index c889381586753..6fee4d8c176eb 100644 --- a/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs +++ b/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs @@ -229,7 +229,8 @@ impl CanonicalizeMode for CanonicalizeUserTypeAnnotation { | ty::ReErased | ty::ReStatic | ty::ReError(_) => r, - ty::ReVar(_) => canonicalizer.canonical_var_for_region_in_root_universe(r), + ty::ReVar(_) => canonicalizer + .canonical_var_for_region(CanonicalVarKind::Region(ty::UniverseIndex::ROOT), r), ty::RePlaceholder(..) | ty::ReBound(..) => { // We only expect region names that the user can type. bug!("unexpected region in query response: `{:?}`", r) @@ -707,23 +708,26 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> { } /// Shorthand helper that creates a canonical region variable for - /// `r` (always in the root universe). The reason that we always - /// put these variables into the root universe is because this - /// method is used during **query construction:** in that case, we - /// are taking all the regions and just putting them into the most - /// generic context we can. This may generate solutions that don't - /// fit (e.g., that equate some region variable with a placeholder - /// it can't name) on the caller side, but that's ok, the caller - /// can figure that out. In the meantime, it maximizes our + /// `r` (always as a placeholder in the root universe). The reason + /// that we always put these variables into the root universe as a + /// placeholder is because this method is used during + /// **query construction:** in that case, we are taking all the + /// free regions and just putting them into the most generic context + /// we can. This makes any region constraints between them, including + /// region equalities, to be preserved and propagated to the caller + /// instead of unifying them. In the meantime, it maximizes our /// caching. - /// - /// (This works because unification never fails -- and hence trait - /// selection is never affected -- due to a universe mismatch.) fn canonical_var_for_region_in_root_universe( &mut self, r: ty::Region<'tcx>, ) -> ty::Region<'tcx> { - self.canonical_var_for_region(CanonicalVarKind::Region(ty::UniverseIndex::ROOT), r) + self.canonical_var_for_region( + CanonicalVarKind::PlaceholderRegion(ty::PlaceholderRegion::new_anon( + ty::UniverseIndex::ROOT, + self.var_kinds.len().into(), + )), + r, + ) } /// Creates a canonical variable (with the given `info`) diff --git a/compiler/rustc_next_trait_solver/src/canonical/canonicalizer.rs b/compiler/rustc_next_trait_solver/src/canonical/canonicalizer.rs index 0a3672343e33c..c5a5d2f53596d 100644 --- a/compiler/rustc_next_trait_solver/src/canonical/canonicalizer.rs +++ b/compiler/rustc_next_trait_solver/src/canonical/canonicalizer.rs @@ -417,7 +417,10 @@ impl, I: Interner> TypeFolder for Canonicaliz // when checking whether a `ParamEnv` candidate is global. ty::ReStatic => match self.canonicalize_mode { CanonicalizeMode::Input(CanonicalizeInputKind::Predicate) => { - CanonicalVarKind::Region(ty::UniverseIndex::ROOT) + CanonicalVarKind::PlaceholderRegion(ty::PlaceholderRegion::new_anon( + ty::UniverseIndex::ROOT, + self.variables.len().into(), + )) } CanonicalizeMode::Input(CanonicalizeInputKind::ParamEnv) | CanonicalizeMode::Response { .. } => return r, @@ -431,24 +434,42 @@ impl, I: Interner> TypeFolder for Canonicaliz // `ReErased`. We may be able to short-circuit registering region // obligations if we encounter a `ReErased` on one side, for example. ty::ReErased | ty::ReError(_) => match self.canonicalize_mode { - CanonicalizeMode::Input(_) => CanonicalVarKind::Region(ty::UniverseIndex::ROOT), + CanonicalizeMode::Input(_) => { + CanonicalVarKind::PlaceholderRegion(ty::PlaceholderRegion::new_anon( + ty::UniverseIndex::ROOT, + self.variables.len().into(), + )) + } CanonicalizeMode::Response { .. } => return r, }, ty::ReEarlyParam(_) | ty::ReLateParam(_) => match self.canonicalize_mode { - CanonicalizeMode::Input(_) => CanonicalVarKind::Region(ty::UniverseIndex::ROOT), + CanonicalizeMode::Input(_) => { + CanonicalVarKind::PlaceholderRegion(ty::PlaceholderRegion::new_anon( + ty::UniverseIndex::ROOT, + self.variables.len().into(), + )) + } CanonicalizeMode::Response { .. } => { panic!("unexpected region in response: {r:?}") } }, ty::RePlaceholder(placeholder) => match self.canonicalize_mode { - // We canonicalize placeholder regions as existentials in query inputs. - CanonicalizeMode::Input(_) => CanonicalVarKind::Region(ty::UniverseIndex::ROOT), + CanonicalizeMode::Input(_) => { + CanonicalVarKind::PlaceholderRegion(ty::PlaceholderRegion::new_anon( + ty::UniverseIndex::ROOT, + self.variables.len().into(), + )) + } CanonicalizeMode::Response { max_input_universe } => { // If we have a placeholder region inside of a query, it must be from - // a new universe. - if max_input_universe.can_name(placeholder.universe()) { + // a new universe, unless it's anon from the root universe, which is + // used for canonicalization of any free region from the input. + if !(placeholder.universe() == ty::UniverseIndex::ROOT + && placeholder.bound.kind == ty::BoundRegionKind::Anon) + && max_input_universe.can_name(placeholder.universe()) + { panic!("new placeholder in universe {max_input_universe:?}: {r:?}"); } CanonicalVarKind::PlaceholderRegion(placeholder) @@ -462,7 +483,12 @@ impl, I: Interner> TypeFolder for Canonicaliz "region vid should have been resolved fully before canonicalization" ); match self.canonicalize_mode { - CanonicalizeMode::Input(_) => CanonicalVarKind::Region(ty::UniverseIndex::ROOT), + CanonicalizeMode::Input(_) => { + CanonicalVarKind::PlaceholderRegion(ty::PlaceholderRegion::new_anon( + ty::UniverseIndex::ROOT, + self.variables.len().into(), + )) + } CanonicalizeMode::Response { .. } => { CanonicalVarKind::Region(self.delegate.universe_of_lt(vid).unwrap()) } diff --git a/tests/ui/async-await/higher-ranked-auto-trait-10.assumptions.stderr b/tests/ui/async-await/higher-ranked-auto-trait-10.assumptions.stderr index 6fcf1b1eac176..eaf7a84b28043 100644 --- a/tests/ui/async-await/higher-ranked-auto-trait-10.assumptions.stderr +++ b/tests/ui/async-await/higher-ranked-auto-trait-10.assumptions.stderr @@ -1,21 +1,21 @@ -error: implementation of `Foo` is not general enough +error[E0308]: mismatched types --> $DIR/higher-ranked-auto-trait-10.rs:32:5 | LL | Box::new(async move { get_foo(x).await }) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other | - = note: `Foo<'1>` would have to be implemented for the type `&'0 str`, for any two lifetimes `'0` and `'1`... - = note: ...but `Foo<'2>` is actually implemented for the type `&'2 str`, for some specific lifetime `'2` + = note: expected enum `Result<&_, _>` + found enum `Result<&_, _>` -error: implementation of `Foo` is not general enough +error: implementation of `Send` is not general enough --> $DIR/higher-ranked-auto-trait-10.rs:32:5 | LL | Box::new(async move { get_foo(x).await }) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Send` is not general enough | - = note: `Foo<'1>` would have to be implemented for the type `&'0 str`, for any two lifetimes `'0` and `'1`... - = note: ...but `Foo<'2>` is actually implemented for the type `&'2 str`, for some specific lifetime `'2` - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + = note: `Send` would have to be implemented for the type `&str` + = note: ...but `Send` is actually implemented for the type `&'0 str`, for some specific lifetime `'0` error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/async-await/higher-ranked-auto-trait-10.no_assumptions.stderr b/tests/ui/async-await/higher-ranked-auto-trait-10.no_assumptions.stderr index 6fcf1b1eac176..eaf7a84b28043 100644 --- a/tests/ui/async-await/higher-ranked-auto-trait-10.no_assumptions.stderr +++ b/tests/ui/async-await/higher-ranked-auto-trait-10.no_assumptions.stderr @@ -1,21 +1,21 @@ -error: implementation of `Foo` is not general enough +error[E0308]: mismatched types --> $DIR/higher-ranked-auto-trait-10.rs:32:5 | LL | Box::new(async move { get_foo(x).await }) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other | - = note: `Foo<'1>` would have to be implemented for the type `&'0 str`, for any two lifetimes `'0` and `'1`... - = note: ...but `Foo<'2>` is actually implemented for the type `&'2 str`, for some specific lifetime `'2` + = note: expected enum `Result<&_, _>` + found enum `Result<&_, _>` -error: implementation of `Foo` is not general enough +error: implementation of `Send` is not general enough --> $DIR/higher-ranked-auto-trait-10.rs:32:5 | LL | Box::new(async move { get_foo(x).await }) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Send` is not general enough | - = note: `Foo<'1>` would have to be implemented for the type `&'0 str`, for any two lifetimes `'0` and `'1`... - = note: ...but `Foo<'2>` is actually implemented for the type `&'2 str`, for some specific lifetime `'2` - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + = note: `Send` would have to be implemented for the type `&str` + = note: ...but `Send` is actually implemented for the type `&'0 str`, for some specific lifetime `'0` error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/async-await/higher-ranked-auto-trait-11.assumptions.stderr b/tests/ui/async-await/higher-ranked-auto-trait-11.assumptions.stderr index d39843f628c46..c45b8ddc6fa47 100644 --- a/tests/ui/async-await/higher-ranked-auto-trait-11.assumptions.stderr +++ b/tests/ui/async-await/higher-ranked-auto-trait-11.assumptions.stderr @@ -13,8 +13,8 @@ error: implementation of `Send` is not general enough LL | Box::pin(async move { >::foo().await }) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Send` is not general enough | - = note: `Send` would have to be implemented for the type `>::Future`, for any lifetime `'0`... - = note: ...but `Send` is actually implemented for the type `>::Future`, for some specific lifetime `'1` + = note: `>::Future` must implement `Send`, for any lifetime `'0`... + = note: ...but `Send` is actually implemented for the type `>::Future` error: aborting due to 2 previous errors diff --git a/tests/ui/async-await/higher-ranked-auto-trait-11.no_assumptions.stderr b/tests/ui/async-await/higher-ranked-auto-trait-11.no_assumptions.stderr index d39843f628c46..c45b8ddc6fa47 100644 --- a/tests/ui/async-await/higher-ranked-auto-trait-11.no_assumptions.stderr +++ b/tests/ui/async-await/higher-ranked-auto-trait-11.no_assumptions.stderr @@ -13,8 +13,8 @@ error: implementation of `Send` is not general enough LL | Box::pin(async move { >::foo().await }) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Send` is not general enough | - = note: `Send` would have to be implemented for the type `>::Future`, for any lifetime `'0`... - = note: ...but `Send` is actually implemented for the type `>::Future`, for some specific lifetime `'1` + = note: `>::Future` must implement `Send`, for any lifetime `'0`... + = note: ...but `Send` is actually implemented for the type `>::Future` error: aborting due to 2 previous errors diff --git a/tests/ui/async-await/higher-ranked-auto-trait-13.no_assumptions.stderr b/tests/ui/async-await/higher-ranked-auto-trait-13.no_assumptions.stderr index cfbdaa8ad4beb..890ab66739fa7 100644 --- a/tests/ui/async-await/higher-ranked-auto-trait-13.no_assumptions.stderr +++ b/tests/ui/async-await/higher-ranked-auto-trait-13.no_assumptions.stderr @@ -17,14 +17,14 @@ LL | assert_send(my_send_async_method(struct_with_lifetime, data)); = note: ...but `Getter<'2>` is actually implemented for the type `GetterImpl<'2, ConstructableImpl<'_>>`, for some specific lifetime `'2` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: implementation of `Callable` is not general enough +error: implementation of `Send` is not general enough --> $DIR/higher-ranked-auto-trait-13.rs:65:5 | LL | assert_send(my_send_async_method(struct_with_lifetime, data)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Callable` is not general enough + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Send` is not general enough | - = note: `Callable<'_>` would have to be implemented for the type `ConstructableImpl<'0>`, for any lifetime `'0`... - = note: ...but `Callable<'1>` is actually implemented for the type `ConstructableImpl<'1>`, for some specific lifetime `'1` + = note: `Send` would have to be implemented for the type `&Vec` + = note: ...but `Send` is actually implemented for the type `&'0 Vec`, for some specific lifetime `'0` error: implementation of `Getter` is not general enough --> $DIR/higher-ranked-auto-trait-13.rs:65:5 @@ -54,7 +54,6 @@ LL | assert_send(my_send_async_method(struct_with_lifetime, data)); | = note: `Callable<'_>` would have to be implemented for the type `ConstructableImpl<'0>`, for any lifetime `'0`... = note: ...but `Callable<'1>` is actually implemented for the type `ConstructableImpl<'1>`, for some specific lifetime `'1` - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: aborting due to 6 previous errors diff --git a/tests/ui/async-await/higher-ranked-auto-trait-5.no_assumptions.stderr b/tests/ui/async-await/higher-ranked-auto-trait-5.no_assumptions.stderr index 8fa3c7483c89d..a7101b7b077c4 100644 --- a/tests/ui/async-await/higher-ranked-auto-trait-5.no_assumptions.stderr +++ b/tests/ui/async-await/higher-ranked-auto-trait-5.no_assumptions.stderr @@ -6,8 +6,8 @@ LL | | call_me.call().await; LL | | }); | |______^ implementation of `Send` is not general enough | - = note: `Send` would have to be implemented for the type `&'0 str`, for any lifetime `'0`... - = note: ...but `Send` is actually implemented for the type `&'1 str`, for some specific lifetime `'1` + = note: `Send` would have to be implemented for the type `&Wrap>` + = note: ...but `Send` is actually implemented for the type `&'0 Wrap>`, for some specific lifetime `'0` error: aborting due to 1 previous error diff --git a/tests/ui/borrowck/closure-upvar-named-lifetime.stderr b/tests/ui/borrowck/closure-upvar-named-lifetime.stderr index fc7c59fa97c89..5e0a06fbdc22d 100644 --- a/tests/ui/borrowck/closure-upvar-named-lifetime.stderr +++ b/tests/ui/borrowck/closure-upvar-named-lifetime.stderr @@ -73,6 +73,9 @@ LL | f(value); | -------- argument requires that `map` is borrowed for `'a` LL | } | - `map` dropped here while still borrowed + | +note: requirement that the value outlives `'a` introduced here + --> $SRC_DIR/core/src/ops/function.rs:LL:COL error[E0716]: temporary value dropped while borrowed --> $DIR/closure-upvar-named-lifetime.rs:34:21 @@ -87,6 +90,9 @@ LL | let value = map.borrow_mut().entry("foo".to_string()); ... LL | f(value); | -------- argument requires that borrow lasts for `'a` + | +note: requirement that the value outlives `'a` introduced here + --> $SRC_DIR/core/src/ops/function.rs:LL:COL error[E0700]: hidden type for `impl Fn(RefCell>)` captures lifetime that does not appear in bounds --> $DIR/closure-upvar-named-lifetime.rs:32:5 diff --git a/tests/ui/coroutine/resume-arg-late-bound.stderr b/tests/ui/coroutine/resume-arg-late-bound.stderr index 646abaf4f7bde..82c1f45d432f7 100644 --- a/tests/ui/coroutine/resume-arg-late-bound.stderr +++ b/tests/ui/coroutine/resume-arg-late-bound.stderr @@ -4,8 +4,8 @@ error: implementation of `Coroutine` is not general enough LL | test(gen); | ^^^^^^^^^ implementation of `Coroutine` is not general enough | - = note: `{coroutine@$DIR/resume-arg-late-bound.rs:11:28: 11:44}` must implement `Coroutine<&'1 mut bool>`, for any lifetime `'1`... - = note: ...but it actually implements `Coroutine<&'2 mut bool>`, for some specific lifetime `'2` + = note: `{coroutine@$DIR/resume-arg-late-bound.rs:11:28: 11:44}` must implement `Coroutine<&'1 mut bool>`, for any two lifetimes `'0` and `'1`... + = note: ...but it actually implements `Coroutine<&mut bool>` error: aborting due to 1 previous error diff --git a/tests/ui/generic-associated-types/must-prove-where-clauses-on-norm.current.stderr b/tests/ui/generic-associated-types/must-prove-where-clauses-on-norm.current.stderr index 2e7e8c12e671e..48da168dc50ed 100644 --- a/tests/ui/generic-associated-types/must-prove-where-clauses-on-norm.current.stderr +++ b/tests/ui/generic-associated-types/must-prove-where-clauses-on-norm.current.stderr @@ -1,10 +1,10 @@ -error: higher-ranked lifetime error +error: lifetime bound not satisfied --> $DIR/must-prove-where-clauses-on-norm.rs:23:61 | LL | let func: for<'a, 'b> fn((), &'b str) -> &'static str = foo::<()>; | ^^^^^^^^^ | - = note: could not normalize `for<'b> fn(<() as Trait>::Assoc<'_, 'b>, &'b str) -> &str` + = note: this is a known limitation that will be removed in the future (see issue #100013 for more information) error: aborting due to 1 previous error diff --git a/tests/ui/generic-associated-types/must-prove-where-clauses-on-norm.rs b/tests/ui/generic-associated-types/must-prove-where-clauses-on-norm.rs index 064ed18248206..fb2da8efb4084 100644 --- a/tests/ui/generic-associated-types/must-prove-where-clauses-on-norm.rs +++ b/tests/ui/generic-associated-types/must-prove-where-clauses-on-norm.rs @@ -21,7 +21,7 @@ fn foo<'a, 'b, T: Trait>(_: ::Assoc<'a, 'b>, x: &'b str) -> &'a str fn main() { let func: for<'a, 'b> fn((), &'b str) -> &'static str = foo::<()>; - //[current]~^ ERROR higher-ranked lifetime error + //[current]~^ ERROR lifetime bound not satisfied //[next]~^^ ERROR mismatched types let x: &'static str = func((), &String::from("temporary")); println!("{x}"); diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-perfect-forwarding.stderr b/tests/ui/higher-ranked/trait-bounds/hrtb-perfect-forwarding.stderr index 327c0faa48287..0aa15643532e0 100644 --- a/tests/ui/higher-ranked/trait-bounds/hrtb-perfect-forwarding.stderr +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-perfect-forwarding.stderr @@ -60,7 +60,7 @@ LL | foo_hrtb_bar_not(&mut t); | ^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Bar` is not general enough | = note: `T` must implement `Bar<&'0 isize>`, for any lifetime `'0`... - = note: ...but it actually implements `Bar<&'1 isize>`, for some specific lifetime `'1` + = note: ...but it actually implements `Bar<&isize>` warning: function cannot return without recursing --> $DIR/hrtb-perfect-forwarding.rs:48:1 diff --git a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-71955.stderr b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-71955.stderr index b2bb417a8f01b..d78db07253d89 100644 --- a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-71955.stderr +++ b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-71955.stderr @@ -4,8 +4,8 @@ error: implementation of `FnOnce` is not general enough LL | foo(bar, "string", |s| s.len() == 5); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough | - = note: closure with signature `for<'a> fn(&'a &'2 str) -> bool` must implement `FnOnce<(&&'1 str,)>`, for any lifetime `'1`... - = note: ...but it actually implements `FnOnce<(&&'2 str,)>`, for some specific lifetime `'2` + = note: closure with signature `for<'a> fn(&'a &'0 str) -> bool` must implement `FnOnce<(&&'1 str,)>`, for any two lifetimes `'0` and `'1`... + = note: ...but it actually implements `FnOnce<(&&str,)>` error: implementation of `FnOnce` is not general enough --> $DIR/issue-71955.rs:45:5 @@ -13,8 +13,8 @@ error: implementation of `FnOnce` is not general enough LL | foo(bar, "string", |s| s.len() == 5); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough | - = note: closure with signature `for<'a> fn(&'a &'2 str) -> bool` must implement `FnOnce<(&&'1 str,)>`, for any lifetime `'1`... - = note: ...but it actually implements `FnOnce<(&&'2 str,)>`, for some specific lifetime `'2` + = note: closure with signature `for<'a> fn(&'a &'0 str) -> bool` must implement `FnOnce<(&&'1 str,)>`, for any two lifetimes `'0` and `'1`... + = note: ...but it actually implements `FnOnce<(&&str,)>` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: implementation of `FnOnce` is not general enough @@ -23,8 +23,8 @@ error: implementation of `FnOnce` is not general enough LL | foo(baz, "string", |s| s.0.len() == 5); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough | - = note: closure with signature `for<'a> fn(&'a Wrapper<'2>) -> bool` must implement `FnOnce<(&Wrapper<'1>,)>`, for any lifetime `'1`... - = note: ...but it actually implements `FnOnce<(&Wrapper<'2>,)>`, for some specific lifetime `'2` + = note: closure with signature `for<'a> fn(&'a Wrapper<'0>) -> bool` must implement `FnOnce<(&Wrapper<'1>,)>`, for any two lifetimes `'0` and `'1`... + = note: ...but it actually implements `FnOnce<(&Wrapper<'_>,)>` error: implementation of `FnOnce` is not general enough --> $DIR/issue-71955.rs:48:5 @@ -32,8 +32,8 @@ error: implementation of `FnOnce` is not general enough LL | foo(baz, "string", |s| s.0.len() == 5); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough | - = note: closure with signature `for<'a> fn(&'a Wrapper<'2>) -> bool` must implement `FnOnce<(&Wrapper<'1>,)>`, for any lifetime `'1`... - = note: ...but it actually implements `FnOnce<(&Wrapper<'2>,)>`, for some specific lifetime `'2` + = note: closure with signature `for<'a> fn(&'a Wrapper<'0>) -> bool` must implement `FnOnce<(&Wrapper<'1>,)>`, for any two lifetimes `'0` and `'1`... + = note: ...but it actually implements `FnOnce<(&Wrapper<'_>,)>` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: aborting due to 4 previous errors diff --git a/tests/ui/implied-bounds/normalization-preserve-equality.borrowck.stderr b/tests/ui/implied-bounds/normalization-preserve-equality.borrowck.stderr deleted file mode 100644 index 96c76ca9ac311..0000000000000 --- a/tests/ui/implied-bounds/normalization-preserve-equality.borrowck.stderr +++ /dev/null @@ -1,28 +0,0 @@ -error: lifetime may not live long enough - --> $DIR/normalization-preserve-equality.rs:24:1 - | -LL | fn test_borrowck<'a, 'b>(_: ( as Trait>::Ty, Equal<'a, 'b>)) { - | ^^^^^^^^^^^^^^^^^--^^--^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | | | - | | | lifetime `'b` defined here - | | lifetime `'a` defined here - | requires that `'a` must outlive `'b` - | - = help: consider adding the following bound: `'a: 'b` - -error: lifetime may not live long enough - --> $DIR/normalization-preserve-equality.rs:24:1 - | -LL | fn test_borrowck<'a, 'b>(_: ( as Trait>::Ty, Equal<'a, 'b>)) { - | ^^^^^^^^^^^^^^^^^--^^--^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | | | - | | | lifetime `'b` defined here - | | lifetime `'a` defined here - | requires that `'b` must outlive `'a` - | - = help: consider adding the following bound: `'b: 'a` - -help: `'a` and `'b` must be the same: replace one with the other - -error: aborting due to 2 previous errors - diff --git a/tests/ui/implied-bounds/normalization-preserve-equality.rs b/tests/ui/implied-bounds/normalization-preserve-equality.rs index 712c8ce945df0..d4c83994702bd 100644 --- a/tests/ui/implied-bounds/normalization-preserve-equality.rs +++ b/tests/ui/implied-bounds/normalization-preserve-equality.rs @@ -1,9 +1,5 @@ -// Both revisions should pass. `borrowck` revision is a bug! -// +//@ check-pass //@ revisions: wfcheck borrowck -//@ [wfcheck] check-pass -//@ [borrowck] check-fail -//@ [borrowck] known-bug: #106569 struct Equal<'a, 'b>(&'a &'b (), &'b &'a ()); // implies 'a == 'b diff --git a/tests/ui/lifetimes/issue-105675.stderr b/tests/ui/lifetimes/issue-105675.stderr index 4b3d0e8ac5efc..01a8494d7afe7 100644 --- a/tests/ui/lifetimes/issue-105675.stderr +++ b/tests/ui/lifetimes/issue-105675.stderr @@ -4,8 +4,8 @@ error: implementation of `FnOnce` is not general enough LL | thing(f); | ^^^^^^^^ implementation of `FnOnce` is not general enough | - = note: closure with signature `for<'a> fn(&'2 u32, &'a u32, u32)` must implement `FnOnce<(&'1 u32, &u32, u32)>`, for any lifetime `'1`... - = note: ...but it actually implements `FnOnce<(&'2 u32, &u32, u32)>`, for some specific lifetime `'2` + = note: closure with signature `for<'a> fn(&'0 u32, &'a u32, u32)` must implement `FnOnce<(&'1 u32, &u32, u32)>`, for any two lifetimes `'0` and `'1`... + = note: ...but it actually implements `FnOnce<(&u32, &u32, u32)>` error: implementation of `FnOnce` is not general enough --> $DIR/issue-105675.rs:5:5 @@ -13,8 +13,8 @@ error: implementation of `FnOnce` is not general enough LL | thing(f); | ^^^^^^^^ implementation of `FnOnce` is not general enough | - = note: closure with signature `for<'a> fn(&'2 u32, &'a u32, u32)` must implement `FnOnce<(&'1 u32, &u32, u32)>`, for any lifetime `'1`... - = note: ...but it actually implements `FnOnce<(&'2 u32, &u32, u32)>`, for some specific lifetime `'2` + = note: closure with signature `for<'a> fn(&'0 u32, &'a u32, u32)` must implement `FnOnce<(&'1 u32, &u32, u32)>`, for any two lifetimes `'0` and `'1`... + = note: ...but it actually implements `FnOnce<(&u32, &u32, u32)>` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: implementation of `FnOnce` is not general enough @@ -23,8 +23,8 @@ error: implementation of `FnOnce` is not general enough LL | thing(f); | ^^^^^^^^ implementation of `FnOnce` is not general enough | - = note: closure with signature `fn(&'2 u32, &u32, u32)` must implement `FnOnce<(&'1 u32, &u32, u32)>`, for any lifetime `'1`... - = note: ...but it actually implements `FnOnce<(&'2 u32, &u32, u32)>`, for some specific lifetime `'2` + = note: closure with signature `fn(&'0 u32, &u32, u32)` must implement `FnOnce<(&'1 u32, &u32, u32)>`, for any two lifetimes `'0` and `'1`... + = note: ...but it actually implements `FnOnce<(&u32, &u32, u32)>` error: implementation of `FnOnce` is not general enough --> $DIR/issue-105675.rs:9:5 @@ -32,8 +32,8 @@ error: implementation of `FnOnce` is not general enough LL | thing(f); | ^^^^^^^^ implementation of `FnOnce` is not general enough | - = note: closure with signature `fn(&u32, &'2 u32, u32)` must implement `FnOnce<(&u32, &'1 u32, u32)>`, for any lifetime `'1`... - = note: ...but it actually implements `FnOnce<(&u32, &'2 u32, u32)>`, for some specific lifetime `'2` + = note: closure with signature `fn(&u32, &'0 u32, u32)` must implement `FnOnce<(&u32, &'1 u32, u32)>`, for any two lifetimes `'0` and `'1`... + = note: ...but it actually implements `FnOnce<(&u32, &u32, u32)>` error: implementation of `FnOnce` is not general enough --> $DIR/issue-105675.rs:9:5 @@ -41,8 +41,8 @@ error: implementation of `FnOnce` is not general enough LL | thing(f); | ^^^^^^^^ implementation of `FnOnce` is not general enough | - = note: closure with signature `fn(&'2 u32, &u32, u32)` must implement `FnOnce<(&'1 u32, &u32, u32)>`, for any lifetime `'1`... - = note: ...but it actually implements `FnOnce<(&'2 u32, &u32, u32)>`, for some specific lifetime `'2` + = note: closure with signature `fn(&'0 u32, &u32, u32)` must implement `FnOnce<(&'1 u32, &u32, u32)>`, for any two lifetimes `'0` and `'1`... + = note: ...but it actually implements `FnOnce<(&u32, &u32, u32)>` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: implementation of `FnOnce` is not general enough @@ -51,8 +51,8 @@ error: implementation of `FnOnce` is not general enough LL | thing(f); | ^^^^^^^^ implementation of `FnOnce` is not general enough | - = note: closure with signature `fn(&u32, &'2 u32, u32)` must implement `FnOnce<(&u32, &'1 u32, u32)>`, for any lifetime `'1`... - = note: ...but it actually implements `FnOnce<(&u32, &'2 u32, u32)>`, for some specific lifetime `'2` + = note: closure with signature `fn(&u32, &'0 u32, u32)` must implement `FnOnce<(&u32, &'1 u32, u32)>`, for any two lifetimes `'0` and `'1`... + = note: ...but it actually implements `FnOnce<(&u32, &u32, u32)>` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: aborting due to 6 previous errors diff --git a/tests/ui/lifetimes/issue-79187-2.stderr b/tests/ui/lifetimes/issue-79187-2.stderr index 78f6ce882dfab..9804bce4eaeb9 100644 --- a/tests/ui/lifetimes/issue-79187-2.stderr +++ b/tests/ui/lifetimes/issue-79187-2.stderr @@ -22,8 +22,8 @@ error: implementation of `FnOnce` is not general enough LL | take_foo(|a| a); | ^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough | - = note: closure with signature `fn(&'2 i32) -> &i32` must implement `FnOnce<(&'1 i32,)>`, for any lifetime `'1`... - = note: ...but it actually implements `FnOnce<(&'2 i32,)>`, for some specific lifetime `'2` + = note: closure with signature `fn(&'0 i32) -> &i32` must implement `FnOnce<(&'1 i32,)>`, for any two lifetimes `'0` and `'1`... + = note: ...but it actually implements `FnOnce<(&i32,)>` error: implementation of `Fn` is not general enough --> $DIR/issue-79187-2.rs:8:5 @@ -31,8 +31,8 @@ error: implementation of `Fn` is not general enough LL | take_foo(|a| a); | ^^^^^^^^^^^^^^^ implementation of `Fn` is not general enough | - = note: closure with signature `fn(&'2 i32) -> &i32` must implement `Fn<(&'1 i32,)>`, for any lifetime `'1`... - = note: ...but it actually implements `Fn<(&'2 i32,)>`, for some specific lifetime `'2` + = note: closure with signature `fn(&'0 i32) -> &i32` must implement `Fn<(&'1 i32,)>`, for any two lifetimes `'0` and `'1`... + = note: ...but it actually implements `Fn<(&i32,)>` error[E0308]: mismatched types --> $DIR/issue-79187-2.rs:11:5 diff --git a/tests/ui/lifetimes/issue-79187.stderr b/tests/ui/lifetimes/issue-79187.stderr index 8adde8d6dfbf3..13731ebf43aa5 100644 --- a/tests/ui/lifetimes/issue-79187.stderr +++ b/tests/ui/lifetimes/issue-79187.stderr @@ -4,8 +4,8 @@ error: implementation of `FnOnce` is not general enough LL | thing(f); | ^^^^^^^^ implementation of `FnOnce` is not general enough | - = note: closure with signature `fn(&'2 u32)` must implement `FnOnce<(&'1 u32,)>`, for any lifetime `'1`... - = note: ...but it actually implements `FnOnce<(&'2 u32,)>`, for some specific lifetime `'2` + = note: closure with signature `fn(&'0 u32)` must implement `FnOnce<(&'1 u32,)>`, for any two lifetimes `'0` and `'1`... + = note: ...but it actually implements `FnOnce<(&u32,)>` error: implementation of `FnOnce` is not general enough --> $DIR/issue-79187.rs:5:5 @@ -13,8 +13,8 @@ error: implementation of `FnOnce` is not general enough LL | thing(f); | ^^^^^^^^ implementation of `FnOnce` is not general enough | - = note: closure with signature `fn(&'2 u32)` must implement `FnOnce<(&'1 u32,)>`, for any lifetime `'1`... - = note: ...but it actually implements `FnOnce<(&'2 u32,)>`, for some specific lifetime `'2` + = note: closure with signature `fn(&'0 u32)` must implement `FnOnce<(&'1 u32,)>`, for any two lifetimes `'0` and `'1`... + = note: ...but it actually implements `FnOnce<(&u32,)>` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: aborting due to 2 previous errors diff --git a/tests/ui/lifetimes/lifetime-errors/issue_74400.stderr b/tests/ui/lifetimes/lifetime-errors/issue_74400.stderr index 4dada6ff014ad..80a2387b384c6 100644 --- a/tests/ui/lifetimes/lifetime-errors/issue_74400.stderr +++ b/tests/ui/lifetimes/lifetime-errors/issue_74400.stderr @@ -48,8 +48,8 @@ error: implementation of `Fn` is not general enough LL | f(data, identity) | ^^^^^^^^^^^^^^^^^ implementation of `Fn` is not general enough | - = note: `fn(&'2 T) -> &'2 T {identity::<&'2 T>}` must implement `Fn<(&'1 T,)>`, for any lifetime `'1`... - = note: ...but it actually implements `Fn<(&'2 T,)>`, for some specific lifetime `'2` + = note: `fn(&'0 T) -> &'0 T {identity::<&'0 T>}` must implement `Fn<(&'1 T,)>`, for any two lifetimes `'0` and `'1`... + = note: ...but it actually implements `Fn<(&T,)>` error: implementation of `FnOnce` is not general enough --> $DIR/issue_74400.rs:12:5 @@ -57,8 +57,8 @@ error: implementation of `FnOnce` is not general enough LL | f(data, identity) | ^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough | - = note: `fn(&'2 T) -> &'2 T {identity::<&'2 T>}` must implement `FnOnce<(&'1 T,)>`, for any lifetime `'1`... - = note: ...but it actually implements `FnOnce<(&'2 T,)>`, for some specific lifetime `'2` + = note: `fn(&'0 T) -> &'0 T {identity::<&'0 T>}` must implement `FnOnce<(&'1 T,)>`, for any two lifetimes `'0` and `'1`... + = note: ...but it actually implements `FnOnce<(&T,)>` error: aborting due to 5 previous errors diff --git a/tests/ui/mismatched_types/closure-arg-type-mismatch.stderr b/tests/ui/mismatched_types/closure-arg-type-mismatch.stderr index 62e872639671b..4926ab1225d9d 100644 --- a/tests/ui/mismatched_types/closure-arg-type-mismatch.stderr +++ b/tests/ui/mismatched_types/closure-arg-type-mismatch.stderr @@ -69,8 +69,8 @@ error: implementation of `Fn` is not general enough LL | baz(f); | ^^^^^^ implementation of `Fn` is not general enough | - = note: `fn(*mut &'2 u32)` must implement `Fn<(*mut &'1 u32,)>`, for any lifetime `'1`... - = note: ...but it actually implements `Fn<(*mut &'2 u32,)>`, for some specific lifetime `'2` + = note: `fn(*mut &'0 u32)` must implement `Fn<(*mut &'1 u32,)>`, for any two lifetimes `'0` and `'1`... + = note: ...but it actually implements `Fn<(*mut &u32,)>` error: implementation of `FnOnce` is not general enough --> $DIR/closure-arg-type-mismatch.rs:10:5 @@ -78,8 +78,8 @@ error: implementation of `FnOnce` is not general enough LL | baz(f); | ^^^^^^ implementation of `FnOnce` is not general enough | - = note: `fn(*mut &'2 u32)` must implement `FnOnce<(*mut &'1 u32,)>`, for any lifetime `'1`... - = note: ...but it actually implements `FnOnce<(*mut &'2 u32,)>`, for some specific lifetime `'2` + = note: `fn(*mut &'0 u32)` must implement `FnOnce<(*mut &'1 u32,)>`, for any two lifetimes `'0` and `'1`... + = note: ...but it actually implements `FnOnce<(*mut &u32,)>` error: aborting due to 6 previous errors diff --git a/tests/ui/mismatched_types/closure-mismatch.current.stderr b/tests/ui/mismatched_types/closure-mismatch.current.stderr index 378fe83ea89bd..dfdd14b9c59a2 100644 --- a/tests/ui/mismatched_types/closure-mismatch.current.stderr +++ b/tests/ui/mismatched_types/closure-mismatch.current.stderr @@ -4,8 +4,8 @@ error: implementation of `FnOnce` is not general enough LL | baz(|_| ()); | ^^^^^^^^^^^ implementation of `FnOnce` is not general enough | - = note: closure with signature `fn(&'2 ())` must implement `FnOnce<(&'1 (),)>`, for any lifetime `'1`... - = note: ...but it actually implements `FnOnce<(&'2 (),)>`, for some specific lifetime `'2` + = note: closure with signature `fn(&'0 ())` must implement `FnOnce<(&'1 (),)>`, for any two lifetimes `'0` and `'1`... + = note: ...but it actually implements `FnOnce<(&(),)>` error: implementation of `Fn` is not general enough --> $DIR/closure-mismatch.rs:12:5 @@ -13,8 +13,8 @@ error: implementation of `Fn` is not general enough LL | baz(|_| ()); | ^^^^^^^^^^^ implementation of `Fn` is not general enough | - = note: closure with signature `fn(&'2 ())` must implement `Fn<(&'1 (),)>`, for any lifetime `'1`... - = note: ...but it actually implements `Fn<(&'2 (),)>`, for some specific lifetime `'2` + = note: closure with signature `fn(&'0 ())` must implement `Fn<(&'1 (),)>`, for any two lifetimes `'0` and `'1`... + = note: ...but it actually implements `Fn<(&(),)>` error: implementation of `FnOnce` is not general enough --> $DIR/closure-mismatch.rs:16:5 @@ -22,8 +22,8 @@ error: implementation of `FnOnce` is not general enough LL | baz(|x| ()); | ^^^^^^^^^^^ implementation of `FnOnce` is not general enough | - = note: closure with signature `fn(&'2 ())` must implement `FnOnce<(&'1 (),)>`, for any lifetime `'1`... - = note: ...but it actually implements `FnOnce<(&'2 (),)>`, for some specific lifetime `'2` + = note: closure with signature `fn(&'0 ())` must implement `FnOnce<(&'1 (),)>`, for any two lifetimes `'0` and `'1`... + = note: ...but it actually implements `FnOnce<(&(),)>` error: implementation of `Fn` is not general enough --> $DIR/closure-mismatch.rs:16:5 @@ -31,8 +31,8 @@ error: implementation of `Fn` is not general enough LL | baz(|x| ()); | ^^^^^^^^^^^ implementation of `Fn` is not general enough | - = note: closure with signature `fn(&'2 ())` must implement `Fn<(&'1 (),)>`, for any lifetime `'1`... - = note: ...but it actually implements `Fn<(&'2 (),)>`, for some specific lifetime `'2` + = note: closure with signature `fn(&'0 ())` must implement `Fn<(&'1 (),)>`, for any two lifetimes `'0` and `'1`... + = note: ...but it actually implements `Fn<(&(),)>` error: aborting due to 4 previous errors diff --git a/tests/ui/nll/ice-106874.stderr b/tests/ui/nll/ice-106874.stderr index 629570b602ed6..a10697a4a0cfd 100644 --- a/tests/ui/nll/ice-106874.stderr +++ b/tests/ui/nll/ice-106874.stderr @@ -37,8 +37,8 @@ error: implementation of `FnOnce` is not general enough LL | A(B(C::new(D::new(move |st| f(st))))) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough | - = note: closure with signature `fn(&'2 mut V)` must implement `FnOnce<(&'1 mut V,)>`, for any lifetime `'1`... - = note: ...but it actually implements `FnOnce<(&'2 mut V,)>`, for some specific lifetime `'2` + = note: closure with signature `fn(&'0 mut V)` must implement `FnOnce<(&'1 mut V,)>`, for any two lifetimes `'0` and `'1`... + = note: ...but it actually implements `FnOnce<(&mut V,)>` error: implementation of `Fn` is not general enough --> $DIR/ice-106874.rs:8:7 @@ -46,8 +46,8 @@ error: implementation of `Fn` is not general enough LL | A(B(C::new(D::new(move |st| f(st))))) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Fn` is not general enough | - = note: closure with signature `fn(&'2 mut V)` must implement `Fn<(&'1 mut V,)>`, for any lifetime `'1`... - = note: ...but it actually implements `Fn<(&'2 mut V,)>`, for some specific lifetime `'2` + = note: closure with signature `fn(&'0 mut V)` must implement `Fn<(&'1 mut V,)>`, for any two lifetimes `'0` and `'1`... + = note: ...but it actually implements `Fn<(&mut V,)>` error: implementation of `FnOnce` is not general enough --> $DIR/ice-106874.rs:8:7 @@ -55,8 +55,8 @@ error: implementation of `FnOnce` is not general enough LL | A(B(C::new(D::new(move |st| f(st))))) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough | - = note: closure with signature `fn(&'2 mut V)` must implement `FnOnce<(&'1 mut V,)>`, for any lifetime `'1`... - = note: ...but it actually implements `FnOnce<(&'2 mut V,)>`, for some specific lifetime `'2` + = note: closure with signature `fn(&'0 mut V)` must implement `FnOnce<(&'1 mut V,)>`, for any two lifetimes `'0` and `'1`... + = note: ...but it actually implements `FnOnce<(&mut V,)>` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: implementation of `Fn` is not general enough @@ -65,8 +65,8 @@ error: implementation of `Fn` is not general enough LL | A(B(C::new(D::new(move |st| f(st))))) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Fn` is not general enough | - = note: closure with signature `fn(&'2 mut V)` must implement `Fn<(&'1 mut V,)>`, for any lifetime `'1`... - = note: ...but it actually implements `Fn<(&'2 mut V,)>`, for some specific lifetime `'2` + = note: closure with signature `fn(&'0 mut V)` must implement `Fn<(&'1 mut V,)>`, for any two lifetimes `'0` and `'1`... + = note: ...but it actually implements `Fn<(&mut V,)>` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: implementation of `FnOnce` is not general enough @@ -75,8 +75,8 @@ error: implementation of `FnOnce` is not general enough LL | A(B(C::new(D::new(move |st| f(st))))) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough | - = note: closure with signature `fn(&'2 mut V)` must implement `FnOnce<(&'1 mut V,)>`, for any lifetime `'1`... - = note: ...but it actually implements `FnOnce<(&'2 mut V,)>`, for some specific lifetime `'2` + = note: closure with signature `fn(&'0 mut V)` must implement `FnOnce<(&'1 mut V,)>`, for any two lifetimes `'0` and `'1`... + = note: ...but it actually implements `FnOnce<(&mut V,)>` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: implementation of `Fn` is not general enough @@ -85,8 +85,8 @@ error: implementation of `Fn` is not general enough LL | A(B(C::new(D::new(move |st| f(st))))) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Fn` is not general enough | - = note: closure with signature `fn(&'2 mut V)` must implement `Fn<(&'1 mut V,)>`, for any lifetime `'1`... - = note: ...but it actually implements `Fn<(&'2 mut V,)>`, for some specific lifetime `'2` + = note: closure with signature `fn(&'0 mut V)` must implement `Fn<(&'1 mut V,)>`, for any two lifetimes `'0` and `'1`... + = note: ...but it actually implements `Fn<(&mut V,)>` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: aborting due to 10 previous errors diff --git a/tests/ui/nll/issue-57843.stderr b/tests/ui/nll/issue-57843.stderr index eed511460cac7..d73396dc3b763 100644 --- a/tests/ui/nll/issue-57843.stderr +++ b/tests/ui/nll/issue-57843.stderr @@ -4,8 +4,8 @@ error: implementation of `FnOnce` is not general enough LL | Foo(Box::new(|_| ())); | ^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough | - = note: closure with signature `fn(&'2 bool)` must implement `FnOnce<(&'1 bool,)>`, for any lifetime `'1`... - = note: ...but it actually implements `FnOnce<(&'2 bool,)>`, for some specific lifetime `'2` + = note: closure with signature `fn(&'0 bool)` must implement `FnOnce<(&'1 bool,)>`, for any two lifetimes `'0` and `'1`... + = note: ...but it actually implements `FnOnce<(&bool,)>` error: aborting due to 1 previous error diff --git a/tests/ui/nll/issue-69114-static-ty.stderr b/tests/ui/nll/issue-69114-static-ty.stderr index a77ae85162187..d8b09bba4cf20 100644 --- a/tests/ui/nll/issue-69114-static-ty.stderr +++ b/tests/ui/nll/issue-69114-static-ty.stderr @@ -11,6 +11,9 @@ LL | FOO(&n); LL | LL | } | - `n` dropped here while still borrowed + | +note: requirement that the value outlives `'static` introduced here + --> $SRC_DIR/core/src/ops/function.rs:LL:COL error: aborting due to 1 previous error diff --git a/tests/ui/nll/missing-universe-cause-issue-114907.stderr b/tests/ui/nll/missing-universe-cause-issue-114907.stderr index c2e91edd13872..758fe5a9089ee 100644 --- a/tests/ui/nll/missing-universe-cause-issue-114907.stderr +++ b/tests/ui/nll/missing-universe-cause-issue-114907.stderr @@ -4,8 +4,8 @@ error: implementation of `FnOnce` is not general enough LL | accept(callback); | ^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough | - = note: closure with signature `fn(&'2 ())` must implement `FnOnce<(&'1 (),)>`, for any lifetime `'1`... - = note: ...but it actually implements `FnOnce<(&'2 (),)>`, for some specific lifetime `'2` + = note: closure with signature `fn(&'0 ())` must implement `FnOnce<(&'1 (),)>`, for any two lifetimes `'0` and `'1`... + = note: ...but it actually implements `FnOnce<(&(),)>` error: implementation of `FnOnce` is not general enough --> $DIR/missing-universe-cause-issue-114907.rs:33:5 @@ -13,8 +13,8 @@ error: implementation of `FnOnce` is not general enough LL | accept(callback); | ^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough | - = note: closure with signature `fn(&'2 ())` must implement `FnOnce<(&'1 (),)>`, for any lifetime `'1`... - = note: ...but it actually implements `FnOnce<(&'2 (),)>`, for some specific lifetime `'2` + = note: closure with signature `fn(&'0 ())` must implement `FnOnce<(&'1 (),)>`, for any two lifetimes `'0` and `'1`... + = note: ...but it actually implements `FnOnce<(&(),)>` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: implementation of `FnOnce` is not general enough @@ -23,8 +23,8 @@ error: implementation of `FnOnce` is not general enough LL | accept(callback); | ^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough | - = note: closure with signature `fn(&'2 ())` must implement `FnOnce<(&'1 (),)>`, for any lifetime `'1`... - = note: ...but it actually implements `FnOnce<(&'2 (),)>`, for some specific lifetime `'2` + = note: closure with signature `fn(&'0 ())` must implement `FnOnce<(&'1 (),)>`, for any two lifetimes `'0` and `'1`... + = note: ...but it actually implements `FnOnce<(&(),)>` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: implementation of `FnOnce` is not general enough @@ -33,8 +33,8 @@ error: implementation of `FnOnce` is not general enough LL | accept(callback); | ^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough | - = note: closure with signature `fn(&'2 ())` must implement `FnOnce<(&'1 (),)>`, for any lifetime `'1`... - = note: ...but it actually implements `FnOnce<(&'2 (),)>`, for some specific lifetime `'2` + = note: closure with signature `fn(&'0 ())` must implement `FnOnce<(&'1 (),)>`, for any two lifetimes `'0` and `'1`... + = note: ...but it actually implements `FnOnce<(&(),)>` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: higher-ranked subtype error diff --git a/tests/ui/nll/polonius/location-insensitive-scopes-issue-117146.nll.stderr b/tests/ui/nll/polonius/location-insensitive-scopes-issue-117146.nll.stderr index 804b3f00a2642..0a0c0f829fffa 100644 --- a/tests/ui/nll/polonius/location-insensitive-scopes-issue-117146.nll.stderr +++ b/tests/ui/nll/polonius/location-insensitive-scopes-issue-117146.nll.stderr @@ -30,8 +30,8 @@ error: implementation of `Fn` is not general enough LL | bad(&b); | ^^^^^^^ implementation of `Fn` is not general enough | - = note: closure with signature `fn(&'2 ()) -> &()` must implement `Fn<(&'1 (),)>`, for any lifetime `'1`... - = note: ...but it actually implements `Fn<(&'2 (),)>`, for some specific lifetime `'2` + = note: closure with signature `fn(&'0 ()) -> &()` must implement `Fn<(&'1 (),)>`, for any two lifetimes `'0` and `'1`... + = note: ...but it actually implements `Fn<(&(),)>` error: implementation of `FnOnce` is not general enough --> $DIR/location-insensitive-scopes-issue-117146.rs:13:5 @@ -39,8 +39,8 @@ error: implementation of `FnOnce` is not general enough LL | bad(&b); | ^^^^^^^ implementation of `FnOnce` is not general enough | - = note: closure with signature `fn(&'2 ()) -> &()` must implement `FnOnce<(&'1 (),)>`, for any lifetime `'1`... - = note: ...but it actually implements `FnOnce<(&'2 (),)>`, for some specific lifetime `'2` + = note: closure with signature `fn(&'0 ()) -> &()` must implement `FnOnce<(&'1 (),)>`, for any two lifetimes `'0` and `'1`... + = note: ...but it actually implements `FnOnce<(&(),)>` error: aborting due to 3 previous errors diff --git a/tests/ui/nll/polonius/location-insensitive-scopes-issue-117146.polonius.stderr b/tests/ui/nll/polonius/location-insensitive-scopes-issue-117146.polonius.stderr index 804b3f00a2642..0a0c0f829fffa 100644 --- a/tests/ui/nll/polonius/location-insensitive-scopes-issue-117146.polonius.stderr +++ b/tests/ui/nll/polonius/location-insensitive-scopes-issue-117146.polonius.stderr @@ -30,8 +30,8 @@ error: implementation of `Fn` is not general enough LL | bad(&b); | ^^^^^^^ implementation of `Fn` is not general enough | - = note: closure with signature `fn(&'2 ()) -> &()` must implement `Fn<(&'1 (),)>`, for any lifetime `'1`... - = note: ...but it actually implements `Fn<(&'2 (),)>`, for some specific lifetime `'2` + = note: closure with signature `fn(&'0 ()) -> &()` must implement `Fn<(&'1 (),)>`, for any two lifetimes `'0` and `'1`... + = note: ...but it actually implements `Fn<(&(),)>` error: implementation of `FnOnce` is not general enough --> $DIR/location-insensitive-scopes-issue-117146.rs:13:5 @@ -39,8 +39,8 @@ error: implementation of `FnOnce` is not general enough LL | bad(&b); | ^^^^^^^ implementation of `FnOnce` is not general enough | - = note: closure with signature `fn(&'2 ()) -> &()` must implement `FnOnce<(&'1 (),)>`, for any lifetime `'1`... - = note: ...but it actually implements `FnOnce<(&'2 (),)>`, for some specific lifetime `'2` + = note: closure with signature `fn(&'0 ()) -> &()` must implement `FnOnce<(&'1 (),)>`, for any two lifetimes `'0` and `'1`... + = note: ...but it actually implements `FnOnce<(&(),)>` error: aborting due to 3 previous errors diff --git a/tests/ui/nll/ty-outlives/projection-where-clause-none.rs b/tests/ui/nll/ty-outlives/projection-where-clause-none.rs index bb201e5c0754c..3e518695d7761 100644 --- a/tests/ui/nll/ty-outlives/projection-where-clause-none.rs +++ b/tests/ui/nll/ty-outlives/projection-where-clause-none.rs @@ -11,7 +11,7 @@ fn foo<'a, T>() -> &'a () where T: MyTrait<'a>, { - bar::() //~ ERROR the parameter type `T` may not live long enough + bar::() //~ ERROR the associated type `>::Output` may not live long enough } fn bar<'a, T>() -> &'a () diff --git a/tests/ui/nll/ty-outlives/projection-where-clause-none.stderr b/tests/ui/nll/ty-outlives/projection-where-clause-none.stderr index b4136be36d315..8aa8a1dadea97 100644 --- a/tests/ui/nll/ty-outlives/projection-where-clause-none.stderr +++ b/tests/ui/nll/ty-outlives/projection-where-clause-none.stderr @@ -1,16 +1,16 @@ -error[E0309]: the parameter type `T` may not live long enough +error[E0309]: the associated type `>::Output` may not live long enough --> $DIR/projection-where-clause-none.rs:14:5 | LL | fn foo<'a, T>() -> &'a () - | -- the parameter type `T` must be valid for the lifetime `'a` as defined here... + | -- the associated type `>::Output` must be valid for the lifetime `'a` as defined here... ... LL | bar::() - | ^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds + | ^^^^^^^^^^^^^^^^ ...so that the type `>::Output` will meet its required lifetime bounds | help: consider adding an explicit lifetime bound | -LL | T: MyTrait<'a> + 'a, - | ++++ +LL | T: MyTrait<'a>, >::Output: 'a + | ++++++++++++++++++++++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/rfcs/rfc-1623-static/rfc1623-2.stderr b/tests/ui/rfcs/rfc-1623-static/rfc1623-2.stderr index 5c98a9d4fb4ce..d49c4d2cf54ca 100644 --- a/tests/ui/rfcs/rfc-1623-static/rfc1623-2.stderr +++ b/tests/ui/rfcs/rfc-1623-static/rfc1623-2.stderr @@ -4,8 +4,8 @@ error: implementation of `Fn` is not general enough LL | f: &id, | ^^^ implementation of `Fn` is not general enough | - = note: `fn(&'2 Foo<'_>) -> &'2 Foo<'_> {id::<&'2 Foo<'_>>}` must implement `Fn<(&'1 Foo<'b>,)>`, for any lifetime `'1`... - = note: ...but it actually implements `Fn<(&'2 Foo<'_>,)>`, for some specific lifetime `'2` + = note: `fn(&'0 Foo<'_>) -> &'0 Foo<'_> {id::<&'0 Foo<'_>>}` must implement `Fn<(&'1 Foo<'b>,)>`, for any two lifetimes `'0` and `'1`... + = note: ...but it actually implements `Fn<(&Foo<'_>,)>` error: implementation of `Fn` is not general enough --> $DIR/rfc1623-2.rs:28:8 @@ -13,8 +13,8 @@ error: implementation of `Fn` is not general enough LL | f: &id, | ^^^ implementation of `Fn` is not general enough | - = note: `fn(&Foo<'2>) -> &Foo<'2> {id::<&Foo<'2>>}` must implement `Fn<(&'a Foo<'1>,)>`, for any lifetime `'1`... - = note: ...but it actually implements `Fn<(&Foo<'2>,)>`, for some specific lifetime `'2` + = note: `fn(&Foo<'0>) -> &Foo<'0> {id::<&Foo<'0>>}` must implement `Fn<(&'a Foo<'1>,)>`, for any two lifetimes `'0` and `'1`... + = note: ...but it actually implements `Fn<(&Foo<'_>,)>` error: implementation of `FnOnce` is not general enough --> $DIR/rfc1623-2.rs:28:8 @@ -22,8 +22,8 @@ error: implementation of `FnOnce` is not general enough LL | f: &id, | ^^^ implementation of `FnOnce` is not general enough | - = note: `fn(&'2 Foo<'_>) -> &'2 Foo<'_> {id::<&'2 Foo<'_>>}` must implement `FnOnce<(&'1 Foo<'b>,)>`, for any lifetime `'1`... - = note: ...but it actually implements `FnOnce<(&'2 Foo<'_>,)>`, for some specific lifetime `'2` + = note: `fn(&'0 Foo<'_>) -> &'0 Foo<'_> {id::<&'0 Foo<'_>>}` must implement `FnOnce<(&'1 Foo<'b>,)>`, for any two lifetimes `'0` and `'1`... + = note: ...but it actually implements `FnOnce<(&Foo<'_>,)>` error: implementation of `FnOnce` is not general enough --> $DIR/rfc1623-2.rs:28:8 @@ -31,8 +31,8 @@ error: implementation of `FnOnce` is not general enough LL | f: &id, | ^^^ implementation of `FnOnce` is not general enough | - = note: `fn(&Foo<'2>) -> &Foo<'2> {id::<&Foo<'2>>}` must implement `FnOnce<(&'a Foo<'1>,)>`, for any lifetime `'1`... - = note: ...but it actually implements `FnOnce<(&Foo<'2>,)>`, for some specific lifetime `'2` + = note: `fn(&Foo<'0>) -> &Foo<'0> {id::<&Foo<'0>>}` must implement `FnOnce<(&'a Foo<'1>,)>`, for any two lifetimes `'0` and `'1`... + = note: ...but it actually implements `FnOnce<(&Foo<'_>,)>` error: aborting due to 4 previous errors diff --git a/tests/ui/traits/associated_type_bound/check-trait-object-bounds-3.stderr b/tests/ui/traits/associated_type_bound/check-trait-object-bounds-3.stderr index 77072656c3366..9266fffdbabb4 100644 --- a/tests/ui/traits/associated_type_bound/check-trait-object-bounds-3.stderr +++ b/tests/ui/traits/associated_type_bound/check-trait-object-bounds-3.stderr @@ -11,6 +11,12 @@ LL | z = f::>(&s); LL | LL | } | - `s` dropped here while still borrowed + | +note: requirement that the value outlives `'static` introduced here + --> $DIR/check-trait-object-bounds-3.rs:7:13 + | +LL | fn f<'a, T: X<'a> + ?Sized>(s: &'a str) -> &'static str { + | ^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/unboxed-closures/issue-30906.stderr b/tests/ui/unboxed-closures/issue-30906.stderr index 0815ae1fb5a2b..29a0a8317040e 100644 --- a/tests/ui/unboxed-closures/issue-30906.stderr +++ b/tests/ui/unboxed-closures/issue-30906.stderr @@ -4,8 +4,8 @@ error: implementation of `FnOnce` is not general enough LL | test(Compose(f, |_| {})); | ^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough | - = note: `fn(&'2 str) -> T` must implement `FnOnce<(&'1 str,)>`, for any lifetime `'1`... - = note: ...but it actually implements `FnOnce<(&'2 str,)>`, for some specific lifetime `'2` + = note: `fn(&'0 str) -> T` must implement `FnOnce<(&'1 str,)>`, for any two lifetimes `'0` and `'1`... + = note: ...but it actually implements `FnOnce<(&str,)>` error: aborting due to 1 previous error