diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2021-10-06 12:33:23 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-06 12:33:23 -0700 |
| commit | eb7da35d8492308e66c5cbf0471548cadcf786af (patch) | |
| tree | adc25deac5852761de577ca0a4e8f96f30b46edc /src/test/ui | |
| parent | 79a1fc84194f5c57afba0f81e628d3543fa2d00c (diff) | |
| parent | edfd6d591b51da089b65c68ece0aecd1e9b8a42b (diff) | |
| download | rust-eb7da35d8492308e66c5cbf0471548cadcf786af.tar.gz rust-eb7da35d8492308e66c5cbf0471548cadcf786af.zip | |
Rollup merge of #89588 - BoxyUwU:add_a_test_uwu, r=lcnr
Add a test for generic_const_exprs Test that const_eval_resolve evaluates consts with unused inference vars in substs r? ``@lcnr``
Diffstat (limited to 'src/test/ui')
| -rw-r--r-- | src/test/ui/const-generics/generic_const_exprs/const_eval_resolve_canonical.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/test/ui/const-generics/generic_const_exprs/const_eval_resolve_canonical.rs b/src/test/ui/const-generics/generic_const_exprs/const_eval_resolve_canonical.rs new file mode 100644 index 00000000000..b79bc262d2b --- /dev/null +++ b/src/test/ui/const-generics/generic_const_exprs/const_eval_resolve_canonical.rs @@ -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); +} |
