]> git.lizzy.rs Git - rust.git/commitdiff
Add exceptions for ExprKind::Err/TyKind::Error.
authorMazdak Farrokhzad <twingoow@gmail.com>
Wed, 24 Jul 2019 02:01:12 +0000 (04:01 +0200)
committerMazdak Farrokhzad <twingoow@gmail.com>
Sun, 28 Jul 2019 04:53:39 +0000 (06:53 +0200)
src/librustc_passes/ast_validation.rs
src/librustc_typeck/check/_match.rs

index b550029d9786d33bdc962ac0e3f718825d2525df..473ba21c77b6d26605a9556513336286a4d1cabb 100644 (file)
@@ -287,7 +287,7 @@ fn no_questions_in_bounds(&self, bounds: &GenericBounds, where_: &str, is_trait:
     // ```
     fn check_expr_within_pat(&self, expr: &Expr, allow_paths: bool) {
         match expr.node {
-            ExprKind::Lit(..) => {}
+            ExprKind::Lit(..) | ExprKind::Err => {}
             ExprKind::Path(..) if allow_paths => {}
             ExprKind::Unary(UnOp::Neg, ref inner)
                 if match inner.node { ExprKind::Lit(_) => true, _ => false } => {}
index 3f0604b84b7d723029cd8cdae8aef45f4e90edd3..defa6fe4ce15e7f31c5e9ad2f5aff48b1b337bc7 100644 (file)
@@ -196,7 +196,11 @@ pub fn check_pat_walk(
                 let rhs_ty = self.check_expr(end);
 
                 // Check that both end-points are of numeric or char type.
-                let numeric_or_char = |ty: Ty<'_>| ty.is_numeric() || ty.is_char();
+                let numeric_or_char = |ty: Ty<'_>| {
+                    ty.is_numeric()
+                    || ty.is_char()
+                    || ty.references_error()
+                };
                 let lhs_compat = numeric_or_char(lhs_ty);
                 let rhs_compat = numeric_or_char(rhs_ty);