Skip to content

Commit

Permalink
Rollup merge of #89588 - BoxyUwU:add_a_test_uwu, r=lcnr
Browse files Browse the repository at this point in the history
Add a test for generic_const_exprs

Test that const_eval_resolve evaluates consts with unused inference vars in substs

r? ``@lcnr``
  • Loading branch information
Manishearth committed Oct 6, 2021
2 parents 79a1fc8 + edfd6d5 commit eb7da35
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// run-pass
#![feature(generic_const_exprs)]
#![allow(incomplete_features)]

trait Foo<const N: usize> {
type Assoc: Default;
}

impl Foo<0> for () {
type Assoc = u32;
}

impl Foo<3> for () {
type Assoc = i64;
}

fn foo<T, const N: usize>(_: T) -> <() as Foo<{ N + 1 }>>::Assoc
where
(): Foo<{ N + 1 }>,
{
Default::default()
}

fn main() {
// Test that we can correctly infer `T` which requires evaluating
// `{ N + 1 }` which has substs containing an inference var
let mut _q = Default::default();
_q = foo::<_, 2>(_q);
}

0 comments on commit eb7da35

Please sign in to comment.