-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix missing diagnostic span for
impl Trait
with const generics
- Loading branch information
Showing
3 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/test/ui/const-generics/min_const_generics/impl-trait-with-const-arguments.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
8 changes: 8 additions & 0 deletions
8
src/test/ui/const-generics/min_const_generics/impl-trait-with-const-arguments.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|