Rust: #![allow(unknown_lints)] 如果自 nightly-2017-08-11-x86_64-unknown-linux-gnu 以来在同一级别存在未知的 lint,则不起作用

创建于 2017-08-11  ·  3评论  ·  资料来源: rust-lang/rust

以下代码段在nightly-2017-08-11-x86_64-unknown-linux-gnu之前工作正常

#![allow(unknown_lints)]
#![allow(clippy)]

但现在它报告了一个警告:

warning: unknown lint: `clippy`
 --> /home/poc/src/../a/b.rs:2:10
  |
2 | #![allow(clippy)]
  |          ^^^^^^
  |
  = note: #[warn(unknown_lints)] on by default

重现步骤:

  1. 克隆https://github.com/overvenus/poc.git
  2. rustup 覆盖设置每晚-2017-08-11
  3. 货物测试

这是预期的行为还是错误? 谢谢!

C-bug T-compiler regression-from-stable-to-nightly

最有用的评论

我已经在https://github.com/rust-lang/rust/pull/43841为此打开了一个 PR

所有3条评论

cc @alexcrichton -- 可能与新的 lint 实现有关

是的,这是由https://github.com/rust-lang/rust/pull/43522引起的这行代码上。 检查allow_lints是否在范围内不是检查当前正在检查的属性集。

例如,这不会警告:

#![allow(unknown_lints)]

#[allow(clippy)]
fn main() {}

但这警告:

#![allow(unknown_lints)]
#![allow(clippy)]

fn main() {}

(正如你所注意到的)

解决方法是将局部变量specs考虑在内,该变量已收集到该点的 lint 属性集。

我已经在https://github.com/rust-lang/rust/pull/43841为此打开了一个 PR

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

withoutboats picture withoutboats  ·  202评论

withoutboats picture withoutboats  ·  211评论

GuillaumeGomez picture GuillaumeGomez  ·  300评论

aturon picture aturon  ·  417评论

nikomatsakis picture nikomatsakis  ·  210评论