From 0918102540bf805caa44ef5b41de451798cb4052 Mon Sep 17 00:00:00 2001 From: Nathan Date: Wed, 20 May 2020 16:46:19 -0400 Subject: [PATCH] Add basic tests for opaque type generics --- tests/test/opaque_types.rs | 58 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/tests/test/opaque_types.rs b/tests/test/opaque_types.rs index b7bf2778f9f..b9940268b7e 100644 --- a/tests/test/opaque_types.rs +++ b/tests/test/opaque_types.rs @@ -45,3 +45,61 @@ fn opaque_reveal() { } } } + +#[test] +fn opaque_generics_simple() { + test! { + program { + trait Iterator { type Item; } + + struct Vec { } + struct Bar { } + impl Iterator for Vec { + type Item = u32; + } + + opaque type Foo: Iterator = Vec; + } + + goal { + Foo: Iterator + } yields { + "Unique; substitution []" + } + + } +} + +#[test] +fn opaque_generics() { + test! { + program { + trait Iterator { type Item; } + + struct Vec { } + struct Bar { } + impl Iterator for Vec { + type Item = T; + } + + opaque type Foo: Iterator = Vec; + } + + goal { + Foo: Iterator + } yields { + "Unique; substitution []" + } + + goal { + forall { + if (T: Iterator) { + Foo: Iterator + } + } + } yields { + "Unique; substitution []" + } + + } +}