about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2022-01-14 18:43:55 -0800
committerMichael Goulet <michael@errs.io>2022-01-14 18:59:54 -0800
commitd671948779fc14c195833f48b64e2c6e1a54a0bb (patch)
treeca6a7c83af17b89888bc4f6d3bef5b6ca89b86b3 /src/test
parentad46af24713115e7b9b258346e66b9b2d14eacfc (diff)
downloadrust-d671948779fc14c195833f48b64e2c6e1a54a0bb.tar.gz
rust-d671948779fc14c195833f48b64e2c6e1a54a0bb.zip
Allow eliding GATs in expr position
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/generic-associated-types/elided-in-expr-position.rs38
-rw-r--r--src/test/ui/generic-associated-types/elided-in-expr-position.stderr35
2 files changed, 73 insertions, 0 deletions
diff --git a/src/test/ui/generic-associated-types/elided-in-expr-position.rs b/src/test/ui/generic-associated-types/elided-in-expr-position.rs
new file mode 100644
index 00000000000..482d0d5c00a
--- /dev/null
+++ b/src/test/ui/generic-associated-types/elided-in-expr-position.rs
@@ -0,0 +1,38 @@
+#![feature(generic_associated_types)]
+#![allow(unused)]
+
+pub trait Trait  {
+    type Assoc<'a> where Self: 'a;
+
+    fn f(&self) -> Self::Assoc<'_>;
+
+    // Disallow elision in return position, for now
+    fn g(&self) -> Self::Assoc;
+    //~^ ERROR missing generics for associated type `Trait::Assoc`
+}
+
+pub struct Struct {
+    item: f32
+}
+
+pub struct GenericStruct<'a> {
+    ref_item: &'a f32
+}
+
+impl Trait for Struct {
+    type Assoc<'a> = GenericStruct<'a>;
+
+    fn f(&self) -> Self::Assoc<'_> {
+        Self::Assoc {
+            ref_item: &self.item
+        }
+    }
+
+    // Disallow elision in return position, for now
+    fn g(&self) -> Self::Assoc {
+    //~^ ERROR missing generics for associated type `Trait::Assoc`
+        todo!()
+    }
+}
+
+fn main() {}
diff --git a/src/test/ui/generic-associated-types/elided-in-expr-position.stderr b/src/test/ui/generic-associated-types/elided-in-expr-position.stderr
new file mode 100644
index 00000000000..9263f3d67e3
--- /dev/null
+++ b/src/test/ui/generic-associated-types/elided-in-expr-position.stderr
@@ -0,0 +1,35 @@
+error[E0107]: missing generics for associated type `Trait::Assoc`
+  --> $DIR/elided-in-expr-position.rs:10:26
+   |
+LL |     fn g(&self) -> Self::Assoc;
+   |                          ^^^^^ expected 1 lifetime argument
+   |
+note: associated type defined here, with 1 lifetime parameter: `'a`
+  --> $DIR/elided-in-expr-position.rs:5:10
+   |
+LL |     type Assoc<'a> where Self: 'a;
+   |          ^^^^^ --
+help: add missing lifetime argument
+   |
+LL |     fn g(&self) -> Self::Assoc<'_>;
+   |                          ~~~~~~~~~
+
+error[E0107]: missing generics for associated type `Trait::Assoc`
+  --> $DIR/elided-in-expr-position.rs:32:26
+   |
+LL |     fn g(&self) -> Self::Assoc {
+   |                          ^^^^^ expected 1 lifetime argument
+   |
+note: associated type defined here, with 1 lifetime parameter: `'a`
+  --> $DIR/elided-in-expr-position.rs:5:10
+   |
+LL |     type Assoc<'a> where Self: 'a;
+   |          ^^^^^ --
+help: add missing lifetime argument
+   |
+LL |     fn g(&self) -> Self::Assoc<'_> {
+   |                          ~~~~~~~~~
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0107`.