about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorOli Scherer <github35764891676564198441@oli-obk.de>2021-07-13 15:19:35 +0000
committerOli Scherer <github35764891676564198441@oli-obk.de>2021-07-13 15:19:35 +0000
commit587e8fd11267911599322878fb37c8d185738c9b (patch)
treef87d0cf3dc8d343714a85d845c51a6f42758c52b /compiler
parent95f296db63d58f82a6a96d8b7baf52efaa26b260 (diff)
downloadrust-587e8fd11267911599322878fb37c8d185738c9b.tar.gz
rust-587e8fd11267911599322878fb37c8d185738c9b.zip
Loop over all opaque types instead of looking at just the first one with the same DefId
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_typeck/src/collect/type_of.rs20
1 files changed, 8 insertions, 12 deletions
diff --git a/compiler/rustc_typeck/src/collect/type_of.rs b/compiler/rustc_typeck/src/collect/type_of.rs
index cfe1a2f56f4..7b0002914ec 100644
--- a/compiler/rustc_typeck/src/collect/type_of.rs
+++ b/compiler/rustc_typeck/src/collect/type_of.rs
@@ -542,13 +542,14 @@ fn find_opaque_ty_constraints(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Ty<'_> {
             }
             // Use borrowck to get the type with unerased regions.
             let concrete_opaque_types = &self.tcx.mir_borrowck(def_id).concrete_opaque_types;
-            if let Some((opaque_type_key, concrete_type)) =
-                concrete_opaque_types.iter().find(|(key, _)| key.def_id == self.def_id)
-            {
-                debug!(
-                    "find_opaque_ty_constraints: found constraint for `{:?}` at `{:?}`: {:?}",
-                    self.def_id, def_id, concrete_type,
-                );
+            debug!(?concrete_opaque_types);
+            for (opaque_type_key, concrete_type) in concrete_opaque_types {
+                if opaque_type_key.def_id != self.def_id {
+                    // Ignore constraints for other opaque types.
+                    continue;
+                }
+
+                debug!(?concrete_type, ?opaque_type_key.substs, "found constraint");
 
                 // FIXME(oli-obk): trace the actual span from inference to improve errors.
                 let span = self.tcx.def_span(def_id);
@@ -613,11 +614,6 @@ fn find_opaque_ty_constraints(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Ty<'_> {
                 } else {
                     self.found = Some((span, concrete_type));
                 }
-            } else {
-                debug!(
-                    "find_opaque_ty_constraints: no constraint for `{:?}` at `{:?}`",
-                    self.def_id, def_id,
-                );
             }
         }
     }