我刚刚将 Rust 更新为 rustc 1.63.0 (4b91a6ea7 2022-08-08)
在我的 .rustfmt.toml 文件中
# Basic
hard_tabs = true
max_width = 100
use_small_heuristics = "Max"
# Imports
imports_granularity = "Crate"
reorder_imports = true
# Consistency
newline_style = "Unix"
# Misc
binop_separator = "Back"
chain_width = 80
match_arm_blocks = false
match_arm_leading_pipes = "Preserve"
match_block_trailing_comma = true
reorder_impl_items = false
spaces_around_ranges = false
trailing_comma = "Vertical"
trailing_semicolon = false
use_field_init_shorthand = true
Run Code Online (Sandbox Code Playgroud)
通过 Rust nightly 工具链安装 rustfmt
rustup toolchain add nightly && rustup component add rustfmt --toolchain nightly
Run Code Online (Sandbox Code Playgroud)
我有nightly-x86_64-unknown-linux-gnu unchanged - rustc 1.65.0-nightly (015a824f2 2022-08-22)
然后运行 rustfmt 来检查我的代码格式......
cargo +nightly fmt
cargo fmt --check
Run Code Online (Sandbox Code Playgroud)
我收到了一堆警告!
Warning: can't set `imports_granularity = Crate`, unstable features are only available in nightly channel.
Warning: can't set `reorder_impl_items = false`, unstable features are only available in nightly channel.
Warning: can't set `spaces_around_ranges = false`, unstable features are only available in nightly channel.
Warning: can't set `binop_separator = Back`, unstable features are only available in nightly channel.
Warning: can't set `match_arm_blocks = false`, unstable features are only available in nightly channel.
Warning: can't set `trailing_semicolon = false`, unstable features are only available in nightly channel.
Warning: can't set `trailing_comma = Vertical`, unstable features are only available in nightly channel.
Run Code Online (Sandbox Code Playgroud)
我该如何解决这些警告?我的 rustfmt.toml 中缺少什么?