summaryrefslogtreecommitdiffstats
path: root/tests/ui/regions/auxiliary
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 /tests/ui/regions/auxiliary
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 'tests/ui/regions/auxiliary')
-rw-r--r--tests/ui/regions/auxiliary/rbmtp_cross_crate_lib.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/ui/regions/auxiliary/rbmtp_cross_crate_lib.rs b/tests/ui/regions/auxiliary/rbmtp_cross_crate_lib.rs
new file mode 100644
index 000000000..ce2a3a7db
--- /dev/null
+++ b/tests/ui/regions/auxiliary/rbmtp_cross_crate_lib.rs
@@ -0,0 +1,32 @@
+// Check that method bounds declared on traits/impls in a cross-crate
+// scenario work. This is the library portion of the test.
+
+pub enum MaybeOwned<'a> {
+ Owned(isize),
+ Borrowed(&'a isize)
+}
+
+pub struct Inv<'a> { // invariant w/r/t 'a
+ x: &'a mut &'a isize
+}
+
+// I encountered a bug at some point with encoding the IntoMaybeOwned
+// trait, so I'll use that as the template for this test.
+pub trait IntoMaybeOwned<'a> {
+ fn into_maybe_owned(self) -> MaybeOwned<'a>;
+
+ // Note: without this `into_inv` method, the trait is
+ // contravariant w/r/t `'a`, since if you look strictly at the
+ // interface, it only returns `'a`. This complicates the
+ // downstream test since it wants invariance to force an error.
+ // Hence we add this method.
+ fn into_inv(self) -> Inv<'a>;
+
+ fn bigger_region<'b:'a>(self, b: Inv<'b>);
+}
+
+impl<'a> IntoMaybeOwned<'a> for Inv<'a> {
+ fn into_maybe_owned(self) -> MaybeOwned<'a> { panic!() }
+ fn into_inv(self) -> Inv<'a> { panic!() }
+ fn bigger_region<'b:'a>(self, b: Inv<'b>) { panic!() }
+}