Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 1a54b61

Browse files
authoredJul 18, 2020
Rollup merge of rust-lang#74445 - lcnr:const-generic-ty-decl, r=Dylan-DPC
add test for rust-lang#62878 forgot to push this as part of rust-lang#74159 r? @Dylan-DPC
2 parents 43ba840 + 0bac361 commit 1a54b61

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#![feature(const_generics)] //~ WARN the feature `const_generics` is incomplete
2+
3+
fn foo<const N: usize, const A: [u8; N]>() {}
4+
//~^ ERROR the type of const parameters must not
5+
6+
fn main() {
7+
foo::<_, {[1]}>();
8+
//~^ ERROR wrong number of const arguments
9+
//~| ERROR wrong number of type arguments
10+
//~| ERROR mismatched types
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
error[E0770]: the type of const parameters must not depend on other generic parameters
2+
--> $DIR/issue-62878.rs:3:38
3+
|
4+
LL | fn foo<const N: usize, const A: [u8; N]>() {}
5+
| ^ the type must not depend on the parameter `N`
6+
7+
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
8+
--> $DIR/issue-62878.rs:1:12
9+
|
10+
LL | #![feature(const_generics)]
11+
| ^^^^^^^^^^^^^^
12+
|
13+
= note: `#[warn(incomplete_features)]` on by default
14+
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
15+
16+
error[E0107]: wrong number of const arguments: expected 2, found 1
17+
--> $DIR/issue-62878.rs:7:5
18+
|
19+
LL | foo::<_, {[1]}>();
20+
| ^^^^^^^^^^^^^^^ expected 2 const arguments
21+
22+
error[E0107]: wrong number of type arguments: expected 0, found 1
23+
--> $DIR/issue-62878.rs:7:11
24+
|
25+
LL | foo::<_, {[1]}>();
26+
| ^ unexpected type argument
27+
28+
error[E0308]: mismatched types
29+
--> $DIR/issue-62878.rs:7:15
30+
|
31+
LL | foo::<_, {[1]}>();
32+
| ^^^ expected `usize`, found array `[{integer}; 1]`
33+
34+
error: aborting due to 4 previous errors; 1 warning emitted
35+
36+
Some errors have detailed explanations: E0107, E0308, E0770.
37+
For more information about an error, try `rustc --explain E0107`.

0 commit comments

Comments
 (0)
Please sign in to comment.