diff options
| author | Stuart Cook <Zalathar@users.noreply.github.com> | 2025-08-19 14:18:22 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-19 14:18:22 +1000 |
| commit | f3f1847e40f0b33dcf7bee55af49054f7ec1875c (patch) | |
| tree | 64d26abe6acd78b4695e8a3e1b5f8ee82e84c432 /tests/ui | |
| parent | 181480d5c40e5bbff1bd05c90951457b3f0449ee (diff) | |
| parent | 3ebf611005370734ddf7ce22e41ac502e4fff59a (diff) | |
| download | rust-f3f1847e40f0b33dcf7bee55af49054f7ec1875c.tar.gz rust-f3f1847e40f0b33dcf7bee55af49054f7ec1875c.zip | |
Rollup merge of #145041 - lcnr:borrowck-limitations-error, r=BoxyUwU
rework GAT borrowck limitation error The old one depends on the `ConstraintCategory` of the constraint which meant we did not emit this note if we had to prove the higher ranked trait bound due to e.g. normalization. This made it annoying brittle and caused MIR borrowck errors to be order dependent, fixes the issue in https://github.com/rust-lang/rust/pull/140737#discussion_r2259592651. r? types cc ```@amandasystems```
Diffstat (limited to 'tests/ui')
19 files changed, 60 insertions, 44 deletions
diff --git a/tests/ui/borrowck/implementation-not-general-enough-ice-133252.stderr b/tests/ui/borrowck/implementation-not-general-enough-ice-133252.stderr index 4ec4d2138db..5389226f7a7 100644 --- a/tests/ui/borrowck/implementation-not-general-enough-ice-133252.stderr +++ b/tests/ui/borrowck/implementation-not-general-enough-ice-133252.stderr @@ -22,12 +22,6 @@ LL | force_send(async_load(¬_static)); ... LL | } | - `not_static` dropped here while still borrowed - | -note: due to current limitations in the borrow checker, this implies a `'static` lifetime - --> $DIR/implementation-not-general-enough-ice-133252.rs:16:18 - | -LL | fn force_send<T: Send>(_: T) {} - | ^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/generic-associated-types/bugs/hrtb-implied-1.stderr b/tests/ui/generic-associated-types/bugs/hrtb-implied-1.stderr index 5dfc42bc873..8bb72833e30 100644 --- a/tests/ui/generic-associated-types/bugs/hrtb-implied-1.stderr +++ b/tests/ui/generic-associated-types/bugs/hrtb-implied-1.stderr @@ -9,11 +9,11 @@ LL | print_items::<WindowsMut<'_>>(windows); 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 +note: due to a current limitation of the type system, this implies a `'static` lifetime + --> $DIR/hrtb-implied-1.rs:26:5 | LL | for<'a> I::Item<'a>: Debug, - | ^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/generic-associated-types/bugs/hrtb-implied-2.stderr b/tests/ui/generic-associated-types/bugs/hrtb-implied-2.stderr index 9a1a09b29df..1a397f6cdb2 100644 --- a/tests/ui/generic-associated-types/bugs/hrtb-implied-2.stderr +++ b/tests/ui/generic-associated-types/bugs/hrtb-implied-2.stderr @@ -15,7 +15,11 @@ LL | let _next = iter2.next(); = note: requirement occurs because of a mutable reference to `Eat<&mut I, F>` = note: mutable references are invariant over their type parameter = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance - = note: due to current limitations in the borrow checker, this implies a `'static` lifetime +note: due to a current limitation of the type system, this implies a `'static` lifetime + --> $DIR/hrtb-implied-2.rs:31:8 + | +LL | F: FnMut(I::Item<'_>), + | ^^^^^^^^^^^^^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/generic-associated-types/bugs/hrtb-implied-3.stderr b/tests/ui/generic-associated-types/bugs/hrtb-implied-3.stderr index 77f363ee87d..aaafcb3b7af 100644 --- a/tests/ui/generic-associated-types/bugs/hrtb-implied-3.stderr +++ b/tests/ui/generic-associated-types/bugs/hrtb-implied-3.stderr @@ -11,11 +11,11 @@ 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 +note: due to a current limitation of the type system, this implies a `'static` lifetime + --> $DIR/hrtb-implied-3.rs:14:5 | LL | for<'a> I::Item<'a>: Sized, - | ^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/generic-associated-types/collectivity-regression.stderr b/tests/ui/generic-associated-types/collectivity-regression.stderr index 1c081ac644a..31349c8eb27 100644 --- a/tests/ui/generic-associated-types/collectivity-regression.stderr +++ b/tests/ui/generic-associated-types/collectivity-regression.stderr @@ -7,7 +7,7 @@ LL | | let _x = x; LL | | }; | |_____^ | -note: due to current limitations in the borrow checker, this implies a `'static` lifetime +note: due to a current limitation of the type system, this implies a `'static` lifetime --> $DIR/collectivity-regression.rs:11:16 | LL | for<'a> T: Get<Value<'a> = ()>, diff --git a/tests/ui/generic-associated-types/extended/lending_iterator.stderr b/tests/ui/generic-associated-types/extended/lending_iterator.stderr index 84f5ed07bda..7af95dc96a1 100644 --- a/tests/ui/generic-associated-types/extended/lending_iterator.stderr +++ b/tests/ui/generic-associated-types/extended/lending_iterator.stderr @@ -12,6 +12,12 @@ error: `Self` does not live long enough | LL | <B as FromLendingIterator<A>>::from_iter(self) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: due to a current limitation of the type system, this implies a `'static` lifetime + --> $DIR/lending_iterator.rs:4:21 + | +LL | fn from_iter<T: for<'x> LendingIterator<Item<'x> = A>>(iter: T) -> Self; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-just-for-static.stderr b/tests/ui/higher-ranked/trait-bounds/hrtb-just-for-static.stderr index 1c077a9b906..697e85dc8c3 100644 --- a/tests/ui/higher-ranked/trait-bounds/hrtb-just-for-static.stderr +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-just-for-static.stderr @@ -15,7 +15,7 @@ LL | fn give_some<'a>() { LL | want_hrtb::<&'a u32>() | ^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static` | -note: due to current limitations in the borrow checker, this implies a `'static` lifetime +note: due to a current limitation of the type system, this implies a `'static` lifetime --> $DIR/hrtb-just-for-static.rs:9:15 | LL | where T : for<'a> Foo<&'a isize> 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 727b9e6bec8..327c0faa482 100644 --- a/tests/ui/higher-ranked/trait-bounds/hrtb-perfect-forwarding.stderr +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-perfect-forwarding.stderr @@ -47,7 +47,7 @@ LL | fn foo_hrtb_bar_not<'b, T>(mut t: T) LL | foo_hrtb_bar_not(&mut t); | ^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'b` must outlive `'static` | -note: due to current limitations in the borrow checker, this implies a `'static` lifetime +note: due to a current limitation of the type system, this implies a `'static` lifetime --> $DIR/hrtb-perfect-forwarding.rs:37:8 | LL | T: for<'a> Foo<&'a isize> + Bar<&'b isize>, diff --git a/tests/ui/implied-bounds/normalization-placeholder-leak.fail.stderr b/tests/ui/implied-bounds/normalization-placeholder-leak.fail.stderr index 8919919d04e..be8b44b1bde 100644 --- a/tests/ui/implied-bounds/normalization-placeholder-leak.fail.stderr +++ b/tests/ui/implied-bounds/normalization-placeholder-leak.fail.stderr @@ -30,6 +30,12 @@ LL | fn test_lifetime<'lt, T: Trait>(_: Foo<&'lt u8>) {} | | | | | lifetime `'lt` defined here | requires that `'lt` must outlive `'static` + | +note: due to a current limitation of the type system, this implies a `'static` lifetime + --> $DIR/normalization-placeholder-leak.rs:19:5 + | +LL | for<'x> T::Ty<'x>: Sized; + | ^^^^^^^^^^^^^^^^^^^^^^^^ error: lifetime may not live long enough --> $DIR/normalization-placeholder-leak.rs:38:5 @@ -39,6 +45,12 @@ LL | fn test_alias<'lt, T: AnotherTrait>(_: Foo<T::Ty2::<'lt>>) {} | | | | | lifetime `'lt` defined here | requires that `'lt` must outlive `'static` + | +note: due to a current limitation of the type system, this implies a `'static` lifetime + --> $DIR/normalization-placeholder-leak.rs:19:5 + | +LL | for<'x> T::Ty<'x>: Sized; + | ^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 6 previous errors diff --git a/tests/ui/issues/issue-26217.stderr b/tests/ui/issues/issue-26217.stderr index 0b153ad7490..a8750567819 100644 --- a/tests/ui/issues/issue-26217.stderr +++ b/tests/ui/issues/issue-26217.stderr @@ -6,11 +6,11 @@ LL | fn bar<'a>() { LL | foo::<&'a i32>(); | ^^^^^^^^^^^^^^ requires that `'a` must outlive `'static` | -note: due to current limitations in the borrow checker, this implies a `'static` lifetime - --> $DIR/issue-26217.rs:1:30 +note: due to a current limitation of the type system, this implies a `'static` lifetime + --> $DIR/issue-26217.rs:1:19 | LL | fn foo<T>() where for<'a> T: 'a {} - | ^^ + | ^^^^^^^^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/lifetimes/issue-105507.fixed b/tests/ui/lifetimes/issue-105507.fixed index 177da01b154..46d4f14a245 100644 --- a/tests/ui/lifetimes/issue-105507.fixed +++ b/tests/ui/lifetimes/issue-105507.fixed @@ -25,8 +25,8 @@ impl<T> 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 + //~^ NOTE due to a current limitation of the type system, this implies a `'static` lifetime + //~| NOTE due to a current limitation of the type system, this implies a `'static` lifetime {} fn require_trait<T: MyTrait>(_: T) {} diff --git a/tests/ui/lifetimes/issue-105507.rs b/tests/ui/lifetimes/issue-105507.rs index 858fa19a029..f1721fee5b4 100644 --- a/tests/ui/lifetimes/issue-105507.rs +++ b/tests/ui/lifetimes/issue-105507.rs @@ -25,8 +25,8 @@ impl<T> 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 + //~^ NOTE due to a current limitation of the type system, this implies a `'static` lifetime + //~| NOTE due to a current limitation of the type system, this implies a `'static` lifetime {} fn require_trait<T: MyTrait>(_: T) {} diff --git a/tests/ui/lifetimes/issue-105507.stderr b/tests/ui/lifetimes/issue-105507.stderr index 44d3a7eb9a4..7fccba7cc44 100644 --- a/tests/ui/lifetimes/issue-105507.stderr +++ b/tests/ui/lifetimes/issue-105507.stderr @@ -4,7 +4,7 @@ error: `T` does not live long enough LL | require_trait(wrap); | ^^^^^^^^^^^^^^^^^^^ | -note: due to current limitations in the borrow checker, this implies a `'static` lifetime +note: due to a current limitation of the type system, this implies a `'static` lifetime --> $DIR/issue-105507.rs:27:35 | LL | for<'a> T::Projected<'a>: MyTrait, @@ -20,7 +20,7 @@ error: `U` does not live long enough LL | require_trait(wrap1); | ^^^^^^^^^^^^^^^^^^^^ | -note: due to current limitations in the borrow checker, this implies a `'static` lifetime +note: due to a current limitation of the type system, this implies a `'static` lifetime --> $DIR/issue-105507.rs:27:35 | LL | for<'a> T::Projected<'a>: MyTrait, diff --git a/tests/ui/mismatched_types/closure-arg-type-mismatch.stderr b/tests/ui/mismatched_types/closure-arg-type-mismatch.stderr index abc5d150a3f..62e87263967 100644 --- a/tests/ui/mismatched_types/closure-arg-type-mismatch.stderr +++ b/tests/ui/mismatched_types/closure-arg-type-mismatch.stderr @@ -57,7 +57,7 @@ LL | baz(f); = note: requirement occurs because of a mutable pointer to `&u32` = note: mutable pointers are invariant over their type parameter = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance -note: due to current limitations in the borrow checker, this implies a `'static` lifetime +note: due to a current limitation of the type system, this implies a `'static` lifetime --> $DIR/closure-arg-type-mismatch.rs:8:11 | LL | fn baz<F: Fn(*mut &u32)>(_: F) {} diff --git a/tests/ui/nll/local-outlives-static-via-hrtb.stderr b/tests/ui/nll/local-outlives-static-via-hrtb.stderr index a6b3328b5a2..a98f11ce513 100644 --- a/tests/ui/nll/local-outlives-static-via-hrtb.stderr +++ b/tests/ui/nll/local-outlives-static-via-hrtb.stderr @@ -12,11 +12,11 @@ LL | assert_static_via_hrtb_with_assoc_type(&&local); LL | } | - `local` dropped here while still borrowed | -note: due to current limitations in the borrow checker, this implies a `'static` lifetime - --> $DIR/local-outlives-static-via-hrtb.rs:15:53 +note: due to a current limitation of the type system, this implies a `'static` lifetime + --> $DIR/local-outlives-static-via-hrtb.rs:15:42 | LL | fn assert_static_via_hrtb<G>(_: G) where for<'a> G: Outlives<'a> {} - | ^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^ error[E0597]: `local` does not live long enough --> $DIR/local-outlives-static-via-hrtb.rs:25:45 @@ -32,11 +32,11 @@ LL | assert_static_via_hrtb_with_assoc_type(&&local); LL | } | - `local` dropped here while still borrowed | -note: due to current limitations in the borrow checker, this implies a `'static` lifetime - --> $DIR/local-outlives-static-via-hrtb.rs:19:20 +note: due to a current limitation of the type system, this implies a `'static` lifetime + --> $DIR/local-outlives-static-via-hrtb.rs:19:5 | LL | for<'a> &'a T: Reference<AssociatedType = &'a ()>, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors 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 1d086c658df..6e47b8e59f5 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 @@ -13,11 +13,11 @@ LL | let b = |_| &a; LL | } | - `a` dropped here while still borrowed | -note: due to current limitations in the borrow checker, this implies a `'static` lifetime - --> $DIR/location-insensitive-scopes-issue-117146.rs:20:22 +note: due to a current limitation of the type system, this implies a `'static` lifetime + --> $DIR/location-insensitive-scopes-issue-117146.rs:20:11 | LL | fn bad<F: Fn(&()) -> &()>(_: F) {} - | ^^^ + | ^^^^^^^^^^^^^^ error: implementation of `Fn` is not general enough --> $DIR/location-insensitive-scopes-issue-117146.rs:13:5 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 1d086c658df..6e47b8e59f5 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 @@ -13,11 +13,11 @@ LL | let b = |_| &a; LL | } | - `a` dropped here while still borrowed | -note: due to current limitations in the borrow checker, this implies a `'static` lifetime - --> $DIR/location-insensitive-scopes-issue-117146.rs:20:22 +note: due to a current limitation of the type system, this implies a `'static` lifetime + --> $DIR/location-insensitive-scopes-issue-117146.rs:20:11 | LL | fn bad<F: Fn(&()) -> &()>(_: F) {} - | ^^^ + | ^^^^^^^^^^^^^^ error: implementation of `Fn` is not general enough --> $DIR/location-insensitive-scopes-issue-117146.rs:13:5 diff --git a/tests/ui/nll/type-test-universe.stderr b/tests/ui/nll/type-test-universe.stderr index 31e17d64b8c..54b48c1597b 100644 --- a/tests/ui/nll/type-test-universe.stderr +++ b/tests/ui/nll/type-test-universe.stderr @@ -12,11 +12,11 @@ LL | fn test2<'a>() { LL | outlives_forall::<Value<'a>>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static` | -note: due to current limitations in the borrow checker, this implies a `'static` lifetime - --> $DIR/type-test-universe.rs:6:16 +note: due to a current limitation of the type system, this implies a `'static` lifetime + --> $DIR/type-test-universe.rs:6:5 | LL | for<'u> T: 'u, - | ^^ + | ^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/transmutability/references/reject_lifetime_extension.stderr b/tests/ui/transmutability/references/reject_lifetime_extension.stderr index a597041c6ca..b9702984145 100644 --- a/tests/ui/transmutability/references/reject_lifetime_extension.stderr +++ b/tests/ui/transmutability/references/reject_lifetime_extension.stderr @@ -67,11 +67,11 @@ LL | unsafe { extend_hrtb(src) } | `src` escapes the function body here | argument requires that `'a` must outlive `'static` | -note: due to current limitations in the borrow checker, this implies a `'static` lifetime - --> $DIR/reject_lifetime_extension.rs:85:25 +note: due to a current limitation of the type system, this implies a `'static` lifetime + --> $DIR/reject_lifetime_extension.rs:85:9 | LL | for<'b> &'b u8: TransmuteFrom<&'a u8>, - | ^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 8 previous errors |
