Uh oh!
There was an error while loading. Please reload this page.
Remove space after negative sign in Literal to_string - #87267
Conversation
rust-highfive
commented
Jul 19, 2021
r? @cjgillot (rust-highfive has picked a reviewer for you, use r? to override) |
cjgillot
commented
Jul 25, 2021
Can this change cause any breakage in proc-macro user code? |
@cjgillot: trivially yes, for example the following user code would break. assert_eq!(Literal::isize_unsuffixed(-10).to_string(),"- 10");But in general token printing only guarantees that the resulting string is valid Rust that parses to the same AST (though lossy with respect to hygiene). It does not guarantee that the precise positioning of every whitespace, trailing commas, and similar details irrelevant to Rust syntax are always kept identical across all versions of the printer. References: |
Aaron1011
commented
Aug 3, 2021
r=me once #87262 lands (since the test output will be changed). |
bors
commented
Aug 3, 2021
☔ The latest upstream changes (presumably #87262) made this pull request unmergeable. Please resolve the merge conflicts. |
dtolnay
commented
Aug 3, 2021
|
dtolnay
commented
Aug 3, 2021
@bors r=Aaron1011 |
bors
commented
Aug 3, 2021
📌 Commit 3744dc8 has been approved by |
Remove space after negative sign in Literal to_string Negative proc macro literal tokens used to be printed with a space between the minus sign and the magnitude. That's because `impl ToString for Literal` used to convert the Literal into a TokenStream, which splits the minus sign into a separate Punct token. ```rust Literal::isize_unsuffixed(-10).to_string() // "- 10" ``` This PR updates the ToString impl to directly use `rustc_ast::token::Lit`'s ToString, which matches the way Rust negative numbers are idiomatically written without a space. ```rust Literal::isize_unsuffixed(-10).to_string() // "-10" ```
Rollup of 8 pull requests Successful merges: - rust-lang#81797 (Add `core::stream::from_iter`) - rust-lang#87267 (Remove space after negative sign in Literal to_string) - rust-lang#87663 (Rustdoc accessibility: use an icon for the [-]/[+] controls) - rust-lang#87720 (don't use .into() to convert types to identical types (clippy::useless_conversion)) - rust-lang#87723 (Use .contains instead of manual reimplementation.) - rust-lang#87729 (Remove the aarch64 `crypto` target_feature) - rust-lang#87731 (Update cargo) - rust-lang#87734 (Test dropping union fields more) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Negative proc macro literal tokens used to be printed with a space between the minus sign and the magnitude. That's because
impl ToString for Literalused to convert the Literal into a TokenStream, which splits the minus sign into a separate Punct token.This PR updates the ToString impl to directly use
rustc_ast::token::Lit's ToString, which matches the way Rust negative numbers are idiomatically written without a space.