about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc_trait_selection/traits/structural_match.rs21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/librustc_trait_selection/traits/structural_match.rs b/src/librustc_trait_selection/traits/structural_match.rs
index 9bd1334bc8e..da207cf7d38 100644
--- a/src/librustc_trait_selection/traits/structural_match.rs
+++ b/src/librustc_trait_selection/traits/structural_match.rs
@@ -187,8 +187,7 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for Search<'a, 'tcx> {
             | ty::Uint(_)
             | ty::Float(_)
             | ty::Str
-            | ty::Never
-            | ty::Error => {
+            | ty::Never => {
                 // These primitive types are always structural match.
                 //
                 // `Never` is kind of special here, but as it is not inhabitable, this should be fine.
@@ -200,17 +199,25 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for Search<'a, 'tcx> {
             | ty::Ref(..)
             | ty::Closure(..)
             | ty::Generator(..)
-            | ty::GeneratorWitness(..)
             | ty::Tuple(..)
             | ty::Projection(..)
-            | ty::UnnormalizedProjection(..)
             | ty::Opaque(..)
-            | ty::Bound(..)
-            | ty::Placeholder(_)
-            | ty::Infer(_) => {
+            | ty::GeneratorWitness(..) => {
                 ty.super_visit_with(self);
                 return false;
             }
+            | ty::Infer(_)
+            | ty::Placeholder(_)
+            | ty::UnnormalizedProjection(..)
+            | ty::Bound(..) => {
+                bug!("unexpected type during structural-match checking: {:?}", ty);
+            }
+            ty::Error => {
+                self.tcx().delay_span_bug(self.span, "ty::Error in structural-match check");
+                // We still want to check other types after encountering an error,
+                // as this may still emit relevant errors.
+                return false;
+            }
         };
 
         if !self.seen.insert(adt_def.did) {