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

rustfmt changes code between stable and beta #6203

Closed
Manishearth opened this issue Jun 20, 2024 · 3 comments
Closed

rustfmt changes code between stable and beta #6203

Manishearth opened this issue Jun 20, 2024 · 3 comments

Comments

@Manishearth
Copy link
Member

With the following code:

fn main() {
    let arr = [
        ("en-001", "", "Hello from 🗺️"),  // WORLD
        ("en-002", "", "Hello from 🌍"), // AFRICA
    ];
}

playground

rustfmt considers it correctly formatted under Rust 1.79, but will remove the space before // WORLD under Rust 1.80-beta3 (and nightly)

This is caused by unicode-width 0.1.13, which changed the predicted widths of a lot of Unicode characters, including emoji. The new version is more accurate, but these changes have not been made in a way that guarantees any kind of stability. The issue I have filed asks for such an API.

In the meantime, should rust/rustfmt pin to 0.1.2?

@Jules-Bertholet
Copy link
Contributor

From the README:

The following list enumerates areas where Rustfmt does not work or where the stability guarantees do not apply (we don't make a distinction between the two because in the future Rustfmt might work on code where it currently does not):

  • […]
  • Code containing non-ascii unicode characters

@Manishearth
Copy link
Member Author

Ah, cool.

@calebcartwright
Copy link
Member

agreed not guaranteed to have stable formatting in this particular case but good find and thank you for sharing it

probably worth a mention in the relnotes and blog post for the release though. if that ship hasn't already sailed i can look into it later tonight

@calebcartwright calebcartwright pinned this issue Jun 21, 2024
@calebcartwright calebcartwright closed this as not planned Won't fix, can't repro, duplicate, stale Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants