Skip to content

needless_return_with_question_mark is not triggered in async functions #16950

@Velnbur

Description

@Velnbur

Summary

needless_return_with_question_mark is not triggering in async functions.

Lint Name

needless_return_with_question_mark

Reproducer

I tried this code (link to playground:

extern crate thiserror; // 2.0.18
extern crate tokio; // 1.52.0

fn result_fn1() -> Result<(), ()> {
    if true {
        return Err(())?;
    }
    
    Ok(())
}

async fn result_fn2() -> Result<(), ()> {
    if true {
        return Err(())?;
    }
    
    Ok(())
}

#[tokio::main]
async fn main() {
    let _ = result_fn1();
    
    let _ = result_fn2().await;
}

I expected to see this happen:

Lint is triggering on both result_fn1 and result_fn2

Instead, this happened:

it triggered only on result_fn1 .

Version

rustc 1.93.0 (254b59607 2026-01-19)
binary: rustc
commit-hash: 254b59607d4417e9dffbc307138ae5c86280fe4c
commit-date: 2026-01-19
host: aarch64-apple-darwin
release: 1.93.0
LLVM version: 21.1.8

Metadata

Metadata

Assignees

Labels

C-bugCategory: Clippy is not doing the correct thingI-false-negativeIssue: The lint should have been triggered on code, but wasn't

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions