Lintcheck: Remove `rust-toolchain` from downloaded crates

This commit is contained in:
xFrednet 2024-07-18 11:08:43 +02:00
parent b31bce4f5f
commit 31fdc2ec09
No known key found for this signature in database
GPG Key ID: F5C59D0E669E5302
2 changed files with 16 additions and 2 deletions

View File

@ -159,11 +159,25 @@ pub fn read_crates(toml_path: &Path) -> (Vec<CrateWithSource>, RecursiveOptions)
}
impl CrateWithSource {
pub fn download_and_prepare(&self) -> Crate {
let krate = self.download_and_extract();
// Downloaded crates might contain a `rust-toolchain` file. This file
// seems to be accessed when `build.rs` files are present. This access
// results in build errors since lintcheck and clippy will most certainly
// use a different toolchain.
// Lintcheck simply removes these files and assumes that our toolchain
// is more up to date.
let _ = fs::remove_file(krate.path.join("rust-toolchain"));
let _ = fs::remove_file(krate.path.join("rust-toolchain.toml"));
krate
}
/// Makes the sources available on the disk for clippy to check.
/// Clones a git repo and checks out the specified commit or downloads a crate from crates.io or
/// copies a local folder
#[expect(clippy::too_many_lines)]
pub fn download_and_extract(&self) -> Crate {
fn download_and_extract(&self) -> Crate {
#[allow(clippy::result_large_err)]
fn get(path: &str) -> Result<ureq::Response, ureq::Error> {
const MAX_RETRIES: u8 = 4;

View File

@ -298,7 +298,7 @@ fn lintcheck(config: LintcheckConfig) {
true
}
})
.map(|krate| krate.download_and_extract())
.map(|krate| krate.download_and_prepare())
.collect();
if crates.is_empty() {