about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-07-17 00:14:06 +0200
committerGitHub <noreply@github.com>2023-07-17 00:14:06 +0200
commitb42ada2b1239cc8da00ee6262d3dba8de4fbd44b (patch)
tree4ddf3cb562cd07d1ba5ed02515e4c56c0cd9272f
parent80599b93a48d53c92477f503fd644d80fa9e7eeb (diff)
parentc856c74764006610e23de4210a17dfb7a1702127 (diff)
downloadrust-b42ada2b1239cc8da00ee6262d3dba8de4fbd44b.tar.gz
rust-b42ada2b1239cc8da00ee6262d3dba8de4fbd44b.zip
Rollup merge of #113755 - fmease:probe-adt-norm-lazy-ty-alias, r=oli-obk
Normalize lazy type aliases when probing for ADTs

Fixes #113736.

r? ```@oli-obk```
-rw-r--r--compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs4
-rw-r--r--tests/ui/type-alias/lazy-type-alias-enum-variant.rs17
2 files changed, 20 insertions, 1 deletions
diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs
index 1e8af6c6ed7..6a82b00211e 100644
--- a/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs
+++ b/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs
@@ -302,7 +302,9 @@ impl<'a, 'tcx> AstConv<'tcx> for FnCtxt<'a, 'tcx> {
         match ty.kind() {
             ty::Adt(adt_def, _) => Some(*adt_def),
             // FIXME(#104767): Should we handle bound regions here?
-            ty::Alias(ty::Projection | ty::Inherent, _) if !ty.has_escaping_bound_vars() => {
+            ty::Alias(ty::Projection | ty::Inherent | ty::Weak, _)
+                if !ty.has_escaping_bound_vars() =>
+            {
                 self.normalize(span, ty).ty_adt_def()
             }
             _ => None,
diff --git a/tests/ui/type-alias/lazy-type-alias-enum-variant.rs b/tests/ui/type-alias/lazy-type-alias-enum-variant.rs
new file mode 100644
index 00000000000..78c3159d1c2
--- /dev/null
+++ b/tests/ui/type-alias/lazy-type-alias-enum-variant.rs
@@ -0,0 +1,17 @@
+// Regression test for issue #113736.
+// check-pass
+
+#![feature(lazy_type_alias)]
+
+enum Enum {
+    Unit,
+    Tuple(),
+    Struct {},
+}
+
+fn main() {
+    type Alias = Enum;
+    let _ = Alias::Unit;
+    let _ = Alias::Tuple();
+    let _ = Alias::Struct {};
+}