Skip to content

Commit

Permalink
Fix missing diagnostic span for impl Trait with const generics
Browse files Browse the repository at this point in the history
  • Loading branch information
varkor committed Oct 2, 2020
1 parent 8fe73e8 commit 0801263
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/rustc_typeck/src/astconv/generics.rs
Expand Up @@ -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<_>>();
Expand Down
@@ -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
}
@@ -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

0 comments on commit 0801263

Please sign in to comment.