Check the base type of pattern types for validity first
This commit is contained in:
parent
2f2b32b84e
commit
ded0836c18
2 changed files with 5 additions and 6 deletions
|
@ -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 { .. } => {},
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue