diff --git a/src/cargo/util/interning.rs b/src/cargo/util/interning.rs index 584fdf623821..4f43b2773747 100644 --- a/src/cargo/util/interning.rs +++ b/src/cargo/util/interning.rs @@ -12,10 +12,6 @@ use std::str; use std::sync::Mutex; use std::sync::OnceLock; -fn leak(s: String) -> &'static str { - Box::leak(s.into_boxed_str()) -} - static STRING_CACHE: OnceLock>> = OnceLock::new(); #[derive(Clone, Copy)] @@ -64,11 +60,11 @@ impl Eq for InternedString {} impl InternedString { pub fn new(str: &str) -> InternedString { let mut cache = STRING_CACHE - .get_or_init(|| Default::default()) + .get_or_init(Default::default) .lock() .unwrap(); let s = cache.get(str).cloned().unwrap_or_else(|| { - let s = leak(str.to_string()); + let s = str.to_string().leak(); cache.insert(s); s });