summaryrefslogtreecommitdiffstats
path: root/src/test/ui/associated-types/issue-21726.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /src/test/ui/associated-types/issue-21726.rs
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/associated-types/issue-21726.rs')
-rw-r--r--src/test/ui/associated-types/issue-21726.rs38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/test/ui/associated-types/issue-21726.rs b/src/test/ui/associated-types/issue-21726.rs
new file mode 100644
index 000000000..b98cf2166
--- /dev/null
+++ b/src/test/ui/associated-types/issue-21726.rs
@@ -0,0 +1,38 @@
+// check-pass
+#![allow(dead_code)]
+// Regression test for #21726: an issue arose around the rules for
+// subtyping of projection types that resulted in an unconstrained
+// region, yielding region inference failures.
+
+// pretty-expanded FIXME #23616
+
+fn main() { }
+
+fn foo<'a>(s: &'a str) {
+ let b: B<()> = B::new(s, ());
+ b.get_short();
+}
+
+trait IntoRef<'a> {
+ type T: Clone;
+ fn into_ref(self, _: &'a str) -> Self::T;
+}
+
+impl<'a> IntoRef<'a> for () {
+ type T = &'a str;
+ fn into_ref(self, s: &'a str) -> &'a str {
+ s
+ }
+}
+
+struct B<'a, P: IntoRef<'a>>(P::T);
+
+impl<'a, P: IntoRef<'a>> B<'a, P> {
+ fn new(s: &'a str, i: P) -> B<'a, P> {
+ B(i.into_ref(s))
+ }
+
+ fn get_short(&self) -> P::T {
+ self.0.clone()
+ }
+}