diff --git a/tests/ui/const-generics/mgca/unconstrained-type-params.rs b/tests/ui/const-generics/mgca/unconstrained-type-params.rs new file mode 100644 index 0000000000000..7b9688f53818f --- /dev/null +++ b/tests/ui/const-generics/mgca/unconstrained-type-params.rs @@ -0,0 +1,12 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/146906 + +#![feature(min_generic_const_args)] + +trait Trait {} + +impl Trait for [(); N] {} +//~^ ERROR mismatched types + +fn N(f: impl FnOnce(f64) -> f64 + Trait) {} + +fn main() {} diff --git a/tests/ui/const-generics/mgca/unconstrained-type-params.stderr b/tests/ui/const-generics/mgca/unconstrained-type-params.stderr new file mode 100644 index 0000000000000..da3f64aedb15b --- /dev/null +++ b/tests/ui/const-generics/mgca/unconstrained-type-params.stderr @@ -0,0 +1,13 @@ +error[E0308]: mismatched types + --> $DIR/unconstrained-type-params.rs:7:21 + | +LL | impl Trait for [(); N] {} + | ^ expected `usize`, found fn item + | + = note: expected type `usize` + found fn item `fn(_) {N::<_>}` + = note: array length can only be `usize` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`.