2020-06-22 07:57:03 -05:00
|
|
|
//@ build-fail
|
2020-07-22 09:03:56 -05:00
|
|
|
//@ compile-flags:-Zpolymorphize=on
|
2020-07-16 11:52:23 -05:00
|
|
|
#![feature(fn_traits, rustc_attrs, unboxed_closures)]
|
2020-06-22 07:57:03 -05:00
|
|
|
|
|
|
|
// This test checks that the polymorphization analysis considers a closure
|
|
|
|
// as using all generic parameters if it does an unsizing cast.
|
|
|
|
|
2020-07-16 11:52:23 -05:00
|
|
|
#[rustc_polymorphize_error]
|
2020-06-22 07:57:03 -05:00
|
|
|
fn foo<T: Default>() {
|
|
|
|
let _: T = Default::default();
|
|
|
|
(|| Box::new(|| {}) as Box<dyn Fn()>)();
|
|
|
|
//~^ ERROR item has unused generic parameters
|
|
|
|
//~^^ ERROR item has unused generic parameters
|
|
|
|
}
|
|
|
|
|
2020-07-16 11:52:23 -05:00
|
|
|
#[rustc_polymorphize_error]
|
2020-06-22 07:57:03 -05:00
|
|
|
fn foo2<T: Default>() {
|
|
|
|
let _: T = Default::default();
|
|
|
|
(|| {
|
2020-08-07 09:59:29 -05:00
|
|
|
//~^ ERROR item has unused generic parameters
|
2020-06-22 07:57:03 -05:00
|
|
|
let call: extern "rust-call" fn(_, _) = Fn::call;
|
|
|
|
call(&|| {}, ());
|
|
|
|
//~^ ERROR item has unused generic parameters
|
|
|
|
})();
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
foo::<u32>();
|
|
|
|
foo2::<u32>();
|
|
|
|
}
|