#E0131: lint
lint 发现的问题:代码能编译,但很可能是个错误。它的 note 会指出 lint 的名称(#[warn(name)],JSON 的 lint 字段)。修正代码,或者用 #[allow(name)] 或 -A name 允许这个 lint;nabi lint --list 会说明每个 lint。
nabi
fn main() {
let total = 10;
let unused = 1;
println(f"{total}");
}
warning[E0131]: unused variable `unused` --> main.nabi:3:9 | 3 | let unused = 1; | ^^^^^^ | = note: if this is intentional, prefix it with an underscore: `_unused` = note: `#[warn(unused_variables)]` on by default
删除这个变量;如果是有意保留的,就给它加上前缀 _:
nabi
fn main() {
let total = 10;
let _unused = 1;
println(f"{total}");
}
10
所有 lint 都使用这个错误码。lint 默认是警告;设为 deny 后会变成错误(在 nabi.nabion 中、在命令行上用 -D,或者在源代码中用 #[deny(..)])。最后一条 note 会指出 lint 的名称以及它的级别是在哪里设置的(6.2.9)。设置级别的方法见第 16 章。
发现错误? 在 GitHub 上编辑此页 最后更新: