Skip to content

Rollup of 5 pull requests #141270

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
May 20, 2025
2 changes: 1 addition & 1 deletion compiler/rustc_session/src/filesearch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 1 addition & 2 deletions library/std/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
30 changes: 0 additions & 30 deletions src/bootstrap/src/utils/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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> {}
Expand Down Expand Up @@ -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.
Expand All @@ -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.
///
Expand Down
20 changes: 0 additions & 20 deletions src/bootstrap/src/utils/cache/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion src/doc/book
Submodule book updated 29 files
+1 −1 listings/ch04-understanding-ownership/listing-04-01/src/main.rs
+4 −4 listings/ch04-understanding-ownership/listing-04-03/src/main.rs
+2 −3 listings/ch04-understanding-ownership/listing-04-08/src/main.rs
+1 −1 listings/ch04-understanding-ownership/no-listing-01-can-mutate-string/src/main.rs
+1 −1 listings/ch04-understanding-ownership/no-listing-08-reference-with-annotations/src/main.rs
+2 −2 listings/ch04-understanding-ownership/no-listing-10-multiple-mut-not-allowed/output.txt
+1 −1 listings/ch04-understanding-ownership/no-listing-10-multiple-mut-not-allowed/src/main.rs
+2 −2 listings/ch04-understanding-ownership/no-listing-12-immutable-and-mutable-not-allowed/output.txt
+1 −1 listings/ch04-understanding-ownership/no-listing-12-immutable-and-mutable-not-allowed/src/main.rs
+1 −1 listings/ch04-understanding-ownership/no-listing-15-dangling-reference-annotated/src/main.rs
+3 −3 listings/ch05-using-structs-to-structure-related-data/listing-05-11/output.txt
+1 −1 listings/ch05-using-structs-to-structure-related-data/listing-05-11/src/main.rs
+26 −22 nostarch/chapter03.md
+36 −34 nostarch/chapter04.md
+32 −28 nostarch/chapter05.md
+49 −54 nostarch/chapter06.md
+ nostarch/docx/chapter03.docx
+ nostarch/docx/chapter04.docx
+ nostarch/docx/chapter05.docx
+ nostarch/docx/chapter06.docx
+12 −12 src/ch03-02-data-types.md
+6 −4 src/ch03-03-how-functions-work.md
+8 −5 src/ch03-05-control-flow.md
+10 −10 src/ch04-01-what-is-ownership.md
+14 −11 src/ch04-03-slices.md
+6 −5 src/ch05-01-defining-structs.md
+5 −5 src/ch06-01-defining-an-enum.md
+19 −17 src/ch06-03-if-let.md
+4 −8 tools/docx-to-md.xsl
2 changes: 1 addition & 1 deletion src/doc/rust-by-example
3 changes: 0 additions & 3 deletions triagebot.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1171,7 +1171,6 @@ contributing_url = "https://rustc-dev-guide.rust-lang.org/getting-started.html"
users_on_vacation = [
"fmease",
"jyn514",
"Noratrieb",
"spastorino",
]

Expand All @@ -1198,15 +1197,13 @@ compiler = [
"@lcnr",
"@Nadrieril",
"@nnethercote",
"@Noratrieb",
"@oli-obk",
"@petrochenkov",
"@SparrowLii",
"@wesleywiser",
]
libs = [
"@Mark-Simulacrum",
"@Noratrieb",
"@workingjubilee",
"@joboet",
"@jhpratt",
Expand Down
Loading