summaryrefslogtreecommitdiffstats
path: root/src/test/ui/hr-subtype
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
commit218caa410aa38c29984be31a5229b9fa717560ee (patch)
treec54bd55eeb6e4c508940a30e94c0032fbd45d677 /src/test/ui/hr-subtype
parentReleasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz
rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/hr-subtype')
-rw-r--r--src/test/ui/hr-subtype/hr-subtype.bound_a_b_ret_a_vs_bound_a_ret_a.stderr17
-rw-r--r--src/test/ui/hr-subtype/hr-subtype.bound_a_vs_free_x.stderr17
-rw-r--r--src/test/ui/hr-subtype/hr-subtype.bound_inv_a_b_vs_bound_inv_a.stderr31
-rw-r--r--src/test/ui/hr-subtype/hr-subtype.free_inv_x_vs_free_inv_y.stderr42
-rw-r--r--src/test/ui/hr-subtype/hr-subtype.free_x_vs_free_y.stderr19
-rw-r--r--src/test/ui/hr-subtype/hr-subtype.rs111
-rw-r--r--src/test/ui/hr-subtype/placeholder-pattern-fail.rs25
-rw-r--r--src/test/ui/hr-subtype/placeholder-pattern-fail.stderr12
-rw-r--r--src/test/ui/hr-subtype/placeholder-pattern.rs18
-rw-r--r--src/test/ui/hr-subtype/return-static.rs13
10 files changed, 0 insertions, 305 deletions
diff --git a/src/test/ui/hr-subtype/hr-subtype.bound_a_b_ret_a_vs_bound_a_ret_a.stderr b/src/test/ui/hr-subtype/hr-subtype.bound_a_b_ret_a_vs_bound_a_ret_a.stderr
deleted file mode 100644
index b7264c7e9..000000000
--- a/src/test/ui/hr-subtype/hr-subtype.bound_a_b_ret_a_vs_bound_a_ret_a.stderr
+++ /dev/null
@@ -1,17 +0,0 @@
-error[E0308]: mismatched types
- --> $DIR/hr-subtype.rs:54:13
- |
-LL | gimme::<$t1>(None::<$t2>);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
-...
-LL | / check! { bound_a_b_ret_a_vs_bound_a_ret_a: (for<'a,'b> fn(&'a u32, &'b u32) -> &'a u32,
-LL | | for<'a> fn(&'a u32, &'a u32) -> &'a u32) }
- | |_____________________________________________- in this macro invocation
- |
- = note: expected enum `Option<for<'a, 'b> fn(&'a u32, &'b u32) -> &'a u32>`
- found enum `Option<for<'a> fn(&'a u32, &'a u32) -> &'a u32>`
- = note: this error originates in the macro `check` (in Nightly builds, run with -Z macro-backtrace for more info)
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/hr-subtype/hr-subtype.bound_a_vs_free_x.stderr b/src/test/ui/hr-subtype/hr-subtype.bound_a_vs_free_x.stderr
deleted file mode 100644
index 2355979b0..000000000
--- a/src/test/ui/hr-subtype/hr-subtype.bound_a_vs_free_x.stderr
+++ /dev/null
@@ -1,17 +0,0 @@
-error[E0308]: mismatched types
- --> $DIR/hr-subtype.rs:54:13
- |
-LL | gimme::<$t1>(None::<$t2>);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
-...
-LL | / check! { bound_a_vs_free_x: (for<'a> fn(&'a u32),
-LL | | fn(&'x u32)) }
- | |______________- in this macro invocation
- |
- = note: expected enum `Option<for<'a> fn(&'a u32)>`
- found enum `Option<fn(&u32)>`
- = note: this error originates in the macro `check` (in Nightly builds, run with -Z macro-backtrace for more info)
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/hr-subtype/hr-subtype.bound_inv_a_b_vs_bound_inv_a.stderr b/src/test/ui/hr-subtype/hr-subtype.bound_inv_a_b_vs_bound_inv_a.stderr
deleted file mode 100644
index a73c03feb..000000000
--- a/src/test/ui/hr-subtype/hr-subtype.bound_inv_a_b_vs_bound_inv_a.stderr
+++ /dev/null
@@ -1,31 +0,0 @@
-error[E0308]: mismatched types
- --> $DIR/hr-subtype.rs:54:13
- |
-LL | gimme::<$t1>(None::<$t2>);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
-...
-LL | / check! { bound_inv_a_b_vs_bound_inv_a: (for<'a,'b> fn(Inv<'a>, Inv<'b>),
-LL | | for<'a> fn(Inv<'a>, Inv<'a>)) }
- | |__________________________________- in this macro invocation
- |
- = note: expected enum `Option<for<'a, 'b> fn(Inv<'a>, Inv<'b>)>`
- found enum `Option<for<'a> fn(Inv<'a>, Inv<'a>)>`
- = note: this error originates in the macro `check` (in Nightly builds, run with -Z macro-backtrace for more info)
-
-error[E0308]: mismatched types
- --> $DIR/hr-subtype.rs:54:13
- |
-LL | gimme::<$t1>(None::<$t2>);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
-...
-LL | / check! { bound_inv_a_b_vs_bound_inv_a: (for<'a,'b> fn(Inv<'a>, Inv<'b>),
-LL | | for<'a> fn(Inv<'a>, Inv<'a>)) }
- | |__________________________________- in this macro invocation
- |
- = note: expected enum `Option<for<'a, 'b> fn(Inv<'a>, Inv<'b>)>`
- found enum `Option<for<'a> fn(Inv<'a>, Inv<'a>)>`
- = note: this error originates in the macro `check` (in Nightly builds, run with -Z macro-backtrace for more info)
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/hr-subtype/hr-subtype.free_inv_x_vs_free_inv_y.stderr b/src/test/ui/hr-subtype/hr-subtype.free_inv_x_vs_free_inv_y.stderr
deleted file mode 100644
index 31d36d716..000000000
--- a/src/test/ui/hr-subtype/hr-subtype.free_inv_x_vs_free_inv_y.stderr
+++ /dev/null
@@ -1,42 +0,0 @@
-error: lifetime may not live long enough
- --> $DIR/hr-subtype.rs:48:13
- |
-LL | fn subtype<'x, 'y: 'x, 'z: 'y>() {
- | -- -- lifetime `'y` defined here
- | |
- | lifetime `'x` defined here
-LL | gimme::<$t2>(None::<$t1>);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'x` must outlive `'y`
-...
-LL | / check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>),
-LL | | fn(Inv<'y>)) }
- | |______________- in this macro invocation
- |
- = help: consider adding the following bound: `'x: 'y`
- = note: requirement occurs because of the type `Inv<'_>`, which makes the generic argument `'_` invariant
- = note: the struct `Inv<'a>` is invariant over the parameter `'a`
- = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
- = note: this error originates in the macro `check` (in Nightly builds, run with -Z macro-backtrace for more info)
-
-error: lifetime may not live long enough
- --> $DIR/hr-subtype.rs:54:13
- |
-LL | fn supertype<'x, 'y: 'x, 'z: 'y>() {
- | -- -- lifetime `'y` defined here
- | |
- | lifetime `'x` defined here
-LL | gimme::<$t1>(None::<$t2>);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'x` must outlive `'y`
-...
-LL | / check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>),
-LL | | fn(Inv<'y>)) }
- | |______________- in this macro invocation
- |
- = help: consider adding the following bound: `'x: 'y`
- = note: requirement occurs because of the type `Inv<'_>`, which makes the generic argument `'_` invariant
- = note: the struct `Inv<'a>` is invariant over the parameter `'a`
- = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
- = note: this error originates in the macro `check` (in Nightly builds, run with -Z macro-backtrace for more info)
-
-error: aborting due to 2 previous errors
-
diff --git a/src/test/ui/hr-subtype/hr-subtype.free_x_vs_free_y.stderr b/src/test/ui/hr-subtype/hr-subtype.free_x_vs_free_y.stderr
deleted file mode 100644
index 269cde54c..000000000
--- a/src/test/ui/hr-subtype/hr-subtype.free_x_vs_free_y.stderr
+++ /dev/null
@@ -1,19 +0,0 @@
-error: lifetime may not live long enough
- --> $DIR/hr-subtype.rs:54:13
- |
-LL | fn supertype<'x, 'y: 'x, 'z: 'y>() {
- | -- -- lifetime `'y` defined here
- | |
- | lifetime `'x` defined here
-LL | gimme::<$t1>(None::<$t2>);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'x` must outlive `'y`
-...
-LL | / check! { free_x_vs_free_y: (fn(&'x u32),
-LL | | fn(&'y u32)) }
- | |______________- in this macro invocation
- |
- = help: consider adding the following bound: `'x: 'y`
- = note: this error originates in the macro `check` (in Nightly builds, run with -Z macro-backtrace for more info)
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/hr-subtype/hr-subtype.rs b/src/test/ui/hr-subtype/hr-subtype.rs
deleted file mode 100644
index c770e0de8..000000000
--- a/src/test/ui/hr-subtype/hr-subtype.rs
+++ /dev/null
@@ -1,111 +0,0 @@
-// Targeted tests for the higher-ranked subtyping code.
-
-#![allow(dead_code)]
-
-// revisions: bound_a_vs_bound_a
-// revisions: bound_a_vs_bound_b
-// revisions: bound_inv_a_vs_bound_inv_b
-// revisions: bound_co_a_vs_bound_co_b
-// revisions: bound_a_vs_free_x
-// revisions: free_x_vs_free_x
-// revisions: free_x_vs_free_y
-// revisions: free_inv_x_vs_free_inv_y
-// revisions: bound_a_b_vs_bound_a
-// revisions: bound_co_a_b_vs_bound_co_a
-// revisions: bound_contra_a_contra_b_ret_co_a
-// revisions: bound_co_a_co_b_ret_contra_a
-// revisions: bound_inv_a_b_vs_bound_inv_a
-// revisions: bound_a_b_ret_a_vs_bound_a_ret_a
-
-//[bound_a_vs_bound_a] check-pass
-//[bound_a_vs_bound_b] check-pass
-//[bound_inv_a_vs_bound_inv_b] check-pass
-//[bound_co_a_vs_bound_co_b] check-pass
-//[free_x_vs_free_x] check-pass
-//[bound_co_a_b_vs_bound_co_a] check-pass
-//[bound_co_a_co_b_ret_contra_a] check-pass
-//[bound_a_b_vs_bound_a] check-pass
-//[bound_contra_a_contra_b_ret_co_a] check-pass
-
-fn gimme<T>(_: Option<T>) {}
-
-struct Inv<'a> {
- x: *mut &'a u32,
-}
-
-struct Co<'a> {
- x: fn(&'a u32),
-}
-
-struct Contra<'a> {
- x: &'a u32,
-}
-
-macro_rules! check {
- ($rev:ident: ($t1:ty, $t2:ty)) => {
- #[cfg($rev)]
- fn subtype<'x, 'y: 'x, 'z: 'y>() {
- gimme::<$t2>(None::<$t1>);
- //[free_inv_x_vs_free_inv_y]~^ ERROR
- }
-
- #[cfg($rev)]
- fn supertype<'x, 'y: 'x, 'z: 'y>() {
- gimme::<$t1>(None::<$t2>);
- //[bound_a_vs_free_x]~^ ERROR
- //[free_x_vs_free_y]~^^ ERROR
- //[bound_inv_a_b_vs_bound_inv_a]~^^^ ERROR
- //[bound_inv_a_b_vs_bound_inv_a]~| ERROR
- //[bound_a_b_ret_a_vs_bound_a_ret_a]~^^^^^ ERROR
- //[free_inv_x_vs_free_inv_y]~^^^^^^ ERROR
- }
- };
-}
-
-// If both have bound regions, they are equivalent, regardless of
-// variant.
-check! { bound_a_vs_bound_a: (for<'a> fn(&'a u32),
-for<'a> fn(&'a u32)) }
-check! { bound_a_vs_bound_b: (for<'a> fn(&'a u32),
-for<'b> fn(&'b u32)) }
-check! { bound_inv_a_vs_bound_inv_b: (for<'a> fn(Inv<'a>),
-for<'b> fn(Inv<'b>)) }
-check! { bound_co_a_vs_bound_co_b: (for<'a> fn(Co<'a>),
-for<'b> fn(Co<'b>)) }
-
-// Bound is a subtype of free.
-check! { bound_a_vs_free_x: (for<'a> fn(&'a u32),
-fn(&'x u32)) }
-
-// Two free regions are relatable if subtyping holds.
-check! { free_x_vs_free_x: (fn(&'x u32),
-fn(&'x u32)) }
-check! { free_x_vs_free_y: (fn(&'x u32),
-fn(&'y u32)) }
-check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>),
-fn(Inv<'y>)) }
-
-// Somewhat surprisingly, a fn taking two distinct bound lifetimes and
-// a fn taking one bound lifetime can be interchangeable, but only if
-// we are co- or contra-variant with respect to both lifetimes.
-//
-// The reason is:
-// - if we are covariant, then 'a and 'b can be set to the call-site
-// intersection;
-// - if we are contravariant, then 'a can be inferred to 'static.
-check! { bound_a_b_vs_bound_a: (for<'a,'b> fn(&'a u32, &'b u32),
-for<'a> fn(&'a u32, &'a u32)) }
-check! { bound_co_a_b_vs_bound_co_a: (for<'a,'b> fn(Co<'a>, Co<'b>),
-for<'a> fn(Co<'a>, Co<'a>)) }
-check! { bound_contra_a_contra_b_ret_co_a: (for<'a,'b> fn(Contra<'a>, Contra<'b>) -> Co<'a>,
-for<'a> fn(Contra<'a>, Contra<'a>) -> Co<'a>) }
-check! { bound_co_a_co_b_ret_contra_a: (for<'a,'b> fn(Co<'a>, Co<'b>) -> Contra<'a>,
-for<'a> fn(Co<'a>, Co<'a>) -> Contra<'a>) }
-
-// If we make those lifetimes invariant, then the two types are not interchangeable.
-check! { bound_inv_a_b_vs_bound_inv_a: (for<'a,'b> fn(Inv<'a>, Inv<'b>),
-for<'a> fn(Inv<'a>, Inv<'a>)) }
-check! { bound_a_b_ret_a_vs_bound_a_ret_a: (for<'a,'b> fn(&'a u32, &'b u32) -> &'a u32,
-for<'a> fn(&'a u32, &'a u32) -> &'a u32) }
-
-fn main() {}
diff --git a/src/test/ui/hr-subtype/placeholder-pattern-fail.rs b/src/test/ui/hr-subtype/placeholder-pattern-fail.rs
deleted file mode 100644
index bd4533e04..000000000
--- a/src/test/ui/hr-subtype/placeholder-pattern-fail.rs
+++ /dev/null
@@ -1,25 +0,0 @@
-// Check that incorrect higher ranked subtyping
-// causes an error.
-struct Inv<'a>(fn(&'a ()) -> &'a ());
-fn hr_subtype<'c>(f: for<'a, 'b> fn(Inv<'a>, Inv<'a>)) {
- // ok
- let _: for<'a> fn(Inv<'a>, Inv<'a>) = f;
- let sub: for<'a> fn(Inv<'a>, Inv<'a>) = f;
- // no
- let _: for<'a, 'b> fn(Inv<'a>, Inv<'b>) = sub;
- //~^ ERROR mismatched types
-}
-
-fn simple1<'c>(x: (&'c i32,)) {
- let _x: (&'static i32,) = x;
-}
-
-fn simple2<'c>(x: (&'c i32,)) {
- let _: (&'static i32,) = x;
-}
-
-fn main() {
- hr_subtype(|_, _| {});
- simple1((&3,));
- simple2((&3,));
-}
diff --git a/src/test/ui/hr-subtype/placeholder-pattern-fail.stderr b/src/test/ui/hr-subtype/placeholder-pattern-fail.stderr
deleted file mode 100644
index 73b0a3173..000000000
--- a/src/test/ui/hr-subtype/placeholder-pattern-fail.stderr
+++ /dev/null
@@ -1,12 +0,0 @@
-error[E0308]: mismatched types
- --> $DIR/placeholder-pattern-fail.rs:9:47
- |
-LL | let _: for<'a, 'b> fn(Inv<'a>, Inv<'b>) = sub;
- | ^^^ one type is more general than the other
- |
- = note: expected fn pointer `for<'a, 'b> fn(Inv<'a>, Inv<'b>)`
- found fn pointer `for<'a> fn(Inv<'a>, Inv<'a>)`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/hr-subtype/placeholder-pattern.rs b/src/test/ui/hr-subtype/placeholder-pattern.rs
deleted file mode 100644
index 061e66e54..000000000
--- a/src/test/ui/hr-subtype/placeholder-pattern.rs
+++ /dev/null
@@ -1,18 +0,0 @@
-// check-pass
-// Check that higher ranked subtyping correctly works when using
-// placeholder patterns.
-fn hr_subtype<'c>(f: for<'a, 'b> fn(&'a (), &'b ())) {
- let _: for<'a> fn(&'a (), &'a ()) = f;
- let _: for<'a, 'b> fn(&'a (), &'b ()) = f;
- let _: for<'a> fn(&'a (), &'c ()) = f;
- let _: fn(&'c (), &'c ()) = f;
-}
-
-fn simple<'c>(x: (&'static i32,)) {
- let _: (&'c i32,) = x;
-}
-
-fn main() {
- hr_subtype(|_, _| {});
- simple((&3,));
-}
diff --git a/src/test/ui/hr-subtype/return-static.rs b/src/test/ui/hr-subtype/return-static.rs
deleted file mode 100644
index 6455854f3..000000000
--- a/src/test/ui/hr-subtype/return-static.rs
+++ /dev/null
@@ -1,13 +0,0 @@
-// check-pass
-
-fn make<T>() -> T {
- panic!()
-}
-
-fn take<T>(x: T) {}
-
-fn main() {
- let x: for<'a> fn(&'a u32) -> _ = make();
- let y: &'static u32 = x(&22);
- take::<for<'b> fn(&'b u32) -> &'b u32>(x);
-}