mirror of
https://github.com/Noratrieb/evaluate_obligation-fingerprints.git
synced 2026-01-16 19:25:04 +01:00
integrate repro from cyrgani
https://github.com/rust-lang/rust/issues/147825#issuecomment-3417158512
This commit is contained in:
parent
5ce26e9089
commit
ee9a455919
1 changed files with 24 additions and 82 deletions
106
src/main.rs
106
src/main.rs
|
|
@ -1,108 +1,50 @@
|
||||||
use std::pin::Pin;
|
use std::{
|
||||||
|
pin::Pin,
|
||||||
|
task::{Context, Poll},
|
||||||
|
};
|
||||||
|
|
||||||
pub trait FnOnce1<A> {
|
trait FnOnce1 {
|
||||||
type Output;
|
type Output;
|
||||||
fn call_once(self, arg: A) -> Self::Output;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, A, R> FnOnce1<A> for T
|
impl<T, R> FnOnce1 for T
|
||||||
where
|
where
|
||||||
T: FnOnce(A) -> R,
|
T: FnOnce() -> R,
|
||||||
{
|
{
|
||||||
type Output = R;
|
type Output = R;
|
||||||
fn call_once(self, arg: A) -> R {
|
|
||||||
self(arg)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
struct Map<F>(F);
|
||||||
|
|
||||||
pub struct MapOkFn<F>(F);
|
impl<F, T> Future for Map<F>
|
||||||
|
|
||||||
impl<F, T, E> FnOnce1<Result<T, E>> for MapOkFn<F>
|
|
||||||
where
|
where
|
||||||
F: FnOnce1<T>,
|
F: FnOnce1<Output = T>,
|
||||||
{
|
|
||||||
type Output = Result<F::Output, E>;
|
|
||||||
fn call_once(self, arg: Result<T, E>) -> Self::Output {
|
|
||||||
arg.map(|x| self.0.call_once(x))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct Map<Fut, F> {
|
|
||||||
inner: (Fut, F),
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<Fut, F, T> Future for Map<Fut, F>
|
|
||||||
where
|
|
||||||
Fut: Future,
|
|
||||||
F: FnOnce1<Fut::Output, Output = T>,
|
|
||||||
{
|
{
|
||||||
type Output = T;
|
type Output = T;
|
||||||
fn poll(
|
|
||||||
self: core::pin::Pin<&mut Self>,
|
fn poll(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<T> {
|
||||||
cx: &mut core::task::Context<'_>,
|
|
||||||
) -> core::task::Poll<Self::Output> {
|
|
||||||
loop {}
|
loop {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct MapOk<Fut, F> {
|
fn take_output<Fut: Future>(_: Pin<&mut Fut>) -> Fut::Output {
|
||||||
inner: Map<Fut, MapOkFn<F>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<Fut, F> Future for MapOk<Fut, F>
|
|
||||||
where
|
|
||||||
Map<Fut, MapOkFn<F>>: Future,
|
|
||||||
{
|
|
||||||
type Output = <Map<Fut, MapOkFn<F>> as Future>::Output;
|
|
||||||
fn poll(
|
|
||||||
self: core::pin::Pin<&mut Self>,
|
|
||||||
cx: &mut core::task::Context<'_>,
|
|
||||||
) -> core::task::Poll<Self::Output> {
|
|
||||||
loop {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct MaybeDone<Fut: Future>(Fut);
|
|
||||||
|
|
||||||
pub fn take_output<Fut: Future>(x: Pin<&mut MaybeDone<Fut>>) -> Fut::Output {
|
|
||||||
loop {}
|
loop {}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct AndThen<Fut1, F>(Fut1, F);
|
fn main() {
|
||||||
impl<Fut1, F> Future for AndThen<Fut1, F>
|
let mut bazz = Map(async || ());
|
||||||
where
|
let mut barr = async { Bazz {} };
|
||||||
MapOk<Fut1, F>: Future,
|
|
||||||
{
|
|
||||||
type Output = ();
|
|
||||||
fn poll(
|
|
||||||
self: Pin<&mut Self>,
|
|
||||||
cx: &mut std::task::Context<'_>,
|
|
||||||
) -> std::task::Poll<Self::Output> {
|
|
||||||
loop {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn and_then<This, F>(s: This, f: F) -> AndThen<This, F> {
|
let mut _fut0 = unsafe { Pin::new_unchecked(&mut bazz) };
|
||||||
loop {}
|
let mut _fut1 = unsafe { Pin::new_unchecked(&mut barr) };
|
||||||
}
|
|| {
|
||||||
|
take_output(_fut0.as_mut());
|
||||||
pub async fn bar_baz() {
|
take_output(_fut1.as_mut());
|
||||||
let bazz = and_then(async { Ok::<(), ()>(()) }, async |_| Ok::<(), ()>(()));
|
};
|
||||||
let barr = async { Bazz {} };
|
|
||||||
|
|
||||||
let mut _fut0 = MaybeDone(bazz);
|
|
||||||
let mut _fut0 = unsafe { std::pin::Pin::new_unchecked(&mut _fut0) };
|
|
||||||
let mut _fut1 = MaybeDone(barr);
|
|
||||||
let mut _fut1 = unsafe { std::pin::Pin::new_unchecked(&mut _fut1) };
|
|
||||||
std::future::poll_fn(move |__cx: &mut std::task::Context<'_>| {
|
|
||||||
std::task::Poll::Ready((take_output(_fut0.as_mut()), take_output(_fut1.as_mut())))
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1
|
// 1
|
||||||
|
// 2
|
||||||
|
|
||||||
#[derive(proc_macro_thing::MyMacro)]
|
#[derive(proc_macro_thing::MyMacro)]
|
||||||
#[helper]
|
#[helper]
|
||||||
pub struct Bazz {}
|
struct Bazz {}
|
||||||
|
|
||||||
fn main() {}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue