Skip to content

Commit 31fdc2e

Browse files
committed
Lintcheck: Remove rust-toolchain from downloaded crates
1 parent b31bce4 commit 31fdc2e

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

lintcheck/src/input.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,25 @@ pub fn read_crates(toml_path: &Path) -> (Vec<CrateWithSource>, RecursiveOptions)
159159
}
160160

161161
impl CrateWithSource {
162+
pub fn download_and_prepare(&self) -> Crate {
163+
let krate = self.download_and_extract();
164+
165+
// Downloaded crates might contain a `rust-toolchain` file. This file
166+
// seems to be accessed when `build.rs` files are present. This access
167+
// results in build errors since lintcheck and clippy will most certainly
168+
// use a different toolchain.
169+
// Lintcheck simply removes these files and assumes that our toolchain
170+
// is more up to date.
171+
let _ = fs::remove_file(krate.path.join("rust-toolchain"));
172+
let _ = fs::remove_file(krate.path.join("rust-toolchain.toml"));
173+
174+
krate
175+
}
162176
/// Makes the sources available on the disk for clippy to check.
163177
/// Clones a git repo and checks out the specified commit or downloads a crate from crates.io or
164178
/// copies a local folder
165179
#[expect(clippy::too_many_lines)]
166-
pub fn download_and_extract(&self) -> Crate {
180+
fn download_and_extract(&self) -> Crate {
167181
#[allow(clippy::result_large_err)]
168182
fn get(path: &str) -> Result<ureq::Response, ureq::Error> {
169183
const MAX_RETRIES: u8 = 4;

lintcheck/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ fn lintcheck(config: LintcheckConfig) {
298298
true
299299
}
300300
})
301-
.map(|krate| krate.download_and_extract())
301+
.map(|krate| krate.download_and_prepare())
302302
.collect();
303303

304304
if crates.is_empty() {

0 commit comments

Comments
 (0)