]> git.proxmox.com Git - rustc.git/blob - src/test/ui/uninhabited/privately-uninhabited-mir-call.rs
Update unsuspicious file list
[rustc.git] / src / test / ui / uninhabited / privately-uninhabited-mir-call.rs
1 // Verifies that MIR building for a call expression respects
2 // privacy when checking if a call return type is uninhabited.
3
4 pub mod widget {
5 enum Unimplemented {}
6 pub struct Widget(Unimplemented);
7
8 impl Widget {
9 pub fn new() -> Widget {
10 todo!();
11 }
12 }
13
14 pub fn f() {
15 let x: &mut u32;
16 Widget::new();
17 // Ok. Widget type returned from new is known to be uninhabited
18 // and the following code is considered unreachable.
19 *x = 1;
20 }
21 }
22
23 fn main() {
24 let y: &mut u32;
25 widget::Widget::new();
26 // Error. Widget type is not known to be uninhabited here,
27 // so the following code is considered reachable.
28 *y = 2; //~ ERROR E0381
29 }