Skip to content

Commit 55dcc20

Browse files
committed
Add tests for uninferred consts during codegen
1 parent 4ad5c62 commit 55dcc20

File tree

4 files changed

+48
-0
lines changed

4 files changed

+48
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// run-pass
2+
3+
#![feature(const_generics)]
4+
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
5+
6+
use std::fmt;
7+
8+
struct Array<T, const N: usize>([T; N]);
9+
10+
impl<T: fmt::Debug, const N: usize> fmt::Debug for Array<T, {N}> {
11+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
12+
f.debug_list().entries(self.0.iter()).finish()
13+
}
14+
}
15+
16+
fn main() {
17+
println!("{:?}", Array([1, 2, 3]));
18+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
2+
--> $DIR/uninferred-consts-during-codegen-1.rs:3:12
3+
|
4+
LL | #![feature(const_generics)]
5+
| ^^^^^^^^^^^^^^
6+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// run-pass
2+
3+
#![feature(const_generics)]
4+
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
5+
6+
use std::fmt;
7+
8+
struct Array<T>(T);
9+
10+
impl<T: fmt::Debug, const N: usize> fmt::Debug for Array<[T; N]> {
11+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
12+
f.debug_list().entries((&self.0 as &[T]).iter()).finish()
13+
}
14+
}
15+
16+
fn main() {
17+
println!("{:?}", Array([1, 2, 3]));
18+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
2+
--> $DIR/uninferred-consts-during-codegen-2.rs:3:12
3+
|
4+
LL | #![feature(const_generics)]
5+
| ^^^^^^^^^^^^^^
6+

0 commit comments

Comments
 (0)