2018-05-08 13:10:16 +00:00
|
|
|
// compile-flags:-Zprint-mono-items=eager
|
2017-10-06 21:59:33 +00:00
|
|
|
// compile-flags:-Zinline-in-all-cgus
|
2015-11-02 13:46:39 +00:00
|
|
|
|
|
|
|
#![deny(dead_code)]
|
|
|
|
#![feature(coerce_unsized)]
|
|
|
|
#![feature(unsize)]
|
2017-12-22 14:31:51 +00:00
|
|
|
#![feature(start)]
|
2015-11-02 13:46:39 +00:00
|
|
|
|
|
|
|
use std::marker::Unsize;
|
|
|
|
use std::ops::CoerceUnsized;
|
|
|
|
|
|
|
|
trait Trait {
|
|
|
|
fn foo(&self);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Simple Case
|
|
|
|
impl Trait for bool {
|
|
|
|
fn foo(&self) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Trait for char {
|
|
|
|
fn foo(&self) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Struct Field Case
|
|
|
|
struct Struct<T: ?Sized> {
|
|
|
|
_a: u32,
|
|
|
|
_b: i32,
|
|
|
|
_c: T
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Trait for f64 {
|
|
|
|
fn foo(&self) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Custom Coercion Case
|
|
|
|
impl Trait for u32 {
|
|
|
|
fn foo(&self) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Copy)]
|
|
|
|
struct Wrapper<T: ?Sized>(*const T);
|
|
|
|
|
|
|
|
impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Wrapper<U>> for Wrapper<T> {}
|
|
|
|
|
2018-05-08 13:10:16 +00:00
|
|
|
//~ MONO_ITEM fn unsizing::start[0]
|
2017-12-22 14:31:51 +00:00
|
|
|
#[start]
|
|
|
|
fn start(_: isize, _: *const *const u8) -> isize {
|
2015-11-02 13:46:39 +00:00
|
|
|
// simple case
|
|
|
|
let bool_sized = &true;
|
2020-01-19 16:09:52 +00:00
|
|
|
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<bool> @@ unsizing-cgu.0[Internal]
|
2018-05-08 13:10:16 +00:00
|
|
|
//~ MONO_ITEM fn unsizing::{{impl}}[0]::foo[0]
|
2015-11-02 13:46:39 +00:00
|
|
|
let _bool_unsized = bool_sized as &Trait;
|
|
|
|
|
2017-03-13 23:08:21 +00:00
|
|
|
let char_sized = &'a';
|
|
|
|
|
2020-01-19 16:09:52 +00:00
|
|
|
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<char> @@ unsizing-cgu.0[Internal]
|
2018-05-08 13:10:16 +00:00
|
|
|
//~ MONO_ITEM fn unsizing::{{impl}}[1]::foo[0]
|
2015-11-02 13:46:39 +00:00
|
|
|
let _char_unsized = char_sized as &Trait;
|
|
|
|
|
|
|
|
// struct field
|
|
|
|
let struct_sized = &Struct {
|
|
|
|
_a: 1,
|
|
|
|
_b: 2,
|
|
|
|
_c: 3.0f64
|
|
|
|
};
|
2020-01-19 16:09:52 +00:00
|
|
|
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<f64> @@ unsizing-cgu.0[Internal]
|
2018-05-08 13:10:16 +00:00
|
|
|
//~ MONO_ITEM fn unsizing::{{impl}}[2]::foo[0]
|
2015-11-02 13:46:39 +00:00
|
|
|
let _struct_unsized = struct_sized as &Struct<Trait>;
|
|
|
|
|
|
|
|
// custom coercion
|
|
|
|
let wrapper_sized = Wrapper(&0u32);
|
2020-01-19 16:09:52 +00:00
|
|
|
//~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<u32> @@ unsizing-cgu.0[Internal]
|
2018-05-08 13:10:16 +00:00
|
|
|
//~ MONO_ITEM fn unsizing::{{impl}}[3]::foo[0]
|
2015-11-02 13:46:39 +00:00
|
|
|
let _wrapper_sized = wrapper_sized as Wrapper<Trait>;
|
2017-12-22 14:31:51 +00:00
|
|
|
|
|
|
|
0
|
2015-11-02 13:46:39 +00:00
|
|
|
}
|