Rollup merge of #105447 - TaKO8Ki:add-test-for-103095, r=petrochenkov
Add a test for #103095 closes #103095
This commit is contained in:
commit
e8fdd6912f
30
src/test/ui/borrowck/issue-103095.rs
Normal file
30
src/test/ui/borrowck/issue-103095.rs
Normal file
@ -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() {}
|
Loading…
Reference in New Issue
Block a user