Auto merge of #141270 - Zalathar:rollup-jd1y1f6, r=Zalathar
Rollup of 5 pull requests Successful merges: - #141211 (Replace `try_reserve_exact` with `try_with_capacity` in `std::fs::read`) - #141257 (trim cache module in utils bootstrap) - #141259 (Update books) - #141261 (current_dll_path: fix mistake in assertion message) - #141262 (Properly remove Noratrieb from review rotation) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
a8e4c68dcb
8 changed files with 5 additions and 59 deletions
|
|
@ -82,7 +82,7 @@ fn current_dll_path() -> Result<PathBuf, String> {
|
|||
let fname_ptr = info.dli_fname.as_ptr();
|
||||
#[cfg(not(target_os = "cygwin"))]
|
||||
let fname_ptr = {
|
||||
assert!(!info.dli_fname.is_null(), "the docs do not allow dladdr to be null");
|
||||
assert!(!info.dli_fname.is_null(), "dli_fname cannot be null");
|
||||
info.dli_fname
|
||||
};
|
||||
let bytes = CStr::from_ptr(fname_ptr).to_bytes();
|
||||
|
|
|
|||
|
|
@ -285,8 +285,7 @@ pub fn read<P: AsRef<Path>>(path: P) -> io::Result<Vec<u8>> {
|
|||
fn inner(path: &Path) -> io::Result<Vec<u8>> {
|
||||
let mut file = File::open(path)?;
|
||||
let size = file.metadata().map(|m| m.len() as usize).ok();
|
||||
let mut bytes = Vec::new();
|
||||
bytes.try_reserve_exact(size.unwrap_or(0))?;
|
||||
let mut bytes = Vec::try_with_capacity(size.unwrap_or(0))?;
|
||||
io::default_read_to_end(&mut file, &mut bytes, size)?;
|
||||
Ok(bytes)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ use std::collections::HashMap;
|
|||
use std::hash::{Hash, Hasher};
|
||||
use std::marker::PhantomData;
|
||||
use std::ops::Deref;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::{LazyLock, Mutex};
|
||||
use std::{fmt, mem};
|
||||
|
||||
|
|
@ -51,26 +50,11 @@ impl<T> PartialEq for Interned<T> {
|
|||
}
|
||||
impl<T> Eq for Interned<T> {}
|
||||
|
||||
impl PartialEq<str> for Interned<String> {
|
||||
fn eq(&self, other: &str) -> bool {
|
||||
*self == other
|
||||
}
|
||||
}
|
||||
impl PartialEq<&str> for Interned<String> {
|
||||
fn eq(&self, other: &&str) -> bool {
|
||||
**self == **other
|
||||
}
|
||||
}
|
||||
impl<T> PartialEq<&Interned<T>> for Interned<T> {
|
||||
fn eq(&self, other: &&Self) -> bool {
|
||||
self.0 == other.0
|
||||
}
|
||||
}
|
||||
impl<T> PartialEq<Interned<T>> for &Interned<T> {
|
||||
fn eq(&self, other: &Interned<T>) -> bool {
|
||||
self.0 == other.0
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<T> Send for Interned<T> {}
|
||||
unsafe impl<T> Sync for Interned<T> {}
|
||||
|
|
@ -188,8 +172,6 @@ impl<T: Hash + Clone + Eq> TyIntern<T> {
|
|||
#[derive(Default)]
|
||||
pub struct Interner {
|
||||
strs: Mutex<TyIntern<String>>,
|
||||
paths: Mutex<TyIntern<PathBuf>>,
|
||||
lists: Mutex<TyIntern<Vec<String>>>,
|
||||
}
|
||||
|
||||
/// Defines the behavior required for a type to be internable.
|
||||
|
|
@ -210,18 +192,6 @@ impl Internable for String {
|
|||
}
|
||||
}
|
||||
|
||||
impl Internable for PathBuf {
|
||||
fn intern_cache() -> &'static Mutex<TyIntern<Self>> {
|
||||
&INTERNER.paths
|
||||
}
|
||||
}
|
||||
|
||||
impl Internable for Vec<String> {
|
||||
fn intern_cache() -> &'static Mutex<TyIntern<Self>> {
|
||||
&INTERNER.lists
|
||||
}
|
||||
}
|
||||
|
||||
impl Interner {
|
||||
/// Interns a string reference, ensuring it is stored uniquely.
|
||||
///
|
||||
|
|
|
|||
20
src/bootstrap/src/utils/cache/tests.rs
vendored
20
src/bootstrap/src/utils/cache/tests.rs
vendored
|
|
@ -12,26 +12,6 @@ fn test_string_interning() {
|
|||
assert_ne!(s1, s3, "Different strings should have different interned values");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_path_interning() {
|
||||
let p1 = PathBuf::from("/tmp/file").intern();
|
||||
let p2 = PathBuf::from("/tmp/file").intern();
|
||||
let p3 = PathBuf::from("/tmp/other").intern();
|
||||
|
||||
assert_eq!(p1, p2);
|
||||
assert_ne!(p1, p3);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_vec_interning() {
|
||||
let v1 = vec!["a".to_string(), "b".to_string()].intern();
|
||||
let v2 = vec!["a".to_string(), "b".to_string()].intern();
|
||||
let v3 = vec!["c".to_string()].intern();
|
||||
|
||||
assert_eq!(v1, v2);
|
||||
assert_ne!(v1, v3);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_interned_equality() {
|
||||
let s1 = INTERNER.intern_str("test");
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit d33916341d480caede1d0ae57cbeae23aab23e88
|
||||
Subproject commit 230c68bc1e08f5f3228384a28cc228c81dfbd10d
|
||||
|
|
@ -1 +1 @@
|
|||
Subproject commit 387392674d74656f7cb437c05a96f0c52ea8e601
|
||||
Subproject commit acd0231ebc74849f6a8907b5e646ce86721aad76
|
||||
|
|
@ -1 +1 @@
|
|||
Subproject commit 8a8918c698534547fa8a1a693cb3e7277f0bfb2f
|
||||
Subproject commit c9d151f9147c4808c77f0375ba3fa5d54443cb9e
|
||||
|
|
@ -1171,7 +1171,6 @@ contributing_url = "https://rustc-dev-guide.rust-lang.org/getting-started.html"
|
|||
users_on_vacation = [
|
||||
"fmease",
|
||||
"jyn514",
|
||||
"Noratrieb",
|
||||
"spastorino",
|
||||
]
|
||||
|
||||
|
|
@ -1198,7 +1197,6 @@ compiler = [
|
|||
"@lcnr",
|
||||
"@Nadrieril",
|
||||
"@nnethercote",
|
||||
"@Noratrieb",
|
||||
"@oli-obk",
|
||||
"@petrochenkov",
|
||||
"@SparrowLii",
|
||||
|
|
@ -1206,7 +1204,6 @@ compiler = [
|
|||
]
|
||||
libs = [
|
||||
"@Mark-Simulacrum",
|
||||
"@Noratrieb",
|
||||
"@workingjubilee",
|
||||
"@joboet",
|
||||
"@jhpratt",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue