forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add regression test for rust-lang#106630
- Loading branch information
1 parent
7b24016
commit 95f16f1
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
tests/ui/impl-trait/not_general_enough_regression_106630.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// edition:2018 | ||
// run-pass | ||
|
||
use std::future::Future; | ||
|
||
trait AsyncCallback<'a> { | ||
type Out; | ||
} | ||
|
||
impl<'a, Fut, T, F> AsyncCallback<'a> for F | ||
where | ||
F: FnOnce(&'a mut ()) -> Fut, | ||
Fut: Future<Output = T> + Send + 'a, | ||
{ | ||
type Out = T; | ||
} | ||
|
||
trait CallbackMarker {} | ||
|
||
impl<F, T> CallbackMarker for F | ||
where | ||
T: 'static, | ||
for<'a> F: AsyncCallback<'a, Out = T> + Send, | ||
{ | ||
} | ||
|
||
fn do_sth<F: CallbackMarker>(_: F) {} | ||
|
||
async fn callback(_: &mut ()) -> impl Send {} | ||
|
||
fn main() { | ||
do_sth(callback); | ||
} |