Skip to content

Commit 2196aff

Browse files
committed
Auto merge of #139119 - matthiaskrgr:rollup-7l2ri0f, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #137928 (stabilize const_cell) - #138431 (Fix `uclibc` LLVM target triples) - #138832 (Start using `with_native_path` in `std::sys::fs`) - #139081 (std: deduplicate `errno` accesses) - #139100 (compiletest: Support matching diagnostics on lines below) - #139105 (`BackendRepr::is_signed`: comment why this may panics) - #139106 (Mark .pp files as Rust) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 1799887 + ed1f776 commit 2196aff

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+264
-173
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*.h rust
66
*.rs rust diff=rust
77
*.fixed linguist-language=Rust
8+
*.pp linguist-language=Rust
89
*.mir linguist-language=Rust
910
src/etc/installer/gfx/* binary
1011
src/vendor/** -text

compiler/rustc_abi/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1462,7 +1462,8 @@ impl BackendRepr {
14621462
!self.is_unsized()
14631463
}
14641464

1465-
/// Returns `true` if this is a single signed integer scalar
1465+
/// Returns `true` if this is a single signed integer scalar.
1466+
/// Sanity check: panics if this is not a scalar type (see PR #70189).
14661467
#[inline]
14671468
pub fn is_signed(&self) -> bool {
14681469
match self {

compiler/rustc_target/src/spec/targets/armv5te_unknown_linux_uclibceabi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::spec::{FloatAbi, Target, TargetMetadata, TargetOptions, base};
22

33
pub(crate) fn target() -> Target {
44
Target {
5-
llvm_target: "armv5te-unknown-linux-uclibcgnueabi".into(),
5+
llvm_target: "armv5te-unknown-linux-gnueabi".into(),
66
metadata: TargetMetadata {
77
description: Some("Armv5TE Linux with uClibc".into()),
88
tier: Some(3),

compiler/rustc_target/src/spec/targets/mips_unknown_linux_uclibc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::spec::{Target, TargetMetadata, TargetOptions, base};
44

55
pub(crate) fn target() -> Target {
66
Target {
7-
llvm_target: "mips-unknown-linux-uclibc".into(),
7+
llvm_target: "mips-unknown-linux-gnu".into(),
88
metadata: TargetMetadata {
99
description: Some("MIPS Linux with uClibc".into()),
1010
tier: Some(3),

compiler/rustc_target/src/spec/targets/mipsel_unknown_linux_uclibc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::spec::{Target, TargetMetadata, TargetOptions, base};
22

33
pub(crate) fn target() -> Target {
44
Target {
5-
llvm_target: "mipsel-unknown-linux-uclibc".into(),
5+
llvm_target: "mipsel-unknown-linux-gnu".into(),
66
metadata: TargetMetadata {
77
description: Some("MIPS (LE) Linux with uClibc".into()),
88
tier: Some(3),

compiler/rustc_target/src/spec/targets/x86_64_unknown_l4re_uclibc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pub(crate) fn target() -> Target {
88
base.panic_strategy = PanicStrategy::Abort;
99

1010
Target {
11-
llvm_target: "x86_64-unknown-l4re-uclibc".into(),
11+
llvm_target: "x86_64-unknown-l4re-gnu".into(),
1212
metadata: TargetMetadata {
1313
description: None,
1414
tier: Some(3),

library/core/src/cell.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ impl<T> Cell<T> {
495495
/// ```
496496
#[inline]
497497
#[stable(feature = "move_cell", since = "1.17.0")]
498-
#[rustc_const_unstable(feature = "const_cell", issue = "131283")]
498+
#[rustc_const_stable(feature = "const_cell", since = "CURRENT_RUSTC_VERSION")]
499499
#[rustc_confusables("swap")]
500500
pub const fn replace(&self, val: T) -> T {
501501
// SAFETY: This can cause data races if called from a separate thread,
@@ -537,7 +537,7 @@ impl<T: Copy> Cell<T> {
537537
/// ```
538538
#[inline]
539539
#[stable(feature = "rust1", since = "1.0.0")]
540-
#[rustc_const_unstable(feature = "const_cell", issue = "131283")]
540+
#[rustc_const_stable(feature = "const_cell", since = "CURRENT_RUSTC_VERSION")]
541541
pub const fn get(&self) -> T {
542542
// SAFETY: This can cause data races if called from a separate thread,
543543
// but `Cell` is `!Sync` so this won't happen.
@@ -617,7 +617,7 @@ impl<T: ?Sized> Cell<T> {
617617
/// ```
618618
#[inline]
619619
#[stable(feature = "cell_get_mut", since = "1.11.0")]
620-
#[rustc_const_unstable(feature = "const_cell", issue = "131283")]
620+
#[rustc_const_stable(feature = "const_cell", since = "CURRENT_RUSTC_VERSION")]
621621
pub const fn get_mut(&mut self) -> &mut T {
622622
self.value.get_mut()
623623
}
@@ -637,7 +637,7 @@ impl<T: ?Sized> Cell<T> {
637637
/// ```
638638
#[inline]
639639
#[stable(feature = "as_cell", since = "1.37.0")]
640-
#[rustc_const_unstable(feature = "const_cell", issue = "131283")]
640+
#[rustc_const_stable(feature = "const_cell", since = "CURRENT_RUSTC_VERSION")]
641641
pub const fn from_mut(t: &mut T) -> &Cell<T> {
642642
// SAFETY: `&mut` ensures unique access.
643643
unsafe { &*(t as *mut T as *const Cell<T>) }
@@ -695,7 +695,7 @@ impl<T> Cell<[T]> {
695695
/// assert_eq!(slice_cell.len(), 3);
696696
/// ```
697697
#[stable(feature = "as_cell", since = "1.37.0")]
698-
#[rustc_const_unstable(feature = "const_cell", issue = "131283")]
698+
#[rustc_const_stable(feature = "const_cell", since = "CURRENT_RUSTC_VERSION")]
699699
pub const fn as_slice_of_cells(&self) -> &[Cell<T>] {
700700
// SAFETY: `Cell<T>` has the same memory layout as `T`.
701701
unsafe { &*(self as *const Cell<[T]> as *const [Cell<T>]) }

library/std/src/fs.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -2370,7 +2370,7 @@ impl AsInner<fs_imp::DirEntry> for DirEntry {
23702370
#[doc(alias = "rm", alias = "unlink", alias = "DeleteFile")]
23712371
#[stable(feature = "rust1", since = "1.0.0")]
23722372
pub fn remove_file<P: AsRef<Path>>(path: P) -> io::Result<()> {
2373-
fs_imp::unlink(path.as_ref())
2373+
fs_imp::remove_file(path.as_ref())
23742374
}
23752375

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

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

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

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

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

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

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

30093009
impl DirBuilder {

library/std/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@
297297
#![feature(extended_varargs_abi_support)]
298298
#![feature(f128)]
299299
#![feature(f16)]
300+
#![feature(ffi_const)]
300301
#![feature(formatting_options)]
301302
#![feature(if_let_guard)]
302303
#![feature(intra_doc_pointers)]

library/std/src/sys/fs/mod.rs

+94-7
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,115 @@
11
#![deny(unsafe_op_in_unsafe_fn)]
22

3+
use crate::io;
4+
use crate::path::{Path, PathBuf};
5+
36
pub mod common;
47

58
cfg_if::cfg_if! {
69
if #[cfg(target_family = "unix")] {
710
mod unix;
8-
pub use unix::*;
11+
use unix as imp;
12+
pub use unix::{chown, fchown, lchown};
13+
#[cfg(not(target_os = "fuchsia"))]
14+
pub use unix::chroot;
15+
pub(crate) use unix::debug_assert_fd_is_open;
16+
#[cfg(any(target_os = "linux", target_os = "android"))]
17+
pub(crate) use unix::CachedFileMetadata;
18+
use crate::sys::common::small_c_string::run_path_with_cstr as with_native_path;
919
} else if #[cfg(target_os = "windows")] {
1020
mod windows;
11-
pub use windows::*;
21+
use windows as imp;
22+
pub use windows::{symlink_inner, junction_point};
1223
} else if #[cfg(target_os = "hermit")] {
1324
mod hermit;
14-
pub use hermit::*;
25+
use hermit as imp;
1526
} else if #[cfg(target_os = "solid_asp3")] {
1627
mod solid;
17-
pub use solid::*;
28+
use solid as imp;
1829
} else if #[cfg(target_os = "uefi")] {
1930
mod uefi;
20-
pub use uefi::*;
31+
use uefi as imp;
2132
} else if #[cfg(target_os = "wasi")] {
2233
mod wasi;
23-
pub use wasi::*;
34+
use wasi as imp;
2435
} else {
2536
mod unsupported;
26-
pub use unsupported::*;
37+
use unsupported as imp;
2738
}
2839
}
40+
41+
// FIXME: Replace this with platform-specific path conversion functions.
42+
#[cfg(not(target_family = "unix"))]
43+
#[inline]
44+
pub fn with_native_path<T>(path: &Path, f: &dyn Fn(&Path) -> io::Result<T>) -> io::Result<T> {
45+
f(path)
46+
}
47+
48+
pub use imp::{
49+
DirBuilder, DirEntry, File, FileAttr, FilePermissions, FileTimes, FileType, OpenOptions,
50+
ReadDir,
51+
};
52+
53+
pub fn read_dir(path: &Path) -> io::Result<ReadDir> {
54+
// FIXME: use with_native_path
55+
imp::readdir(path)
56+
}
57+
58+
pub fn remove_file(path: &Path) -> io::Result<()> {
59+
with_native_path(path, &imp::unlink)
60+
}
61+
62+
pub fn rename(old: &Path, new: &Path) -> io::Result<()> {
63+
with_native_path(old, &|old| with_native_path(new, &|new| imp::rename(old, new)))
64+
}
65+
66+
pub fn remove_dir(path: &Path) -> io::Result<()> {
67+
with_native_path(path, &imp::rmdir)
68+
}
69+
70+
pub fn remove_dir_all(path: &Path) -> io::Result<()> {
71+
// FIXME: use with_native_path
72+
imp::remove_dir_all(path)
73+
}
74+
75+
pub fn read_link(path: &Path) -> io::Result<PathBuf> {
76+
with_native_path(path, &imp::readlink)
77+
}
78+
79+
pub fn symlink(original: &Path, link: &Path) -> io::Result<()> {
80+
with_native_path(original, &|original| {
81+
with_native_path(link, &|link| imp::symlink(original, link))
82+
})
83+
}
84+
85+
pub fn hard_link(original: &Path, link: &Path) -> io::Result<()> {
86+
with_native_path(original, &|original| {
87+
with_native_path(link, &|link| imp::link(original, link))
88+
})
89+
}
90+
91+
pub fn metadata(path: &Path) -> io::Result<FileAttr> {
92+
with_native_path(path, &imp::stat)
93+
}
94+
95+
pub fn symlink_metadata(path: &Path) -> io::Result<FileAttr> {
96+
with_native_path(path, &imp::lstat)
97+
}
98+
99+
pub fn set_permissions(path: &Path, perm: FilePermissions) -> io::Result<()> {
100+
with_native_path(path, &|path| imp::set_perm(path, perm.clone()))
101+
}
102+
103+
pub fn canonicalize(path: &Path) -> io::Result<PathBuf> {
104+
with_native_path(path, &imp::canonicalize)
105+
}
106+
107+
pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
108+
// FIXME: use with_native_path
109+
imp::copy(from, to)
110+
}
111+
112+
pub fn exists(path: &Path) -> io::Result<bool> {
113+
// FIXME: use with_native_path
114+
imp::exists(path)
115+
}

0 commit comments

Comments
 (0)