1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
//@ 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
|