]> git.lizzy.rs Git - rust.git/commitdiff
note for `ty::Error`.
authorBastian Kauschke <bastian_kauschke@hotmail.de>
Tue, 12 May 2020 21:35:29 +0000 (23:35 +0200)
committerBastian Kauschke <bastian_kauschke@hotmail.de>
Wed, 20 May 2020 06:38:16 +0000 (08:38 +0200)
src/librustc_trait_selection/traits/structural_match.rs

index 9bd1334bc8e83cbb2f8e43229318c5c586848200..da207cf7d380416e471ad8a431a513a28eeaa7aa 100644 (file)
@@ -187,8 +187,7 @@ fn visit_ty(&mut self, ty: Ty<'tcx>) -> bool {
             | 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 @@ fn visit_ty(&mut self, ty: Ty<'tcx>) -> bool {
             | 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) {