about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorAaron Hill <aa1ronham@gmail.com>2019-11-11 15:01:53 -0500
committerAaron Hill <aa1ronham@gmail.com>2019-11-24 14:37:24 -0500
commit850e3e6d4db1544b538fcd3d0287cffed06d2b79 (patch)
tree8f6ae0fd0f348734abf0b3d84c3fd396dbda4b89 /src/test
parenta59b7eabe691695c66a9d3b95735121af1ba0166 (diff)
downloadrust-850e3e6d4db1544b538fcd3d0287cffed06d2b79.tar.gz
rust-850e3e6d4db1544b538fcd3d0287cffed06d2b79.zip
bug!() on const inference variable in opaque type
Add some tests to verify that this case is never hit
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/type-alias-impl-trait/assoc-type-const.rs36
-rw-r--r--src/test/ui/type-alias-impl-trait/assoc-type-const.stderr8
-rw-r--r--src/test/ui/type-alias-impl-trait/assoc-type-lifetime.rs28
3 files changed, 72 insertions, 0 deletions
diff --git a/src/test/ui/type-alias-impl-trait/assoc-type-const.rs b/src/test/ui/type-alias-impl-trait/assoc-type-const.rs
new file mode 100644
index 00000000000..5db677d82e2
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/assoc-type-const.rs
@@ -0,0 +1,36 @@
+// Tests that we properly detect defining usages when using
+// const generics in an associated opaque type
+// check-pass
+
+#![feature(type_alias_impl_trait)]
+#![feature(const_generics)]
+//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
+
+trait UnwrapItemsExt<const C: usize> {
+    type Iter;
+    fn unwrap_items(self) -> Self::Iter;
+}
+
+struct MyStruct<const C: usize> {}
+
+trait MyTrait<'a, const C: usize> {
+    type MyItem;
+    const MY_CONST: usize;
+}
+
+impl<'a, const C: usize> MyTrait<'a, {C}> for MyStruct<{C}> {
+    type MyItem = u8;
+    const MY_CONST: usize = C;
+}
+
+impl<'a, I, const C: usize> UnwrapItemsExt<{C}> for I
+where
+{
+    type Iter = impl MyTrait<'a, {C}>;
+
+    fn unwrap_items(self) -> Self::Iter {
+        MyStruct::<{C}> {}
+    }
+}
+
+fn main() {}
diff --git a/src/test/ui/type-alias-impl-trait/assoc-type-const.stderr b/src/test/ui/type-alias-impl-trait/assoc-type-const.stderr
new file mode 100644
index 00000000000..0adbee2f244
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/assoc-type-const.stderr
@@ -0,0 +1,8 @@
+warning: the feature `const_generics` is incomplete and may cause the compiler to crash
+  --> $DIR/assoc-type-const.rs:6:12
+   |
+LL | #![feature(const_generics)]
+   |            ^^^^^^^^^^^^^^
+   |
+   = note: `#[warn(incomplete_features)]` on by default
+
diff --git a/src/test/ui/type-alias-impl-trait/assoc-type-lifetime.rs b/src/test/ui/type-alias-impl-trait/assoc-type-lifetime.rs
new file mode 100644
index 00000000000..cff1d24494e
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/assoc-type-lifetime.rs
@@ -0,0 +1,28 @@
+// Tests that we still detect defining usages when
+// lifetimes are used in an associated opaque type
+// check-pass
+
+#![feature(type_alias_impl_trait)]
+
+trait UnwrapItemsExt {
+    type Iter;
+    fn unwrap_items(self) -> Self::Iter;
+}
+
+struct MyStruct {}
+
+trait MyTrait<'a> {}
+
+impl<'a> MyTrait<'a> for MyStruct {}
+
+impl<'a, I> UnwrapItemsExt for I
+where
+{
+    type Iter = impl MyTrait<'a>;
+
+    fn unwrap_items(self) -> Self::Iter {
+        MyStruct {}
+    }
+}
+
+fn main() {}