Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
matthiaskrgr opened this issue Mar 5, 2023 · 0 comments · Fixed by #10456
Closed

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

matthiaskrgr opened this issue Mar 5, 2023 · 0 comments · Fixed by #10456
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied

Comments

@matthiaskrgr
Copy link
Member

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

@matthiaskrgr matthiaskrgr added C-bug Category: Clippy is not doing the correct thing I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied I-false-positive Issue: The lint was triggered on code it shouldn't have labels Mar 5, 2023
@bors bors closed this as completed in e64c596 Mar 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant