]> git.lizzy.rs Git - rust.git/blob - src/test/ui/reachable/expr_assign.rs
Rollup merge of #93663 - sunfishcode:sunfishcode/as-raw-name, r=joshtriplett
[rust.git] / src / test / ui / reachable / expr_assign.rs
1 #![feature(never_type)]
2 #![allow(unused_variables)]
3 #![allow(unused_assignments)]
4 #![allow(dead_code)]
5 #![deny(unreachable_code)]
6
7 fn foo() {
8     // No error here.
9     let x;
10     x = return; //~ ERROR unreachable
11 }
12
13 fn bar() {
14     use std::ptr;
15     let p: *mut ! = ptr::null_mut::<!>();
16     unsafe {
17         // Here we consider the `return` unreachable because
18         // "evaluating" the `*p` has type `!`. This is somewhat
19         // dubious, I suppose.
20         *p = return; //~ ERROR unreachable
21     }
22 }
23
24 fn baz() {
25     let mut i = 0;
26     *{return; &mut i} = 22; //~ ERROR unreachable
27 }
28
29 fn main() { }