add tests for self with const params
This commit is contained in:
parent
4a15a25662
commit
83ecbb4a29
3 changed files with 31 additions and 7 deletions
|
|
@ -1,4 +1,5 @@
|
|||
// check-pass
|
||||
#![feature(min_const_generics)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
fn foo<T>() {
|
||||
|
|
@ -13,7 +14,19 @@ impl<T> Foo<T> {
|
|||
const ASSOC: usize = 4;
|
||||
|
||||
fn test() {
|
||||
[0; Self::ASSOC];
|
||||
let _ = [0; Self::ASSOC];
|
||||
//~^ WARN cannot use constants which depend on generic parameters in types
|
||||
//~| WARN this was previously accepted by the compiler but is being phased out
|
||||
}
|
||||
}
|
||||
|
||||
struct Bar<const N: usize>;
|
||||
|
||||
impl<const N: usize> Bar<N> {
|
||||
const ASSOC: usize = 4;
|
||||
|
||||
fn test() {
|
||||
let _ = [0; Self::ASSOC];
|
||||
//~^ WARN cannot use constants which depend on generic parameters in types
|
||||
//~| WARN this was previously accepted by the compiler but is being phased out
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,13 +9,22 @@ LL | [0; std::mem::size_of::<*mut T>()];
|
|||
= 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:16:13
|
||||
--> $DIR/const-evaluatable-unchecked.rs:17:21
|
||||
|
|
||||
LL | [0; Self::ASSOC];
|
||||
| ^^^^^^^^^^^
|
||||
LL | let _ = [0; Self::ASSOC];
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #76200 <https://github.com/rust-lang/rust/issues/76200>
|
||||
|
||||
warning: 2 warnings emitted
|
||||
warning: cannot use constants which depend on generic parameters in types
|
||||
--> $DIR/const-evaluatable-unchecked.rs:29:21
|
||||
|
|
||||
LL | let _ = [0; Self::ASSOC];
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #76200 <https://github.com/rust-lang/rust/issues/76200>
|
||||
|
||||
warning: 3 warnings emitted
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue