normalize adt fields during structural match check
This commit is contained in:
parent
4b1f86adbe
commit
29508ce3ad
2 changed files with 28 additions and 1 deletions
|
@ -251,7 +251,11 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for Search<'a, 'tcx> {
|
||||||
// fields of ADT.
|
// fields of ADT.
|
||||||
let tcx = self.tcx();
|
let tcx = self.tcx();
|
||||||
for field_ty in adt_def.all_fields().map(|field| field.ty(tcx, substs)) {
|
for field_ty in adt_def.all_fields().map(|field| field.ty(tcx, substs)) {
|
||||||
if field_ty.visit_with(self) {
|
assert!(!field_ty.needs_subst());
|
||||||
|
let ty = self.tcx().normalize_erasing_regions(ty::ParamEnv::reveal_all(), field_ty);
|
||||||
|
debug!("structural-match ADT: field_ty={:?}, ty={:?}", field_ty, ty);
|
||||||
|
|
||||||
|
if ty.visit_with(self) {
|
||||||
// found an ADT without structural-match; halt visiting!
|
// found an ADT without structural-match; halt visiting!
|
||||||
assert!(self.found.is_some());
|
assert!(self.found.is_some());
|
||||||
return true;
|
return true;
|
||||||
|
|
23
src/test/ui/match/issue-72896.rs
Normal file
23
src/test/ui/match/issue-72896.rs
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
// run-pass
|
||||||
|
trait EnumSetType {
|
||||||
|
type Repr;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum Enum8 { }
|
||||||
|
impl EnumSetType for Enum8 {
|
||||||
|
type Repr = u8;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(PartialEq, Eq)]
|
||||||
|
struct EnumSet<T: EnumSetType> {
|
||||||
|
__enumset_underlying: T::Repr,
|
||||||
|
}
|
||||||
|
|
||||||
|
const CONST_SET: EnumSet<Enum8> = EnumSet { __enumset_underlying: 3 };
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
match CONST_SET {
|
||||||
|
CONST_SET => { /* ok */ }
|
||||||
|
_ => panic!("match fell through?"),
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue