2020-06-22 12:57:03 +00:00
|
|
|
// build-fail
|
2020-07-22 14:03:56 +00:00
|
|
|
// compile-flags:-Zpolymorphize=on
|
2020-07-16 16:52:23 +00:00
|
|
|
#![feature(rustc_attrs)]
|
2020-06-22 12:57:03 +00:00
|
|
|
|
|
|
|
// This test checks that the polymorphization analysis doesn't break when the
|
|
|
|
// function/closure doesn't just have generic parameters.
|
|
|
|
|
|
|
|
// Function has an unused generic parameter.
|
2020-07-16 16:52:23 +00:00
|
|
|
#[rustc_polymorphize_error]
|
2020-06-22 12:57:03 +00:00
|
|
|
pub fn unused<'a, T>(_: &'a u32) {
|
2020-07-16 16:52:23 +00:00
|
|
|
//~^ ERROR item has unused generic parameters
|
2020-06-22 12:57:03 +00:00
|
|
|
}
|
|
|
|
|
2020-07-16 16:52:23 +00:00
|
|
|
#[rustc_polymorphize_error]
|
2020-06-22 12:57:03 +00:00
|
|
|
pub fn used<'a, T: Default>(_: &'a u32) -> u32 {
|
|
|
|
let _: T = Default::default();
|
|
|
|
let add_one = |x: u32| x + 1;
|
2020-07-16 16:52:23 +00:00
|
|
|
//~^ ERROR item has unused generic parameters
|
2020-06-22 12:57:03 +00:00
|
|
|
add_one(3)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
unused::<u32>(&3);
|
|
|
|
used::<u32>(&3);
|
|
|
|
}
|