1 // revisions: nofallback fallback
2 //[fallback] check-pass
3 //[nofallback] check-fail
5 #![feature(never_type)]
6 #![cfg_attr(fallback, feature(never_type_fallback))]
7 #![allow(unreachable_code)]
12 fn raw_ptr_box<T>(t: T) -> *mut T {
16 fn foo(x: !) -> Box<dyn Error> {
17 /* *mut $0 is coerced to Box<dyn Error> here */ Box::<_ /* ! */>::new(x)
18 //[nofallback]~^ ERROR trait bound `(): std::error::Error` is not satisfied
21 fn foo_raw_ptr(x: !) -> *mut dyn Error {
22 /* *mut $0 is coerced to *mut Error here */ raw_ptr_box::<_ /* ! */>(x)
23 //[nofallback]~^ ERROR trait bound `(): std::error::Error` is not satisfied
26 fn no_coercion(d: *mut dyn Error) -> *mut dyn Error {
27 /* an unsize coercion won't compile here, and it is indeed not used
28 because there is nothing requiring the _ to be Sized */
39 let mut x /* : Option<S> */ = None;
40 let mut first_iter = false;
44 = /* Box<$0> is coerced to Box<Xyz> here */ Box::new(x.unwrap());
51 let mut y : Option<S> = None;
52 // assert types are equal
53 mem::swap(&mut x, &mut y);