|
3 | 3 |
|
4 | 4 | use std::borrow::Cow; |
5 | 5 | use std::cell::RefCell; |
6 | | -use std::rc::Rc; |
7 | 6 | use std::num::NonZeroU64; |
| 7 | +use std::rc::Rc; |
8 | 8 |
|
9 | 9 | use rand::rngs::StdRng; |
10 | 10 |
|
11 | | -use rustc_hir::def_id::DefId; |
12 | 11 | use rustc::mir; |
13 | 12 | use rustc::ty::{ |
14 | 13 | self, |
15 | 14 | layout::{LayoutOf, Size}, |
16 | 15 | Ty, TyCtxt, |
17 | 16 | }; |
18 | | -use rustc_span::{source_map::Span, symbol::sym}; |
19 | 17 | use rustc_ast::attr; |
| 18 | +use rustc_hir::def_id::DefId; |
| 19 | +use rustc_span::{source_map::Span, symbol::sym}; |
20 | 20 |
|
21 | 21 | use crate::*; |
22 | 22 |
|
@@ -85,11 +85,7 @@ impl MemoryExtra { |
85 | 85 | } else { |
86 | 86 | None |
87 | 87 | }; |
88 | | - MemoryExtra { |
89 | | - stacked_borrows, |
90 | | - intptrcast: Default::default(), |
91 | | - rng: RefCell::new(rng), |
92 | | - } |
| 88 | + MemoryExtra { stacked_borrows, intptrcast: Default::default(), rng: RefCell::new(rng) } |
93 | 89 | } |
94 | 90 | } |
95 | 91 |
|
@@ -307,18 +303,15 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'tcx> { |
307 | 303 | ) -> (Cow<'b, Allocation<Self::PointerTag, Self::AllocExtra>>, Self::PointerTag) { |
308 | 304 | let kind = kind.expect("we set our STATIC_KIND so this cannot be None"); |
309 | 305 | let alloc = alloc.into_owned(); |
310 | | - let (stacks, base_tag) = if let Some(stacked_borrows) = memory_extra.stacked_borrows.as_ref() { |
311 | | - let (stacks, base_tag) = Stacks::new_allocation( |
312 | | - id, |
313 | | - alloc.size, |
314 | | - Rc::clone(stacked_borrows), |
315 | | - kind, |
316 | | - ); |
317 | | - (Some(stacks), base_tag) |
318 | | - } else { |
319 | | - // No stacks, no tag. |
320 | | - (None, Tag::Untagged) |
321 | | - }; |
| 306 | + let (stacks, base_tag) = |
| 307 | + if let Some(stacked_borrows) = memory_extra.stacked_borrows.as_ref() { |
| 308 | + let (stacks, base_tag) = |
| 309 | + Stacks::new_allocation(id, alloc.size, Rc::clone(stacked_borrows), kind); |
| 310 | + (Some(stacks), base_tag) |
| 311 | + } else { |
| 312 | + // No stacks, no tag. |
| 313 | + (None, Tag::Untagged) |
| 314 | + }; |
322 | 315 | let mut stacked_borrows = memory_extra.stacked_borrows.as_ref().map(|sb| sb.borrow_mut()); |
323 | 316 | let alloc: Allocation<Tag, Self::AllocExtra> = alloc.with_tags_and_extra( |
324 | 317 | |alloc| { |
@@ -360,14 +353,11 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'tcx> { |
360 | 353 |
|
361 | 354 | #[inline(always)] |
362 | 355 | fn stack_push(ecx: &mut InterpCx<'mir, 'tcx, Self>) -> InterpResult<'tcx, FrameData<'tcx>> { |
363 | | - let call_id = ecx.memory.extra.stacked_borrows.as_ref().map_or( |
364 | | - NonZeroU64::new(1).unwrap(), |
365 | | - |stacked_borrows| stacked_borrows.borrow_mut().new_call(), |
366 | | - ); |
367 | | - Ok(FrameData { |
368 | | - call_id, |
369 | | - catch_panic: None, |
370 | | - }) |
| 356 | + let stacked_borrows = ecx.memory.extra.stacked_borrows.as_ref(); |
| 357 | + let call_id = stacked_borrows.map_or(NonZeroU64::new(1).unwrap(), |stacked_borrows| { |
| 358 | + stacked_borrows.borrow_mut().new_call() |
| 359 | + }); |
| 360 | + Ok(FrameData { call_id, catch_panic: None }) |
371 | 361 | } |
372 | 362 |
|
373 | 363 | #[inline(always)] |
|
0 commit comments