2019-12-11 14:51:28 +00:00
|
|
|
#![feature(never_type)]
|
2017-03-21 13:41:41 +00:00
|
|
|
#![allow(unused_variables)]
|
|
|
|
#![allow(unused_assignments)]
|
|
|
|
#![allow(dead_code)]
|
|
|
|
#![deny(unreachable_code)]
|
|
|
|
|
|
|
|
fn foo() {
|
|
|
|
// No error here.
|
|
|
|
let x;
|
2017-11-20 12:13:27 +00:00
|
|
|
x = return; //~ ERROR unreachable
|
2017-03-21 13:41:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn bar() {
|
|
|
|
use std::ptr;
|
|
|
|
let p: *mut ! = ptr::null_mut::<!>();
|
|
|
|
unsafe {
|
|
|
|
// Here we consider the `return` unreachable because
|
|
|
|
// "evaluating" the `*p` has type `!`. This is somewhat
|
|
|
|
// dubious, I suppose.
|
2017-11-20 12:13:27 +00:00
|
|
|
*p = return; //~ ERROR unreachable
|
2017-03-21 13:41:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn baz() {
|
|
|
|
let mut i = 0;
|
2017-11-20 12:13:27 +00:00
|
|
|
*{return; &mut i} = 22; //~ ERROR unreachable
|
2017-03-21 13:41:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() { }
|