about summary refs log tree commit diff
diff options
context:
space:
mode:
authorlcnr <rust@lcnr.de>2024-02-27 17:13:51 +0100
committerlcnr <rust@lcnr.de>2024-02-27 17:13:51 +0100
commit6591c80eea51bfc019972845c08fdb78f1238760 (patch)
tree8071876031408acd0871059fa7c9d72043e9cc67
parent71d82c2899f5d5a4b5ec8c3be3823bf1509d3bf7 (diff)
downloadrust-6591c80eea51bfc019972845c08fdb78f1238760.tar.gz
rust-6591c80eea51bfc019972845c08fdb78f1238760.zip
use typeck root when checking closure oblig
-rw-r--r--compiler/rustc_hir_analysis/src/check/check.rs4
-rw-r--r--tests/ui/traits/next-solver/normalize-async-closure-in-trait.rs2
-rw-r--r--tests/ui/traits/next-solver/normalize-async-closure-in-trait.stderr15
3 files changed, 4 insertions, 17 deletions
diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs
index 1a3aa95743c..cf42a705236 100644
--- a/compiler/rustc_hir_analysis/src/check/check.rs
+++ b/compiler/rustc_hir_analysis/src/check/check.rs
@@ -1554,6 +1554,8 @@ fn opaque_type_cycle_error(
     err.emit()
 }
 
+// FIXME(@lcnr): This should not be computed per coroutine, but instead once for
+// each typeck root.
 pub(super) fn check_coroutine_obligations(
     tcx: TyCtxt<'_>,
     def_id: LocalDefId,
@@ -1561,7 +1563,7 @@ pub(super) fn check_coroutine_obligations(
     debug_assert!(tcx.is_coroutine(def_id.to_def_id()));
 
     let typeck = tcx.typeck(def_id);
-    let param_env = tcx.param_env(def_id);
+    let param_env = tcx.param_env(typeck.hir_owner.def_id);
 
     let coroutine_interior_predicates = &typeck.coroutine_interior_predicates[&def_id];
     debug!(?coroutine_interior_predicates);
diff --git a/tests/ui/traits/next-solver/normalize-async-closure-in-trait.rs b/tests/ui/traits/next-solver/normalize-async-closure-in-trait.rs
index 968c18cb9f5..8cdde4f4d51 100644
--- a/tests/ui/traits/next-solver/normalize-async-closure-in-trait.rs
+++ b/tests/ui/traits/next-solver/normalize-async-closure-in-trait.rs
@@ -1,5 +1,5 @@
 //@ compile-flags: -Znext-solver
-//@ known-bug: unknown
+//@ check-pass
 //@ edition:2021
 
 trait Foo {
diff --git a/tests/ui/traits/next-solver/normalize-async-closure-in-trait.stderr b/tests/ui/traits/next-solver/normalize-async-closure-in-trait.stderr
deleted file mode 100644
index c10cddd95b5..00000000000
--- a/tests/ui/traits/next-solver/normalize-async-closure-in-trait.stderr
+++ /dev/null
@@ -1,15 +0,0 @@
-error[E0271]: type mismatch resolving `impl Future<Output = ()> == {async fn body@$DIR/normalize-async-closure-in-trait.rs:6:20: 6:22}`
-  --> $DIR/normalize-async-closure-in-trait.rs:6:20
-   |
-LL |     async fn bar() {}
-   |                    ^^ types differ
-
-error[E0271]: type mismatch resolving `{async fn body@$DIR/normalize-async-closure-in-trait.rs:6:20: 6:22} <: impl Future<Output = ()>`
-  --> $DIR/normalize-async-closure-in-trait.rs:6:20
-   |
-LL |     async fn bar() {}
-   |                    ^^ types differ
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0271`.