Skip to content

Commit 91dc8b2

Browse files
committed
combinators: remove doc_hack!
The rustdoc issue which this workaround was working around has since been resolved. related: rust-lang/rust#65863
1 parent 2275246 commit 91dc8b2

File tree

1 file changed

+29
-105
lines changed

1 file changed

+29
-105
lines changed

src/combinators.rs

Lines changed: 29 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -57,32 +57,6 @@ impl<T, Head, Tail: CoprodAppend<T>> CoprodAppend<T> for Coproduct<Head, Tail> {
5757
}
5858
}
5959

60-
/// A hack to make `type_alias_impl_trait` work with rustdoc.
61-
///
62-
/// When compiling under rustdoc, the left variant is used, while rustc will use the right
63-
/// variant.
64-
///
65-
/// Tracking issue for the bug: https://github.com/rust-lang/rust/issues/65863
66-
macro_rules! doc_hack {
67-
($doc:expr, $not_doc:expr) => {
68-
#[cfg(doc)]
69-
{
70-
$doc
71-
}
72-
#[cfg(not(doc))]
73-
{
74-
$not_doc
75-
}
76-
};
77-
78-
($doc:item $not_doc:item) => {
79-
#[cfg(doc)]
80-
$doc
81-
#[cfg(not(doc))]
82-
$not_doc
83-
};
84-
}
85-
8660
macro_rules! derive_clone_new_3 {
8761
($t:ty where $( $p:ident $( : $bound:ident )? ),+) => {
8862
impl<$( $p $( : $bound )? ),+> Clone for $t {
@@ -159,19 +133,14 @@ where
159133

160134
type Error = <L as Link<Req, P>>::Error;
161135

162-
doc_hack! {
163-
type Future = BoxFuture<'static, Result<(Self::Output, Self::Params), Self::Error>>;
164-
type Future = impl Future<Output = Result<(Self::Output, Self::Params), Self::Error>>;
165-
}
136+
type Future = impl Future<Output = Result<(Self::Output, Self::Params), Self::Error>>;
166137

167138
fn handle_link(&self, req: Req, p: P) -> Self::Future {
168139
let head = self.value.clone();
169140

170-
let fut = (self.prev)
141+
self.prev
171142
.handle_link(req, p)
172-
.map_ok(move |(tail, p)| (HCons { head, tail }, p));
173-
174-
doc_hack! { fut.boxed(), fut }
143+
.map_ok(move |(tail, p)| (HCons { head, tail }, p))
175144
}
176145
}
177146

@@ -200,19 +169,14 @@ where
200169

201170
type Error = <L as Link<Req, P>>::Error;
202171

203-
doc_hack! {
204-
type Future = BoxFuture<'static, Result<(Self::Output, Self::Params), Self::Error>>;
205-
type Future = impl Future<Output = Result<(Self::Output, Self::Params), Self::Error>>;
206-
}
172+
type Future = impl Future<Output = Result<(Self::Output, Self::Params), Self::Error>>;
207173

208174
fn handle_link(&self, req: Req, p: P) -> Self::Future {
209175
let rest = self.value.clone();
210176

211-
let fut = (self.prev)
177+
self.prev
212178
.handle_link(req, p)
213-
.map_ok(move |(head, p)| (head + rest, p));
214-
215-
doc_hack! { fut.boxed(), fut }
179+
.map_ok(move |(head, p)| (head + rest, p))
216180
}
217181
}
218182

@@ -240,21 +204,16 @@ where
240204

241205
type Error = <L as Link<Req, P>>::Error;
242206

243-
doc_hack! {
244-
type Future = BoxFuture<'static, Result<(Self::Output, Self::Params), Self::Error>>;
245-
type Future = impl Future<Output = Result<(Self::Output, Self::Params), Self::Error>>;
246-
}
207+
type Future = impl Future<Output = Result<(Self::Output, Self::Params), Self::Error>>;
247208

248209
fn handle_link(&self, req: Req, p: P) -> Self::Future {
249210
let next = self.next.clone();
250211

251-
let fut = self.prev.handle_link(req, p).map_ok(move |(stack, p)| {
212+
self.prev.handle_link(req, p).map_ok(move |(stack, p)| {
252213
let (take, rest) = stack.sculpt();
253214
let merge = next(take);
254215
(rest + merge, p)
255-
});
256-
257-
doc_hack! { fut.boxed(), fut }
216+
})
258217
}
259218
}
260219

@@ -283,22 +242,17 @@ where
283242

284243
type Error = Coproduct<E, <L as Link<Req, P>>::Error>;
285244

286-
doc_hack! {
287-
type Future = BoxFuture<'static, Result<(Self::Output, Self::Params), Self::Error>>;
288-
type Future = impl Future<Output = Result<(Self::Output, Self::Params), Self::Error>>;
289-
}
245+
type Future = impl Future<Output = Result<(Self::Output, Self::Params), Self::Error>>;
290246

291247
fn handle_link(&self, req: Req, p: P) -> Self::Future {
292248
let next = self.next.clone();
293249

294-
let fut = self.prev.handle_link(req, p).map(move |res| {
250+
self.prev.handle_link(req, p).map(move |res| {
295251
let (stack, p) = res.map_err(Coproduct::Inr)?;
296252
let (take, rest) = stack.sculpt();
297253
let merge = next(take).map_err(Coproduct::Inl)?;
298254
Ok((rest + merge, p))
299-
});
300-
301-
doc_hack! { fut.boxed(), fut }
255+
})
302256
}
303257
}
304258

@@ -328,21 +282,16 @@ where
328282

329283
type Error = <L as Link<Req, P>>::Error;
330284

331-
doc_hack! {
332-
type Future = BoxFuture<'static, Result<(Self::Output, Self::Params), Self::Error>>;
333-
type Future = impl Future<Output = Result<(Self::Output, Self::Params), Self::Error>>;
334-
}
285+
type Future = impl Future<Output = Result<(Self::Output, Self::Params), Self::Error>>;
335286

336287
fn handle_link(&self, req: Req, p: P) -> Self::Future {
337288
let next = self.next.clone();
338289

339-
let fut = (self.prev.handle_link(req, p)).and_then(|(stack, p)| async move {
290+
(self.prev.handle_link(req, p)).and_then(|(stack, p)| async move {
340291
let (take, rest) = stack.sculpt();
341292
let merge = next(take).await;
342293
Ok((rest + merge, p))
343-
});
344-
345-
doc_hack! { fut.boxed(), fut }
294+
})
346295
}
347296
}
348297

@@ -373,22 +322,17 @@ where
373322

374323
type Error = Coproduct<E, <L as Link<Req, P>>::Error>;
375324

376-
doc_hack! {
377-
type Future = BoxFuture<'static, Result<(Self::Output, Self::Params), Self::Error>>;
378-
type Future = impl Future<Output = Result<(Self::Output, Self::Params), Self::Error>>;
379-
}
325+
type Future = impl Future<Output = Result<(Self::Output, Self::Params), Self::Error>>;
380326

381327
fn handle_link(&self, req: Req, p: P) -> Self::Future {
382328
let next = self.next.clone();
383329

384-
let fut = self.prev.handle_link(req, p).then(|res| async move {
330+
self.prev.handle_link(req, p).then(|res| async move {
385331
let (stack, p) = res.map_err(Coproduct::Inr)?;
386332
let (take, rest) = stack.sculpt();
387333
let merge = next(take).await.map_err(Coproduct::Inl)?;
388334
Ok((rest + merge, p))
389-
});
390-
391-
doc_hack! { fut.boxed(), fut }
335+
})
392336
}
393337
}
394338

@@ -412,17 +356,12 @@ where
412356

413357
type Error = E;
414358

415-
doc_hack! {
416-
type Future = BoxFuture<'static, Result<(Self::Output, Self::Params), Self::Error>>;
417-
type Future = impl Future<Output = Result<(Self::Output, Self::Params), Self::Error>>;
418-
}
359+
type Future = impl Future<Output = Result<(Self::Output, Self::Params), Self::Error>>;
419360

420361
fn handle_link(&self, req: Req, p: P) -> Self::Future {
421362
let next = self.next.clone();
422363

423-
let fut = self.prev.handle_link(req, p).map_err(move |e| next(e));
424-
425-
doc_hack! { fut.boxed(), fut }
364+
self.prev.handle_link(req, p).map_err(move |e| next(e))
426365
}
427366
}
428367

@@ -449,20 +388,15 @@ where
449388

450389
type Error = Coproduct<R, <<L as Link<Req, P>>::Error as CoprodUninjector<E, Ix>>::Remainder>;
451390

452-
doc_hack! {
453-
type Future = BoxFuture<'static, Result<(Self::Output, Self::Params), Self::Error>>;
454-
type Future = impl Future<Output = Result<(Self::Output, Self::Params), Self::Error>>;
455-
}
391+
type Future = impl Future<Output = Result<(Self::Output, Self::Params), Self::Error>>;
456392

457393
fn handle_link(&self, req: Req, p: P) -> Self::Future {
458394
let next = self.next.clone();
459395

460-
let fut = (self.prev.handle_link(req, p)).map_err(move |e| match e.uninject() {
396+
(self.prev.handle_link(req, p)).map_err(move |e| match e.uninject() {
461397
Ok(err) => Coproduct::Inl(next(err)),
462398
Err(no) => Coproduct::Inr(no),
463-
});
464-
465-
doc_hack! { fut.boxed(), fut }
399+
})
466400
}
467401
}
468402

@@ -508,23 +442,18 @@ where
508442
type Error =
509443
<<L as Link<Req, P>>::Error as CoprodAppend<<Sub as Parser<Segment>>::Error>>::Output;
510444

511-
doc_hack! {
512-
type Future = BoxFuture<'static, Result<(Self::Output, Self::Params), Self::Error>>;
513-
type Future = impl Future<Output = Result<(Self::Output, Self::Params), Self::Error>>;
514-
}
445+
type Future = impl Future<Output = Result<(Self::Output, Self::Params), Self::Error>>;
515446

516447
fn handle_link(&self, req: Req, p: P) -> Self::Future {
517-
let fut = self.link.handle_link(req, p).map(|res| match res {
448+
self.link.handle_link(req, p).map(|res| match res {
518449
Ok((stack, p)) => match p.pluck() {
519450
(Ok(ps), rem) => Ok((stack + ps, rem)),
520451
(Err(e), _) => Err(<<L as Link<Req, P>>::Error as CoprodAppend<
521452
<Sub as Parser<Segment>>::Error,
522453
>>::appendr(e)),
523454
},
524455
Err(e) => Err(e.appendl()),
525-
});
526-
527-
doc_hack! { fut.boxed(), fut }
456+
})
528457
}
529458
}
530459

@@ -552,20 +481,15 @@ where
552481

553482
type Error = <L as Link<Req, P>>::Error;
554483

555-
doc_hack! {
556-
type Future = BoxFuture<'static, Result<(Self::Output, Self::Params), Self::Error>>;
557-
type Future = impl Future<Output = Result<(Self::Output, Self::Params), Self::Error>>;
558-
}
484+
type Future = impl Future<Output = Result<(Self::Output, Self::Params), Self::Error>>;
559485

560486
fn handle_link(&self, req: Req, p: P) -> Self::Future {
561487
let next = Arc::clone(&self.next);
562488

563-
let fut = self.prev.handle_link(req, p).and_then(|(s, _)| async move {
489+
self.prev.handle_link(req, p).and_then(|(s, _)| async move {
564490
let (take, _) = s.sculpt();
565491
let reply = next(take).await;
566492
Ok((reply.into_response(), HNil))
567-
});
568-
569-
doc_hack! { fut.boxed(), fut }
493+
})
570494
}
571495
}

0 commit comments

Comments
 (0)