mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-28 14:03:35 +00:00
Support enum in memory map patch address
This commit is contained in:
parent
31c30933cf
commit
021802c59c
2 changed files with 26 additions and 5 deletions
|
@ -2441,14 +2441,14 @@ fn const_loop() {
|
|||
fn const_transfer_memory() {
|
||||
check_number(
|
||||
r#"
|
||||
//- minicore: slice, index, coerce_unsized
|
||||
//- minicore: slice, index, coerce_unsized, option
|
||||
const A1: &i32 = &1;
|
||||
const A2: &i32 = &10;
|
||||
const A3: [&i32; 3] = [&1, &2, &100];
|
||||
const A4: (i32, &i32) = (1, &1000);
|
||||
const GOAL: i32 = *A1 + *A2 + *A3[2] + *A4.1;
|
||||
const A4: (i32, &i32, Option<&i32>) = (1, &1000, Some(&10000));
|
||||
const GOAL: i32 = *A1 + *A2 + *A3[2] + *A4.1 + *A4.2.unwrap_or(&5);
|
||||
"#,
|
||||
1111,
|
||||
11111,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -2007,7 +2007,28 @@ impl Evaluator<'_> {
|
|||
}
|
||||
}
|
||||
AdtId::UnionId(_) => (),
|
||||
AdtId::EnumId(_) => (),
|
||||
AdtId::EnumId(e) => {
|
||||
if let Some((variant, layout)) = detect_variant_from_bytes(
|
||||
&layout,
|
||||
self.db,
|
||||
self.trait_env.clone(),
|
||||
self.read_memory(addr, layout.size.bytes_usize())?,
|
||||
e,
|
||||
) {
|
||||
let ev = EnumVariantId { parent: e, local_id: variant };
|
||||
for (i, (_, ty)) in self.db.field_types(ev.into()).iter().enumerate() {
|
||||
let offset = layout.fields.offset(i).bytes_usize();
|
||||
let ty = ty.clone().substitute(Interner, subst);
|
||||
self.patch_addresses(
|
||||
patch_map,
|
||||
old_vtable,
|
||||
addr.offset(offset),
|
||||
&ty,
|
||||
locals,
|
||||
)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
TyKind::Tuple(_, subst) => {
|
||||
for (id, ty) in subst.iter(Interner).enumerate() {
|
||||
|
|
Loading…
Reference in a new issue