summaryrefslogtreecommitdiffstats
path: root/src/test/ui/generic-associated-types/bugs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/test/ui/generic-associated-types/bugs/issue-80626.rs17
-rw-r--r--src/test/ui/generic-associated-types/bugs/issue-80626.stderr15
-rw-r--r--src/test/ui/generic-associated-types/bugs/issue-86218.rs27
-rw-r--r--src/test/ui/generic-associated-types/bugs/issue-86218.stderr23
-rw-r--r--src/test/ui/generic-associated-types/bugs/issue-87735.rs46
-rw-r--r--src/test/ui/generic-associated-types/bugs/issue-87735.stderr9
-rw-r--r--src/test/ui/generic-associated-types/bugs/issue-87748.rs23
-rw-r--r--src/test/ui/generic-associated-types/bugs/issue-87748.stderr20
-rw-r--r--src/test/ui/generic-associated-types/bugs/issue-87755.rs21
-rw-r--r--src/test/ui/generic-associated-types/bugs/issue-87755.stderr9
-rw-r--r--src/test/ui/generic-associated-types/bugs/issue-87803.rs27
-rw-r--r--src/test/ui/generic-associated-types/bugs/issue-87803.stderr12
-rw-r--r--src/test/ui/generic-associated-types/bugs/issue-88382.rs31
-rw-r--r--src/test/ui/generic-associated-types/bugs/issue-88382.stderr22
-rw-r--r--src/test/ui/generic-associated-types/bugs/issue-88460.rs31
-rw-r--r--src/test/ui/generic-associated-types/bugs/issue-88460.stderr19
-rw-r--r--src/test/ui/generic-associated-types/bugs/issue-88526.rs35
-rw-r--r--src/test/ui/generic-associated-types/bugs/issue-88526.stderr9
-rw-r--r--src/test/ui/generic-associated-types/bugs/issue-89008.rs44
-rw-r--r--src/test/ui/generic-associated-types/bugs/issue-89008.stderr19
20 files changed, 459 insertions, 0 deletions
diff --git a/src/test/ui/generic-associated-types/bugs/issue-80626.rs b/src/test/ui/generic-associated-types/bugs/issue-80626.rs
new file mode 100644
index 000000000..14f27aff1
--- /dev/null
+++ b/src/test/ui/generic-associated-types/bugs/issue-80626.rs
@@ -0,0 +1,17 @@
+// check-fail
+// known-bug: #80626
+
+// This should pass, but it requires `Sized` to be coinductive.
+
+#![feature(generic_associated_types)]
+
+trait Allocator {
+ type Allocated<T>;
+}
+
+enum LinkedList<A: Allocator> {
+ Head,
+ Next(A::Allocated<Self>)
+}
+
+fn main() {}
diff --git a/src/test/ui/generic-associated-types/bugs/issue-80626.stderr b/src/test/ui/generic-associated-types/bugs/issue-80626.stderr
new file mode 100644
index 000000000..487b83dfa
--- /dev/null
+++ b/src/test/ui/generic-associated-types/bugs/issue-80626.stderr
@@ -0,0 +1,15 @@
+error[E0275]: overflow evaluating the requirement `LinkedList<A>: Sized`
+ --> $DIR/issue-80626.rs:14:10
+ |
+LL | Next(A::Allocated<Self>)
+ | ^^^^^^^^^^^^^^^^^^
+ |
+note: required by a bound in `Allocator::Allocated`
+ --> $DIR/issue-80626.rs:9:20
+ |
+LL | type Allocated<T>;
+ | ^ required by this bound in `Allocator::Allocated`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0275`.
diff --git a/src/test/ui/generic-associated-types/bugs/issue-86218.rs b/src/test/ui/generic-associated-types/bugs/issue-86218.rs
new file mode 100644
index 000000000..fb62c10a9
--- /dev/null
+++ b/src/test/ui/generic-associated-types/bugs/issue-86218.rs
@@ -0,0 +1,27 @@
+// check-fail
+// known-bug: #86218
+
+// This should pass, but seems to run into a TAIT issue.
+
+#![feature(generic_associated_types)]
+#![feature(type_alias_impl_trait)]
+
+pub trait Stream {
+ type Item;
+}
+
+impl Stream for () {
+ type Item = i32;
+}
+
+trait Yay<AdditionalValue> {
+ type InnerStream<'s>: Stream<Item = i32> + 's;
+ fn foo<'s>() -> Self::InnerStream<'s>;
+}
+
+impl<'a> Yay<&'a ()> for () {
+ type InnerStream<'s> = impl Stream<Item = i32> + 's;
+ fn foo<'s>() -> Self::InnerStream<'s> { todo!() }
+}
+
+fn main() {}
diff --git a/src/test/ui/generic-associated-types/bugs/issue-86218.stderr b/src/test/ui/generic-associated-types/bugs/issue-86218.stderr
new file mode 100644
index 000000000..fbf1c8f95
--- /dev/null
+++ b/src/test/ui/generic-associated-types/bugs/issue-86218.stderr
@@ -0,0 +1,23 @@
+error[E0477]: the type `<() as Yay<&'a ()>>::InnerStream<'s>` does not fulfill the required lifetime
+ --> $DIR/issue-86218.rs:23:28
+ |
+LL | type InnerStream<'s> = impl Stream<Item = i32> + 's;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+note: type must outlive the lifetime `'s` as defined here as required by this binding
+ --> $DIR/issue-86218.rs:23:22
+ |
+LL | type InnerStream<'s> = impl Stream<Item = i32> + 's;
+ | ^^
+
+error: unconstrained opaque type
+ --> $DIR/issue-86218.rs:23:28
+ |
+LL | type InnerStream<'s> = impl Stream<Item = i32> + 's;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: `InnerStream` must be used in combination with a concrete type within the same module
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0477`.
diff --git a/src/test/ui/generic-associated-types/bugs/issue-87735.rs b/src/test/ui/generic-associated-types/bugs/issue-87735.rs
new file mode 100644
index 000000000..0844d84c3
--- /dev/null
+++ b/src/test/ui/generic-associated-types/bugs/issue-87735.rs
@@ -0,0 +1,46 @@
+// check-fail
+// known-bug: #87735, #88526
+
+// This should pass, but we need an extension of implied bounds (probably).
+
+#![feature(generic_associated_types)]
+
+pub trait AsRef2 {
+ type Output<'a> where Self: 'a;
+
+ fn as_ref2<'a>(&'a self) -> Self::Output<'a>;
+}
+
+impl<T> AsRef2 for Vec<T> {
+ type Output<'a> = &'a [T] where Self: 'a;
+
+ fn as_ref2<'a>(&'a self) -> Self::Output<'a> {
+ &self[..]
+ }
+}
+
+#[derive(Debug)]
+struct Foo<T>(T);
+#[derive(Debug)]
+struct FooRef<'a, U>(&'a [U]);
+
+impl<'b, T, U> AsRef2 for Foo<T>
+where
+ // * `for<'b, 'c> T: AsRef2<Output<'b> = &'c [U]>>` does not work
+ //
+ // * `U` is unconstrained but should be allowed in this context because `Output` is
+ // an associated type
+ T: AsRef2<Output<'b> = &'b [U]>,
+ U: 'b
+{
+ type Output<'a> = FooRef<'a, U> where Self: 'a;
+
+ fn as_ref2<'a>(&'a self) -> Self::Output<'a> {
+ FooRef(self.0.as_ref2())
+ }
+}
+
+fn main() {
+ let foo = Foo(vec![1, 2, 3]);
+ dbg!(foo.as_ref2());
+}
diff --git a/src/test/ui/generic-associated-types/bugs/issue-87735.stderr b/src/test/ui/generic-associated-types/bugs/issue-87735.stderr
new file mode 100644
index 000000000..0a18b5f0c
--- /dev/null
+++ b/src/test/ui/generic-associated-types/bugs/issue-87735.stderr
@@ -0,0 +1,9 @@
+error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates
+ --> $DIR/issue-87735.rs:27:13
+ |
+LL | impl<'b, T, U> AsRef2 for Foo<T>
+ | ^ unconstrained type parameter
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0207`.
diff --git a/src/test/ui/generic-associated-types/bugs/issue-87748.rs b/src/test/ui/generic-associated-types/bugs/issue-87748.rs
new file mode 100644
index 000000000..a3d00ee03
--- /dev/null
+++ b/src/test/ui/generic-associated-types/bugs/issue-87748.rs
@@ -0,0 +1,23 @@
+// check-fail
+// known-bug: #87748
+
+// This should pass, but unnormalized input args aren't treated as implied.
+
+#![feature(generic_associated_types)]
+
+trait MyTrait {
+ type Assoc<'a, 'b> where 'b: 'a;
+ fn do_sth(arg: Self::Assoc<'_, '_>);
+}
+
+struct Foo;
+
+impl MyTrait for Foo {
+ type Assoc<'a, 'b> = u32 where 'b: 'a;
+
+ fn do_sth(_: u32) {}
+ // fn do_sth(_: Self::Assoc<'static, 'static>) {}
+ // fn do_sth(_: Self::Assoc<'_, '_>) {}
+}
+
+fn main() {}
diff --git a/src/test/ui/generic-associated-types/bugs/issue-87748.stderr b/src/test/ui/generic-associated-types/bugs/issue-87748.stderr
new file mode 100644
index 000000000..ac197dfe6
--- /dev/null
+++ b/src/test/ui/generic-associated-types/bugs/issue-87748.stderr
@@ -0,0 +1,20 @@
+error[E0478]: lifetime bound not satisfied
+ --> $DIR/issue-87748.rs:18:5
+ |
+LL | fn do_sth(_: u32) {}
+ | ^^^^^^^^^^^^^^^^^
+ |
+note: lifetime parameter instantiated with the anonymous lifetime as defined here
+ --> $DIR/issue-87748.rs:18:5
+ |
+LL | fn do_sth(_: u32) {}
+ | ^^^^^^^^^^^^^^^^^
+note: but lifetime parameter must outlive the anonymous lifetime as defined here
+ --> $DIR/issue-87748.rs:18:5
+ |
+LL | fn do_sth(_: u32) {}
+ | ^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0478`.
diff --git a/src/test/ui/generic-associated-types/bugs/issue-87755.rs b/src/test/ui/generic-associated-types/bugs/issue-87755.rs
new file mode 100644
index 000000000..efa487d62
--- /dev/null
+++ b/src/test/ui/generic-associated-types/bugs/issue-87755.rs
@@ -0,0 +1,21 @@
+// check-fail
+// known-bug: #87755
+
+// This should pass.
+
+#![feature(generic_associated_types)]
+
+use std::fmt::Debug;
+
+trait Foo {
+ type Ass where Self::Ass: Debug;
+}
+
+#[derive(Debug)]
+struct Bar;
+
+impl Foo for Bar {
+ type Ass = Bar;
+}
+
+fn main() {}
diff --git a/src/test/ui/generic-associated-types/bugs/issue-87755.stderr b/src/test/ui/generic-associated-types/bugs/issue-87755.stderr
new file mode 100644
index 000000000..5d1aff011
--- /dev/null
+++ b/src/test/ui/generic-associated-types/bugs/issue-87755.stderr
@@ -0,0 +1,9 @@
+error[E0275]: overflow evaluating the requirement `<Bar as Foo>::Ass == _`
+ --> $DIR/issue-87755.rs:18:16
+ |
+LL | type Ass = Bar;
+ | ^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0275`.
diff --git a/src/test/ui/generic-associated-types/bugs/issue-87803.rs b/src/test/ui/generic-associated-types/bugs/issue-87803.rs
new file mode 100644
index 000000000..a8a111c99
--- /dev/null
+++ b/src/test/ui/generic-associated-types/bugs/issue-87803.rs
@@ -0,0 +1,27 @@
+// check-fail
+// known-bug: #87803
+
+// This should pass, but using a type alias vs a reference directly
+// changes late-bound -> early-bound.
+
+#![feature(generic_associated_types)]
+
+trait Scanner {
+ type Input<'a>;
+ type Token<'a>;
+
+ fn scan<'a>(&mut self, i : Self::Input<'a>) -> Self::Token<'a>;
+}
+
+struct IdScanner();
+
+impl Scanner for IdScanner {
+ type Input<'a> = &'a str;
+ type Token<'a> = &'a str;
+
+ fn scan<'a>(&mut self, s : &'a str) -> &'a str {
+ s
+ }
+}
+
+fn main() {}
diff --git a/src/test/ui/generic-associated-types/bugs/issue-87803.stderr b/src/test/ui/generic-associated-types/bugs/issue-87803.stderr
new file mode 100644
index 000000000..c81c051d3
--- /dev/null
+++ b/src/test/ui/generic-associated-types/bugs/issue-87803.stderr
@@ -0,0 +1,12 @@
+error[E0195]: lifetime parameters or bounds on method `scan` do not match the trait declaration
+ --> $DIR/issue-87803.rs:22:12
+ |
+LL | fn scan<'a>(&mut self, i : Self::Input<'a>) -> Self::Token<'a>;
+ | ---- lifetimes in impl do not match this method in trait
+...
+LL | fn scan<'a>(&mut self, s : &'a str) -> &'a str {
+ | ^^^^ lifetimes do not match method in trait
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0195`.
diff --git a/src/test/ui/generic-associated-types/bugs/issue-88382.rs b/src/test/ui/generic-associated-types/bugs/issue-88382.rs
new file mode 100644
index 000000000..5493b9b93
--- /dev/null
+++ b/src/test/ui/generic-associated-types/bugs/issue-88382.rs
@@ -0,0 +1,31 @@
+// check-fail
+// known-bug: #88382
+
+// This should pass, but has a missed normalization due to HRTB.
+
+#![feature(generic_associated_types)]
+
+trait Iterable {
+ type Iterator<'a> where Self: 'a;
+ fn iter(&self) -> Self::Iterator<'_>;
+}
+
+struct SomeImplementation();
+
+impl Iterable for SomeImplementation {
+ type Iterator<'a> = std::iter::Empty<usize>;
+ fn iter(&self) -> Self::Iterator<'_> {
+ std::iter::empty()
+ }
+}
+
+fn do_something<I: Iterable>(i: I, mut f: impl for<'a> Fn(&mut I::Iterator<'a>)) {
+ f(&mut i.iter());
+}
+
+fn main() {
+ do_something(SomeImplementation(), |_| ());
+ do_something(SomeImplementation(), test);
+}
+
+fn test<'a, I: Iterable>(_: &mut I::Iterator<'a>) {}
diff --git a/src/test/ui/generic-associated-types/bugs/issue-88382.stderr b/src/test/ui/generic-associated-types/bugs/issue-88382.stderr
new file mode 100644
index 000000000..7210895b7
--- /dev/null
+++ b/src/test/ui/generic-associated-types/bugs/issue-88382.stderr
@@ -0,0 +1,22 @@
+error[E0631]: type mismatch in function arguments
+ --> $DIR/issue-88382.rs:28:40
+ |
+LL | do_something(SomeImplementation(), test);
+ | ------------ ^^^^ expected due to this
+ | |
+ | required by a bound introduced by this call
+...
+LL | fn test<'a, I: Iterable>(_: &mut I::Iterator<'a>) {}
+ | ------------------------------------------------- found signature defined here
+ |
+ = note: expected function signature `for<'r> fn(&'r mut std::iter::Empty<usize>) -> _`
+ found function signature `for<'a, 'r> fn(&'r mut <_ as Iterable>::Iterator<'a>) -> _`
+note: required by a bound in `do_something`
+ --> $DIR/issue-88382.rs:22:48
+ |
+LL | fn do_something<I: Iterable>(i: I, mut f: impl for<'a> Fn(&mut I::Iterator<'a>)) {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `do_something`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0631`.
diff --git a/src/test/ui/generic-associated-types/bugs/issue-88460.rs b/src/test/ui/generic-associated-types/bugs/issue-88460.rs
new file mode 100644
index 000000000..f1c3b2269
--- /dev/null
+++ b/src/test/ui/generic-associated-types/bugs/issue-88460.rs
@@ -0,0 +1,31 @@
+// check-fail
+// known-bug: #88460
+
+// This should pass, but has a missed normalization due to HRTB.
+
+#![feature(generic_associated_types)]
+
+pub trait Marker {}
+
+pub trait Trait {
+ type Assoc<'a>;
+}
+
+fn test<T>(value: T)
+where
+ T: Trait,
+ for<'a> T::Assoc<'a>: Marker,
+{
+}
+
+impl Marker for () {}
+
+struct Foo;
+
+impl Trait for Foo {
+ type Assoc<'a> = ();
+}
+
+fn main() {
+ test(Foo);
+}
diff --git a/src/test/ui/generic-associated-types/bugs/issue-88460.stderr b/src/test/ui/generic-associated-types/bugs/issue-88460.stderr
new file mode 100644
index 000000000..98c304cc9
--- /dev/null
+++ b/src/test/ui/generic-associated-types/bugs/issue-88460.stderr
@@ -0,0 +1,19 @@
+error[E0277]: the trait bound `for<'a> <_ as Trait>::Assoc<'a>: Marker` is not satisfied
+ --> $DIR/issue-88460.rs:30:5
+ |
+LL | test(Foo);
+ | ^^^^ the trait `for<'a> Marker` is not implemented for `<_ as Trait>::Assoc<'a>`
+ |
+ = help: the trait `Marker` is implemented for `()`
+note: required by a bound in `test`
+ --> $DIR/issue-88460.rs:17:27
+ |
+LL | fn test<T>(value: T)
+ | ---- required by a bound in this
+...
+LL | for<'a> T::Assoc<'a>: Marker,
+ | ^^^^^^ required by this bound in `test`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/generic-associated-types/bugs/issue-88526.rs b/src/test/ui/generic-associated-types/bugs/issue-88526.rs
new file mode 100644
index 000000000..15363ad04
--- /dev/null
+++ b/src/test/ui/generic-associated-types/bugs/issue-88526.rs
@@ -0,0 +1,35 @@
+// check-fail
+// known-bug: #88526
+
+// This should pass, but requires more logic.
+
+#![feature(generic_associated_types)]
+
+trait A {
+ type I<'a>;
+}
+
+pub struct TestA<F>
+{
+ f: F,
+}
+
+impl<F> A for TestA<F> {
+ type I<'a> = &'a F;
+}
+
+struct TestB<Q, F>
+{
+ q: Q,
+ f: F,
+}
+
+impl<'q, Q, I, F> A for TestB<Q, F>
+where
+ Q: A<I<'q> = &'q I>,
+ F: Fn(I),
+{
+ type I<'a> = ();
+}
+
+fn main() {}
diff --git a/src/test/ui/generic-associated-types/bugs/issue-88526.stderr b/src/test/ui/generic-associated-types/bugs/issue-88526.stderr
new file mode 100644
index 000000000..127c889bf
--- /dev/null
+++ b/src/test/ui/generic-associated-types/bugs/issue-88526.stderr
@@ -0,0 +1,9 @@
+error[E0207]: the type parameter `I` is not constrained by the impl trait, self type, or predicates
+ --> $DIR/issue-88526.rs:27:13
+ |
+LL | impl<'q, Q, I, F> A for TestB<Q, F>
+ | ^ unconstrained type parameter
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0207`.
diff --git a/src/test/ui/generic-associated-types/bugs/issue-89008.rs b/src/test/ui/generic-associated-types/bugs/issue-89008.rs
new file mode 100644
index 000000000..79c28b0d2
--- /dev/null
+++ b/src/test/ui/generic-associated-types/bugs/issue-89008.rs
@@ -0,0 +1,44 @@
+// check-fail
+// edition:2021
+// known-bug: #88908
+
+// This should pass, but seems to run into a TAIT bug.
+
+#![feature(type_alias_impl_trait)]
+#![feature(generic_associated_types)]
+
+use std::future::Future;
+
+trait Stream {
+ type Item;
+}
+
+struct Empty<T>(T);
+impl<T> Stream for Empty<T> {
+ type Item = ();
+}
+fn empty<T>() -> Empty<T> {
+ todo!()
+}
+
+trait X {
+ type LineStream<'a, Repr>: Stream<Item = Repr> where Self: 'a;
+
+ type LineStreamFut<'a,Repr>: Future<Output = Self::LineStream<'a, Repr>> where Self: 'a;
+
+ fn line_stream<'a,Repr>(&'a self) -> Self::LineStreamFut<'a,Repr>;
+}
+
+struct Y;
+
+impl X for Y {
+ type LineStream<'a, Repr> = impl Stream<Item = Repr>;
+
+ type LineStreamFut<'a, Repr> = impl Future<Output = Self::LineStream<'a, Repr>> ;
+
+ fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr> {
+ async {empty()}
+ }
+}
+
+fn main() {}
diff --git a/src/test/ui/generic-associated-types/bugs/issue-89008.stderr b/src/test/ui/generic-associated-types/bugs/issue-89008.stderr
new file mode 100644
index 000000000..50844fdc1
--- /dev/null
+++ b/src/test/ui/generic-associated-types/bugs/issue-89008.stderr
@@ -0,0 +1,19 @@
+error[E0271]: type mismatch resolving `<Empty<_> as Stream>::Item == Repr`
+ --> $DIR/issue-89008.rs:39:43
+ |
+LL | fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr> {
+ | ---- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type mismatch resolving `<Empty<_> as Stream>::Item == Repr`
+ | |
+ | this type parameter
+ |
+note: expected this to be `()`
+ --> $DIR/issue-89008.rs:18:17
+ |
+LL | type Item = ();
+ | ^^
+ = note: expected unit type `()`
+ found type parameter `Repr`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0271`.