const_evaluatable_unchecked to const eval
This commit is contained in:
parent
660ca48041
commit
116d35d401
12 changed files with 51 additions and 42 deletions
|
|
@ -1,5 +1,5 @@
|
|||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/dependence_lint.rs:13:32
|
||||
--> $DIR/dependence_lint.rs:14:32
|
||||
|
|
||||
LL | let _: [u8; size_of::<*mut T>()]; // error on stable, error with gce
|
||||
| ^ cannot perform const operation using `T`
|
||||
|
|
@ -8,7 +8,7 @@ LL | let _: [u8; size_of::<*mut T>()]; // error on stable, error with gce
|
|||
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
|
||||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/dependence_lint.rs:20:37
|
||||
--> $DIR/dependence_lint.rs:21:37
|
||||
|
|
||||
LL | let _: [u8; if true { size_of::<T>() } else { 3 }]; // error on stable, error with gce
|
||||
| ^ cannot perform const operation using `T`
|
||||
|
|
@ -17,7 +17,7 @@ LL | let _: [u8; if true { size_of::<T>() } else { 3 }]; // error on stable,
|
|||
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
|
||||
warning: cannot use constants which depend on generic parameters in types
|
||||
--> $DIR/dependence_lint.rs:9:9
|
||||
--> $DIR/dependence_lint.rs:10:9
|
||||
|
|
||||
LL | [0; size_of::<*mut T>()]; // lint on stable, error with `generic_const_exprs`
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -27,7 +27,7 @@ LL | [0; size_of::<*mut T>()]; // lint on stable, error with `generic_const_
|
|||
= note: `#[warn(const_evaluatable_unchecked)]` on by default
|
||||
|
||||
warning: cannot use constants which depend on generic parameters in types
|
||||
--> $DIR/dependence_lint.rs:16:9
|
||||
--> $DIR/dependence_lint.rs:17:9
|
||||
|
|
||||
LL | [0; if false { size_of::<T>() } else { 3 }]; // lint on stable, error with gce
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: overly complex generic constant
|
||||
--> $DIR/dependence_lint.rs:16:9
|
||||
--> $DIR/dependence_lint.rs:17:9
|
||||
|
|
||||
LL | [0; if false { size_of::<T>() } else { 3 }]; // lint on stable, error with gce
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ control flow is not supported in generic constants
|
||||
|
|
@ -7,7 +7,7 @@ LL | [0; if false { size_of::<T>() } else { 3 }]; // lint on stable, error w
|
|||
= help: consider moving this anonymous constant into a `const` function
|
||||
|
||||
error: overly complex generic constant
|
||||
--> $DIR/dependence_lint.rs:20:17
|
||||
--> $DIR/dependence_lint.rs:21:17
|
||||
|
|
||||
LL | let _: [u8; if true { size_of::<T>() } else { 3 }]; // error on stable, error with gce
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ control flow is not supported in generic constants
|
||||
|
|
@ -15,7 +15,7 @@ LL | let _: [u8; if true { size_of::<T>() } else { 3 }]; // error on stable,
|
|||
= help: consider moving this anonymous constant into a `const` function
|
||||
|
||||
error: unconstrained generic constant
|
||||
--> $DIR/dependence_lint.rs:13:12
|
||||
--> $DIR/dependence_lint.rs:14:12
|
||||
|
|
||||
LL | let _: [u8; size_of::<*mut T>()]; // error on stable, error with gce
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -23,7 +23,7 @@ LL | let _: [u8; size_of::<*mut T>()]; // error on stable, error with gce
|
|||
= help: try adding a `where` bound using this expression: `where [(); size_of::<*mut T>()]:`
|
||||
|
||||
error: unconstrained generic constant
|
||||
--> $DIR/dependence_lint.rs:9:9
|
||||
--> $DIR/dependence_lint.rs:10:9
|
||||
|
|
||||
LL | [0; size_of::<*mut T>()]; // lint on stable, error with `generic_const_exprs`
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
// revisions: full gce
|
||||
// compile-flags: -Zdeduplicate-diagnostics=yes
|
||||
|
||||
#![cfg_attr(gce, feature(generic_const_exprs))]
|
||||
#![allow(incomplete_features)]
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
// check-pass
|
||||
// compile-flags: -Zdeduplicate-diagnostics=yes
|
||||
|
||||
const fn foo<T>() -> usize {
|
||||
// We might instead branch on `std::mem::size_of::<*mut T>() < 8` here,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
warning: cannot use constants which depend on generic parameters in types
|
||||
--> $DIR/function-call.rs:14:17
|
||||
--> $DIR/function-call.rs:15:17
|
||||
|
|
||||
LL | let _ = [0; foo::<T>()];
|
||||
| ^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// compile-flags: -Zdeduplicate-diagnostics=yes
|
||||
use std::mem::size_of;
|
||||
|
||||
fn test<const N: usize>() {}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/complex-expression.rs:9:38
|
||||
--> $DIR/complex-expression.rs:10:38
|
||||
|
|
||||
LL | struct Break0<const N: usize>([u8; { N + 1 }]);
|
||||
| ^ cannot perform const operation using `N`
|
||||
|
|
@ -8,7 +8,7 @@ LL | struct Break0<const N: usize>([u8; { N + 1 }]);
|
|||
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
|
||||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/complex-expression.rs:12:40
|
||||
--> $DIR/complex-expression.rs:13:40
|
||||
|
|
||||
LL | struct Break1<const N: usize>([u8; { { N } }]);
|
||||
| ^ cannot perform const operation using `N`
|
||||
|
|
@ -17,7 +17,7 @@ LL | struct Break1<const N: usize>([u8; { { N } }]);
|
|||
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
|
||||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/complex-expression.rs:16:17
|
||||
--> $DIR/complex-expression.rs:17:17
|
||||
|
|
||||
LL | let _: [u8; N + 1];
|
||||
| ^ cannot perform const operation using `N`
|
||||
|
|
@ -26,7 +26,7 @@ LL | let _: [u8; N + 1];
|
|||
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
|
||||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/complex-expression.rs:21:17
|
||||
--> $DIR/complex-expression.rs:22:17
|
||||
|
|
||||
LL | let _ = [0; N + 1];
|
||||
| ^ cannot perform const operation using `N`
|
||||
|
|
@ -35,7 +35,7 @@ LL | let _ = [0; N + 1];
|
|||
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
|
||||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/complex-expression.rs:25:45
|
||||
--> $DIR/complex-expression.rs:26:45
|
||||
|
|
||||
LL | struct BreakTy0<T>(T, [u8; { size_of::<*mut T>() }]);
|
||||
| ^ cannot perform const operation using `T`
|
||||
|
|
@ -44,7 +44,7 @@ LL | struct BreakTy0<T>(T, [u8; { size_of::<*mut T>() }]);
|
|||
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
|
||||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/complex-expression.rs:28:47
|
||||
--> $DIR/complex-expression.rs:29:47
|
||||
|
|
||||
LL | struct BreakTy1<T>(T, [u8; { { size_of::<*mut T>() } }]);
|
||||
| ^ cannot perform const operation using `T`
|
||||
|
|
@ -53,7 +53,7 @@ LL | struct BreakTy1<T>(T, [u8; { { size_of::<*mut T>() } }]);
|
|||
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
|
||||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/complex-expression.rs:32:32
|
||||
--> $DIR/complex-expression.rs:33:32
|
||||
|
|
||||
LL | let _: [u8; size_of::<*mut T>() + 1];
|
||||
| ^ cannot perform const operation using `T`
|
||||
|
|
@ -62,7 +62,7 @@ LL | let _: [u8; size_of::<*mut T>() + 1];
|
|||
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
|
||||
warning: cannot use constants which depend on generic parameters in types
|
||||
--> $DIR/complex-expression.rs:37:17
|
||||
--> $DIR/complex-expression.rs:38:17
|
||||
|
|
||||
LL | let _ = [0; size_of::<*mut T>() + 1];
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
// check-pass
|
||||
// compile-flags: -Zdeduplicate-diagnostics=yes
|
||||
#![allow(dead_code)]
|
||||
|
||||
fn foo<T>() {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
warning: cannot use constants which depend on generic parameters in types
|
||||
--> $DIR/const-evaluatable-unchecked.rs:5:9
|
||||
--> $DIR/const-evaluatable-unchecked.rs:6:9
|
||||
|
|
||||
LL | [0; std::mem::size_of::<*mut T>()];
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -9,7 +9,7 @@ LL | [0; std::mem::size_of::<*mut T>()];
|
|||
= note: `#[warn(const_evaluatable_unchecked)]` on by default
|
||||
|
||||
warning: cannot use constants which depend on generic parameters in types
|
||||
--> $DIR/const-evaluatable-unchecked.rs:16:21
|
||||
--> $DIR/const-evaluatable-unchecked.rs:17:21
|
||||
|
|
||||
LL | let _ = [0; Self::ASSOC];
|
||||
| ^^^^^^^^^^^
|
||||
|
|
@ -18,7 +18,7 @@ LL | let _ = [0; Self::ASSOC];
|
|||
= note: for more information, see issue #76200 <https://github.com/rust-lang/rust/issues/76200>
|
||||
|
||||
warning: cannot use constants which depend on generic parameters in types
|
||||
--> $DIR/const-evaluatable-unchecked.rs:28:21
|
||||
--> $DIR/const-evaluatable-unchecked.rs:29:21
|
||||
|
|
||||
LL | let _ = [0; Self::ASSOC];
|
||||
| ^^^^^^^^^^^
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue