diff options
Diffstat (limited to 'compiler/rustc_const_eval/src/interpret/validity.rs')
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/validity.rs | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/validity.rs b/compiler/rustc_const_eval/src/interpret/validity.rs index 649a759bc8b..8e544798742 100644 --- a/compiler/rustc_const_eval/src/interpret/validity.rs +++ b/compiler/rustc_const_eval/src/interpret/validity.rs @@ -4,7 +4,6 @@ //! That's useful because it means other passes (e.g. promotion) can rely on `const`s //! to be const-safe. -use std::assert_matches::assert_matches; use std::borrow::Cow; use std::fmt::Write; use std::hash::Hash; @@ -1241,15 +1240,15 @@ impl<'rt, 'tcx, M: Machine<'tcx>> ValueVisitor<'tcx, M> for ValidityVisitor<'rt, self.visit_field(val, 0, &self.ecx.project_index(val, 0)?)?; } } - ty::Pat(_base, pat) => { + ty::Pat(base, pat) => { + // First check that the base type is valid + self.visit_value(&val.transmute(self.ecx.layout_of(*base)?, self.ecx)?)?; // When you extend this match, make sure to also add tests to // tests/ui/type/pattern_types/validity.rs(( match **pat { // Range patterns are precisely reflected into `valid_range` and thus // handled fully by `visit_scalar` (called below). - ty::PatternKind::Range { .. } => { - assert_matches!(val.layout.backend_repr, BackendRepr::Scalar(_)); - }, + ty::PatternKind::Range { .. } => {}, } } _ => { |
