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

attributes: fix #[instrument(err)] in case of early returns #1006

Commits on Oct 1, 2020

  1. attributes: fix #[instrument(err)] in case of early returns

    For the non-async case, early returns could escape the block so that the
    error handling was skipped.
    nwse-fwn committed Oct 1, 2020
    Configuration menu
    Copy the full SHA
    b52e2c2 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    4bfb293 View commit details
    Browse the repository at this point in the history

Commits on Oct 7, 2020

  1. attributes: improve error messages for #[instrument(err)]

    Annotating the return type of the closure improves the error message in
    case of a mismatch between the function's return type and body.
    
    Example code:
    ```
    fn with_err() -> Result<(), String> {
        Ok(5)
    }
    ```
    
    Without return type annotation:
    ```
    error[E0308]: mismatched types
     --> src/main.rs:2:37
      |
    2 |   fn with_err() -> Result<(), String> {
      |  _____________________________________^
    3 | |     Ok(5)
    4 | | }
      | |_^ expected `()`, found integer
    ```
    
    With return type annotation:
    ```
    error[E0308]: mismatched types
     --> src/main.rs:3:8
      |
    3 |     Ok(5)
      |        ^ expected `()`, found integer
    ```
    nwse-fwn committed Oct 7, 2020
    Configuration menu
    Copy the full SHA
    c94b0ec View commit details
    Browse the repository at this point in the history