Skip to content

Commit

Permalink
Rollup merge of rust-lang#74445 - lcnr:const-generic-ty-decl, r=Dylan…
Browse files Browse the repository at this point in the history
…-DPC

add test for rust-lang#62878

forgot to push this as part of rust-lang#74159

r? @Dylan-DPC
  • Loading branch information
Manishearth authored Jul 18, 2020
2 parents 43ba840 + 0bac361 commit 1a54b61
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/test/ui/const-generics/issues/issue-62878.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#![feature(const_generics)] //~ WARN the feature `const_generics` is incomplete

fn foo<const N: usize, const A: [u8; N]>() {}
//~^ ERROR the type of const parameters must not

fn main() {
foo::<_, {[1]}>();
//~^ ERROR wrong number of const arguments
//~| ERROR wrong number of type arguments
//~| ERROR mismatched types
}
37 changes: 37 additions & 0 deletions src/test/ui/const-generics/issues/issue-62878.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
error[E0770]: the type of const parameters must not depend on other generic parameters
--> $DIR/issue-62878.rs:3:38
|
LL | fn foo<const N: usize, const A: [u8; N]>() {}
| ^ the type must not depend on the parameter `N`

warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/issue-62878.rs:1:12
|
LL | #![feature(const_generics)]
| ^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information

error[E0107]: wrong number of const arguments: expected 2, found 1
--> $DIR/issue-62878.rs:7:5
|
LL | foo::<_, {[1]}>();
| ^^^^^^^^^^^^^^^ expected 2 const arguments

error[E0107]: wrong number of type arguments: expected 0, found 1
--> $DIR/issue-62878.rs:7:11
|
LL | foo::<_, {[1]}>();
| ^ unexpected type argument

error[E0308]: mismatched types
--> $DIR/issue-62878.rs:7:15
|
LL | foo::<_, {[1]}>();
| ^^^ expected `usize`, found array `[{integer}; 1]`

error: aborting due to 4 previous errors; 1 warning emitted

Some errors have detailed explanations: E0107, E0308, E0770.
For more information about an error, try `rustc --explain E0107`.

0 comments on commit 1a54b61

Please sign in to comment.