about summary refs log tree commit diff
diff options
context:
space:
mode:
authorclubby789 <jamie@hill-daniel.co.uk>2024-10-07 11:36:58 +0000
committerclubby789 <jamie@hill-daniel.co.uk>2024-10-07 16:30:48 +0000
commit382365bfe3f136fe97273e58532d799a82b373ea (patch)
tree8a853c56c1edf704a521eea1ceac79070183ce95
parentfa4f18be5553bd23856abf717ad86acf0412a2ef (diff)
downloadrust-382365bfe3f136fe97273e58532d799a82b373ea.tar.gz
rust-382365bfe3f136fe97273e58532d799a82b373ea.zip
Add test for issue 30867
-rw-r--r--tests/ui/traits/hrtb-related-type-params-30867.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/ui/traits/hrtb-related-type-params-30867.rs b/tests/ui/traits/hrtb-related-type-params-30867.rs
new file mode 100644
index 00000000000..ec1e3355bfb
--- /dev/null
+++ b/tests/ui/traits/hrtb-related-type-params-30867.rs
@@ -0,0 +1,14 @@
+//@ check-pass
+//! Tests that HRTB impl selection covers type parameters not directly related
+//! to the trait.
+//! Test for <https://github.com/rust-lang/rust/issues/30867>
+
+#![crate_type = "lib"]
+
+trait Unary<T> {}
+impl<T, U, F: Fn(T) -> U> Unary<T> for F {}
+fn unary<F: for<'a> Unary<&'a T>, T>() {}
+
+pub fn test<F: for<'a> Fn(&'a i32) -> &'a i32>() {
+    unary::<F, i32>()
+}