Skip to content

manual_async_fn butchers fn visibility ("async pub" instead of "pub async") #10450

Closed
@matthiaskrgr

Description

@matthiaskrgr

Summary

.

Lint Name

manual_async_fn

Reproducer

I tried this code:

use std::future::Future;

pub fn get_int_future() -> impl Future<Output = i32> {
    async { 42 }
}

pub fn main() {}

I saw this happen:

help: make the function `async` and return the output of the future directly
  |
5 | async pub fn get_int_future() -> i32 {

I expected to see this happen:

this does not compile, we need pub async instead of async pub here

error: expected one of `extern`, `fn`, or `unsafe`, found keyword `pub`
 --> src/main.rs:5:7
  |
5 | async pub fn get_int_future() -> i32 { 42 }
  | ------^^^
  | |     |
  | |     expected one of `extern`, `fn`, or `unsafe`
  | help: visibility `pub` must come before `async`: `pub async`

error: aborting due to previous error

Version

rustc 1.69.0-nightly (44cfafe2f 2023-03-03)
binary: rustc
commit-hash: 44cfafe2fafe816395d3acc434663a45d5178c41
commit-date: 2023-03-03
host: x86_64-unknown-linux-gnu
release: 1.69.0-nightly
LLVM version: 15.0.7

Additional Labels

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when applied

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions