Insert space after float literal ending with . in pretty printer#154086
Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom Mar 20, 2026
Merged
Insert space after float literal ending with . in pretty printer#154086rust-bors[bot] merged 1 commit intorust-lang:mainfrom
. in pretty printer#154086rust-bors[bot] merged 1 commit intorust-lang:mainfrom
Conversation
Collaborator
|
r? @jackh726 rustbot has assigned @jackh726. Use Why was this reviewer chosen?The reviewer was selected based on:
|
950c2b2 to
4e91a45
Compare
The pretty printer was collapsing unsuffixed float literals (like `0.`) with adjacent dot tokens, producing ambiguous or invalid output: - `0. ..45.` (range) became `0...45.` - `0. ..=360.` (inclusive range) became `0...=360.` - `0. .to_string()` (method call) became `0..to_string()` The fix inserts a space after an unsuffixed float literal ending with `.` when it appears as the start expression of a range operator or the receiver of a method call or field access, preventing the trailing dot from merging with the following `.`, `..`, or `..=` token. This is skipped when the expression is already parenthesized, since the closing `)` naturally provides separation. Signed-off-by: Andrew V. Teylu <andrew.teylu@vector.com>
4e91a45 to
e9740a4
Compare
Member
|
r? me @bors r+ rollup |
Contributor
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Mar 19, 2026
…ivooeo Insert space after float literal ending with `.` in pretty printer The pretty printer was collapsing unsuffixed float literals (like `0.`) with adjacent dot tokens, producing ambiguous or invalid output: - `0. ..45.` (range) became `0...45.` - `0. ..=360.` (inclusive range) became `0...=360.` - `0. .to_string()` (method call) became `0..to_string()` The fix inserts a space after an unsuffixed float literal ending with `.` when it appears as the start expression of a range operator or the receiver of a method call or field access, preventing the trailing dot from merging with the following `.`, `..`, or `..=` token. This is skipped when the expression is already parenthesized, since the closing `)` naturally provides separation. ## Example **before** (`rustc 1.96.0-nightly (3b1b0ef 2026-03-11)`): ```rust #![feature(prelude_import)] #![no_std] extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; //@ pp-exact fn main() { let _ = 0...45.; let _ = 0...=360.; let _ = 0...; let _ = 0..to_string(); } ``` **after** (this branch): ```rust #![feature(prelude_import)] #![no_std] extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; //@ pp-exact fn main() { let _ = 0. ..45.; let _ = 0. ..=360.; let _ = 0. ..; let _ = 0. .to_string(); } ``` Notice `0...45.` (ambiguous — looks like deprecated `...` inclusive range) becomes `0. ..45.` (clear: float `0.` followed by range `..`). Similarly `0..to_string()` (parsed as range) becomes `0. .to_string()` (method call on float).
rust-bors bot
pushed a commit
that referenced
this pull request
Mar 19, 2026
…uwer Rollup of 9 pull requests Successful merges: - #153556 (`impl` restriction lowering) - #153992 (bootstrap: Optionally print a backtrace if a command fails) - #154019 (two smaller feature cleanups) - #154059 (tests: Activate `must_not_suspend` test for `MutexGuard` dropped before `await`) - #154075 (Rewrite `query_ensure_result`.) - #154082 (Updates derive_where and removes workaround) - #154084 (Preserve braces around `self` in use tree pretty printing) - #154086 (Insert space after float literal ending with `.` in pretty printer) - #154087 (Fix whitespace after fragment specifiers in macro pretty printing)
rust-bors bot
pushed a commit
that referenced
this pull request
Mar 19, 2026
…uwer Rollup of 9 pull requests Successful merges: - #153556 (`impl` restriction lowering) - #153992 (bootstrap: Optionally print a backtrace if a command fails) - #154019 (two smaller feature cleanups) - #154059 (tests: Activate `must_not_suspend` test for `MutexGuard` dropped before `await`) - #154075 (Rewrite `query_ensure_result`.) - #154082 (Updates derive_where and removes workaround) - #154084 (Preserve braces around `self` in use tree pretty printing) - #154086 (Insert space after float literal ending with `.` in pretty printer) - #154087 (Fix whitespace after fragment specifiers in macro pretty printing)
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Mar 19, 2026
…ivooeo Insert space after float literal ending with `.` in pretty printer The pretty printer was collapsing unsuffixed float literals (like `0.`) with adjacent dot tokens, producing ambiguous or invalid output: - `0. ..45.` (range) became `0...45.` - `0. ..=360.` (inclusive range) became `0...=360.` - `0. .to_string()` (method call) became `0..to_string()` The fix inserts a space after an unsuffixed float literal ending with `.` when it appears as the start expression of a range operator or the receiver of a method call or field access, preventing the trailing dot from merging with the following `.`, `..`, or `..=` token. This is skipped when the expression is already parenthesized, since the closing `)` naturally provides separation. ## Example **before** (`rustc 1.96.0-nightly (3b1b0ef 2026-03-11)`): ```rust #![feature(prelude_import)] #![no_std] extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; //@ pp-exact fn main() { let _ = 0...45.; let _ = 0...=360.; let _ = 0...; let _ = 0..to_string(); } ``` **after** (this branch): ```rust #![feature(prelude_import)] #![no_std] extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; //@ pp-exact fn main() { let _ = 0. ..45.; let _ = 0. ..=360.; let _ = 0. ..; let _ = 0. .to_string(); } ``` Notice `0...45.` (ambiguous — looks like deprecated `...` inclusive range) becomes `0. ..45.` (clear: float `0.` followed by range `..`). Similarly `0..to_string()` (parsed as range) becomes `0. .to_string()` (method call on float).
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Mar 19, 2026
…ivooeo Insert space after float literal ending with `.` in pretty printer The pretty printer was collapsing unsuffixed float literals (like `0.`) with adjacent dot tokens, producing ambiguous or invalid output: - `0. ..45.` (range) became `0...45.` - `0. ..=360.` (inclusive range) became `0...=360.` - `0. .to_string()` (method call) became `0..to_string()` The fix inserts a space after an unsuffixed float literal ending with `.` when it appears as the start expression of a range operator or the receiver of a method call or field access, preventing the trailing dot from merging with the following `.`, `..`, or `..=` token. This is skipped when the expression is already parenthesized, since the closing `)` naturally provides separation. ## Example **before** (`rustc 1.96.0-nightly (3b1b0ef 2026-03-11)`): ```rust #![feature(prelude_import)] #![no_std] extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; //@ pp-exact fn main() { let _ = 0...45.; let _ = 0...=360.; let _ = 0...; let _ = 0..to_string(); } ``` **after** (this branch): ```rust #![feature(prelude_import)] #![no_std] extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; //@ pp-exact fn main() { let _ = 0. ..45.; let _ = 0. ..=360.; let _ = 0. ..; let _ = 0. .to_string(); } ``` Notice `0...45.` (ambiguous — looks like deprecated `...` inclusive range) becomes `0. ..45.` (clear: float `0.` followed by range `..`). Similarly `0..to_string()` (parsed as range) becomes `0. .to_string()` (method call on float).
rust-bors bot
pushed a commit
that referenced
this pull request
Mar 20, 2026
…uwer Rollup of 12 pull requests Successful merges: - #152909 (sess: `-Zbranch-protection` is a target modifier) - #153556 (`impl` restriction lowering) - #154048 (Don't emit rustdoc `missing_doc_code_examples` lint on impl items) - #153992 (bootstrap: Optionally print a backtrace if a command fails) - #154019 (two smaller feature cleanups) - #154059 (tests: Activate `must_not_suspend` test for `MutexGuard` dropped before `await`) - #154075 (Rewrite `query_ensure_result`.) - #154082 (Updates derive_where and removes workaround) - #154084 (Preserve braces around `self` in use tree pretty printing) - #154086 (Insert space after float literal ending with `.` in pretty printer) - #154087 (Fix whitespace after fragment specifiers in macro pretty printing) - #154109 (tests: Add regression test for async closures involving HRTBs)
rust-bors bot
pushed a commit
that referenced
this pull request
Mar 20, 2026
Rollup of 15 pull requests Successful merges: - #152909 (sess: `-Zbranch-protection` is a target modifier) - #153556 (`impl` restriction lowering) - #154048 (Don't emit rustdoc `missing_doc_code_examples` lint on impl items) - #150935 (Introduce #[diagnostic::on_move(message)]) - #152973 (remove -Csoft-float) - #153862 (Rename `cycle_check` to `find_cycle`) - #153992 (bootstrap: Optionally print a backtrace if a command fails) - #154019 (two smaller feature cleanups) - #154059 (tests: Activate `must_not_suspend` test for `MutexGuard` dropped before `await`) - #154075 (Rewrite `query_ensure_result`.) - #154082 (Updates derive_where and removes workaround) - #154084 (Preserve braces around `self` in use tree pretty printing) - #154086 (Insert space after float literal ending with `.` in pretty printer) - #154087 (Fix whitespace after fragment specifiers in macro pretty printing) - #154109 (tests: Add regression test for async closures involving HRTBs)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The pretty printer was collapsing unsuffixed float literals (like
0.) with adjacent dot tokens, producing ambiguous or invalid output:0. ..45.(range) became0...45.0. ..=360.(inclusive range) became0...=360.0. .to_string()(method call) became0..to_string()The fix inserts a space after an unsuffixed float literal ending with
.when it appears as the start expression of a range operator or the receiver of a method call or field access, preventing the trailing dot from merging with the following.,.., or..=token. This is skipped when the expression is already parenthesized, since the closing)naturally provides separation.Example
before (
rustc 1.96.0-nightly (3b1b0ef4d 2026-03-11)):after (this branch):
Notice
0...45.(ambiguous — looks like deprecated...inclusive range) becomes0. ..45.(clear: float0.followed by range..). Similarly0..to_string()(parsed as range) becomes0. .to_string()(method call on float).