|
2 | 2 | //!
|
3 | 3 | //! The main entry point is the `step` method.
|
4 | 4 |
|
5 |
| -use rustc::mir; |
| 5 | +use rustc::mir::{self, Place, PlaceBase}; |
6 | 6 | use rustc::ty::layout::LayoutOf;
|
7 | 7 | use rustc::mir::interpret::{InterpResult, Scalar, PointerArithmetic};
|
8 | 8 |
|
9 |
| -use super::{InterpCx, Machine}; |
| 9 | +use super::{InterpCx, LocalValue, Machine}; |
10 | 10 |
|
11 | 11 | /// Classify whether an operator is "left-homogeneous", i.e., the LHS has the
|
12 | 12 | /// same type as the result.
|
@@ -240,6 +240,23 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
240 | 240 | }
|
241 | 241 |
|
242 | 242 | Ref(_, _, ref place) => {
|
| 243 | + // FIXME(wesleywiser) we don't currently handle the case where we try to make a ref |
| 244 | + // from a function argument that hasn't been assigned to in this function. So just |
| 245 | + // report those as uninitialized for now. |
| 246 | + if let Place { |
| 247 | + base: PlaceBase::Local(local), |
| 248 | + projection: None |
| 249 | + } = place { |
| 250 | + let alive = |
| 251 | + if let LocalValue::Live(_) = self.frame().locals[*local].value { |
| 252 | + true |
| 253 | + } else { false }; |
| 254 | + |
| 255 | + if local.as_usize() <= self.frame().body.arg_count && !alive { |
| 256 | + trace!("skipping Ref({:?})", place); |
| 257 | + throw_unsup!(UninitializedLocal); |
| 258 | + } |
| 259 | + } |
243 | 260 | let src = self.eval_place(place)?;
|
244 | 261 | let place = self.force_allocation(src)?;
|
245 | 262 | if place.layout.size.bytes() > 0 {
|
|
0 commit comments