Skip to content

Commit

Permalink
Auto merge of rust-lang#126838 - matthiaskrgr:rollup-qkop22o, r=matth…
Browse files Browse the repository at this point in the history
…iaskrgr

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
  • Loading branch information
bors committed Jun 22, 2024
2 parents e1edea8 + ec8af4b commit a48f3d6
Show file tree
Hide file tree
Showing 20 changed files with 30 additions and 38 deletions.
1 change: 0 additions & 1 deletion alloc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@
#![feature(const_mut_refs)]
#![feature(const_precise_live_drops)]
#![feature(const_ptr_write)]
#![feature(const_trait_impl)]
#![feature(const_try)]
#![feature(decl_macro)]
#![feature(dropck_eyepatch)]
Expand Down
4 changes: 1 addition & 3 deletions core/src/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ use self::Ordering::*;
append_const_msg
)]
#[rustc_diagnostic_item = "PartialEq"]
#[const_trait]
pub trait PartialEq<Rhs: ?Sized = Self> {
/// This method tests for `self` and `other` values to be equal, and is used
/// by `==`.
Expand Down Expand Up @@ -1475,8 +1474,7 @@ mod impls {
macro_rules! partial_eq_impl {
($($t:ty)*) => ($(
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "92391")]
impl const PartialEq for $t {
impl PartialEq for $t {
#[inline]
fn eq(&self, other: &$t) -> bool { (*self) == (*other) }
#[inline]
Expand Down
2 changes: 1 addition & 1 deletion core/src/escape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const fn escape_ascii<const N: usize>(byte: u8) -> ([ascii::Char; N], Range<u8>)
const fn escape_unicode<const N: usize>(c: char) -> ([ascii::Char; N], Range<u8>) {
const { assert!(N >= 10 && N < u8::MAX as usize) };

let c = u32::from(c);
let c = c as u32;

// OR-ing `1` ensures that for `c == 0` the code computes that
// one digit should be printed.
Expand Down
5 changes: 4 additions & 1 deletion core/src/ffi/c_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,10 @@ impl CStr {
#[inline]
#[must_use]
const fn as_non_null_ptr(&self) -> NonNull<c_char> {
NonNull::from(&self.inner).as_non_null_ptr()
// FIXME(effects) replace with `NonNull::from`
// SAFETY: a reference is never null
unsafe { NonNull::new_unchecked(&self.inner as *const [c_char] as *mut [c_char]) }
.as_non_null_ptr()
}

/// Returns the length of `self`. Like C's `strlen`, this does not include the nul terminator.
Expand Down
3 changes: 1 addition & 2 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@
// Language features:
// tidy-alphabetical-start
#![cfg_attr(bootstrap, feature(c_unwind))]
#![cfg_attr(bootstrap, feature(effects))]
#![feature(abi_unadjusted)]
#![feature(adt_const_params)]
#![feature(allow_internal_unsafe)]
Expand All @@ -214,13 +215,11 @@
#![feature(const_mut_refs)]
#![feature(const_precise_live_drops)]
#![feature(const_refs_to_cell)]
#![feature(const_trait_impl)]
#![feature(decl_macro)]
#![feature(deprecated_suggestion)]
#![feature(doc_cfg)]
#![feature(doc_cfg_hide)]
#![feature(doc_notable_trait)]
#![feature(effects)]
#![feature(extern_types)]
#![feature(f128)]
#![feature(f16)]
Expand Down
1 change: 0 additions & 1 deletion core/src/marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,6 @@ marker_impls! {
#[lang = "destruct"]
#[rustc_on_unimplemented(message = "can't drop `{Self}`", append_const_msg)]
#[rustc_deny_explicit_impl(implement_via_object = false)]
#[const_trait]
pub trait Destruct {}

/// A marker for tuple types.
Expand Down
6 changes: 2 additions & 4 deletions core/src/num/nonzero.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ use super::{IntErrorKind, ParseIntError};
reason = "implementation detail which may disappear or be replaced at any time",
issue = "none"
)]
#[const_trait]
pub unsafe trait ZeroablePrimitive: Sized + Copy + private::Sealed {
#[doc(hidden)]
type NonZeroInner: Sized + Copy;
Expand All @@ -47,7 +46,6 @@ macro_rules! impl_zeroable_primitive {
reason = "implementation detail which may disappear or be replaced at any time",
issue = "none"
)]
#[const_trait]
pub trait Sealed {}

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

#[unstable(
feature = "nonzero_internals",
reason = "implementation detail which may disappear or be replaced at any time",
issue = "none"
)]
unsafe impl const ZeroablePrimitive for $primitive {
unsafe impl ZeroablePrimitive for $primitive {
type NonZeroInner = private::$NonZeroInner;
}
)+
Expand Down
4 changes: 1 addition & 3 deletions core/src/ops/arith.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
append_const_msg
)]
#[doc(alias = "+")]
#[const_trait]
pub trait Add<Rhs = Self> {
/// The resulting type after applying the `+` operator.
#[stable(feature = "rust1", since = "1.0.0")]
Expand All @@ -95,8 +94,7 @@ pub trait Add<Rhs = Self> {
macro_rules! add_impl {
($($t:ty)*) => ($(
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const Add for $t {
impl Add for $t {
type Output = $t;

#[inline]
Expand Down
4 changes: 2 additions & 2 deletions core/src/task/wake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ impl<'a> Context<'a> {
pub const fn ext(&mut self) -> &mut dyn Any {
// FIXME: this field makes Context extra-weird about unwind safety
// can we justify AssertUnwindSafe if we stabilize this? do we care?
match &mut *self.ext {
match &mut self.ext.0 {
ExtData::Some(data) => *data,
ExtData::None(unit) => unit,
}
Expand Down Expand Up @@ -356,7 +356,7 @@ impl<'a> ContextBuilder<'a> {
#[rustc_const_unstable(feature = "const_waker", issue = "102012")]
#[unstable(feature = "context_ext", issue = "123392")]
pub const fn from(cx: &'a mut Context<'_>) -> Self {
let ext = match &mut *cx.ext {
let ext = match &mut cx.ext.0 {
ExtData::Some(ext) => ExtData::Some(*ext),
ExtData::None(()) => ExtData::None(()),
};
Expand Down
13 changes: 5 additions & 8 deletions std/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2742,18 +2742,15 @@ impl AsInnerMut<fs_imp::DirBuilder> for DirBuilder {
/// # Examples
///
/// ```no_run
/// #![feature(fs_try_exists)]
/// use std::fs;
///
/// assert!(!fs::try_exists("does_not_exist.txt").expect("Can't check existence of file does_not_exist.txt"));
/// assert!(fs::try_exists("/root/secret_file.txt").is_err());
/// assert!(!fs::exists("does_not_exist.txt").expect("Can't check existence of file does_not_exist.txt"));
/// assert!(fs::exists("/root/secret_file.txt").is_err());
/// ```
///
/// [`Path::exists`]: crate::path::Path::exists
// FIXME: stabilization should modify documentation of `exists()` to recommend this method
// instead.
#[unstable(feature = "fs_try_exists", issue = "83186")]
#[stable(feature = "fs_try_exists", since = "CURRENT_RUSTC_VERSION")]
#[inline]
pub fn try_exists<P: AsRef<Path>>(path: P) -> io::Result<bool> {
fs_imp::try_exists(path.as_ref())
pub fn exists<P: AsRef<Path>>(path: P) -> io::Result<bool> {
fs_imp::exists(path.as_ref())
}
1 change: 0 additions & 1 deletion std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,6 @@
#![feature(cfi_encoding)]
#![feature(concat_idents)]
#![feature(const_mut_refs)]
#![feature(const_trait_impl)]
#![feature(decl_macro)]
#![feature(deprecated_suggestion)]
#![feature(doc_cfg)]
Expand Down
4 changes: 3 additions & 1 deletion std/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2907,6 +2907,8 @@ impl Path {
/// prevent time-of-check to time-of-use (TOCTOU) bugs. You should only use it in scenarios
/// where those bugs are not an issue.
///
/// This is an alias for [`std::fs::exists`](crate::fs::exists).
///
/// # Examples
///
/// ```no_run
Expand All @@ -2919,7 +2921,7 @@ impl Path {
#[stable(feature = "path_try_exists", since = "1.63.0")]
#[inline]
pub fn try_exists(&self) -> io::Result<bool> {
fs::try_exists(self)
fs::exists(self)
}

/// Returns `true` if the path exists on disk and is pointing at a regular file.
Expand Down
2 changes: 1 addition & 1 deletion std/src/sys/pal/hermit/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::sys::time::SystemTime;
use crate::sys::unsupported;
use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner};

pub use crate::sys_common::fs::{copy, try_exists};
pub use crate::sys_common::fs::{copy, exists};

#[derive(Debug)]
pub struct File(FileDesc);
Expand Down
2 changes: 1 addition & 1 deletion std/src/sys/pal/solid/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::{
sys::unsupported,
};

pub use crate::sys_common::fs::try_exists;
pub use crate::sys_common::fs::exists;

/// A file descriptor.
#[derive(Clone, Copy)]
Expand Down
2 changes: 1 addition & 1 deletion std/src/sys/pal/unix/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ use libc::{
))]
use libc::{dirent64, fstat64, ftruncate64, lseek64, lstat64, off64_t, open64, stat64};

pub use crate::sys_common::fs::try_exists;
pub use crate::sys_common::fs::exists;

pub struct File(FileDesc);

Expand Down
6 changes: 3 additions & 3 deletions std/src/sys/pal/unix/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ mod cgroups {
use crate::borrow::Cow;
use crate::ffi::OsString;
use crate::fs::{try_exists, File};
use crate::fs::{exists, File};
use crate::io::Read;
use crate::io::{BufRead, BufReader};
use crate::os::unix::ffi::OsStringExt;
Expand Down Expand Up @@ -556,7 +556,7 @@ mod cgroups {
path.push("cgroup.controllers");

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

Expand Down Expand Up @@ -613,7 +613,7 @@ mod cgroups {
path.push(&group_path);

// skip if we guessed the mount incorrectly
if matches!(try_exists(&path), Err(_) | Ok(false)) {
if matches!(exists(&path), Err(_) | Ok(false)) {
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion std/src/sys/pal/unsupported/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ pub fn remove_dir_all(_path: &Path) -> io::Result<()> {
unsupported()
}

pub fn try_exists(_path: &Path) -> io::Result<bool> {
pub fn exists(_path: &Path) -> io::Result<bool> {
unsupported()
}

Expand Down
2 changes: 1 addition & 1 deletion std/src/sys/pal/wasi/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::sys::time::SystemTime;
use crate::sys::unsupported;
use crate::sys_common::{AsInner, FromInner, IntoInner};

pub use crate::sys_common::fs::try_exists;
pub use crate::sys_common::fs::exists;

pub struct File {
fd: WasiFd,
Expand Down
2 changes: 1 addition & 1 deletion std/src/sys/pal/windows/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1531,7 +1531,7 @@ pub fn junction_point(original: &Path, link: &Path) -> io::Result<()> {
}

// Try to see if a file exists but, unlike `exists`, report I/O errors.
pub fn try_exists(path: &Path) -> io::Result<bool> {
pub fn exists(path: &Path) -> io::Result<bool> {
// Open the file to ensure any symlinks are followed to their target.
let mut opts = OpenOptions::new();
// No read, write, etc access rights are needed.
Expand Down
2 changes: 1 addition & 1 deletion std/src/sys_common/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fn remove_dir_all_recursive(path: &Path) -> io::Result<()> {
fs::remove_dir(path)
}

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

0 comments on commit a48f3d6

Please sign in to comment.