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

Do not parenthesize exterior struct lit inside match guards #118726

Merged
merged 7 commits into from
Dec 11, 2023

Commits on Dec 8, 2023

  1. Configuration menu
    Copy the full SHA
    419b269 View commit details
    Browse the repository at this point in the history
  2. Inline npals closure

    dtolnay committed Dec 8, 2023
    Configuration menu
    Copy the full SHA
    d2b7bd4 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    8d64961 View commit details
    Browse the repository at this point in the history
  4. Rearrange logic of needs_par computation in print_let

    True || needs_par_as_let_scrutinee(...) is always true.
    dtolnay committed Dec 8, 2023
    Configuration menu
    Copy the full SHA
    dc5ec72 View commit details
    Browse the repository at this point in the history
  5. Delete special handling of some expr kinds from print_let

    In all four of Break, Closure, Ret, Yeet, the needs_par_as_let_scrutinee
    is guaranteed to return true because the .precedence().order() of those
    expr kinds is <= AssocOp::LAnd.precedence().
    
    The relevant functions in rustc_ast::util::parser are:
    
        fn needs_par_as_let_scrutinee(order: i8) -> bool {
            order <= prec_let_scrutinee_needs_par() as i8
        }
    
        fn prec_let_scrutinee_needs_par() -> usize {
            AssocOp::LAnd.precedence()
        }
    
    The .precedence().order() of Closure is PREC_CLOSURE (-40) and of Break,
    Ret, Yeet is PREC_JUMP (-30).
    
    The value of AssocOp::LAnd.precedence() is 6.
    
    So this commit causes no change in behavior, only potentially
    performance by doing a redundant call to contains_exterior_struct_lit in
    those four cases. This is fine because Break, Closure, Ret, Yeet should
    be exceedingly rare in the position of a let scrutinee.
    dtolnay committed Dec 8, 2023
    Configuration menu
    Copy the full SHA
    7f314ac View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    6f1d763 View commit details
    Browse the repository at this point in the history
  7. Fix tidy ```ignore error

        tidy error: /git/rust/compiler/rustc_ast_pretty/src/pprust/state.rs:1165: unexplained "```ignore" doctest; try one:
    
        * make the test actually pass, by adding necessary imports and declarations, or
        * use "```text", if the code is not Rust code, or
        * use "```compile_fail,Ennnn", if the code is expected to fail at compile time, or
        * use "```should_panic", if the code is expected to fail at run time, or
        * use "```no_run", if the code should type-check but not necessary linkable/runnable, or
        * explain it like "```ignore (cannot-test-this-because-xxxx)", if the annotation cannot be avoided.
    
        tidy error: /git/rust/compiler/rustc_ast_pretty/src/pprust/state.rs:1176: unexplained "```ignore" doctest; try one:
    
        * make the test actually pass, by adding necessary imports and declarations, or
        * use "```text", if the code is not Rust code, or
        * use "```compile_fail,Ennnn", if the code is expected to fail at compile time, or
        * use "```should_panic", if the code is expected to fail at run time, or
        * use "```no_run", if the code should type-check but not necessary linkable/runnable, or
        * explain it like "```ignore (cannot-test-this-because-xxxx)", if the annotation cannot be avoided.
    dtolnay committed Dec 8, 2023
    Configuration menu
    Copy the full SHA
    8997215 View commit details
    Browse the repository at this point in the history