首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么在运行rustfmt时我会得到“不稳定的特性只能在夜间频道中使用”?

为什么在运行rustfmt时我会得到“不稳定的特性只能在夜间频道中使用”?
EN

Stack Overflow用户
提问于 2022-08-23 09:08:02
回答 1查看 336关注 0票数 2

我刚刚把我的锈蚀更新为rustc 1.63.0 (4b91a6ea7 2022-08-08)

在我的.rustfmt.toml文件中

代码语言:javascript
复制
# 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

通过锈蚀夜间工具链安装锈蚀

代码语言:javascript
复制
rustup toolchain add nightly && rustup component add rustfmt --toolchain nightly

我得到了nightly-x86_64-unknown-linux-gnu unchanged - rustc 1.65.0-nightly (015a824f2 2022-08-22)

然后运行rustfmt检查我的代码格式。

代码语言:javascript
复制
cargo +nightly fmt
cargo fmt --check

我收到了一大堆警告!

代码语言:javascript
复制
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.

我该如何解决这些警告呢?我的rustfmt.toml中缺少了什么?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-08-23 10:49:23

对每个cargo fmt调用显式使用夜间工具链:

代码语言:javascript
复制
cargo +nightly fmt --check
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73455965

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档