about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTakayuki Maeda <takoyaki0316@gmail.com>2022-12-08 16:55:57 +0900
committerTakayuki Maeda <takoyaki0316@gmail.com>2022-12-08 16:55:57 +0900
commit2423ea2c5f430616f593fcffe43f17a3f669d881 (patch)
treef3a7868a1cfd54e7034417e1ee0c798ba7c684d9
parented61c139c2bc778ebb91f5dd6a5393aa20467f78 (diff)
downloadrust-2423ea2c5f430616f593fcffe43f17a3f669d881.tar.gz
rust-2423ea2c5f430616f593fcffe43f17a3f669d881.zip
add a test for #103095
-rw-r--r--src/test/ui/borrowck/issue-103095.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/test/ui/borrowck/issue-103095.rs b/src/test/ui/borrowck/issue-103095.rs
new file mode 100644
index 00000000000..0340f39243f
--- /dev/null
+++ b/src/test/ui/borrowck/issue-103095.rs
@@ -0,0 +1,30 @@
+// check-pass
+
+trait FnOnceForGenericRef<T>: FnOnce(&T) -> Self::FnOutput {
+    type FnOutput;
+}
+
+impl<T, R, F: FnOnce(&T) -> R> FnOnceForGenericRef<T> for F {
+    type FnOutput = R;
+}
+
+struct Data<T, D: FnOnceForGenericRef<T>> {
+    value: Option<T>,
+    output: Option<D::FnOutput>,
+}
+
+impl<T, D: FnOnceForGenericRef<T>> Data<T, D> {
+    fn new(value: T, f: D) -> Self {
+        let output = f(&value);
+        Self {
+            value: Some(value),
+            output: Some(output),
+        }
+    }
+}
+
+fn test() {
+    Data::new(String::new(), |_| {});
+}
+
+fn main() {}