]> git.lizzy.rs Git - rust.git/blob - tests/ui/never_type/fallback-closure-wrap.rs
Rollup merge of #107615 - notriddle:notriddle/nbsp, r=GuillaumeGomez
[rust.git] / tests / ui / never_type / fallback-closure-wrap.rs
1 // This is a minified example from Crater breakage observed when attempting to
2 // stabilize never type, nstoddard/webgl-gui @ 22f0169f.
3 //
4 // This particular test case currently fails as the inference to `()` rather
5 // than `!` happens as a result of an `as` cast, which is not currently tracked.
6 // Crater did not find many cases of this occurring, but it is included for
7 // awareness.
8 //
9 // revisions: nofallback fallback
10 //[nofallback] check-pass
11 //[fallback] check-fail
12
13 #![cfg_attr(fallback, feature(never_type_fallback))]
14
15 use std::marker::PhantomData;
16
17 fn main() {
18     let error = Closure::wrap(Box::new(move || {
19         //[fallback]~^ to be a closure that returns `()`, but it returns `!`
20         panic!("Can't connect to server.");
21     }) as Box<dyn FnMut()>);
22 }
23
24 struct Closure<T: ?Sized>(PhantomData<T>);
25
26 impl<T: ?Sized> Closure<T> {
27     fn wrap(data: Box<T>) -> Closure<T> {
28         todo!()
29     }
30 }