about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-10-02 18:46:27 +0000
committerbors <bors@rust-lang.org>2021-10-02 18:46:27 +0000
commitf03eb6bef8ced8a243858b819e013b9caf83d757 (patch)
tree3d7a5598b782533000f0c026859f6a987a3d9041 /src
parentd14731cb3ced8318d7fc83cbe838f0e7f2fb3b40 (diff)
parent87241e909933b30bb31af4edf58d1a331589df3c (diff)
downloadrust-f03eb6bef8ced8a243858b819e013b9caf83d757.tar.gz
rust-f03eb6bef8ced8a243858b819e013b9caf83d757.zip
Auto merge of #89341 - audunhalland:derive-type-params-with-bound-generic-params, r=jackh726
Deriving: Include bound generic params in type parameters for where clause

Fixes #89188.

The `derive` macro ignored the `for<'s>` needed with the `Fn` trait in that code example.

edit: I'm unsure if this might cause regressions. I'm not an experienced compiler developer so I'm not used to thinking about unwanted side effects code changes like this might have.
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/deriving/issue-89188-gat-hrtb.rs39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/test/ui/deriving/issue-89188-gat-hrtb.rs b/src/test/ui/deriving/issue-89188-gat-hrtb.rs
new file mode 100644
index 00000000000..abd85a616a4
--- /dev/null
+++ b/src/test/ui/deriving/issue-89188-gat-hrtb.rs
@@ -0,0 +1,39 @@
+// check-pass
+
+#![feature(generic_associated_types)]
+
+trait CallWithShim: Sized {
+    type Shim<'s>
+    where
+        Self: 's;
+}
+
+#[derive(Clone)]
+struct ShimMethod<T: CallWithShim + 'static>(pub &'static dyn for<'s> Fn(&'s mut T::Shim<'s>));
+
+trait CallWithShim2: Sized {
+    type Shim<T>;
+}
+
+struct S<'s>(&'s ());
+
+#[derive(Clone)]
+struct ShimMethod2<T: CallWithShim2 + 'static>(pub &'static dyn for<'s> Fn(&'s mut T::Shim<S<'s>>));
+
+trait Trait<'s, 't, 'u> {}
+
+#[derive(Clone)]
+struct ShimMethod3<T: CallWithShim2 + 'static>(
+    pub  &'static dyn for<'s> Fn(
+        &'s mut T::Shim<dyn for<'t> Fn(&'s mut T::Shim<dyn for<'u> Trait<'s, 't, 'u>>)>,
+    ),
+);
+
+trait Trait2 {
+    type As;
+}
+
+#[derive(Clone)]
+struct ShimMethod4<T: Trait2 + 'static>(pub &'static dyn for<'s> Fn(&'s mut T::As));
+
+pub fn main() {}