Skip to content

Commit c3f842b

Browse files
authored
Rollup merge of #78391 - JulianKnodt:mc_test, r=lcnr
Add const_fn in generics test Adds a test that constant functions in generic parameters work properly. I was surprised this works, but I also to turbofish the constant in main, otherwise it didn't infer properly: ``` let v: ConstU32<3> = ... ``` Did not work as I expected, which I can highlight in the test if that's the intended behaviour. r? @lcnr
2 parents 892ebe9 + 23c4a46 commit c3f842b

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// run-pass
2+
3+
#![feature(min_const_generics)]
4+
5+
const fn identity<const T: u32>() -> u32 { T }
6+
7+
#[derive(Eq, PartialEq, Debug)]
8+
pub struct ConstU32<const U: u32>;
9+
10+
pub fn new() -> ConstU32<{ identity::<3>() }> {
11+
ConstU32::<{ identity::<3>() }>
12+
}
13+
14+
fn main() {
15+
let v = new();
16+
assert_eq!(v, ConstU32::<3>);
17+
}

0 commit comments

Comments
 (0)