Skip to content

Commit eed7738

Browse files
Add test for projection in const generics
1 parent 291bc0d commit eed7738

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// run-pass
2+
3+
#![allow(incomplete_features)] // This is needed for the `adt_const_params` feature.
4+
#![feature(associated_type_defaults)]
5+
6+
pub trait Identity: Sized {
7+
type Identity = Self;
8+
// ^ This is needed because otherwise we get:
9+
// error: internal compiler error: compiler/rustc_hir_analysis/src/collect/type_of.rs:271:17: \
10+
// associated type missing default
11+
// --> test.rs:6:5
12+
// |
13+
// 6 | type Identity;
14+
// | ^^^^^^^^^^^^^^
15+
}
16+
17+
impl<T> Identity for T {}
18+
19+
pub fn foo<const X: <i32 as Identity>::Identity>() {
20+
assert!(X == 12);
21+
}
22+
23+
fn main() {
24+
foo::<12>();
25+
}

0 commit comments

Comments
 (0)