summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Hodge <tpg@ucc.asn.au>2019-01-04 22:03:41 +0800
committerJohn Hodge <tpg@ucc.asn.au>2019-01-04 22:03:41 +0800
commitd681c0cfa1077e4646a292695b6a7426f2056414 (patch)
treed1b403908d327e324b67bd8255929f268969fc88 /src
parentfe650f59cddee21a86b1697c6db6b6e1ab89ecaf (diff)
downloadmrust-d681c0cfa1077e4646a292695b6a7426f2056414.tar.gz
Typecheck Expressions - Short-circuit wildcard pattern matches
Diffstat (limited to 'src')
-rw-r--r--src/hir_typeck/expr_cs.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/hir_typeck/expr_cs.cpp b/src/hir_typeck/expr_cs.cpp
index 301c5d54..a0634022 100644
--- a/src/hir_typeck/expr_cs.cpp
+++ b/src/hir_typeck/expr_cs.cpp
@@ -3835,6 +3835,12 @@ void Context::handle_pattern(const Span& sp, ::HIR::Pattern& pat, const ::HIR::T
}
}
+ // For `_` patterns, there's nothing to match, so they just succeed with no derefs
+ if( pattern.m_data.is_Any() )
+ {
+ return true;
+ }
+
// If the type is a borrow, then count derefs required for the borrow
// - If the first non-borrow inner is an ivar, return false
unsigned n_deref = 0;