Update const generics tests

Co-Authored-By: Gabriel Smith <yodaldevoid@users.noreply.github.com>
This commit is contained in:
varkor 2019-02-20 01:20:22 +00:00
parent 54b935b9b9
commit 4c18ee4abd
10 changed files with 30 additions and 53 deletions

View File

@ -2,7 +2,6 @@
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
fn u32_identity<const X: u32>() -> u32 {
//~^ ERROR const generics in any position are currently unsupported
5
}
@ -16,6 +15,8 @@ fn foo_b() {
fn foo_c() {
u32_identity::< -1 >(); // ok
// FIXME(const_generics)
//~^^ ERROR cannot apply unary operator `-` to type `u32` [E0600]
}
fn main() {

View File

@ -1,11 +1,11 @@
error: expected identifier, found `<-`
--> $DIR/const-expression-parameter.rs:10:19
--> $DIR/const-expression-parameter.rs:9:19
|
LL | u32_identity::<-1>(); //~ ERROR expected identifier, found `<-`
| ^^ expected identifier
error: expected one of `,` or `>`, found `+`
--> $DIR/const-expression-parameter.rs:14:22
--> $DIR/const-expression-parameter.rs:13:22
|
LL | u32_identity::<1 + 2>(); //~ ERROR expected one of `,` or `>`, found `+`
| ^ expected one of `,` or `>` here
@ -16,11 +16,14 @@ warning: the feature `const_generics` is incomplete and may cause the compiler t
LL | #![feature(const_generics)]
| ^^^^^^^^^^^^^^
error: const generics in any position are currently unsupported
--> $DIR/const-expression-parameter.rs:4:23
error[E0600]: cannot apply unary operator `-` to type `u32`
--> $DIR/const-expression-parameter.rs:17:21
|
LL | fn u32_identity<const X: u32>() -> u32 {
| ^
LL | u32_identity::< -1 >(); // ok
| ^^ cannot apply unary operator `-`
|
= note: unsigned values cannot be negated
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0600`.

View File

@ -3,7 +3,6 @@
const fn const_u32_identity<const X: u32>() -> u32 {
//~^ ERROR const parameters are not permitted in `const fn`
//~^^ ERROR const generics in any position are currently unsupported
X
}

View File

@ -9,16 +9,9 @@ error: const parameters are not permitted in `const fn`
|
LL | / const fn const_u32_identity<const X: u32>() -> u32 {
LL | | //~^ ERROR const parameters are not permitted in `const fn`
LL | | //~^^ ERROR const generics in any position are currently unsupported
LL | | X
LL | | }
| |_^
error: const generics in any position are currently unsupported
--> $DIR/const-fn-with-const-param.rs:4:35
|
LL | const fn const_u32_identity<const X: u32>() -> u32 {
| ^
error: aborting due to 2 previous errors
error: aborting due to previous error

View File

@ -1,14 +1,12 @@
#![feature(const_generics)]
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
fn foo<const X: (), T>(_: T) {
fn foo<const X: (), T>(_: &T) {
//~^ ERROR type parameters must be declared prior to const parameters
//~^^ ERROR const generics in any position are currently unsupported
}
fn bar<const X: (), 'a>(_: &'a ()) {
//~^ ERROR lifetime parameters must be declared prior to const parameters
//~^^ ERROR const generics in any position are currently unsupported
}
fn main() {}

View File

@ -7,26 +7,14 @@ LL | #![feature(const_generics)]
error: type parameters must be declared prior to const parameters
--> $DIR/const-param-before-other-params.rs:4:21
|
LL | fn foo<const X: (), T>(_: T) {
LL | fn foo<const X: (), T>(_: &T) {
| --------------^- help: reorder the parameters: lifetimes, then types, then consts: `<T, const X: ()>`
error: lifetime parameters must be declared prior to const parameters
--> $DIR/const-param-before-other-params.rs:9:21
--> $DIR/const-param-before-other-params.rs:8:21
|
LL | fn bar<const X: (), 'a>(_: &'a ()) {
| --------------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, const X: ()>`
error: const generics in any position are currently unsupported
--> $DIR/const-param-before-other-params.rs:4:14
|
LL | fn foo<const X: (), T>(_: T) {
| ^
error: const generics in any position are currently unsupported
--> $DIR/const-param-before-other-params.rs:9:14
|
LL | fn bar<const X: (), 'a>(_: &'a ()) {
| ^
error: aborting due to 4 previous errors
error: aborting due to 2 previous errors

View File

@ -2,7 +2,6 @@
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
fn foo<const X: u32>() {
//~^ ERROR const generics in any position are currently unsupported
fn bar() -> u32 {
X //~ ERROR can't use generic parameters from outer function
}

View File

@ -5,22 +5,15 @@ LL | #![feature(const_generics)]
| ^^^^^^^^^^^^^^
error[E0401]: can't use generic parameters from outer function
--> $DIR/const-param-from-outer-fn.rs:7:9
--> $DIR/const-param-from-outer-fn.rs:6:9
|
LL | fn foo<const X: u32>() {
| - const variable from outer function
LL | //~^ ERROR const generics in any position are currently unsupported
LL | fn bar() -> u32 {
| --- try adding a local generic parameter in this method instead
LL | X //~ ERROR can't use generic parameters from outer function
| ^ use of generic parameter from outer function
error: const generics in any position are currently unsupported
--> $DIR/const-param-from-outer-fn.rs:4:14
|
LL | fn foo<const X: u32>() {
| ^
error: aborting due to 2 previous errors
error: aborting due to previous error
For more information about this error, try `rustc --explain E0401`.

View File

@ -4,5 +4,7 @@
#![deny(non_upper_case_globals)]
fn noop<const x: u32>() {
//~^ ERROR const generics in any position are currently unsupported
//~^ ERROR const parameter `x` should have an upper case name
}
fn main() {}

View File

@ -4,16 +4,17 @@ warning: the feature `const_generics` is incomplete and may cause the compiler t
LL | #![feature(const_generics)]
| ^^^^^^^^^^^^^^
error[E0601]: `main` function not found in crate `const_parameter_uppercase_lint`
|
= note: consider adding a `main` function to `$DIR/const-parameter-uppercase-lint.rs`
error: const generics in any position are currently unsupported
error: const parameter `x` should have an upper case name
--> $DIR/const-parameter-uppercase-lint.rs:6:15
|
LL | fn noop<const x: u32>() {
| ^
| ^ help: convert the identifier to upper case: `X`
|
note: lint level defined here
--> $DIR/const-parameter-uppercase-lint.rs:4:9
|
LL | #![deny(non_upper_case_globals)]
| ^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors
error: aborting due to previous error
For more information about this error, try `rustc --explain E0601`.