提交 e79bb42a 编写于 作者: E Eduard-Mihai Burtescu 提交者: GitHub

Merge pull request #262 from RalfJung/never

remove ad-hoc 'never' type check in read_lvalue
......@@ -182,7 +182,6 @@ fn try_read_lvalue_projection(&mut self, proj: &mir::LvalueProjection<'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 @@ pub(super) fn eval_and_read_lvalue(&mut self, lvalue: &mir::Lvalue<'tcx>) -> Eva
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 @@ fn eval_lvalue_projection(
}
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) |
......
......@@ -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)
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册