Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: dcchut/async-recursion
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.0.4
Choose a base ref
...
head repository: dcchut/async-recursion
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.0.5
Choose a head ref
  • 3 commits
  • 4 files changed
  • 1 contributor

Commits on Jun 2, 2023

  1. Copy the full SHA
    41aae56 View commit details

Commits on Sep 2, 2023

  1. Copy the full SHA
    833b021 View commit details
  2. prepare for 1.0.5 release

    dcchut committed Sep 2, 2023
    Copy the full SHA
    c59b504 View commit details
Showing with 43 additions and 3 deletions.
  1. +1 −1 Cargo.toml
  2. +12 −2 src/expand.rs
  3. +26 −0 tests/macros_all_the_way_down.rs
  4. +4 −0 tests/ui/must_use.stderr
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "async-recursion"
version = "1.0.4"
version = "1.0.5"
authors = ["Robert Usher <266585+dcchut@users.noreply.github.com>"]
edition = "2018"
license = "MIT OR Apache-2.0"
14 changes: 12 additions & 2 deletions src/expand.rs
Original file line number Diff line number Diff line change
@@ -61,8 +61,18 @@ fn transform_sig(sig: &mut Signature, args: &RecursionArgs) {

for arg in &mut sig.inputs {
if let FnArg::Typed(pt) = arg {
if let Type::Reference(tr) = pt.ty.as_mut() {
ref_arguments.push(tr);
match pt.ty.as_mut() {
// rustc can give us a None-delimited group if this type comes from
// a macro_rules macro. I don't this can happen for code the user has written.
Type::Group(tg) => {
if let Type::Reference(tr) = &mut *tg.elem {
ref_arguments.push(tr);
}
}
Type::Reference(tr) => {
ref_arguments.push(tr);
}
_ => {}
}
} else if let FnArg::Receiver(recv) = arg {
if let Some((_, slt)) = &mut recv.reference {
26 changes: 26 additions & 0 deletions tests/macros_all_the_way_down.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
use futures_executor::block_on;

macro_rules! recurse {
($name:ident, $param:ty) => {
#[::async_recursion::async_recursion]
async fn $name<F>(param: $param, f: &F)
where
F: Fn($param) + Sync + Send,
{
f(param);
}
};
}

recurse!(owned, usize);
recurse!(by_ref, &usize);
recurse!(by_ref_mut, &mut usize);

#[test]
fn async_in_macro() {
block_on(async move {
owned(5, &|_| ()).await;
by_ref(&5, &|_| ()).await;
by_ref_mut(&mut 5, &|_| ()).await;
});
}
4 changes: 4 additions & 0 deletions tests/ui/must_use.stderr
Original file line number Diff line number Diff line change
@@ -9,3 +9,7 @@ note: the lint level is defined here
|
1 | #![deny(unused_must_use)]
| ^^^^^^^^^^^^^^^
help: use `let _ = ...` to ignore the resulting value
|
9 | let _ = apples(3);
| +++++++