Skip to content

Commit 8fcf207

Browse files
Compile static Mutex where possible
A few of Rustup's `lazy_static!` instances are for simple locks. These are easy to evaluate at compile time, and doing so is stable, so reduce usage of the more heavyweight dependency.
1 parent e724717 commit 8fcf207

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

download/tests/read-proxy-env.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,10 @@ use std::thread;
99
use std::time::Duration;
1010

1111
use env_proxy::for_url;
12-
use lazy_static::lazy_static;
1312
use reqwest::{blocking::Client, Proxy};
1413
use url::Url;
1514

16-
lazy_static! {
17-
static ref SERIALISE_TESTS: Mutex<()> = Mutex::new(());
18-
}
15+
static SERIALISE_TESTS: Mutex<()> = Mutex::new(());
1916

2017
fn scrub_env() {
2118
remove_var("http_proxy");

src/cli/self_update/test.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
33
use std::sync::Mutex;
44

5-
use lazy_static::lazy_static;
65
#[cfg(not(unix))]
76
use winreg::{
87
enums::{HKEY_CURRENT_USER, KEY_READ, KEY_WRITE},
@@ -38,9 +37,7 @@ fn restore_path(p: Option<RegValue>) {
3837
/// Support testing of code that mutates global path state
3938
pub fn with_saved_path(f: &mut dyn FnMut()) {
4039
// Lock protects concurrent mutation of registry
41-
lazy_static! {
42-
static ref LOCK: Mutex<()> = Mutex::new(());
43-
}
40+
static LOCK: Mutex<()> = Mutex::new(());
4441
let _g = LOCK.lock();
4542

4643
// On windows these tests mess with the user's PATH. Save

0 commit comments

Comments
 (0)