【问题标题】:Exclude dependencies when running Clippy运行 Clippy 时排除依赖项
【发布时间】:2016-11-10 00:56:45
【问题描述】:

我第一次尝试运行 clippy(我知道.. 我现在真的应该这样做是吗?)我遇到了一些错误。

我尝试 lint 的项目依赖于 Piston,它编译并成功运行。但是,当我运行clippy as described in the README:

rustup run nightly cargo clippy

它似乎开始尝试构建 Piston 并报告如下错误:

error[E0433]: failed to resolve. Use of undeclared type or module `gfx`
  --> /Users/Simon/.cargo/registry/src/github.com-    1ecc6299db9ec823/piston2d-gfx_graphics-0.31.2/src/back_end.rs:31:10
   |
31 |     pos: gfx::VertexBuffer<PositionFormat>,
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use of undeclared type or module `gfx`

error[E0433]: failed to resolve. Use of undeclared type or module     `gfx`
  --> /Users/Simon/.cargo/registry/src/github.com-    1ecc6299db9ec823/piston2d-gfx_graphics-0.31.2/src/back_end.rs:32:12
   |
32 |     color: gfx::VertexBuffer<ColorFormat>,
   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use of undeclared type or module `gfx`

error[E0433]: failed to resolve. Use of undeclared type or module `gfx`
  --> /Users/Simon/.cargo/registry/src/github.com-1ecc6299db9ec823/piston2d-gfx_graphics-0.31.2/src/back_end.rs:33:19
   |
33 |     blend_target: gfx::BlendTarget<gfx::format::Srgba8>,
   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use of undeclared type or module `gfx`

error[E0433]: failed to resolve. Use of undeclared type or module `gfx`
  --> /Users/Simon/.cargo/registry/src/github.com-1ecc6299db9ec823/piston2d-gfx_graphics-0.31.2/src/back_end.rs:33:36
   |
33 |     blend_target: gfx::BlendTarget<gfx::format::Srgba8>,
   |                                    ^^^^^^^^^^^^^^^^^^^ Use of undeclared type or module `gfx`

error[E0433]: failed to resolve. Use of undeclared type or module `gfx`
  --> /Users/Simon/.cargo/registry/src/github.com-1ecc6299db9ec823/piston2d-gfx_graphics-0.31.2/src/back_end.rs:34:21
   |
34 |     stencil_target: gfx::StencilTarget<gfx::format::DepthStencil>,
   |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use of undeclared type or module `gfx`

我如何告诉 Clippy 不要构建 Piston 和/或 lint 它?我怎样才能让它构建我的项目并检查我的代码?

cargo build 从同一文件夹成功构建项目。

我还没有深入研究 clippy 的代码,但我认为它在 AST 上工作并且实际上并没有构建二进制文件……看来我是不正确的?

【问题讨论】:

  • 谢谢@Shepmaster 我不知道 标记。我学到了一些东西!
  • 太糟糕了,我无法真正帮助解决真正的问题:-)

标签: rust rust-clippy


【解决方案1】:

我如何告诉 Clippy 不要构建 Piston 和/或对其进行 lint?

你不能。

Clippy 需要构建所有依赖项才能对您的项目进行 lint。这是因为只有少数 lint 仅在 AST 上运行。大多数 lints 在 HIR 上运行,并且还需要类型信息。

很遗憾,我无法在 piston_window v0.57.0 上重现您的错误,但该版本引入了 piston2d-gfx_graphics v0.33.1,它比您正在使用的 0.31.2 更新。也许更新会解决你的问题。

【讨论】:

  • 谢谢。我实际上从未想过要检查更新。我将所有 Piston 板条箱的版本转换为星号并运行 cargo update 并且...你不知道吗...rustup run nightly cargo clippy 现在返回实际的剪辑结果。感谢您的提示!
  • 也许它可以构建它需要的所有依赖项,但可以选择不标记项目代码之外您无法修复的警告/错误?
  • @AndrewMackenzie 这就是我认为它可以工作的方式,但我找不到任何此类用于货物检查或货物剪辑的标志/选项,因此第 3 方问题甚至阻止剪辑检查我的本地代码.事实
  • @danda - 是的,这似乎就是这样,我们只能忍受它。
猜你喜欢
  • 1970-01-01
  • 2011-02-15
  • 1970-01-01
  • 2020-04-19
  • 1970-01-01
  • 1970-01-01
  • 2019-06-06
  • 2023-03-25
  • 1970-01-01
相关资源
最近更新 更多