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

Allow any identifier as format arg name #66847

Merged
merged 1 commit into from
Nov 30, 2019
Merged

Allow any identifier as format arg name #66847

merged 1 commit into from
Nov 30, 2019

Commits on Nov 28, 2019

  1. Allow any identifier as format arg name

    Previously:
    
        error: invalid format string: invalid argument name `_x`
         --> src/main.rs:2:16
          |
        2 |     println!("{_x}", a=0);
          |                ^^ invalid argument name in format string
          |
          = note: argument names cannot start with an underscore
    
    Not supporting identifiers starting with underscore appears to have been
    an arbitrary limitation from 2013 in code that was most likely never
    reviewed:
    https://github.com/rust-lang/rust/pull/8245/files#diff-0347868ef389c805e97636623e4a4ea6R277
    
    The error message was dutifully improved in rust-lang#50610 but is there any
    reason that leading underscore would be a special case?
    
    This commit updates the format_args parser to accept identifiers with
    leading underscores.
    dtolnay committed Nov 28, 2019
    Configuration menu
    Copy the full SHA
    423a5d3 View commit details
    Browse the repository at this point in the history