Fix missing diagnostic span for impl Trait with const generics

This commit is contained in:
varkor 2020-10-02 01:39:04 +01:00
parent 8fe73e80d7
commit 0801263279
3 changed files with 31 additions and 1 deletions

View File

@ -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::<Vec<_>>();

View File

@ -0,0 +1,22 @@
#![feature(min_const_generics)]
trait Usizer {
fn m(self) -> usize;
}
fn f<const N: usize>(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
}

View File

@ -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