Skip to content

Commit

Permalink
Rollup merge of #105447 - TaKO8Ki:add-test-for-103095, r=petrochenkov
Browse files Browse the repository at this point in the history
Add a test for #103095

closes #103095
  • Loading branch information
matthiaskrgr authored Dec 18, 2022
2 parents 1ca43d4 + 2423ea2 commit e8fdd69
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/test/ui/borrowck/issue-103095.rs
Original file line number Diff line number Diff line change
@@ -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() {}

0 comments on commit e8fdd69

Please sign in to comment.