]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_mir_build/hair/pattern/const_to_pat.rs
Add issue number to novel violation warning
[rust.git] / src / librustc_mir_build / hair / pattern / const_to_pat.rs
index 9e3f75fdc078c41fffc64006e2b9821a7bc20b7a..1aed8e844b60b02f261b2b3e27fddbe7be608ae2 100644 (file)
@@ -80,7 +80,7 @@ fn search_for_structural_match_violation(
     }
 
     fn type_marked_structural(&self, ty: Ty<'tcx>) -> bool {
-        traits::type_marked_structural(self.id, self.span, &self.infcx, ty)
+        ty.is_structural_eq_shallow(self.infcx.tcx)
     }
 
     fn to_pat(
@@ -107,8 +107,15 @@ fn to_pat(
                 cv.ty, structural
             );
 
+            // This can occur because const qualification treats all associated constants as
+            // opaque, whereas `search_for_structural_match_violation` tries to monomorphize them
+            // before it runs.
+            //
+            // FIXME(#73448): Find a way to bring const qualification into parity with
+            // `search_for_structural_match_violation`.
             if structural.is_none() && mir_structural_match_violation {
-                bug!("MIR const-checker found novel structural match violation");
+                warn!("MIR const-checker found novel structural match violation. See #73448.");
+                return inlined_const_as_pat;
             }
 
             if let Some(non_sm_ty) = structural {
@@ -130,6 +137,9 @@ fn to_pat(
                     traits::NonStructuralMatchTy::Generator => {
                         "generators cannot be used in patterns".to_string()
                     }
+                    traits::NonStructuralMatchTy::Closure => {
+                        "closures cannot be used in patterns".to_string()
+                    }
                     traits::NonStructuralMatchTy::Param => {
                         bug!("use of a constant whose type is a parameter inside a pattern")
                     }