Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a48f3d6

Browse files
committedJun 22, 2024
Auto merge of rust-lang#126838 - matthiaskrgr:rollup-qkop22o, r=matthiaskrgr
Rollup of 3 pull requests Successful merges: - rust-lang#126140 (Rename `std::fs::try_exists` to `std::fs::exists` and stabilize fs_try_exists) - rust-lang#126318 (Add a `x perf` command for integrating bootstrap with `rustc-perf`) - rust-lang#126552 (Remove use of const traits (and `feature(effects)`) from stdlib) r? `@ghost` `@rustbot` modify labels: rollup
2 parents e1edea8 + ec8af4b commit a48f3d6

File tree

20 files changed

+30
-38
lines changed

20 files changed

+30
-38
lines changed
 

‎alloc/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@
176176
#![feature(const_mut_refs)]
177177
#![feature(const_precise_live_drops)]
178178
#![feature(const_ptr_write)]
179-
#![feature(const_trait_impl)]
180179
#![feature(const_try)]
181180
#![feature(decl_macro)]
182181
#![feature(dropck_eyepatch)]

‎core/src/cmp.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,6 @@ use self::Ordering::*;
245245
append_const_msg
246246
)]
247247
#[rustc_diagnostic_item = "PartialEq"]
248-
#[const_trait]
249248
pub trait PartialEq<Rhs: ?Sized = Self> {
250249
/// This method tests for `self` and `other` values to be equal, and is used
251250
/// by `==`.
@@ -1475,8 +1474,7 @@ mod impls {
14751474
macro_rules! partial_eq_impl {
14761475
($($t:ty)*) => ($(
14771476
#[stable(feature = "rust1", since = "1.0.0")]
1478-
#[rustc_const_unstable(feature = "const_cmp", issue = "92391")]
1479-
impl const PartialEq for $t {
1477+
impl PartialEq for $t {
14801478
#[inline]
14811479
fn eq(&self, other: &$t) -> bool { (*self) == (*other) }
14821480
#[inline]

‎core/src/escape.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const fn escape_ascii<const N: usize>(byte: u8) -> ([ascii::Char; N], Range<u8>)
6060
const fn escape_unicode<const N: usize>(c: char) -> ([ascii::Char; N], Range<u8>) {
6161
const { assert!(N >= 10 && N < u8::MAX as usize) };
6262

63-
let c = u32::from(c);
63+
let c = c as u32;
6464

6565
// OR-ing `1` ensures that for `c == 0` the code computes that
6666
// one digit should be printed.

‎core/src/ffi/c_str.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,10 @@ impl CStr {
515515
#[inline]
516516
#[must_use]
517517
const fn as_non_null_ptr(&self) -> NonNull<c_char> {
518-
NonNull::from(&self.inner).as_non_null_ptr()
518+
// FIXME(effects) replace with `NonNull::from`
519+
// SAFETY: a reference is never null
520+
unsafe { NonNull::new_unchecked(&self.inner as *const [c_char] as *mut [c_char]) }
521+
.as_non_null_ptr()
519522
}
520523

521524
/// Returns the length of `self`. Like C's `strlen`, this does not include the nul terminator.

‎core/src/lib.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@
200200
// Language features:
201201
// tidy-alphabetical-start
202202
#![cfg_attr(bootstrap, feature(c_unwind))]
203+
#![cfg_attr(bootstrap, feature(effects))]
203204
#![feature(abi_unadjusted)]
204205
#![feature(adt_const_params)]
205206
#![feature(allow_internal_unsafe)]
@@ -214,13 +215,11 @@
214215
#![feature(const_mut_refs)]
215216
#![feature(const_precise_live_drops)]
216217
#![feature(const_refs_to_cell)]
217-
#![feature(const_trait_impl)]
218218
#![feature(decl_macro)]
219219
#![feature(deprecated_suggestion)]
220220
#![feature(doc_cfg)]
221221
#![feature(doc_cfg_hide)]
222222
#![feature(doc_notable_trait)]
223-
#![feature(effects)]
224223
#![feature(extern_types)]
225224
#![feature(f128)]
226225
#![feature(f16)]

‎core/src/marker.rs

-1
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,6 @@ marker_impls! {
944944
#[lang = "destruct"]
945945
#[rustc_on_unimplemented(message = "can't drop `{Self}`", append_const_msg)]
946946
#[rustc_deny_explicit_impl(implement_via_object = false)]
947-
#[const_trait]
948947
pub trait Destruct {}
949948

950949
/// A marker for tuple types.

‎core/src/num/nonzero.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ use super::{IntErrorKind, ParseIntError};
3333
reason = "implementation detail which may disappear or be replaced at any time",
3434
issue = "none"
3535
)]
36-
#[const_trait]
3736
pub unsafe trait ZeroablePrimitive: Sized + Copy + private::Sealed {
3837
#[doc(hidden)]
3938
type NonZeroInner: Sized + Copy;
@@ -47,7 +46,6 @@ macro_rules! impl_zeroable_primitive {
4746
reason = "implementation detail which may disappear or be replaced at any time",
4847
issue = "none"
4948
)]
50-
#[const_trait]
5149
pub trait Sealed {}
5250

5351
$(
@@ -70,14 +68,14 @@ macro_rules! impl_zeroable_primitive {
7068
reason = "implementation detail which may disappear or be replaced at any time",
7169
issue = "none"
7270
)]
73-
impl const private::Sealed for $primitive {}
71+
impl private::Sealed for $primitive {}
7472

7573
#[unstable(
7674
feature = "nonzero_internals",
7775
reason = "implementation detail which may disappear or be replaced at any time",
7876
issue = "none"
7977
)]
80-
unsafe impl const ZeroablePrimitive for $primitive {
78+
unsafe impl ZeroablePrimitive for $primitive {
8179
type NonZeroInner = private::$NonZeroInner;
8280
}
8381
)+

‎core/src/ops/arith.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@
7373
append_const_msg
7474
)]
7575
#[doc(alias = "+")]
76-
#[const_trait]
7776
pub trait Add<Rhs = Self> {
7877
/// The resulting type after applying the `+` operator.
7978
#[stable(feature = "rust1", since = "1.0.0")]
@@ -95,8 +94,7 @@ pub trait Add<Rhs = Self> {
9594
macro_rules! add_impl {
9695
($($t:ty)*) => ($(
9796
#[stable(feature = "rust1", since = "1.0.0")]
98-
#[rustc_const_unstable(feature = "const_ops", issue = "90080")]
99-
impl const Add for $t {
97+
impl Add for $t {
10098
type Output = $t;
10199

102100
#[inline]

‎core/src/task/wake.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ impl<'a> Context<'a> {
282282
pub const fn ext(&mut self) -> &mut dyn Any {
283283
// FIXME: this field makes Context extra-weird about unwind safety
284284
// can we justify AssertUnwindSafe if we stabilize this? do we care?
285-
match &mut *self.ext {
285+
match &mut self.ext.0 {
286286
ExtData::Some(data) => *data,
287287
ExtData::None(unit) => unit,
288288
}
@@ -356,7 +356,7 @@ impl<'a> ContextBuilder<'a> {
356356
#[rustc_const_unstable(feature = "const_waker", issue = "102012")]
357357
#[unstable(feature = "context_ext", issue = "123392")]
358358
pub const fn from(cx: &'a mut Context<'_>) -> Self {
359-
let ext = match &mut *cx.ext {
359+
let ext = match &mut cx.ext.0 {
360360
ExtData::Some(ext) => ExtData::Some(*ext),
361361
ExtData::None(()) => ExtData::None(()),
362362
};

‎std/src/fs.rs

+5-8
Original file line numberDiff line numberDiff line change
@@ -2742,18 +2742,15 @@ impl AsInnerMut<fs_imp::DirBuilder> for DirBuilder {
27422742
/// # Examples
27432743
///
27442744
/// ```no_run
2745-
/// #![feature(fs_try_exists)]
27462745
/// use std::fs;
27472746
///
2748-
/// assert!(!fs::try_exists("does_not_exist.txt").expect("Can't check existence of file does_not_exist.txt"));
2749-
/// assert!(fs::try_exists("/root/secret_file.txt").is_err());
2747+
/// assert!(!fs::exists("does_not_exist.txt").expect("Can't check existence of file does_not_exist.txt"));
2748+
/// assert!(fs::exists("/root/secret_file.txt").is_err());
27502749
/// ```
27512750
///
27522751
/// [`Path::exists`]: crate::path::Path::exists
2753-
// FIXME: stabilization should modify documentation of `exists()` to recommend this method
2754-
// instead.
2755-
#[unstable(feature = "fs_try_exists", issue = "83186")]
2752+
#[stable(feature = "fs_try_exists", since = "CURRENT_RUSTC_VERSION")]
27562753
#[inline]
2757-
pub fn try_exists<P: AsRef<Path>>(path: P) -> io::Result<bool> {
2758-
fs_imp::try_exists(path.as_ref())
2754+
pub fn exists<P: AsRef<Path>>(path: P) -> io::Result<bool> {
2755+
fs_imp::exists(path.as_ref())
27592756
}

‎std/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,6 @@
284284
#![feature(cfi_encoding)]
285285
#![feature(concat_idents)]
286286
#![feature(const_mut_refs)]
287-
#![feature(const_trait_impl)]
288287
#![feature(decl_macro)]
289288
#![feature(deprecated_suggestion)]
290289
#![feature(doc_cfg)]

‎std/src/path.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -2907,6 +2907,8 @@ impl Path {
29072907
/// prevent time-of-check to time-of-use (TOCTOU) bugs. You should only use it in scenarios
29082908
/// where those bugs are not an issue.
29092909
///
2910+
/// This is an alias for [`std::fs::exists`](crate::fs::exists).
2911+
///
29102912
/// # Examples
29112913
///
29122914
/// ```no_run
@@ -2919,7 +2921,7 @@ impl Path {
29192921
#[stable(feature = "path_try_exists", since = "1.63.0")]
29202922
#[inline]
29212923
pub fn try_exists(&self) -> io::Result<bool> {
2922-
fs::try_exists(self)
2924+
fs::exists(self)
29232925
}
29242926

29252927
/// Returns `true` if the path exists on disk and is pointing at a regular file.

‎std/src/sys/pal/hermit/fs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use crate::sys::time::SystemTime;
1818
use crate::sys::unsupported;
1919
use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner};
2020

21-
pub use crate::sys_common::fs::{copy, try_exists};
21+
pub use crate::sys_common::fs::{copy, exists};
2222

2323
#[derive(Debug)]
2424
pub struct File(FileDesc);

‎std/src/sys/pal/solid/fs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::{
1212
sys::unsupported,
1313
};
1414

15-
pub use crate::sys_common::fs::try_exists;
15+
pub use crate::sys_common::fs::exists;
1616

1717
/// A file descriptor.
1818
#[derive(Clone, Copy)]

‎std/src/sys/pal/unix/fs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ use libc::{
9797
))]
9898
use libc::{dirent64, fstat64, ftruncate64, lseek64, lstat64, off64_t, open64, stat64};
9999

100-
pub use crate::sys_common::fs::try_exists;
100+
pub use crate::sys_common::fs::exists;
101101

102102
pub struct File(FileDesc);
103103

‎std/src/sys/pal/unix/thread.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ mod cgroups {
478478
479479
use crate::borrow::Cow;
480480
use crate::ffi::OsString;
481-
use crate::fs::{try_exists, File};
481+
use crate::fs::{exists, File};
482482
use crate::io::Read;
483483
use crate::io::{BufRead, BufReader};
484484
use crate::os::unix::ffi::OsStringExt;
@@ -556,7 +556,7 @@ mod cgroups {
556556
path.push("cgroup.controllers");
557557

558558
// skip if we're not looking at cgroup2
559-
if matches!(try_exists(&path), Err(_) | Ok(false)) {
559+
if matches!(exists(&path), Err(_) | Ok(false)) {
560560
return usize::MAX;
561561
};
562562

@@ -613,7 +613,7 @@ mod cgroups {
613613
path.push(&group_path);
614614

615615
// skip if we guessed the mount incorrectly
616-
if matches!(try_exists(&path), Err(_) | Ok(false)) {
616+
if matches!(exists(&path), Err(_) | Ok(false)) {
617617
continue;
618618
}
619619

‎std/src/sys/pal/unsupported/fs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ pub fn remove_dir_all(_path: &Path) -> io::Result<()> {
291291
unsupported()
292292
}
293293

294-
pub fn try_exists(_path: &Path) -> io::Result<bool> {
294+
pub fn exists(_path: &Path) -> io::Result<bool> {
295295
unsupported()
296296
}
297297

‎std/src/sys/pal/wasi/fs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use crate::sys::time::SystemTime;
1717
use crate::sys::unsupported;
1818
use crate::sys_common::{AsInner, FromInner, IntoInner};
1919

20-
pub use crate::sys_common::fs::try_exists;
20+
pub use crate::sys_common::fs::exists;
2121

2222
pub struct File {
2323
fd: WasiFd,

‎std/src/sys/pal/windows/fs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1531,7 +1531,7 @@ pub fn junction_point(original: &Path, link: &Path) -> io::Result<()> {
15311531
}
15321532

15331533
// Try to see if a file exists but, unlike `exists`, report I/O errors.
1534-
pub fn try_exists(path: &Path) -> io::Result<bool> {
1534+
pub fn exists(path: &Path) -> io::Result<bool> {
15351535
// Open the file to ensure any symlinks are followed to their target.
15361536
let mut opts = OpenOptions::new();
15371537
// No read, write, etc access rights are needed.

‎std/src/sys_common/fs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ fn remove_dir_all_recursive(path: &Path) -> io::Result<()> {
4242
fs::remove_dir(path)
4343
}
4444

45-
pub fn try_exists(path: &Path) -> io::Result<bool> {
45+
pub fn exists(path: &Path) -> io::Result<bool> {
4646
match fs::metadata(path) {
4747
Ok(_) => Ok(true),
4848
Err(error) if error.kind() == io::ErrorKind::NotFound => Ok(false),

0 commit comments

Comments
 (0)
Failed to load comments.