gpt4 book ai didi

rust - 运行 Clippy 时排除依赖项

转载 作者:行者123 更新时间:2023-11-29 07:45:37 26 4
gpt4 key购买 nike

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

我尝试检查的项目依赖于 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 运行的,实际上并没有构建二进制文件……看来我错了?

最佳答案

How can I tell clippy to not build Piston and/or lint it?

你不能。

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

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

关于rust - 运行 Clippy 时排除依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40518446/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com