mirror of
https://github.com/rust-lang/rust.git
synced 2025-11-10 03:50:17 +00:00
Previously `-Zprint-mono-items` would override the mono item collection strategy. When debugging one doesn't want to change the behaviour, so this was counter productive. Additionally, the produced behaviour was artificial and might never arise without using the option in the first place (`-Zprint-mono-items=eager` without `-Clink-dead-code`). Finally, the option was incorrectly marked as `UNTRACKED`. Resolve those issues, by turning `-Zprint-mono-items` into a boolean flag that prints results of mono item collection without changing the behaviour of mono item collection. For codegen-units test incorporate `-Zprint-mono-items` flag directly into compiletest tool. Test changes are mechanical. `-Zprint-mono-items=lazy` was removed without additional changes, and `-Zprint-mono-items=eager` was turned into `-Clink-dead-code`. Linking dead code disables internalization, so tests have been updated accordingly.
76 lines
1.7 KiB
Rust
76 lines
1.7 KiB
Rust
//@ compile-flags:-Zmir-opt-level=0
|
|
|
|
#![deny(dead_code)]
|
|
#![feature(coerce_unsized)]
|
|
#![feature(unsize)]
|
|
#![crate_type = "lib"]
|
|
|
|
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>(#[allow(dead_code)] *const T);
|
|
|
|
impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Wrapper<U>> for Wrapper<T> {}
|
|
|
|
//~ MONO_ITEM fn start
|
|
#[no_mangle]
|
|
pub fn start(_: isize, _: *const *const u8) -> isize {
|
|
// simple case
|
|
let bool_sized = &true;
|
|
//~ MONO_ITEM fn std::ptr::drop_in_place::<bool> - shim(None) @@ unsizing-cgu.0[Internal]
|
|
//~ MONO_ITEM fn <bool as Trait>::foo
|
|
let _bool_unsized = bool_sized as &Trait;
|
|
|
|
let char_sized = &'a';
|
|
|
|
//~ MONO_ITEM fn std::ptr::drop_in_place::<char> - shim(None) @@ unsizing-cgu.0[Internal]
|
|
//~ MONO_ITEM fn <char as Trait>::foo
|
|
let _char_unsized = char_sized as &Trait;
|
|
|
|
// struct field
|
|
let struct_sized = &Struct { _a: 1, _b: 2, _c: 3.0f64 };
|
|
//~ MONO_ITEM fn std::ptr::drop_in_place::<f64> - shim(None) @@ unsizing-cgu.0[Internal]
|
|
//~ MONO_ITEM fn <f64 as Trait>::foo
|
|
let _struct_unsized = struct_sized as &Struct<Trait>;
|
|
|
|
// custom coercion
|
|
let wrapper_sized = Wrapper(&0u32);
|
|
//~ MONO_ITEM fn std::ptr::drop_in_place::<u32> - shim(None) @@ unsizing-cgu.0[Internal]
|
|
//~ MONO_ITEM fn <u32 as Trait>::foo
|
|
let _wrapper_sized = wrapper_sized as Wrapper<Trait>;
|
|
|
|
false.foo();
|
|
|
|
0
|
|
}
|