Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
c13669e
Implement `AsFd` and `AsRawFd` for `Rc`
ids1024 Jan 26, 2023
83b05ef
Stabilize feature 'cstr_from_bytes_until_nul'
tgross35 Jan 28, 2023
877e9f5
Change 'from_bytes_until_nul' to const stable
tgross35 Jan 30, 2023
f95b553
Replace a command line flag with an env var to allow tools to initial…
oli-obk Feb 7, 2023
4259073
x.py fails all downloads that use a tempdir with snap curl #107722
tharunsuresh-code Feb 8, 2023
0017822
Do not eagerly recover for bad impl-trait in macros
compiler-errors Feb 8, 2023
a516460
correctly update goals in the cache
lcnr Feb 8, 2023
4c7c5e5
add (currently ICEing) test
lcnr Feb 8, 2023
8cb5be9
rustdoc: use [svgo] to shrink `wheel.svg`
notriddle Feb 8, 2023
730470c
Set `rust-analyzer.check.invocationLocation` to `root`
clubby789 Feb 8, 2023
a70d03b
Extend `BYTE_SLICE_IN_PACKED_STRUCT_WITH_DERIVE`.
nnethercote Feb 6, 2023
a478b83
Rollup merge of #107317 - ids1024:asfd-rc, r=dtolnay
compiler-errors Feb 9, 2023
aee4570
Rollup merge of #107429 - tgross35:from-bytes-until-null-stabilizatio…
compiler-errors Feb 9, 2023
04f7708
Rollup merge of #107713 - nnethercote:extend-BYTE_SLICE_IN_PACKED_STR…
compiler-errors Feb 9, 2023
32bb73e
Rollup merge of #107761 - oli-obk:miri_🪵, r=TaKO8Ki
compiler-errors Feb 9, 2023
04ebaba
Rollup merge of #107790 - tharunsuresh-code:snap_curl, r=jyn514
compiler-errors Feb 9, 2023
46c7c91
Rollup merge of #107799 - lcnr:update-provisional-result, r=oli-obk
compiler-errors Feb 9, 2023
ab09405
Rollup merge of #107813 - compiler-errors:bad-impl-trait-in-macro-is-…
compiler-errors Feb 9, 2023
ae2ecff
Rollup merge of #107817 - notriddle:notriddle/wheel-svg, r=GuillaumeG…
compiler-errors Feb 9, 2023
3e07554
Rollup merge of #107819 - clubby789:x-py-root, r=jyn514
compiler-errors Feb 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion library/alloc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@
#![feature(const_eval_select)]
#![feature(const_pin)]
#![feature(const_waker)]
#![feature(cstr_from_bytes_until_nul)]
#![feature(dispatch_from_dyn)]
#![feature(error_generic_member_access)]
#![feature(error_in_core)]
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ impl Error for crate::ffi::FromBytesWithNulError {
}
}

#[unstable(feature = "cstr_from_bytes_until_nul", issue = "95027")]
#[stable(feature = "cstr_from_bytes_until_nul", since = "CURRENT_RUSTC_VERSION")]
impl Error for crate::ffi::FromBytesUntilNulError {}

#[unstable(feature = "get_many_mut", issue = "104642")]
Expand Down
11 changes: 5 additions & 6 deletions library/core/src/ffi/c_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,10 @@ impl FromBytesWithNulError {
/// This error is created by the [`CStr::from_bytes_until_nul`] method.
///
#[derive(Clone, PartialEq, Eq, Debug)]
#[unstable(feature = "cstr_from_bytes_until_nul", issue = "95027")]
#[stable(feature = "cstr_from_bytes_until_nul", since = "CURRENT_RUSTC_VERSION")]
pub struct FromBytesUntilNulError(());

#[unstable(feature = "cstr_from_bytes_until_nul", issue = "95027")]
#[stable(feature = "cstr_from_bytes_until_nul", since = "CURRENT_RUSTC_VERSION")]
impl fmt::Display for FromBytesUntilNulError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "data provided does not contain a nul")
Expand Down Expand Up @@ -306,8 +306,6 @@ impl CStr {
///
/// # Examples
/// ```
/// #![feature(cstr_from_bytes_until_nul)]
///
/// use std::ffi::CStr;
///
/// let mut buffer = [0u8; 16];
Expand All @@ -322,8 +320,9 @@ impl CStr {
/// assert_eq!(c_str.to_str().unwrap(), "AAAAAAAA");
/// ```
///
#[unstable(feature = "cstr_from_bytes_until_nul", issue = "95027")]
#[rustc_const_unstable(feature = "cstr_from_bytes_until_nul", issue = "95027")]
#[rustc_allow_const_fn_unstable(const_slice_index)]
#[stable(feature = "cstr_from_bytes_until_nul", since = "CURRENT_RUSTC_VERSION")]
#[rustc_const_stable(feature = "cstr_from_bytes_until_nul", since = "CURRENT_RUSTC_VERSION")]
pub const fn from_bytes_until_nul(bytes: &[u8]) -> Result<&CStr, FromBytesUntilNulError> {
let nul_pos = memchr::memchr(0, bytes);
match nul_pos {
Expand Down
15 changes: 12 additions & 3 deletions library/core/src/slice/memchr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,29 @@ const USIZE_BYTES: usize = mem::size_of::<usize>();
/// bytes where the borrow propagated all the way to the most significant
/// bit."
#[inline]
#[rustc_const_stable(feature = "const_memchr", since = "1.65.0")]
const fn contains_zero_byte(x: usize) -> bool {
x.wrapping_sub(LO_USIZE) & !x & HI_USIZE != 0
}

#[cfg(target_pointer_width = "16")]
#[inline]
#[cfg(target_pointer_width = "16")]
#[rustc_const_stable(feature = "const_memchr", since = "1.65.0")]
const fn repeat_byte(b: u8) -> usize {
(b as usize) << 8 | b as usize
}

#[cfg(not(target_pointer_width = "16"))]
#[inline]
#[cfg(not(target_pointer_width = "16"))]
#[rustc_const_stable(feature = "const_memchr", since = "1.65.0")]
const fn repeat_byte(b: u8) -> usize {
(b as usize) * (usize::MAX / 255)
}

/// Returns the first index matching the byte `x` in `text`.
#[must_use]
#[inline]
#[must_use]
#[rustc_const_stable(feature = "const_memchr", since = "1.65.0")]
pub const fn memchr(x: u8, text: &[u8]) -> Option<usize> {
// Fast path for small slices.
if text.len() < 2 * USIZE_BYTES {
Expand All @@ -45,6 +49,7 @@ pub const fn memchr(x: u8, text: &[u8]) -> Option<usize> {
}

#[inline]
#[rustc_const_stable(feature = "const_memchr", since = "1.65.0")]
const fn memchr_naive(x: u8, text: &[u8]) -> Option<usize> {
let mut i = 0;

Expand All @@ -60,6 +65,10 @@ const fn memchr_naive(x: u8, text: &[u8]) -> Option<usize> {
None
}

#[rustc_allow_const_fn_unstable(const_cmp)]
#[rustc_allow_const_fn_unstable(const_slice_index)]
#[rustc_allow_const_fn_unstable(const_align_offset)]
#[rustc_const_stable(feature = "const_memchr", since = "1.65.0")]
const fn memchr_aligned(x: u8, text: &[u8]) -> Option<usize> {
// Scan for a single byte value by reading two `usize` words at a time.
//
Expand Down
1 change: 0 additions & 1 deletion library/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,6 @@
#![feature(char_error_internals)]
#![feature(char_internals)]
#![feature(core_intrinsics)]
#![feature(cstr_from_bytes_until_nul)]
#![feature(cstr_internals)]
#![feature(duration_constants)]
#![feature(error_generic_member_access)]
Expand Down
1 change: 0 additions & 1 deletion src/tools/miri/tests/pass-dep/shims/pthreads.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//@ignore-target-windows: No libc on Windows
#![feature(cstr_from_bytes_until_nul)]
use std::ffi::{CStr, CString};
use std::thread;

Expand Down