Skip to content

Commit 50d1dd1

Browse files
committed
Add a test for an incorrect number of const args
1 parent 5509991 commit 50d1dd1

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn foo<const X: usize>() -> usize { 0 }
12+
13+
fn main() {
14+
foo(); //~ ERROR too few const parameters provided
15+
foo::<0, 0>(); //~ ERROR too many const parameters provided
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
error[E0086]: too few const parameters provided: expected 1 const parameter, found 0 const parameters
2+
--> $DIR/incorrect-number-of-const-args.rs:14:5
3+
|
4+
LL | foo(); //~ ERROR too few const parameters provided
5+
| ^^^ expected 1 const parameter
6+
7+
error[E0085]: too many const parameters provided: expected at most 1 const parameter, found 2 const parameters
8+
--> $DIR/incorrect-number-of-const-args.rs:15:14
9+
|
10+
LL | foo::<0, 0>(); //~ ERROR too many const parameters provided
11+
| ^ expected 1 const parameter
12+
13+
error: aborting due to 2 previous errors
14+
15+
Some errors occurred: E0085, E0086.
16+
For more information about an error, try `rustc --explain E0085`.

0 commit comments

Comments
 (0)