Skip to content

Rollup of 7 pull requests #139119

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 14 commits into from
Mar 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*.h rust
*.rs rust diff=rust
*.fixed linguist-language=Rust
*.pp linguist-language=Rust
*.mir linguist-language=Rust
src/etc/installer/gfx/* binary
src/vendor/** -text
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_abi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1462,7 +1462,8 @@ impl BackendRepr {
!self.is_unsized()
}

/// Returns `true` if this is a single signed integer scalar
/// Returns `true` if this is a single signed integer scalar.
/// Sanity check: panics if this is not a scalar type (see PR #70189).
#[inline]
pub fn is_signed(&self) -> bool {
match self {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::spec::{FloatAbi, Target, TargetMetadata, TargetOptions, base};

pub(crate) fn target() -> Target {
Target {
llvm_target: "armv5te-unknown-linux-uclibcgnueabi".into(),
llvm_target: "armv5te-unknown-linux-gnueabi".into(),
metadata: TargetMetadata {
description: Some("Armv5TE Linux with uClibc".into()),
tier: Some(3),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::spec::{Target, TargetMetadata, TargetOptions, base};

pub(crate) fn target() -> Target {
Target {
llvm_target: "mips-unknown-linux-uclibc".into(),
llvm_target: "mips-unknown-linux-gnu".into(),
metadata: TargetMetadata {
description: Some("MIPS Linux with uClibc".into()),
tier: Some(3),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::spec::{Target, TargetMetadata, TargetOptions, base};

pub(crate) fn target() -> Target {
Target {
llvm_target: "mipsel-unknown-linux-uclibc".into(),
llvm_target: "mipsel-unknown-linux-gnu".into(),
metadata: TargetMetadata {
description: Some("MIPS (LE) Linux with uClibc".into()),
tier: Some(3),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub(crate) fn target() -> Target {
base.panic_strategy = PanicStrategy::Abort;

Target {
llvm_target: "x86_64-unknown-l4re-uclibc".into(),
llvm_target: "x86_64-unknown-l4re-gnu".into(),
metadata: TargetMetadata {
description: None,
tier: Some(3),
Expand Down
10 changes: 5 additions & 5 deletions library/core/src/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ impl<T> Cell<T> {
/// ```
#[inline]
#[stable(feature = "move_cell", since = "1.17.0")]
#[rustc_const_unstable(feature = "const_cell", issue = "131283")]
#[rustc_const_stable(feature = "const_cell", since = "CURRENT_RUSTC_VERSION")]
#[rustc_confusables("swap")]
pub const fn replace(&self, val: T) -> T {
// SAFETY: This can cause data races if called from a separate thread,
Expand Down Expand Up @@ -537,7 +537,7 @@ impl<T: Copy> Cell<T> {
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cell", issue = "131283")]
#[rustc_const_stable(feature = "const_cell", since = "CURRENT_RUSTC_VERSION")]
pub const fn get(&self) -> T {
// SAFETY: This can cause data races if called from a separate thread,
// but `Cell` is `!Sync` so this won't happen.
Expand Down Expand Up @@ -617,7 +617,7 @@ impl<T: ?Sized> Cell<T> {
/// ```
#[inline]
#[stable(feature = "cell_get_mut", since = "1.11.0")]
#[rustc_const_unstable(feature = "const_cell", issue = "131283")]
#[rustc_const_stable(feature = "const_cell", since = "CURRENT_RUSTC_VERSION")]
pub const fn get_mut(&mut self) -> &mut T {
self.value.get_mut()
}
Expand All @@ -637,7 +637,7 @@ impl<T: ?Sized> Cell<T> {
/// ```
#[inline]
#[stable(feature = "as_cell", since = "1.37.0")]
#[rustc_const_unstable(feature = "const_cell", issue = "131283")]
#[rustc_const_stable(feature = "const_cell", since = "CURRENT_RUSTC_VERSION")]
pub const fn from_mut(t: &mut T) -> &Cell<T> {
// SAFETY: `&mut` ensures unique access.
unsafe { &*(t as *mut T as *const Cell<T>) }
Expand Down Expand Up @@ -695,7 +695,7 @@ impl<T> Cell<[T]> {
/// assert_eq!(slice_cell.len(), 3);
/// ```
#[stable(feature = "as_cell", since = "1.37.0")]
#[rustc_const_unstable(feature = "const_cell", issue = "131283")]
#[rustc_const_stable(feature = "const_cell", since = "CURRENT_RUSTC_VERSION")]
pub const fn as_slice_of_cells(&self) -> &[Cell<T>] {
// SAFETY: `Cell<T>` has the same memory layout as `T`.
unsafe { &*(self as *const Cell<[T]> as *const [Cell<T>]) }
Expand Down
16 changes: 8 additions & 8 deletions library/std/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2370,7 +2370,7 @@ impl AsInner<fs_imp::DirEntry> for DirEntry {
#[doc(alias = "rm", alias = "unlink", alias = "DeleteFile")]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn remove_file<P: AsRef<Path>>(path: P) -> io::Result<()> {
fs_imp::unlink(path.as_ref())
fs_imp::remove_file(path.as_ref())
}

/// Given a path, queries the file system to get information about a file,
Expand Down Expand Up @@ -2409,7 +2409,7 @@ pub fn remove_file<P: AsRef<Path>>(path: P) -> io::Result<()> {
#[doc(alias = "stat")]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn metadata<P: AsRef<Path>>(path: P) -> io::Result<Metadata> {
fs_imp::stat(path.as_ref()).map(Metadata)
fs_imp::metadata(path.as_ref()).map(Metadata)
}

/// Queries the metadata about a file without following symlinks.
Expand Down Expand Up @@ -2444,7 +2444,7 @@ pub fn metadata<P: AsRef<Path>>(path: P) -> io::Result<Metadata> {
#[doc(alias = "lstat")]
#[stable(feature = "symlink_metadata", since = "1.1.0")]
pub fn symlink_metadata<P: AsRef<Path>>(path: P) -> io::Result<Metadata> {
fs_imp::lstat(path.as_ref()).map(Metadata)
fs_imp::symlink_metadata(path.as_ref()).map(Metadata)
}

/// Renames a file or directory to a new name, replacing the original file if
Expand Down Expand Up @@ -2598,7 +2598,7 @@ pub fn copy<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> io::Result<u64> {
#[doc(alias = "CreateHardLink", alias = "linkat")]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn hard_link<P: AsRef<Path>, Q: AsRef<Path>>(original: P, link: Q) -> io::Result<()> {
fs_imp::link(original.as_ref(), link.as_ref())
fs_imp::hard_link(original.as_ref(), link.as_ref())
}

/// Creates a new symbolic link on the filesystem.
Expand Down Expand Up @@ -2664,7 +2664,7 @@ pub fn soft_link<P: AsRef<Path>, Q: AsRef<Path>>(original: P, link: Q) -> io::Re
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn read_link<P: AsRef<Path>>(path: P) -> io::Result<PathBuf> {
fs_imp::readlink(path.as_ref())
fs_imp::read_link(path.as_ref())
}

/// Returns the canonical, absolute form of a path with all intermediate
Expand Down Expand Up @@ -2840,7 +2840,7 @@ pub fn create_dir_all<P: AsRef<Path>>(path: P) -> io::Result<()> {
#[doc(alias = "rmdir", alias = "RemoveDirectory")]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn remove_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
fs_imp::rmdir(path.as_ref())
fs_imp::remove_dir(path.as_ref())
}

/// Removes a directory at this path, after removing all its contents. Use
Expand Down Expand Up @@ -2967,7 +2967,7 @@ pub fn remove_dir_all<P: AsRef<Path>>(path: P) -> io::Result<()> {
#[doc(alias = "ls", alias = "opendir", alias = "FindFirstFile", alias = "FindNextFile")]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn read_dir<P: AsRef<Path>>(path: P) -> io::Result<ReadDir> {
fs_imp::readdir(path.as_ref()).map(ReadDir)
fs_imp::read_dir(path.as_ref()).map(ReadDir)
}

/// Changes the permissions found on a file or a directory.
Expand Down Expand Up @@ -3003,7 +3003,7 @@ pub fn read_dir<P: AsRef<Path>>(path: P) -> io::Result<ReadDir> {
#[doc(alias = "chmod", alias = "SetFileAttributes")]
#[stable(feature = "set_permissions", since = "1.1.0")]
pub fn set_permissions<P: AsRef<Path>>(path: P, perm: Permissions) -> io::Result<()> {
fs_imp::set_perm(path.as_ref(), perm.0)
fs_imp::set_permissions(path.as_ref(), perm.0)
}

impl DirBuilder {
Expand Down
1 change: 1 addition & 0 deletions library/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@
#![feature(extended_varargs_abi_support)]
#![feature(f128)]
#![feature(f16)]
#![feature(ffi_const)]
#![feature(formatting_options)]
#![feature(if_let_guard)]
#![feature(intra_doc_pointers)]
Expand Down
101 changes: 94 additions & 7 deletions library/std/src/sys/fs/mod.rs
Original file line number Diff line number Diff line change
@@ -1,28 +1,115 @@
#![deny(unsafe_op_in_unsafe_fn)]

use crate::io;
use crate::path::{Path, PathBuf};

pub mod common;

cfg_if::cfg_if! {
if #[cfg(target_family = "unix")] {
mod unix;
pub use unix::*;
use unix as imp;
pub use unix::{chown, fchown, lchown};
#[cfg(not(target_os = "fuchsia"))]
pub use unix::chroot;
pub(crate) use unix::debug_assert_fd_is_open;
#[cfg(any(target_os = "linux", target_os = "android"))]
pub(crate) use unix::CachedFileMetadata;
use crate::sys::common::small_c_string::run_path_with_cstr as with_native_path;
} else if #[cfg(target_os = "windows")] {
mod windows;
pub use windows::*;
use windows as imp;
pub use windows::{symlink_inner, junction_point};
} else if #[cfg(target_os = "hermit")] {
mod hermit;
pub use hermit::*;
use hermit as imp;
} else if #[cfg(target_os = "solid_asp3")] {
mod solid;
pub use solid::*;
use solid as imp;
} else if #[cfg(target_os = "uefi")] {
mod uefi;
pub use uefi::*;
use uefi as imp;
} else if #[cfg(target_os = "wasi")] {
mod wasi;
pub use wasi::*;
use wasi as imp;
} else {
mod unsupported;
pub use unsupported::*;
use unsupported as imp;
}
}

// FIXME: Replace this with platform-specific path conversion functions.
#[cfg(not(target_family = "unix"))]
#[inline]
pub fn with_native_path<T>(path: &Path, f: &dyn Fn(&Path) -> io::Result<T>) -> io::Result<T> {
f(path)
}

pub use imp::{
DirBuilder, DirEntry, File, FileAttr, FilePermissions, FileTimes, FileType, OpenOptions,
ReadDir,
};

pub fn read_dir(path: &Path) -> io::Result<ReadDir> {
// FIXME: use with_native_path
imp::readdir(path)
}

pub fn remove_file(path: &Path) -> io::Result<()> {
with_native_path(path, &imp::unlink)
}

pub fn rename(old: &Path, new: &Path) -> io::Result<()> {
with_native_path(old, &|old| with_native_path(new, &|new| imp::rename(old, new)))
}

pub fn remove_dir(path: &Path) -> io::Result<()> {
with_native_path(path, &imp::rmdir)
}

pub fn remove_dir_all(path: &Path) -> io::Result<()> {
// FIXME: use with_native_path
imp::remove_dir_all(path)
}

pub fn read_link(path: &Path) -> io::Result<PathBuf> {
with_native_path(path, &imp::readlink)
}

pub fn symlink(original: &Path, link: &Path) -> io::Result<()> {
with_native_path(original, &|original| {
with_native_path(link, &|link| imp::symlink(original, link))
})
}

pub fn hard_link(original: &Path, link: &Path) -> io::Result<()> {
with_native_path(original, &|original| {
with_native_path(link, &|link| imp::link(original, link))
})
}

pub fn metadata(path: &Path) -> io::Result<FileAttr> {
with_native_path(path, &imp::stat)
}

pub fn symlink_metadata(path: &Path) -> io::Result<FileAttr> {
with_native_path(path, &imp::lstat)
}

pub fn set_permissions(path: &Path, perm: FilePermissions) -> io::Result<()> {
with_native_path(path, &|path| imp::set_perm(path, perm.clone()))
}

pub fn canonicalize(path: &Path) -> io::Result<PathBuf> {
with_native_path(path, &imp::canonicalize)
}

pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
// FIXME: use with_native_path
imp::copy(from, to)
}

pub fn exists(path: &Path) -> io::Result<bool> {
// FIXME: use with_native_path
imp::exists(path)
}
Loading
Loading