about summary refs log tree commit diff
path: root/tests/ui/async-await/higher-ranked-normalize-assumptions-2.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-10-04 00:02:26 +0000
committerbors <bors@rust-lang.org>2025-10-04 00:02:26 +0000
commit7950f244e7ef55b61a83d12f4662be643cd182d6 (patch)
tree6f741b4059ce1061d04ffa47c43658535c62b6f3 /tests/ui/async-await/higher-ranked-normalize-assumptions-2.rs
parent595b9a498bc55fcd30111e430d8e4290ed833b4c (diff)
parente3f104608c0ad26e80b1ebedef2ab8a748189e52 (diff)
downloadrust-7950f244e7ef55b61a83d12f4662be643cd182d6.tar.gz
rust-7950f244e7ef55b61a83d12f4662be643cd182d6.zip
Auto merge of #147299 - compiler-errors:hr-norm, r=jackh726
Don't normalize higher-ranked assumptions if they're not used

See the comment in the code.

Normalizing these assumptions may cause us to register things like new placeholder outlives obligations that cause higher-ranked lifetime errors, and this is problematic if we're not even using these assumptions in borrowck.

Fixes rust-lang/rust#147244
Fixes rust-lang/rust#147285
Diffstat (limited to 'tests/ui/async-await/higher-ranked-normalize-assumptions-2.rs')
-rw-r--r--tests/ui/async-await/higher-ranked-normalize-assumptions-2.rs38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/ui/async-await/higher-ranked-normalize-assumptions-2.rs b/tests/ui/async-await/higher-ranked-normalize-assumptions-2.rs
new file mode 100644
index 00000000000..410d4e503b7
--- /dev/null
+++ b/tests/ui/async-await/higher-ranked-normalize-assumptions-2.rs
@@ -0,0 +1,38 @@
+//@ revisions: stock hr
+//@[hr] compile-flags: -Zhigher-ranked-assumptions
+//@ edition: 2024
+//@ check-pass
+
+// Test that we don't normalize the higher-ranked assumptions of an auto trait goal
+// unless we have `-Zhigher-ranked-assumptions`, since obligations that result from
+// this normalization may lead to higher-ranked lifetime errors when the flag is not
+// enabled.
+
+// Regression test for <https://github.com/rust-lang/rust/issues/147244>.
+
+pub fn a() -> impl Future + Send {
+    async {
+        let queries = core::iter::empty().map(Thing::f);
+        b(queries).await;
+    }
+}
+
+async fn b(queries: impl IntoIterator) {
+    c(queries).await;
+}
+
+fn c<'a, I>(_queries: I) -> impl Future
+where
+    I: IntoIterator,
+    I::IntoIter: 'a,
+{
+    async {}
+}
+
+pub struct Thing<'a>(pub &'a ());
+
+impl Thing<'_> {
+    fn f(_: &Self) {}
+}
+
+fn main() {}