2018-05-08 08:10:16 -05:00
|
|
|
//@ compile-flags:-Zprint-mono-items=eager
|
2015-11-02 07:46:39 -06:00
|
|
|
|
2024-05-28 23:25:55 -05:00
|
|
|
#![crate_type = "lib"]
|
2015-11-02 07:46:39 -06:00
|
|
|
#![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> {
|
2024-05-28 23:25:55 -05:00
|
|
|
x: T,
|
2015-11-02 07:46:39 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<T> Struct<T> {
|
|
|
|
pub fn foo(self) -> T {
|
|
|
|
self.x
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn bar() {}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub enum Enum<T> {
|
|
|
|
A(T),
|
2024-05-28 23:25:55 -05:00
|
|
|
B { x: T },
|
2015-11-02 07:46:39 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
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 {
|
2024-05-28 23:25:55 -05:00
|
|
|
x: i32,
|
2015-11-02 07:46:39 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
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:
|
2020-08-28 08:31:03 -05:00
|
|
|
//~ MONO_ITEM fn NonGeneric::foo
|