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

[RFC] Add #[diagnostic::blocking] attribute #3639

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on May 17, 2024

  1. Add #[diagnostic::blocking] attribute

    `#[diagnostic::blocking]` is a marker attribute for functions that are
    considered (by their author) to be a blocking operation, and as such
    shouldn't be invoked from an `async` function. `rustc`, `clippy` and other
    tools can use this signal to lint against calling these functions in `async`
    contexts.
    
    It would allow `rustc`, `clippy` and other tools to provide lints like
    
    ```
    warning: async function `foo` can block
      --> $DIR/blocking-calls-in-async.rs:28:1
       |
    28 | async fn foo() {
       | --------------
    29 |     interesting();
       |     ^^^^^^^^^^^^^`foo` is determined to block because it calls into `interesting`
       |
    note: `interesting` is considered to be blocking because it was explicitly marked as such
      --> $DIR/blocking-calls-in-async.rs:5:1
       |
    5  | #[diagnostic::blocking]
       | ^^^^^^^^^^^^^^^^^^^^^^^
    6  | fn interesting() {}
       | ----------------
    ```
    estebank committed May 17, 2024
    Configuration menu
    Copy the full SHA
    d3afb4c View commit details
    Browse the repository at this point in the history