简体   繁体   English

运行Clippy时排除依赖项

[英]Exclude dependencies when running Clippy

I'm trying to run clippy for the first time (I know.. I really should have done it by now eh?) and I am facing some errors. 我第一次尝试运行clippy(我知道......我现在真的应该这样做呃?)我面临一些错误。

The project I'm trying to lint depends on Piston and it compiles and runs successfully. 我试图lint的项目取决于Piston,它编译并成功运行。 However, when I run clippy as described in the README : 但是,当我按照自述文件中的描述运行clippy时:

rustup run nightly cargo clippy

It looks like it starts trying to build Piston and reports errors like this: 看起来它开始尝试构建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`

How can I tell clippy to not build Piston and/or lint it? 我怎么能告诉clippy不要建造活塞和/或皮棉呢? How can I just have it build my project and lint my code? 我怎样才能让它构建我的项目并提取我的代码?

cargo build builds the project successfully from the same folder. cargo build从同一个文件夹成功构建项目。

I haven't dug deep into clippy's code, but I assumed it worked off an AST and didn't actually build the binaries... it seems I was incorrect? 我没有深入研究clippy的代码,但是我认为它在AST中运行并且实际上没有构建二进制文件......看起来我不正确?

How can I tell clippy to not build Piston and/or lint it? 我怎么能告诉clippy不要建造活塞和/或皮棉呢?

You can't. 你不能。

Clippy needs to build all dependencies to be able to lint your project. Clippy需要构建所有依赖项才能使项目失效。 This is because only a few lints run solely on the AST. 这是因为只有少量lint仅在AST上运行。 Most lints run on the HIR and also require type information. 大多数lint在HIR上运行,也需要类型信息。

Unfortunately I cannot reproduce your error on piston_window v0.57.0 , but that version pulls in piston2d-gfx_graphics v0.33.1 , which is newer than the 0.31.2 that you are using. 不幸的是我无法在piston_window v0.57.0上重现你的错误,但是该版本piston2d-gfx_graphics v0.33.1 ,这比你正在使用的0.31.2更新。 Maybe updating will solve your issues. 也许更新将解决您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM