rust-lang / rust-lang/rustfmt

Wrong indentation when using double `?` to handle long async function calls

Open
#6,564 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-closures
Dominant language
Rust
Stars
7k
Forks
1.1k
Avg merge
2d 13h
Merged PRs (30d)
24

Description

I really don't know how to describe this ... How i found it ??? This is the simplest case I've tried to summarize.

For the code:

mod any {
    async fn f2345678901234567890123456789012345678901() -> Option<Option<((), ())>> {
        None
    }

    async fn foo() -> Option<()> {
        let a23456789012345678901234567890 = f2345678901234567890123456789012345678901()
            .await
            .inspect(|_| {
            println!();
            println!();
        })??;

        Some(())
    }
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running rustfmt on the Rust reproducer in the issue and inspect the indentation around the chained async call and its closure. Compare the formatted output with the reported behavior; the issue is done when the double ? case produces correct, consistent indentation.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.