diff options
| author | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2017-07-20 15:13:21 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-07-20 15:13:21 +0300 |
| commit | e79bb42ab32c48e4afd8423d14f7f74444a2263d (patch) | |
| tree | 1fabbb941f7f9fbaa1bdcece5b31a8b9bf012c10 | |
| parent | f02d9e63fde6d692b38b3843b16132c0b79a7ef6 (diff) | |
| parent | 3b19c83c678a74a508fe874ac261a99121e51397 (diff) | |
| download | rust-e79bb42ab32c48e4afd8423d14f7f74444a2263d.tar.gz rust-e79bb42ab32c48e4afd8423d14f7f74444a2263d.zip | |
Merge pull request #262 from RalfJung/never
remove ad-hoc 'never' type check in read_lvalue
| -rw-r--r-- | src/lvalue.rs | 11 | ||||
| -rw-r--r-- | tests/compile-fail/never_say_never.rs | 2 |
2 files changed, 4 insertions, 9 deletions
diff --git a/src/lvalue.rs b/src/lvalue.rs index 9fc01eb0384..59f5dc8f4bb 100644 --- a/src/lvalue.rs +++ b/src/lvalue.rs @@ -182,7 +182,6 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { /// Returns a value and (in case of a ByRef) if we are supposed to use aligned accesses. pub(super) fn eval_and_read_lvalue(&mut self, lvalue: &mir::Lvalue<'tcx>) -> EvalResult<'tcx, Value> { - let ty = self.lvalue_ty(lvalue); // Shortcut for things like accessing a fat pointer's field, // which would otherwise (in the `eval_lvalue` path) require moving a `ByValPair` to memory // and returning an `Lvalue::Ptr` to it @@ -190,14 +189,10 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { return Ok(val); } let lvalue = self.eval_lvalue(lvalue)?; - self.read_lvalue(lvalue, ty) + self.read_lvalue(lvalue) } - pub fn read_lvalue(&self, lvalue: Lvalue<'tcx>, ty: Ty<'tcx>) -> EvalResult<'tcx, Value> { - if ty.is_never() { - return Err(EvalError::Unreachable); - } - + pub fn read_lvalue(&self, lvalue: Lvalue<'tcx>) -> EvalResult<'tcx, Value> { match lvalue { Lvalue::Ptr { ptr, extra, aligned } => { assert_eq!(extra, LvalueExtra::None); @@ -382,7 +377,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { } Deref => { - let val = self.read_lvalue(base, base_ty)?; + let val = self.read_lvalue(base)?; let pointee_type = match base_ty.sty { ty::TyRawPtr(ref tam) | diff --git a/tests/compile-fail/never_say_never.rs b/tests/compile-fail/never_say_never.rs index 5d7e9fec62c..3e80cb20b3f 100644 --- a/tests/compile-fail/never_say_never.rs +++ b/tests/compile-fail/never_say_never.rs @@ -4,7 +4,7 @@ fn main() { let y = &5; let x: ! = unsafe { - *(y as *const _ as *const !) //~ ERROR entered unreachable code + *(y as *const _ as *const !) //~ ERROR tried to access a dead local variable }; f(x) } |
