Skip to content

Commit

Permalink
Auto merge of #75322 - JulianKnodt:revisions, r=lcnr
Browse files Browse the repository at this point in the history
Add a bunch of const-generic revisions for `min_const_generics`

This adds a bunch of revisions to `const-generic` tests which is part of #75279, but doesn't cover everything.

r? @lcnr
  • Loading branch information
bors committed Aug 13, 2020
2 parents 3fbed17 + 5c0b416 commit 1a7d9f5
Show file tree
Hide file tree
Showing 155 changed files with 1,325 additions and 853 deletions.
6 changes: 4 additions & 2 deletions src/test/ui/const-generics/apit-with-const-param.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// check-pass
// revisions: full min

#![feature(const_generics)]
//~^ WARN the feature `const_generics` is incomplete
#![cfg_attr(full, feature(const_generics))]
#![cfg_attr(full, allow(incomplete_features))]
#![cfg_attr(min, feature(min_const_generics))]

trait Trait {}

Expand Down
11 changes: 0 additions & 11 deletions src/test/ui/const-generics/apit-with-const-param.stderr

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
error: constant expression depends on a generic parameter
--> $DIR/array-size-in-generic-struct-param.rs:9:38
|
LL | struct ArithArrayLen<const N: usize>([u32; 0 + N]);
| ^^^^^^^^^^^^
|
= note: this may fail depending on what value the parameter takes

error: constant expression depends on a generic parameter
--> $DIR/array-size-in-generic-struct-param.rs:20:10
|
LL | arr: [u8; CFG.arr_size],
| ^^^^^^^^^^^^^^^^^^
|
= note: this may fail depending on what value the parameter takes

error: aborting due to 2 previous errors

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
error: generic parameters must not be used inside of non trivial constant values
--> $DIR/array-size-in-generic-struct-param.rs:9:48
|
LL | struct ArithArrayLen<const N: usize>([u32; 0 + N]);
| ^ non-trivial anonymous constants must not depend on the parameter `N`
|
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants

error: generic parameters must not be used inside of non trivial constant values
--> $DIR/array-size-in-generic-struct-param.rs:20:15
|
LL | arr: [u8; CFG.arr_size],
| ^^^ non-trivial anonymous constants must not depend on the parameter `CFG`
|
= help: it is currently only allowed to use either `CFG` or `{ CFG }` as generic constants

error: using `Config` as const generic parameters is forbidden
--> $DIR/array-size-in-generic-struct-param.rs:18:21
|
LL | struct B<const CFG: Config> {
| ^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
= note: more complex types are supported with `#[feature(const_generics)]`

error: aborting due to 3 previous errors

16 changes: 12 additions & 4 deletions src/test/ui/const-generics/array-size-in-generic-struct-param.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
#![feature(const_generics)]
//~^ WARN the feature `const_generics` is incomplete
// Tests that array sizes that depend on const-params are checked using `ConstEvaluatable`.
// revisions: full min

#![cfg_attr(full, feature(const_generics))]
#![cfg_attr(full, allow(incomplete_features))]
#![cfg_attr(min, feature(min_const_generics))]

#[allow(dead_code)]
struct ArithArrayLen<const N: usize>([u32; 0 + N]);
//~^ ERROR constant expression depends on a generic parameter
//[full]~^ ERROR constant expression depends on a generic parameter
//[min]~^^ ERROR generic parameters must not be used inside of non trivial constant values

#[derive(PartialEq, Eq)]
struct Config {
arr_size: usize,
}

struct B<const CFG: Config> {
arr: [u8; CFG.arr_size], //~ ERROR constant expression depends on a generic parameter
//[min]~^ ERROR using `Config` as const generic parameters is forbidden
arr: [u8; CFG.arr_size],
//[full]~^ ERROR constant expression depends on a generic parameter
//[min]~^^ ERROR generic parameters must not be used inside of non trivial
}

const C: Config = Config { arr_size: 5 };
Expand Down

This file was deleted.

6 changes: 4 additions & 2 deletions src/test/ui/const-generics/broken-mir-1.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// run-pass
// revisions: full min

#![feature(const_generics)]
//~^ WARN the feature `const_generics` is incomplete
#![cfg_attr(full, feature(const_generics))]
#![cfg_attr(full, allow(incomplete_features))]
#![cfg_attr(min, feature(min_const_generics))]

pub trait Foo {
fn foo(&self);
Expand Down
11 changes: 0 additions & 11 deletions src/test/ui/const-generics/broken-mir-1.stderr

This file was deleted.

6 changes: 4 additions & 2 deletions src/test/ui/const-generics/broken-mir-2.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// run-pass
// revisions: full min

#![feature(const_generics)]
//~^ WARN the feature `const_generics` is incomplete
#![cfg_attr(full, feature(const_generics))]
#![cfg_attr(full, allow(incomplete_features))]
#![cfg_attr(min, feature(min_const_generics))]

use std::fmt::Debug;

Expand Down
11 changes: 0 additions & 11 deletions src/test/ui/const-generics/broken-mir-2.stderr

This file was deleted.

11 changes: 11 additions & 0 deletions src/test/ui/const-generics/cannot-infer-const-args.full.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
error[E0282]: type annotations needed
--> $DIR/cannot-infer-const-args.rs:12:5
|
LL | foo();
| ^^^
|
= note: unable to infer the value of a const parameter

error: aborting due to previous error

For more information about this error, try `rustc --explain E0282`.
11 changes: 11 additions & 0 deletions src/test/ui/const-generics/cannot-infer-const-args.min.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
error[E0282]: type annotations needed
--> $DIR/cannot-infer-const-args.rs:12:5
|
LL | foo();
| ^^^
|
= note: unable to infer the value of a const parameter

error: aborting due to previous error

For more information about this error, try `rustc --explain E0282`.
7 changes: 5 additions & 2 deletions src/test/ui/const-generics/cannot-infer-const-args.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#![feature(const_generics)]
//~^ WARN the feature `const_generics` is incomplete
// revisions: full min

#![cfg_attr(full, feature(const_generics))]
#![cfg_attr(full, allow(incomplete_features))]
#![cfg_attr(min, feature(min_const_generics))]

fn foo<const X: usize>() -> usize {
0
Expand Down
20 changes: 0 additions & 20 deletions src/test/ui/const-generics/cannot-infer-const-args.stderr

This file was deleted.

7 changes: 5 additions & 2 deletions src/test/ui/const-generics/coerce_unsized_array.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// run-pass
#![feature(const_generics)]
#![allow(incomplete_features)]
// revisions: full min

#![cfg_attr(full, feature(const_generics))]
#![cfg_attr(full, allow(incomplete_features))]
#![cfg_attr(min, feature(min_const_generics))]

fn foo<const N: usize>(v: &[u8; N]) -> &[u8] {
v
Expand Down
6 changes: 4 additions & 2 deletions src/test/ui/const-generics/concrete-const-as-fn-arg.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// Test that a concrete const type i.e. A<2>, can be used as an argument type in a function
// run-pass
// revisions: full min

#![feature(const_generics)]
//~^ WARN the feature `const_generics` is incomplete
#![cfg_attr(full, feature(const_generics))]
#![cfg_attr(full, allow(incomplete_features))]
#![cfg_attr(min, feature(min_const_generics))]

struct A<const N: usize>; // ok

Expand Down
11 changes: 0 additions & 11 deletions src/test/ui/const-generics/concrete-const-as-fn-arg.stderr

This file was deleted.

6 changes: 4 additions & 2 deletions src/test/ui/const-generics/concrete-const-impl-method.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// Test that a method/associated non-method within an impl block of a concrete const type i.e. A<2>,
// is callable.
// run-pass
// revisions: full min

#![feature(const_generics)]
//~^ WARN the feature `const_generics` is incomplete
#![cfg_attr(full, feature(const_generics))]
#![cfg_attr(full, allow(incomplete_features))]
#![cfg_attr(min, feature(min_const_generics))]

pub struct A<const N: u32>;

Expand Down
11 changes: 0 additions & 11 deletions src/test/ui/const-generics/concrete-const-impl-method.stderr

This file was deleted.

7 changes: 5 additions & 2 deletions src/test/ui/const-generics/condition-in-trait-const-arg.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
// Checks that `impl Trait<{anon_const}> for Type` evaluates successfully.
// run-pass
// revisions: full min

#![feature(const_generics)]
//~^ WARN the feature `const_generics` is incomplete
#![cfg_attr(full, feature(const_generics))]
#![cfg_attr(full, allow(incomplete_features))]
#![cfg_attr(min, feature(min_const_generics))]

trait IsZeroTrait<const IS_ZERO: bool>{}

Expand Down
11 changes: 0 additions & 11 deletions src/test/ui/const-generics/condition-in-trait-const-arg.stderr

This file was deleted.

6 changes: 4 additions & 2 deletions src/test/ui/const-generics/const-arg-in-fn.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// run-pass
// revisions: full min

#![feature(const_generics)]
//~^ WARN the feature `const_generics` is incomplete
#![cfg_attr(full, feature(const_generics))]
#![cfg_attr(full, allow(incomplete_features))]
#![cfg_attr(min, feature(min_const_generics))]

fn const_u32_identity<const X: u32>() -> u32 {
X
Expand Down
11 changes: 0 additions & 11 deletions src/test/ui/const-generics/const-arg-in-fn.stderr

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// run-pass
// revisions: full
// FIXME(#75323) Omitted min revision for now due to ICE.

#![feature(const_generics)]
//~^ WARN the feature `const_generics` is incomplete
#![cfg_attr(full, feature(const_generics))]
#![cfg_attr(full, allow(incomplete_features))]
#![allow(dead_code)]

fn test<const N: usize>() {}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
error: expected one of `,` or `>`, found `+`
--> $DIR/const-expression-parameter.rs:16:22
|
LL | i32_identity::<1 + 2>();
| ^ expected one of `,` or `>`

error: aborting due to previous error

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
error: expected one of `,` or `>`, found `+`
--> $DIR/const-expression-parameter.rs:16:22
|
LL | i32_identity::<1 + 2>();
| ^ expected one of `,` or `>`

error: aborting due to previous error

7 changes: 5 additions & 2 deletions src/test/ui/const-generics/const-expression-parameter.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#![feature(const_generics)]
//~^ WARN the feature `const_generics` is incomplete
// revisions: full min

#![cfg_attr(full, feature(const_generics))]
#![cfg_attr(full, allow(incomplete_features))]
#![cfg_attr(min, feature(min_const_generics))]

fn i32_identity<const X: i32>() -> i32 {
5
Expand Down
Loading

0 comments on commit 1a7d9f5

Please sign in to comment.