diff --git a/compiler/rustc_typeck/src/astconv/generics.rs b/compiler/rustc_typeck/src/astconv/generics.rs index b54de1d0916..b867798c76c 100644 --- a/compiler/rustc_typeck/src/astconv/generics.rs +++ b/compiler/rustc_typeck/src/astconv/generics.rs @@ -562,7 +562,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { .args .iter() .filter_map(|arg| match arg { - GenericArg::Type(_) => Some(arg.span()), + GenericArg::Type(_) | GenericArg::Const(_) => Some(arg.span()), _ => None, }) .collect::>(); diff --git a/src/test/ui/const-generics/min_const_generics/impl-trait-with-const-arguments.rs b/src/test/ui/const-generics/min_const_generics/impl-trait-with-const-arguments.rs new file mode 100644 index 00000000000..97ae3b838a3 --- /dev/null +++ b/src/test/ui/const-generics/min_const_generics/impl-trait-with-const-arguments.rs @@ -0,0 +1,22 @@ +#![feature(min_const_generics)] + +trait Usizer { + fn m(self) -> usize; +} + +fn f(u: impl Usizer) -> usize { + N + u.m() +} + +struct Usizable; + +impl Usizer for Usizable { + fn m(self) -> usize { + 16 + } +} + +fn main() { + assert_eq!(f::<4usize>(Usizable), 20usize); +//~^ ERROR cannot provide explicit generic arguments when `impl Trait` is used in argument position +} diff --git a/src/test/ui/const-generics/min_const_generics/impl-trait-with-const-arguments.stderr b/src/test/ui/const-generics/min_const_generics/impl-trait-with-const-arguments.stderr new file mode 100644 index 00000000000..0a6d3509863 --- /dev/null +++ b/src/test/ui/const-generics/min_const_generics/impl-trait-with-const-arguments.stderr @@ -0,0 +1,8 @@ +error[E0632]: cannot provide explicit generic arguments when `impl Trait` is used in argument position + --> $DIR/impl-trait-with-const-arguments.rs:20:20 + | +LL | assert_eq!(f::<4usize>(Usizable), 20usize); + | ^^^^^^ explicit generic argument not allowed + +error: aborting due to previous error +