1 // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
13 #![feature(never_type)]
14 #![allow(unreachable_code)]
16 use std::error::Error;
19 fn raw_ptr_box<T>(t: T) -> *mut T {
23 fn foo(x: !) -> Box<dyn Error> {
24 /* *mut $0 is coerced to Box<dyn Error> here */ Box::<_ /* ! */>::new(x)
27 fn foo_raw_ptr(x: !) -> *mut dyn Error {
28 /* *mut $0 is coerced to *mut Error here */ raw_ptr_box::<_ /* ! */>(x)
31 fn no_coercion(d: *mut dyn Error) -> *mut dyn Error {
32 /* an unsize coercion won't compile here, and it is indeed not used
33 because there is nothing requiring the _ to be Sized */
44 let mut x /* : Option<S> */ = None;
45 let mut first_iter = false;
49 = /* Box<$0> is coerced to Box<Xyz> here */ Box::new(x.unwrap());
56 let mut y : Option<S> = None;
57 // assert types are equal
58 mem::swap(&mut x, &mut y);