rust 运行Clippy时排除依赖项

fiei3ece  于 2023-06-06  发布在  其他
关注(0)|答案(2)|浏览(119)

我第一次尝试运行Clippy(我知道..我现在真的应该做了,呵呵。)而且我正面临着一些错误。
我尝试lint的项目依赖于Piston,它编译并成功运行。但是,当我按照README中的描述运行clippy时:

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不建立活塞和/或lint它?我如何让它构建我的项目并对我的代码进行lint?
cargo build从同一个文件夹成功构建了项目。
我还没有深入研究clippy的代码,但我认为它是在AST上工作的,实际上并没有构建二进制文件……看来我错了

fwzugrvs

fwzugrvs1#

我怎么能告诉clippy不建立活塞和/或lint它?
你不能
Clippy需要构建所有的依赖项,以便能够对项目进行lint。这是因为只有少数lint单独在AST上运行。大多数lint在HIR上运行,并且还需要类型信息。
不幸的是,我无法在piston_window v0.57.0上重现您的错误,但该版本引入了piston2d-gfx_graphics v0.33.1,它比您正在使用的0.31.2更新。更新可能会解决你的问题。

pokxtpni

pokxtpni2#

在某些时候,Clippy获得了--no-deps选项,根据文档,
只在给定的crate上运行Clippy,而不对依赖项进行linting
这应该可以解决这个问题。

相关问题