interpret: refactor projection code to work on a common trait, and use that for visitors
This commit is contained in:
parent
a593de4fab
commit
a2bcafa500
44 changed files with 863 additions and 1210 deletions
|
@ -102,7 +102,7 @@ pub(crate) fn try_destructure_mir_constant_for_diagnostics<'tcx>(
|
|||
}
|
||||
ty::Adt(def, _) => {
|
||||
let variant = ecx.read_discriminant(&op).ok()?.1;
|
||||
let down = ecx.operand_downcast(&op, variant).ok()?;
|
||||
let down = ecx.project_downcast(&op, variant).ok()?;
|
||||
(def.variants()[variant].fields.len(), Some(variant), down)
|
||||
}
|
||||
ty::Tuple(args) => (args.len(), None, op),
|
||||
|
@ -111,7 +111,7 @@ pub(crate) fn try_destructure_mir_constant_for_diagnostics<'tcx>(
|
|||
|
||||
let fields_iter = (0..field_count)
|
||||
.map(|i| {
|
||||
let field_op = ecx.operand_field(&down, i).ok()?;
|
||||
let field_op = ecx.project_field(&down, i).ok()?;
|
||||
let val = op_to_const(&ecx, &field_op);
|
||||
Some((val, field_op.layout.ty))
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue