2020-06-22 07:57:03 -05:00
|
|
|
// build-fail
|
2020-07-22 09:03:56 -05:00
|
|
|
// compile-flags:-Zpolymorphize=on
|
2021-08-27 11:04:57 -05:00
|
|
|
#![feature(generic_const_exprs, rustc_attrs)]
|
|
|
|
//~^ WARN the feature `generic_const_exprs` is incomplete
|
2020-06-22 07:57:03 -05:00
|
|
|
|
|
|
|
// This test checks that the polymorphization analysis correctly detects unused const
|
|
|
|
// parameters in functions.
|
|
|
|
|
|
|
|
// Function doesn't have any generic parameters to be unused.
|
2020-07-16 11:52:23 -05:00
|
|
|
#[rustc_polymorphize_error]
|
2020-06-22 07:57:03 -05:00
|
|
|
pub fn no_parameters() {}
|
|
|
|
|
|
|
|
// Function has an unused generic parameter.
|
2020-07-16 11:52:23 -05:00
|
|
|
#[rustc_polymorphize_error]
|
2020-06-22 07:57:03 -05:00
|
|
|
pub fn unused<const T: usize>() {
|
2020-07-16 11:52:23 -05:00
|
|
|
//~^ ERROR item has unused generic parameters
|
2020-06-22 07:57:03 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// Function uses generic parameter in value of a binding.
|
2020-07-16 11:52:23 -05:00
|
|
|
#[rustc_polymorphize_error]
|
2020-06-22 07:57:03 -05:00
|
|
|
pub fn used_binding<const T: usize>() -> usize {
|
|
|
|
let x: usize = T;
|
|
|
|
x
|
|
|
|
}
|
|
|
|
|
|
|
|
// Function uses generic parameter in substitutions to another function.
|
2020-07-16 11:52:23 -05:00
|
|
|
#[rustc_polymorphize_error]
|
2020-06-22 07:57:03 -05:00
|
|
|
pub fn used_substs<const T: usize>() {
|
|
|
|
unused::<T>()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
no_parameters();
|
|
|
|
unused::<1>();
|
|
|
|
used_binding::<1>();
|
|
|
|
used_substs::<1>();
|
|
|
|
}
|