diff options
Diffstat (limited to 'src/test/codegen-units/item-collection')
31 files changed, 0 insertions, 1404 deletions
diff --git a/src/test/codegen-units/item-collection/asm-sym.rs b/src/test/codegen-units/item-collection/asm-sym.rs deleted file mode 100644 index 8bafb95bc..000000000 --- a/src/test/codegen-units/item-collection/asm-sym.rs +++ /dev/null @@ -1,20 +0,0 @@ -// needs-asm-support -// compile-flags: -Ccodegen-units=1 -Zprint-mono-items=lazy --crate-type=lib - -#[inline(always)] -pub unsafe fn f() { - //~ MONO_ITEM static f::S @@ asm_sym-cgu.0[External] - static S: usize = 1; - //~ MONO_ITEM fn f::fun @@ asm_sym-cgu.0[External] - fn fun() {} - core::arch::asm!("/* {0} {1} */", sym S, sym fun); -} - -//~ MONO_ITEM fn g @@ asm_sym-cgu.0[External] -pub unsafe fn g() { - //~ MONO_ITEM static g::S @@ asm_sym-cgu.0[Internal] - static S: usize = 2; - //~ MONO_ITEM fn g::fun @@ asm_sym-cgu.0[Internal] - fn fun() {} - core::arch::asm!("/* {0} {1} */", sym S, sym fun); -} diff --git a/src/test/codegen-units/item-collection/auxiliary/cgu_export_trait_method.rs b/src/test/codegen-units/item-collection/auxiliary/cgu_export_trait_method.rs deleted file mode 100644 index ecea26dc4..000000000 --- a/src/test/codegen-units/item-collection/auxiliary/cgu_export_trait_method.rs +++ /dev/null @@ -1,24 +0,0 @@ -#![crate_type = "lib"] - -pub trait Trait : Sized { - fn without_self() -> u32; - fn without_self_default() -> u32 { 0 } - - fn with_default_impl(self) -> Self { self } - fn with_default_impl_generic<T>(self, x: T) -> (Self, T) { (self, x) } - - fn without_default_impl(x: u32) -> (Self, u32); - fn without_default_impl_generic<T>(x: T) -> (Self, T); -} - -impl Trait for char { - fn without_self() -> u32 { 2 } - fn without_default_impl(x: u32) -> (Self, u32) { ('c', x) } - fn without_default_impl_generic<T>(x: T) -> (Self, T) { ('c', x) } -} - -impl Trait for u32 { - fn without_self() -> u32 { 1 } - fn without_default_impl(x: u32) -> (Self, u32) { (0, x) } - fn without_default_impl_generic<T>(x: T) -> (Self, T) { (0, x) } -} diff --git a/src/test/codegen-units/item-collection/auxiliary/cgu_extern_closures.rs b/src/test/codegen-units/item-collection/auxiliary/cgu_extern_closures.rs deleted file mode 100644 index 05ea0a89f..000000000 --- a/src/test/codegen-units/item-collection/auxiliary/cgu_extern_closures.rs +++ /dev/null @@ -1,23 +0,0 @@ -#![crate_type = "lib"] - -#[inline] -pub fn inlined_fn(x: i32, y: i32) -> i32 { - - let closure = |a, b| { a + b }; - - closure(x, y) -} - -pub fn inlined_fn_generic<T>(x: i32, y: i32, z: T) -> (i32, T) { - - let closure = |a, b| { a + b }; - - (closure(x, y), z) -} - -pub fn non_inlined_fn(x: i32, y: i32) -> i32 { - - let closure = |a, b| { a + b }; - - closure(x, y) -} diff --git a/src/test/codegen-units/item-collection/auxiliary/cgu_generic_function.rs b/src/test/codegen-units/item-collection/auxiliary/cgu_generic_function.rs deleted file mode 100644 index 3926f2957..000000000 --- a/src/test/codegen-units/item-collection/auxiliary/cgu_generic_function.rs +++ /dev/null @@ -1,26 +0,0 @@ -#![crate_type = "lib"] - -struct Struct(u32); - -#[inline(never)] -pub fn foo<T>(x: T) -> (T, u32, i8) { - let (x, Struct(y)) = bar(x); - (x, y, 2) -} - -#[inline(never)] -fn bar<T>(x: T) -> (T, Struct) { - let _ = not_exported_and_not_generic(0); - (x, Struct(1)) -} - -// These should not contribute to the codegen items of other crates. -#[inline(never)] -pub fn exported_but_not_generic(x: i32) -> i64 { - x as i64 -} - -#[inline(never)] -fn not_exported_and_not_generic(x: u32) -> u64 { - x as u64 -} diff --git a/src/test/codegen-units/item-collection/cross-crate-closures.rs b/src/test/codegen-units/item-collection/cross-crate-closures.rs deleted file mode 100644 index 6af344fab..000000000 --- a/src/test/codegen-units/item-collection/cross-crate-closures.rs +++ /dev/null @@ -1,33 +0,0 @@ -// In the current version of the collector that still has to support -// legacy-codegen, closures do not generate their own MonoItems, so we are -// ignoring this test until MIR codegen has taken over completely -// ignore-test - -// compile-flags:-Zprint-mono-items=eager - -#![deny(dead_code)] -#![feature(start)] - -// aux-build:cgu_extern_closures.rs -extern crate cgu_extern_closures; - -//~ MONO_ITEM fn cross_crate_closures::start[0] -#[start] -fn start(_: isize, _: *const *const u8) -> isize { - - //~ MONO_ITEM fn cgu_extern_closures::inlined_fn[0] - //~ MONO_ITEM fn cgu_extern_closures::inlined_fn[0]::{{closure}}[0] - let _ = cgu_extern_closures::inlined_fn(1, 2); - - //~ MONO_ITEM fn cgu_extern_closures::inlined_fn_generic[0]<i32> - //~ MONO_ITEM fn cgu_extern_closures::inlined_fn_generic[0]::{{closure}}[0]<i32> - let _ = cgu_extern_closures::inlined_fn_generic(3, 4, 5i32); - - // Nothing should be generated for this call, we just link to the instance - // in the extern crate. - let _ = cgu_extern_closures::non_inlined_fn(6, 7); - - 0 -} - -//~ MONO_ITEM drop-glue i8 diff --git a/src/test/codegen-units/item-collection/cross-crate-generic-functions.rs b/src/test/codegen-units/item-collection/cross-crate-generic-functions.rs deleted file mode 100644 index 7289ceee9..000000000 --- a/src/test/codegen-units/item-collection/cross-crate-generic-functions.rs +++ /dev/null @@ -1,24 +0,0 @@ -// compile-flags:-Zprint-mono-items=eager - -#![deny(dead_code)] -#![feature(start)] - -// aux-build:cgu_generic_function.rs -extern crate cgu_generic_function; - -//~ MONO_ITEM fn start -#[start] -fn start(_: isize, _: *const *const u8) -> isize { - //~ MONO_ITEM fn cgu_generic_function::bar::<u32> - //~ MONO_ITEM fn cgu_generic_function::foo::<u32> - let _ = cgu_generic_function::foo(1u32); - - //~ MONO_ITEM fn cgu_generic_function::bar::<u64> - //~ MONO_ITEM fn cgu_generic_function::foo::<u64> - let _ = cgu_generic_function::foo(2u64); - - // This should not introduce a codegen item - let _ = cgu_generic_function::exported_but_not_generic(3); - - 0 -} diff --git a/src/test/codegen-units/item-collection/cross-crate-trait-method.rs b/src/test/codegen-units/item-collection/cross-crate-trait-method.rs deleted file mode 100644 index dc0984c8a..000000000 --- a/src/test/codegen-units/item-collection/cross-crate-trait-method.rs +++ /dev/null @@ -1,50 +0,0 @@ -// compile-flags:-Zprint-mono-items=eager - -#![deny(dead_code)] -#![feature(start)] - -// aux-build:cgu_export_trait_method.rs -extern crate cgu_export_trait_method; - -use cgu_export_trait_method::Trait; - -//~ MONO_ITEM fn start -#[start] -fn start(_: isize, _: *const *const u8) -> isize { - // The object code of these methods is contained in the external crate, so - // calling them should *not* introduce codegen items in the current crate. - let _: (u32, u32) = Trait::without_default_impl(0); - let _: (char, u32) = Trait::without_default_impl(0); - - // Currently, no object code is generated for trait methods with default - // implementations, unless they are actually called from somewhere. Therefore - // we cannot import the implementations and have to create our own inline. - //~ MONO_ITEM fn <u32 as cgu_export_trait_method::Trait>::with_default_impl - let _ = Trait::with_default_impl(0u32); - //~ MONO_ITEM fn <char as cgu_export_trait_method::Trait>::with_default_impl - let _ = Trait::with_default_impl('c'); - - - - //~ MONO_ITEM fn <u32 as cgu_export_trait_method::Trait>::with_default_impl_generic::<&str> - let _ = Trait::with_default_impl_generic(0u32, "abc"); - //~ MONO_ITEM fn <u32 as cgu_export_trait_method::Trait>::with_default_impl_generic::<bool> - let _ = Trait::with_default_impl_generic(0u32, false); - - //~ MONO_ITEM fn <char as cgu_export_trait_method::Trait>::with_default_impl_generic::<i16> - let _ = Trait::with_default_impl_generic('x', 1i16); - //~ MONO_ITEM fn <char as cgu_export_trait_method::Trait>::with_default_impl_generic::<i32> - let _ = Trait::with_default_impl_generic('y', 0i32); - - //~ MONO_ITEM fn <u32 as cgu_export_trait_method::Trait>::without_default_impl_generic::<char> - let _: (u32, char) = Trait::without_default_impl_generic('c'); - //~ MONO_ITEM fn <u32 as cgu_export_trait_method::Trait>::without_default_impl_generic::<bool> - let _: (u32, bool) = Trait::without_default_impl_generic(false); - - //~ MONO_ITEM fn <char as cgu_export_trait_method::Trait>::without_default_impl_generic::<char> - let _: (char, char) = Trait::without_default_impl_generic('c'); - //~ MONO_ITEM fn <char as cgu_export_trait_method::Trait>::without_default_impl_generic::<bool> - let _: (char, bool) = Trait::without_default_impl_generic(false); - - 0 -} diff --git a/src/test/codegen-units/item-collection/drop_in_place_intrinsic.rs b/src/test/codegen-units/item-collection/drop_in_place_intrinsic.rs deleted file mode 100644 index a3f1fb5e7..000000000 --- a/src/test/codegen-units/item-collection/drop_in_place_intrinsic.rs +++ /dev/null @@ -1,36 +0,0 @@ -// -// compile-flags:-Zprint-mono-items=eager -// compile-flags:-Zinline-in-all-cgus - -#![feature(start)] - -//~ MONO_ITEM fn std::ptr::drop_in_place::<StructWithDtor> - shim(Some(StructWithDtor)) @@ drop_in_place_intrinsic-cgu.0[Internal] -struct StructWithDtor(u32); - -impl Drop for StructWithDtor { - //~ MONO_ITEM fn <StructWithDtor as std::ops::Drop>::drop - fn drop(&mut self) {} -} - -//~ MONO_ITEM fn start -#[start] -fn start(_: isize, _: *const *const u8) -> isize { - - //~ MONO_ITEM fn std::ptr::drop_in_place::<[StructWithDtor; 2]> - shim(Some([StructWithDtor; 2])) @@ drop_in_place_intrinsic-cgu.0[Internal] - let x = [StructWithDtor(0), StructWithDtor(1)]; - - drop_slice_in_place(&x); - - 0 -} - -//~ MONO_ITEM fn drop_slice_in_place -fn drop_slice_in_place(x: &[StructWithDtor]) { - unsafe { - // This is the interesting thing in this test case: Normally we would - // not have drop-glue for the unsized [StructWithDtor]. This has to be - // generated though when the drop_in_place() intrinsic is used. - //~ MONO_ITEM fn std::ptr::drop_in_place::<[StructWithDtor]> - shim(Some([StructWithDtor])) @@ drop_in_place_intrinsic-cgu.0[Internal] - ::std::ptr::drop_in_place(x as *const _ as *mut [StructWithDtor]); - } -} diff --git a/src/test/codegen-units/item-collection/function-as-argument.rs b/src/test/codegen-units/item-collection/function-as-argument.rs deleted file mode 100644 index ea500c311..000000000 --- a/src/test/codegen-units/item-collection/function-as-argument.rs +++ /dev/null @@ -1,40 +0,0 @@ -// -// compile-flags:-Zprint-mono-items=eager - -#![deny(dead_code)] -#![feature(start)] - -fn take_fn_once<T1, T2, F: FnOnce(T1, T2)>(f: F, x: T1, y: T2) { - (f)(x, y) -} - -fn function<T1, T2>(_: T1, _: T2) {} - -fn take_fn_pointer<T1, T2>(f: fn(T1, T2), x: T1, y: T2) { - (f)(x, y) -} - -//~ MONO_ITEM fn start -#[start] -fn start(_: isize, _: *const *const u8) -> isize { - - //~ MONO_ITEM fn take_fn_once::<u32, &str, fn(u32, &str) {function::<u32, &str>}> - //~ MONO_ITEM fn function::<u32, &str> - //~ MONO_ITEM fn <fn(u32, &str) {function::<u32, &str>} as std::ops::FnOnce<(u32, &str)>>::call_once - shim(fn(u32, &str) {function::<u32, &str>}) - take_fn_once(function, 0u32, "abc"); - - //~ MONO_ITEM fn take_fn_once::<char, f64, fn(char, f64) {function::<char, f64>}> - //~ MONO_ITEM fn function::<char, f64> - //~ MONO_ITEM fn <fn(char, f64) {function::<char, f64>} as std::ops::FnOnce<(char, f64)>>::call_once - shim(fn(char, f64) {function::<char, f64>}) - take_fn_once(function, 'c', 0f64); - - //~ MONO_ITEM fn take_fn_pointer::<i32, ()> - //~ MONO_ITEM fn function::<i32, ()> - take_fn_pointer(function, 0i32, ()); - - //~ MONO_ITEM fn take_fn_pointer::<f32, i64> - //~ MONO_ITEM fn function::<f32, i64> - take_fn_pointer(function, 0f32, 0i64); - - 0 -} diff --git a/src/test/codegen-units/item-collection/generic-drop-glue.rs b/src/test/codegen-units/item-collection/generic-drop-glue.rs deleted file mode 100644 index 6df4ff7e5..000000000 --- a/src/test/codegen-units/item-collection/generic-drop-glue.rs +++ /dev/null @@ -1,91 +0,0 @@ -// -// compile-flags:-Zprint-mono-items=eager -// compile-flags:-Zinline-in-all-cgus - -#![deny(dead_code)] -#![feature(start)] - -struct StructWithDrop<T1, T2> { - x: T1, - y: T2, -} - -impl<T1, T2> Drop for StructWithDrop<T1, T2> { - fn drop(&mut self) {} -} - -struct StructNoDrop<T1, T2> { - x: T1, - y: T2, -} - -enum EnumWithDrop<T1, T2> { - A(T1), - B(T2) -} - -impl<T1, T2> Drop for EnumWithDrop<T1, T2> { - fn drop(&mut self) {} -} - -enum EnumNoDrop<T1, T2> { - A(T1), - B(T2) -} - - -struct NonGenericNoDrop(#[allow(unused_tuple_struct_fields)] i32); - -struct NonGenericWithDrop(#[allow(unused_tuple_struct_fields)] i32); -//~ MONO_ITEM fn std::ptr::drop_in_place::<NonGenericWithDrop> - shim(Some(NonGenericWithDrop)) @@ generic_drop_glue-cgu.0[Internal] - -impl Drop for NonGenericWithDrop { - //~ MONO_ITEM fn <NonGenericWithDrop as std::ops::Drop>::drop - fn drop(&mut self) {} -} - -//~ MONO_ITEM fn start -#[start] -fn start(_: isize, _: *const *const u8) -> isize { - //~ MONO_ITEM fn std::ptr::drop_in_place::<StructWithDrop<i8, char>> - shim(Some(StructWithDrop<i8, char>)) @@ generic_drop_glue-cgu.0[Internal] - //~ MONO_ITEM fn <StructWithDrop<i8, char> as std::ops::Drop>::drop - let _ = StructWithDrop { x: 0i8, y: 'a' }.x; - - //~ MONO_ITEM fn std::ptr::drop_in_place::<StructWithDrop<&str, NonGenericNoDrop>> - shim(Some(StructWithDrop<&str, NonGenericNoDrop>)) @@ generic_drop_glue-cgu.0[Internal] - //~ MONO_ITEM fn <StructWithDrop<&str, NonGenericNoDrop> as std::ops::Drop>::drop - let _ = StructWithDrop { x: "&str", y: NonGenericNoDrop(0) }.y; - - // Should produce no drop glue - let _ = StructNoDrop { x: 'a', y: 0u32 }.x; - - // This is supposed to generate drop-glue because it contains a field that - // needs to be dropped. - //~ MONO_ITEM fn std::ptr::drop_in_place::<StructNoDrop<NonGenericWithDrop, f64>> - shim(Some(StructNoDrop<NonGenericWithDrop, f64>)) @@ generic_drop_glue-cgu.0[Internal] - let _ = StructNoDrop { x: NonGenericWithDrop(0), y: 0f64 }.y; - - //~ MONO_ITEM fn std::ptr::drop_in_place::<EnumWithDrop<i32, i64>> - shim(Some(EnumWithDrop<i32, i64>)) @@ generic_drop_glue-cgu.0[Internal] - //~ MONO_ITEM fn <EnumWithDrop<i32, i64> as std::ops::Drop>::drop - let _ = match EnumWithDrop::A::<i32, i64>(0) { - EnumWithDrop::A(x) => x, - EnumWithDrop::B(x) => x as i32 - }; - - //~ MONO_ITEM fn std::ptr::drop_in_place::<EnumWithDrop<f64, f32>> - shim(Some(EnumWithDrop<f64, f32>)) @@ generic_drop_glue-cgu.0[Internal] - //~ MONO_ITEM fn <EnumWithDrop<f64, f32> as std::ops::Drop>::drop - let _ = match EnumWithDrop::B::<f64, f32>(1.0) { - EnumWithDrop::A(x) => x, - EnumWithDrop::B(x) => x as f64 - }; - - let _ = match EnumNoDrop::A::<i32, i64>(0) { - EnumNoDrop::A(x) => x, - EnumNoDrop::B(x) => x as i32 - }; - - let _ = match EnumNoDrop::B::<f64, f32>(1.0) { - EnumNoDrop::A(x) => x, - EnumNoDrop::B(x) => x as f64 - }; - - 0 -} diff --git a/src/test/codegen-units/item-collection/generic-functions.rs b/src/test/codegen-units/item-collection/generic-functions.rs deleted file mode 100644 index 04383bb8e..000000000 --- a/src/test/codegen-units/item-collection/generic-functions.rs +++ /dev/null @@ -1,55 +0,0 @@ -// compile-flags:-Zprint-mono-items=eager - -#![deny(dead_code)] -#![feature(start)] - -fn foo1<T1>(a: T1) -> (T1, u32) { - (a, 1) -} - -fn foo2<T1, T2>(a: T1, b: T2) -> (T1, T2) { - (a, b) -} - -fn foo3<T1, T2, T3>(a: T1, b: T2, c: T3) -> (T1, T2, T3) { - (a, b, c) -} - -// This function should be instantiated even if no used -//~ MONO_ITEM fn lifetime_only -pub fn lifetime_only<'a>(a: &'a u32) -> &'a u32 { - a -} - -//~ MONO_ITEM fn start -#[start] -fn start(_: isize, _: *const *const u8) -> isize { - //~ MONO_ITEM fn foo1::<i32> - let _ = foo1(2i32); - //~ MONO_ITEM fn foo1::<i64> - let _ = foo1(2i64); - //~ MONO_ITEM fn foo1::<&str> - let _ = foo1("abc"); - //~ MONO_ITEM fn foo1::<char> - let _ = foo1('v'); - - //~ MONO_ITEM fn foo2::<i32, i32> - let _ = foo2(2i32, 2i32); - //~ MONO_ITEM fn foo2::<i64, &str> - let _ = foo2(2i64, "abc"); - //~ MONO_ITEM fn foo2::<&str, usize> - let _ = foo2("a", 2usize); - //~ MONO_ITEM fn foo2::<char, ()> - let _ = foo2('v', ()); - - //~ MONO_ITEM fn foo3::<i32, i32, i32> - let _ = foo3(2i32, 2i32, 2i32); - //~ MONO_ITEM fn foo3::<i64, &str, char> - let _ = foo3(2i64, "abc", 'c'); - //~ MONO_ITEM fn foo3::<i16, &str, usize> - let _ = foo3(0i16, "a", 2usize); - //~ MONO_ITEM fn foo3::<char, (), ()> - let _ = foo3('v', (), ()); - - 0 -} diff --git a/src/test/codegen-units/item-collection/generic-impl.rs b/src/test/codegen-units/item-collection/generic-impl.rs deleted file mode 100644 index 4260230c2..000000000 --- a/src/test/codegen-units/item-collection/generic-impl.rs +++ /dev/null @@ -1,71 +0,0 @@ -// compile-flags:-Zprint-mono-items=eager - -#![deny(dead_code)] -#![feature(start)] - -struct Struct<T> { - x: T, - f: fn(x: T) -> T, -} - -fn id<T>(x: T) -> T { x } - -impl<T> Struct<T> { - - fn new(x: T) -> Struct<T> { - Struct { - x: x, - f: id - } - } - - fn get<T2>(self, x: T2) -> (T, T2) { - (self.x, x) - } -} - -pub struct LifeTimeOnly<'a> { - _a: &'a u32 -} - -impl<'a> LifeTimeOnly<'a> { - - //~ MONO_ITEM fn LifeTimeOnly::<'_>::foo - pub fn foo(&self) {} - //~ MONO_ITEM fn LifeTimeOnly::<'_>::bar - pub fn bar(&'a self) {} - //~ MONO_ITEM fn LifeTimeOnly::<'_>::baz - pub fn baz<'b>(&'b self) {} - - pub fn non_instantiated<T>(&self) {} -} - -//~ MONO_ITEM fn start -#[start] -fn start(_: isize, _: *const *const u8) -> isize { - //~ MONO_ITEM fn Struct::<i32>::new - //~ MONO_ITEM fn id::<i32> - //~ MONO_ITEM fn Struct::<i32>::get::<i16> - let _ = Struct::new(0i32).get(0i16); - - //~ MONO_ITEM fn Struct::<i64>::new - //~ MONO_ITEM fn id::<i64> - //~ MONO_ITEM fn Struct::<i64>::get::<i16> - let _ = Struct::new(0i64).get(0i16); - - //~ MONO_ITEM fn Struct::<char>::new - //~ MONO_ITEM fn id::<char> - //~ MONO_ITEM fn Struct::<char>::get::<i16> - let _ = Struct::new('c').get(0i16); - - //~ MONO_ITEM fn Struct::<&str>::new - //~ MONO_ITEM fn id::<&str> - //~ MONO_ITEM fn Struct::<Struct<&str>>::get::<i16> - let _ = Struct::new(Struct::new("str")).get(0i16); - - //~ MONO_ITEM fn Struct::<Struct<&str>>::new - //~ MONO_ITEM fn id::<Struct<&str>> - let _ = (Struct::new(Struct::new("str")).f)(Struct::new("str")); - - 0 -} diff --git a/src/test/codegen-units/item-collection/impl-in-non-instantiated-generic.rs b/src/test/codegen-units/item-collection/impl-in-non-instantiated-generic.rs deleted file mode 100644 index c01398eb2..000000000 --- a/src/test/codegen-units/item-collection/impl-in-non-instantiated-generic.rs +++ /dev/null @@ -1,27 +0,0 @@ -// compile-flags:-Zprint-mono-items=eager - -#![deny(dead_code)] -#![feature(start)] - -trait SomeTrait { - fn foo(&self); -} - -// This function is never instantiated but the contained impl must still be -// discovered. -pub fn generic_function<T>(x: T) -> (T, i32) { - impl SomeTrait for i64 { - //~ MONO_ITEM fn generic_function::<impl SomeTrait for i64>::foo - fn foo(&self) {} - } - - (x, 0) -} - -//~ MONO_ITEM fn start -#[start] -fn start(_: isize, _: *const *const u8) -> isize { - 0i64.foo(); - - 0 -} diff --git a/src/test/codegen-units/item-collection/implicit-panic-call.rs b/src/test/codegen-units/item-collection/implicit-panic-call.rs deleted file mode 100644 index abec7ad50..000000000 --- a/src/test/codegen-units/item-collection/implicit-panic-call.rs +++ /dev/null @@ -1,58 +0,0 @@ -// compile-flags:-Zprint-mono-items=lazy - -// rust-lang/rust#90405 -// Ensure implicit panic calls are collected - -#![feature(lang_items)] -#![feature(no_core)] -#![crate_type = "lib"] -#![no_core] -#![no_std] - -#[lang = "panic_location"] -struct Location<'a> { - _file: &'a str, - _line: u32, - _col: u32, -} - -#[lang = "panic"] -#[inline] -#[track_caller] -fn panic(_: &'static str) -> ! { - loop {} -} - -#[lang = "sized"] -trait Sized {} - -#[lang = "copy"] -trait Copy {} - -#[lang = "freeze"] -trait Freeze {} - -impl Copy for i32 {} - -#[lang = "div"] -trait Div<Rhs = Self> { - type Output; - fn div(self, rhs: Rhs) -> Self::Output; -} - -impl Div for i32 { - type Output = i32; - fn div(self, rhs: i32) -> i32 { - self / rhs - } -} - -#[allow(unconditional_panic)] -pub fn foo() { - // This implicitly generates a panic call. - let _ = 1 / 0; -} - -//~ MONO_ITEM fn foo -//~ MONO_ITEM fn <i32 as Div>::div -//~ MONO_ITEM fn panic diff --git a/src/test/codegen-units/item-collection/instantiation-through-vtable.rs b/src/test/codegen-units/item-collection/instantiation-through-vtable.rs deleted file mode 100644 index e78226d40..000000000 --- a/src/test/codegen-units/item-collection/instantiation-through-vtable.rs +++ /dev/null @@ -1,38 +0,0 @@ -// -// compile-flags:-Zprint-mono-items=eager -Zinline-in-all-cgus -Zmir-opt-level=0 - -#![deny(dead_code)] -#![feature(start)] - -trait Trait { - fn foo(&self) -> u32; - fn bar(&self); -} - -struct Struct<T> { - _a: T -} - -impl<T> Trait for Struct<T> { - fn foo(&self) -> u32 { 0 } - fn bar(&self) {} -} - -//~ MONO_ITEM fn start -#[start] -fn start(_: isize, _: *const *const u8) -> isize { - let s1 = Struct { _a: 0u32 }; - - //~ MONO_ITEM fn std::ptr::drop_in_place::<Struct<u32>> - shim(None) @@ instantiation_through_vtable-cgu.0[Internal] - //~ MONO_ITEM fn <Struct<u32> as Trait>::foo - //~ MONO_ITEM fn <Struct<u32> as Trait>::bar - let _ = &s1 as &Trait; - - let s1 = Struct { _a: 0u64 }; - //~ MONO_ITEM fn std::ptr::drop_in_place::<Struct<u64>> - shim(None) @@ instantiation_through_vtable-cgu.0[Internal] - //~ MONO_ITEM fn <Struct<u64> as Trait>::foo - //~ MONO_ITEM fn <Struct<u64> as Trait>::bar - let _ = &s1 as &Trait; - - 0 -} diff --git a/src/test/codegen-units/item-collection/items-within-generic-items.rs b/src/test/codegen-units/item-collection/items-within-generic-items.rs deleted file mode 100644 index d37d7f7d9..000000000 --- a/src/test/codegen-units/item-collection/items-within-generic-items.rs +++ /dev/null @@ -1,35 +0,0 @@ -// compile-flags:-Zprint-mono-items=eager - -#![deny(dead_code)] -#![feature(start)] - -fn generic_fn<T>(a: T) -> (T, i32) { - //~ MONO_ITEM fn generic_fn::nested_fn - fn nested_fn(a: i32) -> i32 { - a + 1 - } - - let x = { - //~ MONO_ITEM fn generic_fn::nested_fn - fn nested_fn(a: i32) -> i32 { - a + 2 - } - - 1 + nested_fn(1) - }; - - return (a, x + nested_fn(0)); -} - -//~ MONO_ITEM fn start -#[start] -fn start(_: isize, _: *const *const u8) -> isize { - //~ MONO_ITEM fn generic_fn::<i64> - let _ = generic_fn(0i64); - //~ MONO_ITEM fn generic_fn::<u16> - let _ = generic_fn(0u16); - //~ MONO_ITEM fn generic_fn::<i8> - let _ = generic_fn(0i8); - - 0 -} diff --git a/src/test/codegen-units/item-collection/non-generic-closures.rs b/src/test/codegen-units/item-collection/non-generic-closures.rs deleted file mode 100644 index 379fbcf26..000000000 --- a/src/test/codegen-units/item-collection/non-generic-closures.rs +++ /dev/null @@ -1,60 +0,0 @@ -// In the current version of the collector that still has to support -// legacy-codegen, closures do not generate their own MonoItems, so we are -// ignoring this test until MIR codegen has taken over completely -// ignore-test - -// -// compile-flags:-Zprint-mono-items=eager - -#![deny(dead_code)] -#![feature(start)] - -//~ MONO_ITEM fn non_generic_closures::temporary[0] -fn temporary() { - //~ MONO_ITEM fn non_generic_closures::temporary[0]::{{closure}}[0] - (|a: u32| { - let _ = a; - })(4); -} - -//~ MONO_ITEM fn non_generic_closures::assigned_to_variable_but_not_executed[0] -fn assigned_to_variable_but_not_executed() { - //~ MONO_ITEM fn non_generic_closures::assigned_to_variable_but_not_executed[0]::{{closure}}[0] - let _x = |a: i16| { - let _ = a + 1; - }; -} - -//~ MONO_ITEM fn non_generic_closures::assigned_to_variable_executed_directly[0] -fn assigned_to_variable_executed_indirectly() { - //~ MONO_ITEM fn non_generic_closures::assigned_to_variable_executed_directly[0]::{{closure}}[0] - let f = |a: i32| { - let _ = a + 2; - }; - run_closure(&f); -} - -//~ MONO_ITEM fn non_generic_closures::assigned_to_variable_executed_indirectly[0] -fn assigned_to_variable_executed_directly() { - //~ MONO_ITEM fn non_generic_closures::assigned_to_variable_executed_indirectly[0]::{{closure}}[0] - let f = |a: i64| { - let _ = a + 3; - }; - f(4); -} - -//~ MONO_ITEM fn non_generic_closures::start[0] -#[start] -fn start(_: isize, _: *const *const u8) -> isize { - temporary(); - assigned_to_variable_but_not_executed(); - assigned_to_variable_executed_directly(); - assigned_to_variable_executed_indirectly(); - - 0 -} - -//~ MONO_ITEM fn non_generic_closures::run_closure[0] -fn run_closure(f: &Fn(i32)) { - f(3); -} diff --git a/src/test/codegen-units/item-collection/non-generic-drop-glue.rs b/src/test/codegen-units/item-collection/non-generic-drop-glue.rs deleted file mode 100644 index 06f76f7db..000000000 --- a/src/test/codegen-units/item-collection/non-generic-drop-glue.rs +++ /dev/null @@ -1,49 +0,0 @@ -// -// compile-flags:-Zprint-mono-items=eager -// compile-flags:-Zinline-in-all-cgus - -#![deny(dead_code)] -#![feature(start)] - -//~ MONO_ITEM fn std::ptr::drop_in_place::<StructWithDrop> - shim(Some(StructWithDrop)) @@ non_generic_drop_glue-cgu.0[Internal] -struct StructWithDrop { - x: i32 -} - -impl Drop for StructWithDrop { - //~ MONO_ITEM fn <StructWithDrop as std::ops::Drop>::drop - fn drop(&mut self) {} -} - -struct StructNoDrop { - x: i32 -} - -//~ MONO_ITEM fn std::ptr::drop_in_place::<EnumWithDrop> - shim(Some(EnumWithDrop)) @@ non_generic_drop_glue-cgu.0[Internal] -enum EnumWithDrop { - A(i32) -} - -impl Drop for EnumWithDrop { - //~ MONO_ITEM fn <EnumWithDrop as std::ops::Drop>::drop - fn drop(&mut self) {} -} - -enum EnumNoDrop { - A(i32) -} - -//~ MONO_ITEM fn start -#[start] -fn start(_: isize, _: *const *const u8) -> isize { - let _ = StructWithDrop { x: 0 }.x; - let _ = StructNoDrop { x: 0 }.x; - let _ = match EnumWithDrop::A(0) { - EnumWithDrop::A(x) => x - }; - let _ = match EnumNoDrop::A(0) { - EnumNoDrop::A(x) => x - }; - - 0 -} diff --git a/src/test/codegen-units/item-collection/non-generic-functions.rs b/src/test/codegen-units/item-collection/non-generic-functions.rs deleted file mode 100644 index 092e64562..000000000 --- a/src/test/codegen-units/item-collection/non-generic-functions.rs +++ /dev/null @@ -1,72 +0,0 @@ -// compile-flags:-Zprint-mono-items=eager - -#![deny(dead_code)] -#![feature(start)] - -//~ MONO_ITEM fn foo -fn foo() { - { - //~ MONO_ITEM fn foo::foo - fn foo() {} - foo(); - } - - { - //~ MONO_ITEM fn foo::foo - fn foo() {} - foo(); - } -} - -//~ MONO_ITEM fn bar -fn bar() { - //~ MONO_ITEM fn bar::baz - fn baz() {} - baz(); -} - -struct Struct { _x: i32 } - -impl Struct { - //~ MONO_ITEM fn Struct::foo - fn foo() { - { - //~ MONO_ITEM fn Struct::foo::foo - fn foo() {} - foo(); - } - - { - //~ MONO_ITEM fn Struct::foo::foo - fn foo() {} - foo(); - } - } - - //~ MONO_ITEM fn Struct::bar - fn bar(&self) { - { - //~ MONO_ITEM fn Struct::bar::foo - fn foo() {} - foo(); - } - - { - //~ MONO_ITEM fn Struct::bar::foo - fn foo() {} - foo(); - } - } -} - -//~ MONO_ITEM fn start -#[start] -fn start(_: isize, _: *const *const u8) -> isize { - foo(); - bar(); - Struct::foo(); - let x = Struct { _x: 0 }; - x.bar(); - - 0 -} diff --git a/src/test/codegen-units/item-collection/overloaded-operators.rs b/src/test/codegen-units/item-collection/overloaded-operators.rs deleted file mode 100644 index 2be7eba1d..000000000 --- a/src/test/codegen-units/item-collection/overloaded-operators.rs +++ /dev/null @@ -1,59 +0,0 @@ -// compile-flags:-Zprint-mono-items=eager - -#![deny(dead_code)] -#![crate_type="lib"] - -use std::ops::{Index, IndexMut, Add, Deref}; - -pub struct Indexable { - data: [u8; 3] -} - -impl Index<usize> for Indexable { - type Output = u8; - - //~ MONO_ITEM fn <Indexable as std::ops::Index<usize>>::index - fn index(&self, index: usize) -> &Self::Output { - if index >= 3 { - &self.data[0] - } else { - &self.data[index] - } - } -} - -impl IndexMut<usize> for Indexable { - //~ MONO_ITEM fn <Indexable as std::ops::IndexMut<usize>>::index_mut - fn index_mut(&mut self, index: usize) -> &mut Self::Output { - if index >= 3 { - &mut self.data[0] - } else { - &mut self.data[index] - } - } -} - - -//~ MONO_ITEM fn <Equatable as std::cmp::PartialEq>::eq -//~ MONO_ITEM fn <Equatable as std::cmp::PartialEq>::ne -#[derive(PartialEq)] -pub struct Equatable(u32); - - -impl Add<u32> for Equatable { - type Output = u32; - - //~ MONO_ITEM fn <Equatable as std::ops::Add<u32>>::add - fn add(self, rhs: u32) -> u32 { - self.0 + rhs - } -} - -impl Deref for Equatable { - type Target = u32; - - //~ MONO_ITEM fn <Equatable as std::ops::Deref>::deref - fn deref(&self) -> &Self::Target { - &self.0 - } -} diff --git a/src/test/codegen-units/item-collection/static-init.rs b/src/test/codegen-units/item-collection/static-init.rs deleted file mode 100644 index 287ec8f24..000000000 --- a/src/test/codegen-units/item-collection/static-init.rs +++ /dev/null @@ -1,16 +0,0 @@ -// compile-flags:-Zprint-mono-items=eager -Zpolymorphize=on - -#![feature(start)] - -pub static FN : fn() = foo::<i32>; - -pub fn foo<T>() { } - -//~ MONO_ITEM fn foo::<T> -//~ MONO_ITEM static FN - -//~ MONO_ITEM fn start -#[start] -fn start(_: isize, _: *const *const u8) -> isize { - 0 -} diff --git a/src/test/codegen-units/item-collection/statics-and-consts.rs b/src/test/codegen-units/item-collection/statics-and-consts.rs deleted file mode 100644 index 49a8d3dff..000000000 --- a/src/test/codegen-units/item-collection/statics-and-consts.rs +++ /dev/null @@ -1,54 +0,0 @@ -// compile-flags:-Zprint-mono-items=eager - -#![deny(dead_code)] -#![feature(start)] - -static STATIC1: i64 = { - const STATIC1_CONST1: i64 = 2; - 1 + CONST1 as i64 + STATIC1_CONST1 -}; - -const CONST1: i64 = { - const CONST1_1: i64 = { - const CONST1_1_1: i64 = 2; - CONST1_1_1 + 1 - }; - 1 + CONST1_1 as i64 -}; - -fn foo() { - let _ = { - const CONST2: i64 = 0; - static STATIC2: i64 = CONST2; - - let x = { - const CONST2: i64 = 1; - static STATIC2: i64 = CONST2; - STATIC2 - }; - - x + STATIC2 - }; - - let _ = { - const CONST2: i64 = 0; - static STATIC2: i64 = CONST2; - STATIC2 - }; -} - -//~ MONO_ITEM fn start -#[start] -fn start(_: isize, _: *const *const u8) -> isize { - foo(); - let _ = STATIC1; - - 0 -} - -//~ MONO_ITEM static STATIC1 - -//~ MONO_ITEM fn foo -//~ MONO_ITEM static foo::STATIC2 -//~ MONO_ITEM static foo::STATIC2 -//~ MONO_ITEM static foo::STATIC2 diff --git a/src/test/codegen-units/item-collection/trait-implementations.rs b/src/test/codegen-units/item-collection/trait-implementations.rs deleted file mode 100644 index a816cb032..000000000 --- a/src/test/codegen-units/item-collection/trait-implementations.rs +++ /dev/null @@ -1,73 +0,0 @@ -// compile-flags:-Zprint-mono-items=eager - -#![deny(dead_code)] -#![feature(start)] - -pub trait SomeTrait { - fn foo(&self); - fn bar<T>(&self, x: T); -} - -impl SomeTrait for i64 { - - //~ MONO_ITEM fn <i64 as SomeTrait>::foo - fn foo(&self) {} - - fn bar<T>(&self, _: T) {} -} - -impl SomeTrait for i32 { - - //~ MONO_ITEM fn <i32 as SomeTrait>::foo - fn foo(&self) {} - - fn bar<T>(&self, _: T) {} -} - -pub trait SomeGenericTrait<T> { - fn foo(&self, x: T); - fn bar<T2>(&self, x: T, y: T2); -} - -// Concrete impl of generic trait -impl SomeGenericTrait<u32> for f64 { - - //~ MONO_ITEM fn <f64 as SomeGenericTrait<u32>>::foo - fn foo(&self, _: u32) {} - - fn bar<T2>(&self, _: u32, _: T2) {} -} - -// Generic impl of generic trait -impl<T> SomeGenericTrait<T> for f32 { - - fn foo(&self, _: T) {} - fn bar<T2>(&self, _: T, _: T2) {} -} - -//~ MONO_ITEM fn start -#[start] -fn start(_: isize, _: *const *const u8) -> isize { - //~ MONO_ITEM fn <i32 as SomeTrait>::bar::<char> - 0i32.bar('x'); - - //~ MONO_ITEM fn <f64 as SomeGenericTrait<u32>>::bar::<&str> - 0f64.bar(0u32, "&str"); - - //~ MONO_ITEM fn <f64 as SomeGenericTrait<u32>>::bar::<()> - 0f64.bar(0u32, ()); - - //~ MONO_ITEM fn <f32 as SomeGenericTrait<char>>::foo - 0f32.foo('x'); - - //~ MONO_ITEM fn <f32 as SomeGenericTrait<i64>>::foo - 0f32.foo(-1i64); - - //~ MONO_ITEM fn <f32 as SomeGenericTrait<u32>>::bar::<()> - 0f32.bar(0u32, ()); - - //~ MONO_ITEM fn <f32 as SomeGenericTrait<&str>>::bar::<&str> - 0f32.bar("&str", "&str"); - - 0 -} diff --git a/src/test/codegen-units/item-collection/trait-method-as-argument.rs b/src/test/codegen-units/item-collection/trait-method-as-argument.rs deleted file mode 100644 index 235569728..000000000 --- a/src/test/codegen-units/item-collection/trait-method-as-argument.rs +++ /dev/null @@ -1,60 +0,0 @@ -// -// compile-flags:-Zprint-mono-items=eager - -#![deny(dead_code)] -#![feature(start)] - -trait Trait : Sized { - fn foo(self) -> Self { self } -} - -impl Trait for u32 { - fn foo(self) -> u32 { self } -} - -impl Trait for char { -} - -fn take_foo_once<T, F: FnOnce(T) -> T>(f: F, arg: T) -> T { - (f)(arg) -} - -fn take_foo<T, F: Fn(T) -> T>(f: F, arg: T) -> T { - (f)(arg) -} - -fn take_foo_mut<T, F: FnMut(T) -> T>(mut f: F, arg: T) -> T { - (f)(arg) -} - -//~ MONO_ITEM fn start -#[start] -fn start(_: isize, _: *const *const u8) -> isize { - //~ MONO_ITEM fn take_foo_once::<u32, fn(u32) -> u32 {<u32 as Trait>::foo}> - //~ MONO_ITEM fn <u32 as Trait>::foo - //~ MONO_ITEM fn <fn(u32) -> u32 {<u32 as Trait>::foo} as std::ops::FnOnce<(u32,)>>::call_once - shim(fn(u32) -> u32 {<u32 as Trait>::foo}) - take_foo_once(Trait::foo, 0u32); - - //~ MONO_ITEM fn take_foo_once::<char, fn(char) -> char {<char as Trait>::foo}> - //~ MONO_ITEM fn <char as Trait>::foo - //~ MONO_ITEM fn <fn(char) -> char {<char as Trait>::foo} as std::ops::FnOnce<(char,)>>::call_once - shim(fn(char) -> char {<char as Trait>::foo}) - take_foo_once(Trait::foo, 'c'); - - //~ MONO_ITEM fn take_foo::<u32, fn(u32) -> u32 {<u32 as Trait>::foo}> - //~ MONO_ITEM fn <fn(u32) -> u32 {<u32 as Trait>::foo} as std::ops::Fn<(u32,)>>::call - shim(fn(u32) -> u32 {<u32 as Trait>::foo}) - take_foo(Trait::foo, 0u32); - - //~ MONO_ITEM fn take_foo::<char, fn(char) -> char {<char as Trait>::foo}> - //~ MONO_ITEM fn <fn(char) -> char {<char as Trait>::foo} as std::ops::Fn<(char,)>>::call - shim(fn(char) -> char {<char as Trait>::foo}) - take_foo(Trait::foo, 'c'); - - //~ MONO_ITEM fn take_foo_mut::<u32, fn(u32) -> u32 {<u32 as Trait>::foo}> - //~ MONO_ITEM fn <fn(u32) -> u32 {<u32 as Trait>::foo} as std::ops::FnMut<(u32,)>>::call_mut - shim(fn(u32) -> u32 {<u32 as Trait>::foo}) - take_foo_mut(Trait::foo, 0u32); - - //~ MONO_ITEM fn take_foo_mut::<char, fn(char) -> char {<char as Trait>::foo}> - //~ MONO_ITEM fn <fn(char) -> char {<char as Trait>::foo} as std::ops::FnMut<(char,)>>::call_mut - shim(fn(char) -> char {<char as Trait>::foo}) - take_foo_mut(Trait::foo, 'c'); - - 0 -} diff --git a/src/test/codegen-units/item-collection/trait-method-default-impl.rs b/src/test/codegen-units/item-collection/trait-method-default-impl.rs deleted file mode 100644 index bfcdb6fa1..000000000 --- a/src/test/codegen-units/item-collection/trait-method-default-impl.rs +++ /dev/null @@ -1,61 +0,0 @@ -// compile-flags:-Zprint-mono-items=eager -Zpolymorphize=on - -#![deny(dead_code)] -#![feature(start)] - -trait SomeTrait { - fn foo(&self) { } - fn bar<T>(&self, x: T) -> T { x } -} - -impl SomeTrait for i8 { - // take the default implementations - - // For the non-generic foo(), we should generate a codegen-item even if it - // is not called anywhere - //~ MONO_ITEM fn <i8 as SomeTrait>::foo -} - -trait SomeGenericTrait<T1> { - fn foo(&self) { } - fn bar<T2>(&self, x: T1, y: T2) {} -} - -// Non-generic impl of generic trait -impl SomeGenericTrait<u64> for i32 { - // take the default implementations - - // For the non-generic foo(), we should generate a codegen-item even if it - // is not called anywhere - //~ MONO_ITEM fn <i32 as SomeGenericTrait<T1>>::foo -} - -// Non-generic impl of generic trait -impl<T1> SomeGenericTrait<T1> for u32 { - // take the default implementations - // since nothing is monomorphic here, nothing should be generated unless used somewhere. -} - -//~ MONO_ITEM fn start -#[start] -fn start(_: isize, _: *const *const u8) -> isize { - //~ MONO_ITEM fn <i8 as SomeTrait>::bar::<char> - let _ = 1i8.bar('c'); - - //~ MONO_ITEM fn <i8 as SomeTrait>::bar::<&str> - let _ = 2i8.bar("&str"); - - //~ MONO_ITEM fn <i32 as SomeGenericTrait<u64>>::bar::<char> - 0i32.bar(0u64, 'c'); - - //~ MONO_ITEM fn <i32 as SomeGenericTrait<u64>>::bar::<&str> - 0i32.bar(0u64, "&str"); - - //~ MONO_ITEM fn <u32 as SomeGenericTrait<i8>>::bar::<&[char; 1]> - 0u32.bar(0i8, &['c']); - - //~ MONO_ITEM fn <u32 as SomeGenericTrait<i16>>::bar::<()> - 0u32.bar(0i16, ()); - - 0 -} diff --git a/src/test/codegen-units/item-collection/transitive-drop-glue.rs b/src/test/codegen-units/item-collection/transitive-drop-glue.rs deleted file mode 100644 index e286c800b..000000000 --- a/src/test/codegen-units/item-collection/transitive-drop-glue.rs +++ /dev/null @@ -1,46 +0,0 @@ -// -// compile-flags:-Zprint-mono-items=eager -// compile-flags:-Zinline-in-all-cgus - -#![deny(dead_code)] -#![feature(start)] - -//~ MONO_ITEM fn std::ptr::drop_in_place::<Root> - shim(Some(Root)) @@ transitive_drop_glue-cgu.0[Internal] -struct Root(#[allow(unused_tuple_struct_fields)] Intermediate); -//~ MONO_ITEM fn std::ptr::drop_in_place::<Intermediate> - shim(Some(Intermediate)) @@ transitive_drop_glue-cgu.0[Internal] -struct Intermediate(#[allow(unused_tuple_struct_fields)] Leaf); -//~ MONO_ITEM fn std::ptr::drop_in_place::<Leaf> - shim(Some(Leaf)) @@ transitive_drop_glue-cgu.0[Internal] -struct Leaf; - -impl Drop for Leaf { - //~ MONO_ITEM fn <Leaf as std::ops::Drop>::drop - fn drop(&mut self) {} -} - -struct RootGen<T>(#[allow(unused_tuple_struct_fields)] IntermediateGen<T>); -struct IntermediateGen<T>(#[allow(unused_tuple_struct_fields)] LeafGen<T>); -struct LeafGen<T>(#[allow(unused_tuple_struct_fields)] T); - -impl<T> Drop for LeafGen<T> { - fn drop(&mut self) {} -} - -//~ MONO_ITEM fn start -#[start] -fn start(_: isize, _: *const *const u8) -> isize { - let _ = Root(Intermediate(Leaf)); - - //~ MONO_ITEM fn std::ptr::drop_in_place::<RootGen<u32>> - shim(Some(RootGen<u32>)) @@ transitive_drop_glue-cgu.0[Internal] - //~ MONO_ITEM fn std::ptr::drop_in_place::<IntermediateGen<u32>> - shim(Some(IntermediateGen<u32>)) @@ transitive_drop_glue-cgu.0[Internal] - //~ MONO_ITEM fn std::ptr::drop_in_place::<LeafGen<u32>> - shim(Some(LeafGen<u32>)) @@ transitive_drop_glue-cgu.0[Internal] - //~ MONO_ITEM fn <LeafGen<u32> as std::ops::Drop>::drop - let _ = RootGen(IntermediateGen(LeafGen(0u32))); - - //~ MONO_ITEM fn std::ptr::drop_in_place::<RootGen<i16>> - shim(Some(RootGen<i16>)) @@ transitive_drop_glue-cgu.0[Internal] - //~ MONO_ITEM fn std::ptr::drop_in_place::<IntermediateGen<i16>> - shim(Some(IntermediateGen<i16>)) @@ transitive_drop_glue-cgu.0[Internal] - //~ MONO_ITEM fn std::ptr::drop_in_place::<LeafGen<i16>> - shim(Some(LeafGen<i16>)) @@ transitive_drop_glue-cgu.0[Internal] - //~ MONO_ITEM fn <LeafGen<i16> as std::ops::Drop>::drop - let _ = RootGen(IntermediateGen(LeafGen(0i16))); - - 0 -} diff --git a/src/test/codegen-units/item-collection/tuple-drop-glue.rs b/src/test/codegen-units/item-collection/tuple-drop-glue.rs deleted file mode 100644 index ae3b2e081..000000000 --- a/src/test/codegen-units/item-collection/tuple-drop-glue.rs +++ /dev/null @@ -1,27 +0,0 @@ -// -// compile-flags:-Zprint-mono-items=eager -// compile-flags:-Zinline-in-all-cgus - -#![deny(dead_code)] -#![feature(start)] - -//~ MONO_ITEM fn std::ptr::drop_in_place::<Dropped> - shim(Some(Dropped)) @@ tuple_drop_glue-cgu.0[Internal] -struct Dropped; - -impl Drop for Dropped { - //~ MONO_ITEM fn <Dropped as std::ops::Drop>::drop - fn drop(&mut self) {} -} - -//~ MONO_ITEM fn start -#[start] -fn start(_: isize, _: *const *const u8) -> isize { - //~ MONO_ITEM fn std::ptr::drop_in_place::<(u32, Dropped)> - shim(Some((u32, Dropped))) @@ tuple_drop_glue-cgu.0[Internal] - let x = (0u32, Dropped); - - //~ MONO_ITEM fn std::ptr::drop_in_place::<(i16, (Dropped, bool))> - shim(Some((i16, (Dropped, bool)))) @@ tuple_drop_glue-cgu.0[Internal] - //~ MONO_ITEM fn std::ptr::drop_in_place::<(Dropped, bool)> - shim(Some((Dropped, bool))) @@ tuple_drop_glue-cgu.0[Internal] - let x = (0i16, (Dropped, true)); - - 0 -} diff --git a/src/test/codegen-units/item-collection/unreferenced-const-fn.rs b/src/test/codegen-units/item-collection/unreferenced-const-fn.rs deleted file mode 100644 index 17b92eae0..000000000 --- a/src/test/codegen-units/item-collection/unreferenced-const-fn.rs +++ /dev/null @@ -1,9 +0,0 @@ -// compile-flags:-Zprint-mono-items=lazy - -#![deny(dead_code)] -#![crate_type = "rlib"] - -//~ MONO_ITEM fn foo @@ unreferenced_const_fn-cgu.0[External] -pub const fn foo(x: u32) -> u32 { - x + 0xf00 -} diff --git a/src/test/codegen-units/item-collection/unreferenced-inline-function.rs b/src/test/codegen-units/item-collection/unreferenced-inline-function.rs deleted file mode 100644 index 4d095e4d6..000000000 --- a/src/test/codegen-units/item-collection/unreferenced-inline-function.rs +++ /dev/null @@ -1,11 +0,0 @@ -// compile-flags:-Zprint-mono-items=lazy - -// N.B., we do not expect *any* monomorphization to be generated here. - -#![deny(dead_code)] -#![crate_type = "rlib"] - -#[inline] -pub fn foo() -> bool { - [1, 2] == [3, 4] -} diff --git a/src/test/codegen-units/item-collection/unsizing.rs b/src/test/codegen-units/item-collection/unsizing.rs deleted file mode 100644 index 111a72312..000000000 --- a/src/test/codegen-units/item-collection/unsizing.rs +++ /dev/null @@ -1,79 +0,0 @@ -// compile-flags:-Zprint-mono-items=eager -// compile-flags:-Zinline-in-all-cgus -// compile-flags:-Zmir-opt-level=0 - -#![deny(dead_code)] -#![feature(coerce_unsized)] -#![feature(unsize)] -#![feature(start)] - -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(unused_tuple_struct_fields)] *const T); - -impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Wrapper<U>> for Wrapper<T> {} - -//~ MONO_ITEM fn start -#[start] -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>; - - 0 -} diff --git a/src/test/codegen-units/item-collection/unused-traits-and-generics.rs b/src/test/codegen-units/item-collection/unused-traits-and-generics.rs deleted file mode 100644 index 561dc1a5c..000000000 --- a/src/test/codegen-units/item-collection/unused-traits-and-generics.rs +++ /dev/null @@ -1,77 +0,0 @@ -// compile-flags:-Zprint-mono-items=eager - -#![crate_type="lib"] -#![deny(dead_code)] - -// This test asserts that no codegen items are generated for generic items that -// are never instantiated in the local crate. - -pub trait Trait { - fn foo() {} - fn bar(&self) {} -} - -pub fn foo<T: Copy>(x: T) -> (T, T) { - (x, x) -} - -pub struct Struct<T> { - x: T -} - -impl<T> Struct<T> { - pub fn foo(self) -> T { - self.x - } - - pub fn bar() {} -} - -pub enum Enum<T> { - A(T), - B { x: T } -} - -impl<T> Enum<T> { - pub fn foo(self) -> T { - match self { - Enum::A(x) => x, - Enum::B { x } => x, - } - } - - pub fn bar() {} -} - -pub struct TupleStruct<T>(T); - -impl<T> TupleStruct<T> { - pub fn foo(self) -> T { - self.0 - } - - pub fn bar() {} -} - -pub type Pair<T> = (T, T); - -pub struct NonGeneric { - x: i32 -} - -impl NonGeneric { - pub fn foo(self) -> i32 { - self.x - } - - pub fn generic_foo<T>(&self, x: T) -> (T, i32) { - (x, self.x) - } - - pub fn generic_bar<T: Copy>(x: T) -> (T, T) { - (x, x) - } -} - -// Only the non-generic methods should be instantiated: -//~ MONO_ITEM fn NonGeneric::foo |