Fortify generic param default checks

This commit is contained in:
León Orell Valerian Liehr
2025-08-06 01:26:26 +02:00
parent ec7c026125
commit 02ea38cfff
30 changed files with 298 additions and 286 deletions

View File

@@ -1,7 +1,15 @@
// Ensure that we reject generic parameters on foreign items.
extern "C" {
fn foo<T>(); //~ ERROR foreign items may not have type parameters
// Furthermore, check that type parameter defaults lead to a *hard* error,
// not just a lint error, for maximum forward compatibility.
#[allow(invalid_type_param_default)] // Should have no effect here.
fn bar<T = ()>(); //~ ERROR foreign items may not have type parameters
//~^ ERROR defaults for generic parameters are not allowed here
}
fn main() {
foo::<i32>(); //~ ERROR requires unsafe
unsafe { foo::<i32>() };
}