]> git.proxmox.com Git - rustc.git/blame - src/test/ui/never_type/fallback-closure-wrap.rs
New upstream version 1.67.1+dfsg1
[rustc.git] / src / test / ui / never_type / fallback-closure-wrap.rs
CommitLineData
c295e0f8
XL
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.
f2b60f7d 6// Crater did not find many cases of this occurring, but it is included for
c295e0f8
XL
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
15use std::marker::PhantomData;
16
17fn main() {
18 let error = Closure::wrap(Box::new(move || {
f2b60f7d 19 //[fallback]~^ to be a closure that returns `()`, but it returns `!`
c295e0f8
XL
20 panic!("Can't connect to server.");
21 }) as Box<dyn FnMut()>);
22}
23
24struct Closure<T: ?Sized>(PhantomData<T>);
25
26impl<T: ?Sized> Closure<T> {
27 fn wrap(data: Box<T>) -> Closure<T> {
28 todo!()
29 }
30}