Skip to content

Commit 7210e46

Browse files
committed
Auto merge of rust-lang#99315 - JohnTitor:rollup-77wzoc1, r=JohnTitor
Rollup of 7 pull requests Successful merges: - rust-lang#98387 (Add new unstable API `downcast` to `std::io::Error`) - rust-lang#98662 (Add std::fs::write documentation precision) - rust-lang#99253 (Remove FIXME from MIR `always_storage_live_locals`) - rust-lang#99264 (Fix typo in mod.rs) - rust-lang#99270 (Add `#[must_use]` to `Box::from_raw`) - rust-lang#99277 (Stabilize `core::ffi::CStr`, `alloc::ffi::CString`, and friends) - rust-lang#99307 (Add regression test for rust-lang#64401) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 5635158 + 202c11b commit 7210e46

File tree

19 files changed

+226
-39
lines changed

19 files changed

+226
-39
lines changed

compiler/rustc_mir_dataflow/src/storage.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ use rustc_middle::mir::{self, Local};
44
/// The set of locals in a MIR body that do not have `StorageLive`/`StorageDead` annotations.
55
///
66
/// These locals have fixed storage for the duration of the body.
7-
//
8-
// FIXME: Currently, we need to traverse the entire MIR to compute this. We should instead store it
9-
// as a field in the `LocalDecl` for each `Local`.
107
pub fn always_storage_live_locals(body: &mir::Body<'_>) -> BitSet<Local> {
118
let mut always_live_locals = BitSet::new_filled(body.local_decls.len());
129

library/alloc/src/boxed.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -949,6 +949,7 @@ impl<T: ?Sized> Box<T> {
949949
/// [`Layout`]: crate::Layout
950950
#[stable(feature = "box_raw", since = "1.4.0")]
951951
#[inline]
952+
#[must_use = "call `drop(from_raw(ptr))` if you intend to drop the `Box`"]
952953
pub unsafe fn from_raw(raw: *mut T) -> Self {
953954
unsafe { Self::from_raw_in(raw, Global) }
954955
}

library/alloc/src/ffi/c_str.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ use crate::sync::Arc;
108108
/// and other memory errors.
109109
#[derive(PartialEq, PartialOrd, Eq, Ord, Hash, Clone)]
110110
#[cfg_attr(not(test), rustc_diagnostic_item = "cstring_type")]
111-
#[unstable(feature = "alloc_c_string", issue = "94079")]
111+
#[stable(feature = "alloc_c_string", since = "1.64.0")]
112112
pub struct CString {
113113
// Invariant 1: the slice ends with a zero byte and has a length of at least one.
114114
// Invariant 2: the slice contains only one zero byte.
@@ -132,7 +132,7 @@ pub struct CString {
132132
/// let _: NulError = CString::new(b"f\0oo".to_vec()).unwrap_err();
133133
/// ```
134134
#[derive(Clone, PartialEq, Eq, Debug)]
135-
#[unstable(feature = "alloc_c_string", issue = "94079")]
135+
#[stable(feature = "alloc_c_string", since = "1.64.0")]
136136
pub struct NulError(usize, Vec<u8>);
137137

138138
#[derive(Clone, PartialEq, Eq, Debug)]
@@ -157,7 +157,7 @@ enum FromBytesWithNulErrorKind {
157157
/// let _: FromVecWithNulError = CString::from_vec_with_nul(b"f\0oo".to_vec()).unwrap_err();
158158
/// ```
159159
#[derive(Clone, PartialEq, Eq, Debug)]
160-
#[unstable(feature = "alloc_c_string", issue = "94079")]
160+
#[stable(feature = "alloc_c_string", since = "1.64.0")]
161161
pub struct FromVecWithNulError {
162162
error_kind: FromBytesWithNulErrorKind,
163163
bytes: Vec<u8>,
@@ -223,7 +223,7 @@ impl FromVecWithNulError {
223223
/// This `struct` is created by [`CString::into_string()`]. See
224224
/// its documentation for more.
225225
#[derive(Clone, PartialEq, Eq, Debug)]
226-
#[unstable(feature = "alloc_c_string", issue = "94079")]
226+
#[stable(feature = "alloc_c_string", since = "1.64.0")]
227227
pub struct IntoStringError {
228228
inner: CString,
229229
error: Utf8Error,

library/alloc/src/ffi/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,11 @@
7878
//! [`String`]: crate::string::String
7979
//! [`CStr`]: core::ffi::CStr
8080
81-
#![unstable(feature = "alloc_ffi", issue = "94079")]
81+
#![stable(feature = "alloc_ffi", since = "1.64.0")]
8282

83-
#[unstable(feature = "alloc_c_string", issue = "94079")]
83+
#[stable(feature = "alloc_c_string", since = "1.64.0")]
8484
pub use self::c_str::FromVecWithNulError;
85-
#[unstable(feature = "alloc_c_string", issue = "94079")]
85+
#[stable(feature = "alloc_c_string", since = "1.64.0")]
8686
pub use self::c_str::{CString, IntoStringError, NulError};
8787

8888
mod c_str;

library/alloc/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@
8686
#![allow(explicit_outlives_requirements)]
8787
//
8888
// Library features:
89-
#![cfg_attr(not(no_global_oom_handling), feature(alloc_c_string))]
9089
#![feature(alloc_layout_extra)]
9190
#![feature(allocator_api)]
9291
#![feature(array_chunks)]
@@ -106,7 +105,6 @@
106105
#![feature(const_maybe_uninit_write)]
107106
#![feature(const_maybe_uninit_as_mut_ptr)]
108107
#![feature(const_refs_to_cell)]
109-
#![feature(core_c_str)]
110108
#![feature(core_intrinsics)]
111109
#![feature(const_eval_select)]
112110
#![feature(const_pin)]

library/alloc/tests/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#![feature(const_nonnull_slice_from_raw_parts)]
1212
#![feature(const_ptr_write)]
1313
#![feature(const_try)]
14-
#![feature(core_c_str)]
1514
#![feature(core_intrinsics)]
1615
#![feature(drain_filter)]
1716
#![feature(exact_size_is_empty)]

library/core/src/ffi/c_str.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ use crate::str;
7676
/// [str]: prim@str "str"
7777
#[derive(Hash)]
7878
#[cfg_attr(not(test), rustc_diagnostic_item = "CStr")]
79-
#[unstable(feature = "core_c_str", issue = "94079")]
79+
#[stable(feature = "core_c_str", since = "1.64.0")]
8080
#[rustc_has_incoherent_inherent_impls]
8181
// FIXME:
8282
// `fn from` in `impl From<&CStr> for Box<CStr>` current implementation relies
@@ -108,7 +108,7 @@ pub struct CStr {
108108
/// let _: FromBytesWithNulError = CStr::from_bytes_with_nul(b"f\0oo").unwrap_err();
109109
/// ```
110110
#[derive(Clone, PartialEq, Eq, Debug)]
111-
#[unstable(feature = "core_c_str", issue = "94079")]
111+
#[stable(feature = "core_c_str", since = "1.64.0")]
112112
pub struct FromBytesWithNulError {
113113
kind: FromBytesWithNulErrorKind,
114114
}

library/core/src/ffi/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use crate::marker::PhantomData;
1414
use crate::num::*;
1515
use crate::ops::{Deref, DerefMut};
1616

17-
#[unstable(feature = "core_c_str", issue = "94079")]
17+
#[stable(feature = "core_c_str", since = "1.64.0")]
1818
pub use self::c_str::{CStr, FromBytesUntilNulError, FromBytesWithNulError};
1919

2020
mod c_str;

library/std/src/ffi/mod.rs

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -146,24 +146,10 @@
146146
147147
#![stable(feature = "rust1", since = "1.0.0")]
148148

149-
/// See [alloc::ffi::FromVecWithNulError].
150-
#[stable(feature = "cstring_from_vec_with_nul", since = "1.58.0")]
151-
pub type FromVecWithNulError = alloc::ffi::FromVecWithNulError;
152-
/// See [alloc::ffi::CString].
153-
#[stable(feature = "rust1", since = "1.0.0")]
154-
pub type CString = alloc::ffi::CString;
155-
/// See [alloc::ffi::IntoStringError].
156-
#[stable(feature = "rust1", since = "1.0.0")]
157-
pub type IntoStringError = alloc::ffi::IntoStringError;
158-
/// See [alloc::ffi::NulError].
159-
#[stable(feature = "rust1", since = "1.0.0")]
160-
pub type NulError = alloc::ffi::NulError;
161-
/// See [core::ffi::CStr].
162-
#[stable(feature = "rust1", since = "1.0.0")]
163-
pub type CStr = core::ffi::CStr;
164-
/// See [core::ffi::FromBytesWithNulError].
165-
#[stable(feature = "cstr_from_bytes", since = "1.10.0")]
166-
pub type FromBytesWithNulError = core::ffi::FromBytesWithNulError;
149+
#[stable(feature = "alloc_c_string", since = "1.64.0")]
150+
pub use alloc::ffi::{CString, FromVecWithNulError, IntoStringError, NulError};
151+
#[stable(feature = "core_c_str", since = "1.64.0")]
152+
pub use core::ffi::{CStr, FromBytesWithNulError};
167153

168154
#[stable(feature = "rust1", since = "1.0.0")]
169155
pub use self::os_str::{OsStr, OsString};

library/std/src/fs.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,9 @@ pub fn read_to_string<P: AsRef<Path>>(path: P) -> io::Result<String> {
295295
/// This function will create a file if it does not exist,
296296
/// and will entirely replace its contents if it does.
297297
///
298+
/// Depending on the platform, this function may fail if the
299+
/// full directory path does not exist.
300+
///
298301
/// This is a convenience function for using [`File::create`] and [`write_all`]
299302
/// with fewer imports.
300303
///
@@ -349,6 +352,9 @@ impl File {
349352
/// This function will create a file if it does not exist,
350353
/// and will truncate it if it does.
351354
///
355+
/// Depending on the platform, this function may fail if the
356+
/// full directory path does not exist.
357+
///
352358
/// See the [`OpenOptions::open`] function for more details.
353359
///
354360
/// # Examples

0 commit comments

Comments
 (0)