diff options
| author | Dylan DPC <dylan.dpc@gmail.com> | 2020-10-28 01:21:27 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-10-28 01:21:27 +0100 |
| commit | c3f842baee8c480faa1e6ca0741d131a0663a92d (patch) | |
| tree | db5bbad6314ecb5587dc7c35216869dc75866f7b | |
| parent | 892ebe9afe9d299a5ff22b9dec1a84a653b85f78 (diff) | |
| parent | 23c4a46efffebec56648d1b87204466acf1eb15f (diff) | |
| download | rust-c3f842baee8c480faa1e6ca0741d131a0663a92d.tar.gz rust-c3f842baee8c480faa1e6ca0741d131a0663a92d.zip | |
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
| -rw-r--r-- | src/test/ui/const-generics/min_const_generics/const_fn_in_generics.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/test/ui/const-generics/min_const_generics/const_fn_in_generics.rs b/src/test/ui/const-generics/min_const_generics/const_fn_in_generics.rs new file mode 100644 index 00000000000..3370666cc5c --- /dev/null +++ b/src/test/ui/const-generics/min_const_generics/const_fn_in_generics.rs @@ -0,0 +1,17 @@ +// run-pass + +#![feature(min_const_generics)] + +const fn identity<const T: u32>() -> u32 { T } + +#[derive(Eq, PartialEq, Debug)] +pub struct ConstU32<const U: u32>; + +pub fn new() -> ConstU32<{ identity::<3>() }> { + ConstU32::<{ identity::<3>() }> +} + +fn main() { + let v = new(); + assert_eq!(v, ConstU32::<3>); +} |
