summaryrefslogtreecommitdiffstats
path: root/src/test/ui/late-bound-lifetimes
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/late-bound-lifetimes')
-rw-r--r--src/test/ui/late-bound-lifetimes/auxiliary/upstream_alias.rs5
-rw-r--r--src/test/ui/late-bound-lifetimes/cross_crate_alias.rs10
-rw-r--r--src/test/ui/late-bound-lifetimes/downgraded_to_early_through_alias.rs24
-rw-r--r--src/test/ui/late-bound-lifetimes/issue-47511.rs21
-rw-r--r--src/test/ui/late-bound-lifetimes/late_bound_through_alias.rs16
-rw-r--r--src/test/ui/late-bound-lifetimes/mismatched_arg_count.rs12
-rw-r--r--src/test/ui/late-bound-lifetimes/mismatched_arg_count.stderr17
7 files changed, 105 insertions, 0 deletions
diff --git a/src/test/ui/late-bound-lifetimes/auxiliary/upstream_alias.rs b/src/test/ui/late-bound-lifetimes/auxiliary/upstream_alias.rs
new file mode 100644
index 000000000..5b9dc0e43
--- /dev/null
+++ b/src/test/ui/late-bound-lifetimes/auxiliary/upstream_alias.rs
@@ -0,0 +1,5 @@
+pub trait Trait<'a> {
+ type Assoc;
+}
+
+pub type Alias<'a, T> = <T as Trait<'a>>::Assoc;
diff --git a/src/test/ui/late-bound-lifetimes/cross_crate_alias.rs b/src/test/ui/late-bound-lifetimes/cross_crate_alias.rs
new file mode 100644
index 000000000..4154c2792
--- /dev/null
+++ b/src/test/ui/late-bound-lifetimes/cross_crate_alias.rs
@@ -0,0 +1,10 @@
+// aux-build:upstream_alias.rs
+// check-pass
+
+extern crate upstream_alias;
+
+fn foo<'a, T: for<'b> upstream_alias::Trait<'b>>(_: upstream_alias::Alias<'a, T>) -> &'a () {
+ todo!()
+}
+
+fn main() {}
diff --git a/src/test/ui/late-bound-lifetimes/downgraded_to_early_through_alias.rs b/src/test/ui/late-bound-lifetimes/downgraded_to_early_through_alias.rs
new file mode 100644
index 000000000..e56a34218
--- /dev/null
+++ b/src/test/ui/late-bound-lifetimes/downgraded_to_early_through_alias.rs
@@ -0,0 +1,24 @@
+// check-pass
+
+trait Gats<'a> {
+ type Assoc;
+ type Assoc2;
+}
+
+trait Trait: for<'a> Gats<'a> {
+ fn foo<'a>(_: &mut <Self as Gats<'a>>::Assoc) -> <Self as Gats<'a>>::Assoc2;
+}
+
+impl<'a> Gats<'a> for () {
+ type Assoc = &'a u32;
+ type Assoc2 = ();
+}
+
+type GatsAssoc<'a, T> = <T as Gats<'a>>::Assoc;
+type GatsAssoc2<'a, T> = <T as Gats<'a>>::Assoc2;
+
+impl Trait for () {
+ fn foo<'a>(_: &mut GatsAssoc<'a, Self>) -> GatsAssoc2<'a, Self> {}
+}
+
+fn main() {}
diff --git a/src/test/ui/late-bound-lifetimes/issue-47511.rs b/src/test/ui/late-bound-lifetimes/issue-47511.rs
new file mode 100644
index 000000000..789443515
--- /dev/null
+++ b/src/test/ui/late-bound-lifetimes/issue-47511.rs
@@ -0,0 +1,21 @@
+// check-pass
+
+fn f(_: X) -> X {
+ unimplemented!()
+}
+
+fn g<'a>(_: X<'a>) -> X<'a> {
+ unimplemented!()
+}
+
+type X<'a> = <&'a () as Trait>::Value;
+
+trait Trait {
+ type Value;
+}
+
+impl<'a> Trait for &'a () {
+ type Value = ();
+}
+
+fn main() {}
diff --git a/src/test/ui/late-bound-lifetimes/late_bound_through_alias.rs b/src/test/ui/late-bound-lifetimes/late_bound_through_alias.rs
new file mode 100644
index 000000000..91839673c
--- /dev/null
+++ b/src/test/ui/late-bound-lifetimes/late_bound_through_alias.rs
@@ -0,0 +1,16 @@
+// check-pass
+
+fn f(_: X) -> X {
+ unimplemented!()
+}
+
+fn g<'a>(_: X<'a>) -> X<'a> {
+ unimplemented!()
+}
+
+type X<'a> = &'a ();
+
+fn main() {
+ let _: for<'a> fn(X<'a>) -> X<'a> = g;
+ let _: for<'a> fn(X<'a>) -> X<'a> = f;
+}
diff --git a/src/test/ui/late-bound-lifetimes/mismatched_arg_count.rs b/src/test/ui/late-bound-lifetimes/mismatched_arg_count.rs
new file mode 100644
index 000000000..0b331e203
--- /dev/null
+++ b/src/test/ui/late-bound-lifetimes/mismatched_arg_count.rs
@@ -0,0 +1,12 @@
+// ensures that we don't ICE when there are too many args supplied to the alias.
+
+trait Trait<'a> {
+ type Assoc;
+}
+
+type Alias<'a, T> = <T as Trait<'a>>::Assoc;
+
+fn bar<'a, T: Trait<'a>>(_: Alias<'a, 'a, T>) {}
+//~^ error: this type alias takes 1 lifetime argument but 2 lifetime arguments were supplied
+
+fn main() {}
diff --git a/src/test/ui/late-bound-lifetimes/mismatched_arg_count.stderr b/src/test/ui/late-bound-lifetimes/mismatched_arg_count.stderr
new file mode 100644
index 000000000..3704d9bb9
--- /dev/null
+++ b/src/test/ui/late-bound-lifetimes/mismatched_arg_count.stderr
@@ -0,0 +1,17 @@
+error[E0107]: this type alias takes 1 lifetime argument but 2 lifetime arguments were supplied
+ --> $DIR/mismatched_arg_count.rs:9:29
+ |
+LL | fn bar<'a, T: Trait<'a>>(_: Alias<'a, 'a, T>) {}
+ | ^^^^^ -- help: remove this lifetime argument
+ | |
+ | expected 1 lifetime argument
+ |
+note: type alias defined here, with 1 lifetime parameter: `'a`
+ --> $DIR/mismatched_arg_count.rs:7:6
+ |
+LL | type Alias<'a, T> = <T as Trait<'a>>::Assoc;
+ | ^^^^^ --
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0107`.