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