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() {}