运行Clippy时排除依赖项

Sim*_*ead 8 rust clippy

我第一次尝试运行clippy(我知道......我现在真的应该这样做呃?)我面临一些错误.

我试图lint的项目取决于Piston,它编译并成功运行.但是,当我按照自述文件中的描述运行clippy时:

rustup run nightly cargo clippy
Run Code Online (Sandbox Code Playgroud)

看起来它开始尝试构建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`
Run Code Online (Sandbox Code Playgroud)

我怎么能告诉clippy不要建造活塞和/或皮棉呢?我怎样才能让它构建我的项目并提取我的代码?

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

我没有深入研究clippy的代码,但我认为它在AST中运行并且实际上并没有构建二进制文件......看起来我不正确?

oli*_*obk 6

我怎么能告诉clippy不要建造活塞和/或皮棉呢?

你不能.

Clippy需要构建所有依赖项才能使项目失效.这是因为只有少量lint仅在AST上运行.大多数lint在HIR上运行,也需要类型信息.

不幸的是,我无法重现您的错误piston_window v0.57.0,但该版本会进入piston2d-gfx_graphics v0.33.1,这比0.31.2您正在使用的版本更新.也许更新将解决您的问题.