Skip to content

Commit a00a551

Browse files
committed
clippy: allow usages of std::env::{var,var_os} by exceptions
1 parent 959819c commit a00a551

File tree

9 files changed

+19
-3
lines changed

9 files changed

+19
-3
lines changed

build.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(clippy::disallowed_methods)]
2+
13
use flate2::{Compression, GzBuilder};
24
use std::ffi::OsStr;
35
use std::fs;

src/cargo/core/compiler/custom_build.rs

+2
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ fn build_work(cx: &mut Context<'_, '_>, unit: &Unit) -> CargoResult<Job> {
410410
// If we're opting into backtraces, mention that build dependencies' backtraces can
411411
// be improved by requesting debuginfo to be built, if we're not building with
412412
// debuginfo already.
413+
#[allow(clippy::disallowed_methods)]
413414
if let Ok(show_backtraces) = std::env::var("RUST_BACKTRACE") {
414415
if !built_with_debuginfo && show_backtraces != "0" {
415416
build_error_context.push_str(&format!(
@@ -727,6 +728,7 @@ impl BuildOutput {
727728
None => return false,
728729
Some(n) => n,
729730
};
731+
#[allow(clippy::disallowed_methods)]
730732
std::env::var("RUSTC_BOOTSTRAP")
731733
.map_or(false, |var| var.split(',').any(|s| s == name))
732734
};

src/cargo/core/features.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1173,9 +1173,11 @@ impl CliUnstable {
11731173

11741174
/// Returns the current release channel ("stable", "beta", "nightly", "dev").
11751175
pub fn channel() -> String {
1176+
#[allow(clippy::disallowed_methods)]
11761177
if let Ok(override_channel) = env::var("__CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS") {
11771178
return override_channel;
11781179
}
1180+
#[allow(clippy::disallowed_methods)]
11791181
if let Ok(staging) = env::var("RUSTC_BOOTSTRAP") {
11801182
if staging == "1" {
11811183
return "dev".to_string();

src/cargo/core/resolver/types.rs

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ impl ResolverProgress {
3131
// Architectures that do not have a modern processor, hardware emulation, etc.
3232
// In the test code we have `slow_cpu_multiplier`, but that is not accessible here.
3333
#[cfg(debug_assertions)]
34+
#[allow(clippy::disallowed_methods)]
3435
slow_cpu_multiplier: std::env::var("CARGO_TEST_SLOW_CPU_MULTIPLIER")
3536
.ok()
3637
.and_then(|m| m.parse().ok())

src/cargo/core/shell.rs

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ impl TtyWidth {
1717
/// Returns the width of the terminal to use for diagnostics (which is
1818
/// relayed to rustc via `--diagnostic-width`).
1919
pub fn diagnostic_terminal_width(&self) -> Option<usize> {
20+
#[allow(clippy::disallowed_methods)]
2021
if let Ok(width) = std::env::var("__CARGO_TEST_TTY_WIDTH_DO_NOT_USE_THIS") {
2122
return Some(width.parse().unwrap());
2223
}

src/cargo/core/source/source_id.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -428,9 +428,12 @@ impl SourceId {
428428
_ => return false,
429429
}
430430
let url = self.inner.url.as_str();
431-
url == CRATES_IO_INDEX
432-
|| url == CRATES_IO_HTTP_INDEX
433-
|| std::env::var("__CARGO_TEST_CRATES_IO_URL_DO_NOT_USE_THIS").as_deref() == Ok(url)
431+
if url == CRATES_IO_INDEX || url == CRATES_IO_HTTP_INDEX {
432+
true
433+
} else {
434+
#[allow(clippy::disallowed_methods)]
435+
std::env::var("__CARGO_TEST_CRATES_IO_URL_DO_NOT_USE_THIS").map_or(false, |v| v == url)
436+
}
434437
}
435438

436439
/// Hashes `self`.

src/cargo/ops/fix.rs

+3
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ to prevent this issue from happening.
339339
/// Returns `None` if `fix` is not being run (not in proxy mode). Returns
340340
/// `Some(...)` if in `fix` proxy mode
341341
pub fn fix_get_proxy_lock_addr() -> Option<String> {
342+
#[allow(clippy::disallowed_methods)]
342343
env::var(FIX_ENV).ok()
343344
}
344345

@@ -847,8 +848,10 @@ impl FixArgs {
847848
}
848849

849850
let file = file.ok_or_else(|| anyhow::anyhow!("could not find .rs file in rustc args"))?;
851+
#[allow(clippy::disallowed_methods)]
850852
let idioms = env::var(IDIOMS_ENV).is_ok();
851853

854+
#[allow(clippy::disallowed_methods)]
852855
let prepare_for_edition = env::var(EDITION_ENV).ok().map(|_| {
853856
enabled_edition
854857
.unwrap_or(Edition::Edition2015)

src/cargo/util/job.rs

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ mod imp {
3232
// when-cargo-is-killed-subprocesses-are-also-killed, but that requires
3333
// one cargo spawned to become its own session leader, so we do that
3434
// here.
35+
#[allow(clippy::disallowed_methods)]
3536
if env::var("__CARGO_TEST_SETSID_PLEASE_DONT_USE_ELSEWHERE").is_ok() {
3637
libc::setsid();
3738
}

src/cargo/util/profile.rs

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pub struct Profiler {
2222
}
2323

2424
fn enabled_level() -> Option<usize> {
25+
#[allow(clippy::disallowed_methods)]
2526
env::var("CARGO_PROFILE").ok().and_then(|s| s.parse().ok())
2627
}
2728

0 commit comments

Comments
 (0)