Skip to content

Commit e8fdd69

Browse files
authored
Rollup merge of #105447 - TaKO8Ki:add-test-for-103095, r=petrochenkov
Add a test for #103095 closes #103095
2 parents 1ca43d4 + 2423ea2 commit e8fdd69

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/test/ui/borrowck/issue-103095.rs

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// check-pass
2+
3+
trait FnOnceForGenericRef<T>: FnOnce(&T) -> Self::FnOutput {
4+
type FnOutput;
5+
}
6+
7+
impl<T, R, F: FnOnce(&T) -> R> FnOnceForGenericRef<T> for F {
8+
type FnOutput = R;
9+
}
10+
11+
struct Data<T, D: FnOnceForGenericRef<T>> {
12+
value: Option<T>,
13+
output: Option<D::FnOutput>,
14+
}
15+
16+
impl<T, D: FnOnceForGenericRef<T>> Data<T, D> {
17+
fn new(value: T, f: D) -> Self {
18+
let output = f(&value);
19+
Self {
20+
value: Some(value),
21+
output: Some(output),
22+
}
23+
}
24+
}
25+
26+
fn test() {
27+
Data::new(String::new(), |_| {});
28+
}
29+
30+
fn main() {}

0 commit comments

Comments
 (0)