Skip to content

use_try_shorthand = true disallows formatting on chains with comments #6121

Description

@Laifsyn

rustfmt.toml

# rustfmt.toml
# outdated default — `?` was unstable at the time
# additionally the `try!` macro is deprecated now
use_try_shorthand =true

main.rs

fn main() {
    let e: Result<(), &str> = Ok(());
    let _e = e // hello comment
            .map_err(|_| "This is an error message") // Hello comment - Fails to format
        .map(|_| ());

    println!("Hello, world!");
}
rustfmt version: 
    `rustfmt 1.7.0-stable (07dca489 2024-02-04)`
Nightly:
    `rustfmt 1.7.0-nightly (1388d7a0 2024-03-20)`

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ASTArea: Abstract Syntax Tree (AST) related thingsA-commentsArea: commentsC-bugCategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICESO-use_try_shorthandStable option: use_try_shorthandonly-with-optionRequires a non-default option value to reproduce

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions