mir: use attribute over -Z polymorphize-errors
This commit replaces the `-Z polymorphize-errors` debugging flag with a `#[rustc_polymorphize_error]` attribute for use on functions. Signed-off-by: David Wood <david@davidtw.co>
This commit is contained in:
parent
5ce29d3d6f
commit
b1f8bd6356
21 changed files with 125 additions and 76 deletions
|
@ -1,26 +1,29 @@
|
|||
// build-fail
|
||||
// compile-flags: -Zpolymorphize-errors
|
||||
#![feature(const_generics)]
|
||||
#![feature(const_generics, rustc_attrs)]
|
||||
//~^ WARN the feature `const_generics` is incomplete
|
||||
|
||||
// This test checks that the polymorphization analysis correctly detects unused const
|
||||
// parameters in functions.
|
||||
|
||||
// Function doesn't have any generic parameters to be unused.
|
||||
#[rustc_polymorphize_error]
|
||||
pub fn no_parameters() {}
|
||||
|
||||
// Function has an unused generic parameter.
|
||||
#[rustc_polymorphize_error]
|
||||
pub fn unused<const T: usize>() {
|
||||
//~^ ERROR item has unused generic parameters
|
||||
//~^ ERROR item has unused generic parameters
|
||||
}
|
||||
|
||||
// Function uses generic parameter in value of a binding.
|
||||
#[rustc_polymorphize_error]
|
||||
pub fn used_binding<const T: usize>() -> usize {
|
||||
let x: usize = T;
|
||||
x
|
||||
}
|
||||
|
||||
// Function uses generic parameter in substitutions to another function.
|
||||
#[rustc_polymorphize_error]
|
||||
pub fn used_substs<const T: usize>() {
|
||||
unused::<T>()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue