Auto merge of #126838 - matthiaskrgr:rollup-qkop22o, r=matthiaskrgr · model-checking/verify-rust-std@a48f3d6 (original) (raw)
20 files changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -176,7 +176,6 @@ | ||
176 | 176 | #![feature(const_mut_refs)] |
177 | 177 | #![feature(const_precise_live_drops)] |
178 | 178 | #![feature(const_ptr_write)] |
179 | -#![feature(const_trait_impl)] | |
180 | 179 | #![feature(const_try)] |
181 | 180 | #![feature(decl_macro)] |
182 | 181 | #![feature(dropck_eyepatch)] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -245,7 +245,6 @@ use self::Ordering::*; | ||
245 | 245 | append_const_msg |
246 | 246 | )] |
247 | 247 | #[rustc_diagnostic_item = "PartialEq"] |
248 | -#[const_trait] | |
249 | 248 | pub trait PartialEq<Rhs: ?Sized = Self> { |
250 | 249 | /// This method tests for `self` and `other` values to be equal, and is used |
251 | 250 | /// by `==`. |
@@ -1475,8 +1474,7 @@ mod impls { | ||
1475 | 1474 | macro_rules! partial_eq_impl { |
1476 | 1475 | ($($t:ty)*) => ($( |
1477 | 1476 | #[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 { | |
1480 | 1478 | #[inline] |
1481 | 1479 | fn eq(&self, other: &$t) -> bool { (*self) == (*other) } |
1482 | 1480 | #[inline] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -60,7 +60,7 @@ const fn escape_ascii(byte: u8) -> ([ascii::Char; N], Range) | ||
60 | 60 | const fn escape_unicode<const N: usize>(c: char) -> ([ascii::Char; N], Range<u8>) { |
61 | 61 | const { assert!(N >= 10 && N < u8::MAX as usize) }; |
62 | 62 | |
63 | -let c = u32::from(c); | |
63 | +let c = c as u32; | |
64 | 64 | |
65 | 65 | // OR-ing `1` ensures that for `c == 0` the code computes that |
66 | 66 | // one digit should be printed. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -515,7 +515,10 @@ impl CStr { | ||
515 | 515 | #[inline] |
516 | 516 | #[must_use] |
517 | 517 | 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() | |
519 | 522 | } |
520 | 523 | |
521 | 524 | /// Returns the length of `self`. Like C's `strlen`, this does not include the nul terminator. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -200,6 +200,7 @@ | ||
200 | 200 | // Language features: |
201 | 201 | // tidy-alphabetical-start |
202 | 202 | #![cfg_attr(bootstrap, feature(c_unwind))] |
203 | +#![cfg_attr(bootstrap, feature(effects))] | |
203 | 204 | #![feature(abi_unadjusted)] |
204 | 205 | #![feature(adt_const_params)] |
205 | 206 | #![feature(allow_internal_unsafe)] |
@@ -214,13 +215,11 @@ | ||
214 | 215 | #![feature(const_mut_refs)] |
215 | 216 | #![feature(const_precise_live_drops)] |
216 | 217 | #![feature(const_refs_to_cell)] |
217 | -#![feature(const_trait_impl)] | |
218 | 218 | #![feature(decl_macro)] |
219 | 219 | #![feature(deprecated_suggestion)] |
220 | 220 | #![feature(doc_cfg)] |
221 | 221 | #![feature(doc_cfg_hide)] |
222 | 222 | #![feature(doc_notable_trait)] |
223 | -#![feature(effects)] | |
224 | 223 | #![feature(extern_types)] |
225 | 224 | #![feature(f128)] |
226 | 225 | #![feature(f16)] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -944,7 +944,6 @@ marker_impls! { | ||
944 | 944 | #[lang = "destruct"] |
945 | 945 | #[rustc_on_unimplemented(message = "can't drop `{Self}`", append_const_msg)] |
946 | 946 | #[rustc_deny_explicit_impl(implement_via_object = false)] |
947 | -#[const_trait] | |
948 | 947 | pub trait Destruct {} |
949 | 948 | |
950 | 949 | /// A marker for tuple types. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -33,7 +33,6 @@ use super::{IntErrorKind, ParseIntError}; | ||
33 | 33 | reason = "implementation detail which may disappear or be replaced at any time", |
34 | 34 | issue = "none" |
35 | 35 | )] |
36 | -#[const_trait] | |
37 | 36 | pub unsafe trait ZeroablePrimitive: Sized + Copy + private::Sealed { |
38 | 37 | #[doc(hidden)] |
39 | 38 | type NonZeroInner: Sized + Copy; |
@@ -47,7 +46,6 @@ macro_rules! impl_zeroable_primitive { | ||
47 | 46 | reason = "implementation detail which may disappear or be replaced at any time", |
48 | 47 | issue = "none" |
49 | 48 | )] |
50 | - #[const_trait] | |
51 | 49 | pub trait Sealed {} |
52 | 50 | |
53 | 51 | $( |
@@ -70,14 +68,14 @@ macro_rules! impl_zeroable_primitive { | ||
70 | 68 | reason = "implementation detail which may disappear or be replaced at any time", |
71 | 69 | issue = "none" |
72 | 70 | )] |
73 | -impl const private::Sealed for $primitive {} | |
71 | +impl private::Sealed for $primitive {} | |
74 | 72 | |
75 | 73 | #[unstable( |
76 | 74 | feature = "nonzero_internals", |
77 | 75 | reason = "implementation detail which may disappear or be replaced at any time", |
78 | 76 | issue = "none" |
79 | 77 | )] |
80 | -unsafe impl const ZeroablePrimitive for $primitive { | |
78 | +unsafe impl ZeroablePrimitive for $primitive { | |
81 | 79 | type NonZeroInner = private::$NonZeroInner; |
82 | 80 | } |
83 | 81 | )+ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -73,7 +73,6 @@ | ||
73 | 73 | append_const_msg |
74 | 74 | )] |
75 | 75 | #[doc(alias = "+")] |
76 | -#[const_trait] | |
77 | 76 | pub trait Add<Rhs = Self> { |
78 | 77 | /// The resulting type after applying the `+` operator. |
79 | 78 | #[stable(feature = "rust1", since = "1.0.0")] |
@@ -95,8 +94,7 @@ pub trait Add<Rhs = Self> { | ||
95 | 94 | macro_rules! add_impl { |
96 | 95 | ($($t:ty)*) => ($( |
97 | 96 | #[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 { | |
100 | 98 | type Output = $t; |
101 | 99 | |
102 | 100 | #[inline] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -282,7 +282,7 @@ impl<'a> Context<'a> { | ||
282 | 282 | pub const fn ext(&mut self) -> &mut dyn Any { |
283 | 283 | // FIXME: this field makes Context extra-weird about unwind safety |
284 | 284 | // can we justify AssertUnwindSafe if we stabilize this? do we care? |
285 | -match &mut *self.ext { | |
285 | +match &mut self.ext.0 { | |
286 | 286 | ExtData::Some(data) => *data, |
287 | 287 | ExtData::None(unit) => unit, |
288 | 288 | } |
@@ -356,7 +356,7 @@ impl<'a> ContextBuilder<'a> { | ||
356 | 356 | #[rustc_const_unstable(feature = "const_waker", issue = "102012")] |
357 | 357 | #[unstable(feature = "context_ext", issue = "123392")] |
358 | 358 | pub const fn from(cx: &'a mut Context<'_>) -> Self { |
359 | -let ext = match &mut *cx.ext { | |
359 | +let ext = match &mut cx.ext.0 { | |
360 | 360 | ExtData::Some(ext) => ExtData::Some(*ext), |
361 | 361 | ExtData::None(()) => ExtData::None(()), |
362 | 362 | }; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -2742,18 +2742,15 @@ impl AsInnerMut<fs_imp::DirBuilder> for DirBuilder { | ||
2742 | 2742 | /// # Examples |
2743 | 2743 | /// |
2744 | 2744 | /// ```no_run |
2745 | -/// #![feature(fs_try_exists)] | |
2746 | 2745 | /// use std::fs; |
2747 | 2746 | /// |
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()); | |
2750 | 2749 | /// ``` |
2751 | 2750 | /// |
2752 | 2751 | /// [`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")] | |
2756 | 2753 | #[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()) | |
2759 | 2756 | } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -284,7 +284,6 @@ | ||
284 | 284 | #![feature(cfi_encoding)] |
285 | 285 | #![feature(concat_idents)] |
286 | 286 | #![feature(const_mut_refs)] |
287 | -#![feature(const_trait_impl)] | |
288 | 287 | #![feature(decl_macro)] |
289 | 288 | #![feature(deprecated_suggestion)] |
290 | 289 | #![feature(doc_cfg)] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -2907,6 +2907,8 @@ impl Path { | ||
2907 | 2907 | /// prevent time-of-check to time-of-use (TOCTOU) bugs. You should only use it in scenarios |
2908 | 2908 | /// where those bugs are not an issue. |
2909 | 2909 | /// |
2910 | + /// This is an alias for [`std::fs::exists`](crate::fs::exists). | |
2911 | + /// | |
2910 | 2912 | /// # Examples |
2911 | 2913 | /// |
2912 | 2914 | /// ```no_run |
@@ -2919,7 +2921,7 @@ impl Path { | ||
2919 | 2921 | #[stable(feature = "path_try_exists", since = "1.63.0")] |
2920 | 2922 | #[inline] |
2921 | 2923 | pub fn try_exists(&self) -> io::Result<bool> { |
2922 | - fs::try_exists(self) | |
2924 | + fs::exists(self) | |
2923 | 2925 | } |
2924 | 2926 | |
2925 | 2927 | /// Returns `true` if the path exists on disk and is pointing at a regular file. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -18,7 +18,7 @@ use crate::sys::time::SystemTime; | ||
18 | 18 | use crate::sys::unsupported; |
19 | 19 | use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner}; |
20 | 20 | |
21 | -pub use crate::sys_common::fs::{copy, try_exists}; | |
21 | +pub use crate::sys_common::fs::{copy, exists}; | |
22 | 22 | |
23 | 23 | #[derive(Debug)] |
24 | 24 | pub struct File(FileDesc); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -12,7 +12,7 @@ use crate::{ | ||
12 | 12 | sys::unsupported, |
13 | 13 | }; |
14 | 14 | |
15 | -pub use crate::sys_common::fs::try_exists; | |
15 | +pub use crate::sys_common::fs::exists; | |
16 | 16 | |
17 | 17 | /// A file descriptor. |
18 | 18 | #[derive(Clone, Copy)] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -97,7 +97,7 @@ use libc::{ | ||
97 | 97 | ))] |
98 | 98 | use libc::{dirent64, fstat64, ftruncate64, lseek64, lstat64, off64_t, open64, stat64}; |
99 | 99 | |
100 | -pub use crate::sys_common::fs::try_exists; | |
100 | +pub use crate::sys_common::fs::exists; | |
101 | 101 | |
102 | 102 | pub struct File(FileDesc); |
103 | 103 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -478,7 +478,7 @@ mod cgroups { | ||
478 | 478 | |
479 | 479 | use crate::borrow::Cow; |
480 | 480 | use crate::ffi::OsString; |
481 | -use crate::fs::{try_exists, File}; | |
481 | +use crate::fs::{exists, File}; | |
482 | 482 | use crate::io::Read; |
483 | 483 | use crate::io::{BufRead, BufReader}; |
484 | 484 | use crate::os::unix::ffi::OsStringExt; |
@@ -556,7 +556,7 @@ mod cgroups { | ||
556 | 556 | path.push("cgroup.controllers"); |
557 | 557 | |
558 | 558 | // 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)) { | |
560 | 560 | return usize::MAX; |
561 | 561 | }; |
562 | 562 | |
@@ -613,7 +613,7 @@ mod cgroups { | ||
613 | 613 | path.push(&group_path); |
614 | 614 | |
615 | 615 | // skip if we guessed the mount incorrectly |
616 | -if matches!(try_exists(&path), Err(_) | Ok(false)) { | |
616 | +if matches!(exists(&path), Err(_) | Ok(false)) { | |
617 | 617 | continue; |
618 | 618 | } |
619 | 619 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -291,7 +291,7 @@ pub fn remove_dir_all(_path: &Path) -> io::Result<()> { | ||
291 | 291 | unsupported() |
292 | 292 | } |
293 | 293 | |
294 | -pub fn try_exists(_path: &Path) -> io::Result<bool> { | |
294 | +pub fn exists(_path: &Path) -> io::Result<bool> { | |
295 | 295 | unsupported() |
296 | 296 | } |
297 | 297 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -17,7 +17,7 @@ use crate::sys::time::SystemTime; | ||
17 | 17 | use crate::sys::unsupported; |
18 | 18 | use crate::sys_common::{AsInner, FromInner, IntoInner}; |
19 | 19 | |
20 | -pub use crate::sys_common::fs::try_exists; | |
20 | +pub use crate::sys_common::fs::exists; | |
21 | 21 | |
22 | 22 | pub struct File { |
23 | 23 | fd: WasiFd, |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1531,7 +1531,7 @@ pub fn junction_point(original: &Path, link: &Path) -> io::Result<()> { | ||
1531 | 1531 | } |
1532 | 1532 | |
1533 | 1533 | // 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> { | |
1535 | 1535 | // Open the file to ensure any symlinks are followed to their target. |
1536 | 1536 | let mut opts = OpenOptions::new(); |
1537 | 1537 | // No read, write, etc access rights are needed. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -42,7 +42,7 @@ fn remove_dir_all_recursive(path: &Path) -> io::Result<()> { | ||
42 | 42 | fs::remove_dir(path) |
43 | 43 | } |
44 | 44 | |
45 | -pub fn try_exists(path: &Path) -> io::Result<bool> { | |
45 | +pub fn exists(path: &Path) -> io::Result<bool> { | |
46 | 46 | match fs::metadata(path) { |
47 | 47 | Ok(_) => Ok(true), |
48 | 48 | Err(error) if error.kind() == io::ErrorKind::NotFound => Ok(false), |