Skip to content

Commit 86732ff

Browse files
Rollup merge of rust-lang#81566 - osa1:issue71202, r=jonas-schievink
Add a test for rust-lang#71202 Closes rust-lang#71202 --- Note that the test normally generates this warning: ``` warning: cannot use constants which depend on generic parameters in types --> test.rs:10:5 | 10 | / const ITEM_IS_COPY: [(); 1 - { 11 | | trait NotCopy { 12 | | const VALUE: bool = false; 13 | | } ... | 26 | | <IsCopy<T>>::VALUE 27 | | } as usize] = []; | |_____________________^ | = note: `#[warn(const_evaluatable_unchecked)]` on by default = 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 rust-lang#76200 <rust-lang#76200> ``` I added `allow(const_evaluatable_unchecked)`, but maybe we just don't want to add a test for this as the program is not really valid?
2 parents 47a5312 + 5f1a7aa commit 86732ff

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// check-pass
2+
3+
#![feature(const_generics)]
4+
#![allow(incomplete_features, const_evaluatable_unchecked)]
5+
6+
use std::marker::PhantomData;
7+
8+
struct DataHolder<T> {
9+
item: T,
10+
}
11+
12+
impl<T: Copy> DataHolder<T> {
13+
const ITEM_IS_COPY: [(); 1 - {
14+
trait NotCopy {
15+
const VALUE: bool = false;
16+
}
17+
18+
impl<__Type: ?Sized> NotCopy for __Type {}
19+
20+
struct IsCopy<__Type: ?Sized>(PhantomData<__Type>);
21+
22+
impl<__Type> IsCopy<__Type>
23+
where
24+
__Type: Sized + Copy,
25+
{
26+
const VALUE: bool = true;
27+
}
28+
29+
<IsCopy<T>>::VALUE
30+
} as usize] = [];
31+
}
32+
33+
fn main() {}

0 commit comments

Comments
 (0)