Skip to content

Latest commit

 

History

History
52 lines (33 loc) · 1.38 KB

rustfmt-raw-identifiers.md

File metadata and controls

52 lines (33 loc) · 1.38 KB

Rustfmt: raw identifier sorting

🚧 The 2024 Edition has not yet been released and hence this section is still "under construction".

More information may be found in rust-lang/rust#124764.

Summary

rustfmt now properly sorts raw identifiers.

Details

The Rust Style Guide includes rules for sorting that rustfmt applies in various contexts, such as on imports.

Prior to the 2024 Edition, when sorting rustfmt would use the leading r# token instead of the ident which led to specious results.

For example:

use websocket::client::ClientBuilder;
use websocket::r#async::futures::Stream;
use websocket::result::WebSocketError;

Which is now corrected in the 2024 Edition:

use websocket::r#async::futures::Stream;
use websocket::client::ClientBuilder;
use websocket::result::WebSocketError;

Migration

The change can be applied automatically by running cargo fmt or rustfmt with the 2024 Edition.

With a Cargo.toml file that has edition set to 2024:

cargo fmt

Or by running rustfmt directly:

rustfmt foo.rs --style-edition 2024