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

Change how the 0 flag works in format! #40241

Merged
merged 2 commits into from
Mar 20, 2017
Merged

Conversation

Sawyer47
Copy link
Contributor

@Sawyer47 Sawyer47 commented Mar 3, 2017

Now it always implies right-alignment, so that padding zeroes are placed after the sign (if any) and before the digits. In other words, it always takes precedence over explicitly specified [[fill]align]. This also affects the '#' flag: zeroes are placed after the prefix (0b, 0o, 0x) and before the digits.

Here's a short summary of how similar format strings work in Python and Rust:

              :05     :<05    :>05    :^05 
Python 3.6  |-0001| |-1000| |000-1| |0-100|
Rust before |-0001| |-1000| |-0001| |-0100|
Rust after  |-0001| |-0001| |-0001| |-0001| 

             :#05x   :<#05x  :>#05x  :^#05x 
Python 3.6  |0x001| |0x100| |000x1| |00x10|
Rust before |0x001| |0x100| |000x1| |0x010|
Rust after  |0x001| |0x001| |0x001| |0x001| 

Fixes #39997 [breaking-change]

@rust-highfive
Copy link
Collaborator

r? @sfackler

(rust_highfive has picked a reviewer for you, use r? to override)

@Sawyer47
Copy link
Contributor Author

Sawyer47 commented Mar 3, 2017

Please don't merge it yet as I completely forgot about floats. I was slightly misled by the current documentation of 0 flag, because it only says about integer formats.

@Sawyer47
Copy link
Contributor Author

Sawyer47 commented Mar 4, 2017

I updated the logic for floats as well.

@alexcrichton alexcrichton added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Mar 6, 2017
@alexcrichton
Copy link
Member

Thanks for the PR @Sawyer47! I've tagged this with T-libs to ensure that it comes up during triage which is where we'll discuss the breakage aspect

@alexcrichton
Copy link
Member

@rust-lang/libs if you've got opinions ahead of time, feel free to comment here!

I'm fine landing this PR personally.

@alexcrichton
Copy link
Member

Discussed during libs triage today the conclusion was that athis is good to go. Thanks for the PR @Sawyer47!

@bors: r+

@bors
Copy link
Contributor

bors commented Mar 14, 2017

📌 Commit 6652cef has been approved by alexcrichton

@bors
Copy link
Contributor

bors commented Mar 15, 2017

🔒 Merge conflict

Now it always implies right-alignment, so that padding zeroes are placed after the sign (if any) and before the digits. In other words, it always takes precedence over explicitly specified `[[fill]align]`. This also affects the '#' flag: zeroes are placed after the prefix (0b, 0o, 0x) and before the digits.

           :05     :<05    :>05    :^05
before   |-0001| |-1000| |-0001| |-0100|
after    |-0001| |-0001| |-0001| |-0001|
          :#05x   :<#05x  :>#05x  :^#05x
before   |0x001| |0x100| |000x1| |0x010|
after    |0x001| |0x001| |0x001| |0x001|

Fixes rust-lang#39997 [breaking-change]
Now it always implies right-alignment, so that padding zeroes are placed after the sign (if any) and before the digits. In other words, it always takes precedence over explicitly specified `[[fill]align]`.

               :06      :<06     :>06     :^06
    before   |-001.2| |-1.200| |-001.2| |-01.20|
    after    |-001.2| |-001.2| |-001.2| |-001.2|
@alexcrichton
Copy link
Member

@bors: r+

@bors
Copy link
Contributor

bors commented Mar 15, 2017

📌 Commit 8065486 has been approved by alexcrichton

frewsxcv added a commit to frewsxcv/rust that referenced this pull request Mar 18, 2017
Change how the `0` flag works in format!

Now it always implies right-alignment, so that padding zeroes are placed after the sign (if any) and before the digits. In other words, it always takes precedence over explicitly specified `[[fill]align]`. This also affects the '#' flag: zeroes are placed after the prefix (0b, 0o, 0x) and before the digits.

Here's a short summary of how similar format strings work in Python and Rust:

```
              :05     :<05    :>05    :^05
Python 3.6  |-0001| |-1000| |000-1| |0-100|
Rust before |-0001| |-1000| |-0001| |-0100|
Rust after  |-0001| |-0001| |-0001| |-0001|

             :#05x   :<#05x  :>#05x  :^#05x
Python 3.6  |0x001| |0x100| |000x1| |00x10|
Rust before |0x001| |0x100| |000x1| |0x010|
Rust after  |0x001| |0x001| |0x001| |0x001|
```

Fixes rust-lang#39997 [breaking-change]
arielb1 pushed a commit to arielb1/rust that referenced this pull request Mar 18, 2017
Change how the `0` flag works in format!

Now it always implies right-alignment, so that padding zeroes are placed after the sign (if any) and before the digits. In other words, it always takes precedence over explicitly specified `[[fill]align]`. This also affects the '#' flag: zeroes are placed after the prefix (0b, 0o, 0x) and before the digits.

Here's a short summary of how similar format strings work in Python and Rust:

```
              :05     :<05    :>05    :^05
Python 3.6  |-0001| |-1000| |000-1| |0-100|
Rust before |-0001| |-1000| |-0001| |-0100|
Rust after  |-0001| |-0001| |-0001| |-0001|

             :#05x   :<#05x  :>#05x  :^#05x
Python 3.6  |0x001| |0x100| |000x1| |00x10|
Rust before |0x001| |0x100| |000x1| |0x010|
Rust after  |0x001| |0x001| |0x001| |0x001|
```

Fixes rust-lang#39997 [breaking-change]
bors added a commit that referenced this pull request Mar 18, 2017
arielb1 pushed a commit to arielb1/rust that referenced this pull request Mar 19, 2017
Change how the `0` flag works in format!

Now it always implies right-alignment, so that padding zeroes are placed after the sign (if any) and before the digits. In other words, it always takes precedence over explicitly specified `[[fill]align]`. This also affects the '#' flag: zeroes are placed after the prefix (0b, 0o, 0x) and before the digits.

Here's a short summary of how similar format strings work in Python and Rust:

```
              :05     :<05    :>05    :^05
Python 3.6  |-0001| |-1000| |000-1| |0-100|
Rust before |-0001| |-1000| |-0001| |-0100|
Rust after  |-0001| |-0001| |-0001| |-0001|

             :#05x   :<#05x  :>#05x  :^#05x
Python 3.6  |0x001| |0x100| |000x1| |00x10|
Rust before |0x001| |0x100| |000x1| |0x010|
Rust after  |0x001| |0x001| |0x001| |0x001|
```

Fixes rust-lang#39997 [breaking-change]
frewsxcv added a commit to frewsxcv/rust that referenced this pull request Mar 19, 2017
Change how the `0` flag works in format!

Now it always implies right-alignment, so that padding zeroes are placed after the sign (if any) and before the digits. In other words, it always takes precedence over explicitly specified `[[fill]align]`. This also affects the '#' flag: zeroes are placed after the prefix (0b, 0o, 0x) and before the digits.

Here's a short summary of how similar format strings work in Python and Rust:

```
              :05     :<05    :>05    :^05
Python 3.6  |-0001| |-1000| |000-1| |0-100|
Rust before |-0001| |-1000| |-0001| |-0100|
Rust after  |-0001| |-0001| |-0001| |-0001|

             :#05x   :<#05x  :>#05x  :^#05x
Python 3.6  |0x001| |0x100| |000x1| |00x10|
Rust before |0x001| |0x100| |000x1| |0x010|
Rust after  |0x001| |0x001| |0x001| |0x001|
```

Fixes rust-lang#39997 [breaking-change]
@bors
Copy link
Contributor

bors commented Mar 19, 2017

⌛ Testing commit 8065486 with merge bd14bc3...

@bors
Copy link
Contributor

bors commented Mar 19, 2017

💔 Test failed - status-travis

@alexcrichton
Copy link
Member

alexcrichton commented Mar 19, 2017 via email

frewsxcv added a commit to frewsxcv/rust that referenced this pull request Mar 20, 2017
Change how the `0` flag works in format!

Now it always implies right-alignment, so that padding zeroes are placed after the sign (if any) and before the digits. In other words, it always takes precedence over explicitly specified `[[fill]align]`. This also affects the '#' flag: zeroes are placed after the prefix (0b, 0o, 0x) and before the digits.

Here's a short summary of how similar format strings work in Python and Rust:

```
              :05     :<05    :>05    :^05
Python 3.6  |-0001| |-1000| |000-1| |0-100|
Rust before |-0001| |-1000| |-0001| |-0100|
Rust after  |-0001| |-0001| |-0001| |-0001|

             :#05x   :<#05x  :>#05x  :^#05x
Python 3.6  |0x001| |0x100| |000x1| |00x10|
Rust before |0x001| |0x100| |000x1| |0x010|
Rust after  |0x001| |0x001| |0x001| |0x001|
```

Fixes rust-lang#39997 [breaking-change]
@bors
Copy link
Contributor

bors commented Mar 20, 2017

⌛ Testing commit 8065486 with merge 9902af4...

@bors
Copy link
Contributor

bors commented Mar 20, 2017

💔 Test failed - status-appveyor

bors added a commit that referenced this pull request Mar 20, 2017
Rollup of 9 pull requests

- Successful merges: #40241, #40281, #40398, #40521, #40532, #40554, #40566, #40581, #40587
- Failed merges:
@bors bors merged commit 8065486 into rust-lang:master Mar 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Text formatting: a leading zero on the minimum width should really mean leading zero
5 participants