Skip to content

Commit 220f817

Browse files
committed
Workaround to support old nightlies
1 parent bfe44b3 commit 220f817

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,10 @@ proc-macro = true
1616
proc-macro2 = "0.4"
1717
quote = "0.6"
1818
syn = { version = "0.15.41", features = ["full", "visit-mut"] }
19+
20+
[features]
21+
# Alternative implementation that produces worse error messages but potentially
22+
# works on old nightlies without https://github.com/rust-lang/rust/pull/61775 in
23+
# some cases where the default implementation does not. This feature is semver
24+
# exempt and might get removed without notice in any patch version.
25+
support_old_nightly = []

src/expand.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,15 @@ fn transform_sig(context: Context, sig: &mut MethodSig, has_self: bool, has_defa
207207
// }
208208
// Pin::from(Box::new(async_trait_method::<T, Self>(self, x)))
209209
fn transform_block(context: Context, sig: &mut MethodSig, block: &mut Block, has_self: bool) {
210+
if cfg!(feature = "support_old_nightly") {
211+
let brace = block.brace_token;
212+
*block = parse_quote!({
213+
core::pin::Pin::from(Box::new(async move #block))
214+
});
215+
block.brace_token = brace;
216+
return;
217+
}
218+
210219
let inner = Ident::new(&format!("__{}", sig.ident), sig.ident.span());
211220
let args = sig
212221
.decl

0 commit comments

Comments
 (0)