about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2022-01-27 14:19:54 +0000
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2022-02-02 15:40:11 +0000
commit94d6a9acc91b9eab01e0815d0683cf2764a543ff (patch)
treed009e8b3c9bd0df5150deac1092cd23a855f47f8
parent3146c961fe3c11271313c227aecc610db90a8555 (diff)
downloadrust-94d6a9acc91b9eab01e0815d0683cf2764a543ff.tar.gz
rust-94d6a9acc91b9eab01e0815d0683cf2764a543ff.zip
This can't happen anymore. An opaque type can't end up with itself as its hidden type
-rw-r--r--compiler/rustc_borrowck/src/type_check/mod.rs41
1 files changed, 4 insertions, 37 deletions
diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs
index eb9d16e01dd..900ee2455ef 100644
--- a/compiler/rustc_borrowck/src/type_check/mod.rs
+++ b/compiler/rustc_borrowck/src/type_check/mod.rs
@@ -193,9 +193,9 @@ pub(crate) fn type_check<'mir, 'tcx>(
             let opaque_type_values =
                 infcx.inner.borrow_mut().opaque_type_storage.take_opaque_types();
 
-            let opaque_type_values = opaque_type_values
+            opaque_type_values
                 .into_iter()
-                .filter_map(|(opaque_type_key, decl)| {
+                .map(|(opaque_type_key, decl)| {
                     cx.fully_perform_op(
                         Locations::All(body.span),
                         ConstraintCategory::OpaqueType,
@@ -226,43 +226,10 @@ pub(crate) fn type_check<'mir, 'tcx>(
                         );
                         hidden_type = infcx.tcx.ty_error();
                     }
-                    let concrete_is_opaque = if let ty::Opaque(def_id, _) = hidden_type.kind() {
-                        *def_id == opaque_type_key.def_id
-                    } else {
-                        false
-                    };
 
-                    if concrete_is_opaque {
-                        // We're using an opaque `impl Trait` type without
-                        // 'revealing' it. For example, code like this:
-                        //
-                        // type Foo = impl Debug;
-                        // fn foo1() -> Foo { ... }
-                        // fn foo2() -> Foo { foo1() }
-                        //
-                        // In `foo2`, we're not revealing the type of `Foo` - we're
-                        // just treating it as the opaque type.
-                        //
-                        // When this occurs, we do *not* want to try to equate
-                        // the concrete type with the underlying defining type
-                        // of the opaque type - this will always fail, since
-                        // the defining type of an opaque type is always
-                        // some other type (e.g. not itself)
-                        // Essentially, none of the normal obligations apply here -
-                        // we're just passing around some unknown opaque type,
-                        // without actually looking at the underlying type it
-                        // gets 'revealed' into
-                        debug!(
-                            "eq_opaque_type_and_type: non-defining use of {:?}",
-                            opaque_type_key.def_id,
-                        );
-                        None
-                    } else {
-                        Some((opaque_type_key, (hidden_type, decl.hidden_type.span, decl.origin)))
-                    }
+                    (opaque_type_key, (hidden_type, decl.hidden_type.span, decl.origin))
                 })
-                .collect();
-            opaque_type_values
+                .collect()
         },
     );