From 2423ea2c5f430616f593fcffe43f17a3f669d881 Mon Sep 17 00:00:00 2001 From: Takayuki Maeda Date: Thu, 8 Dec 2022 16:55:57 +0900 Subject: [PATCH] add a test for #103095 --- src/test/ui/borrowck/issue-103095.rs | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/test/ui/borrowck/issue-103095.rs 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: FnOnce(&T) -> Self::FnOutput { + type FnOutput; +} + +impl R> FnOnceForGenericRef for F { + type FnOutput = R; +} + +struct Data> { + value: Option, + output: Option, +} + +impl> Data { + 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() {}