add a test for dereferencing a pointer to a `!`

上级 7c486416
......@@ -52,6 +52,7 @@ pub enum EvalError<'tcx> {
ReallocatedFrozenMemory,
DeallocatedFrozenMemory,
Layout(layout::LayoutError<'tcx>),
Unreachable,
}
pub type EvalResult<'tcx, T> = Result<T, EvalError<'tcx>>;
......@@ -122,6 +123,8 @@ fn description(&self) -> &str {
"rustc layout computation failed",
EvalError::UnterminatedCString(_) =>
"attempted to get length of a null terminated string, but no null found before end of allocation",
EvalError::Unreachable =>
"entered unreachable code",
}
}
......
......@@ -155,7 +155,7 @@ pub(super) fn eval_terminator(
DropAndReplace { .. } => unimplemented!(),
Resume => unimplemented!(),
Unreachable => unimplemented!(),
Unreachable => return Err(EvalError::Unreachable),
}
Ok(())
......
#![feature(never_type)]
#![allow(unreachable_code)]
fn main() {
let y = &5;
let x: ! = unsafe {
*(y as *const _ as *const !) //~ ERROR entered unreachable code
};
f(x)
}
fn f(x: !) -> ! { x }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册