Stacked Borrows: don't read from memory during retagging
This commit is contained in:
parent
283928ad55
commit
79dd70fd9b
1 changed files with 17 additions and 2 deletions
|
|
@ -222,8 +222,23 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
|||
// This is `Freeze`, there cannot be an `UnsafeCell`
|
||||
Ok(())
|
||||
} else {
|
||||
// Proceed further
|
||||
self.walk_value(v)
|
||||
// We want to not actually read from memory for this visit. So, before
|
||||
// walking this value, we have to make sure it is not a
|
||||
// `Variants::Multiple`.
|
||||
match v.layout.variants {
|
||||
layout::Variants::Multiple { .. } => {
|
||||
// A multi-variant enum, or generator, or so.
|
||||
// Treat this like a union: without reading from memory,
|
||||
// we cannot determine the variant we are in. Reading from
|
||||
// memory would be subject to Stacked Borrows rules, leading
|
||||
// to all sorts of "funny" recursion.
|
||||
self.visit_union(v)
|
||||
}
|
||||
layout::Variants::Single { .. } => {
|
||||
// Proceed further
|
||||
self.walk_value(v)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue