Skip to content

Commit a30f892

Browse files
author
The Miri Cronjob Bot
committed
Merge from rustc
2 parents e33b994 + fa7412b commit a30f892

File tree

29 files changed

+105
-82
lines changed

29 files changed

+105
-82
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

alloc/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ edition = "2021"
1010

1111
[dependencies]
1212
core = { path = "../core" }
13-
compiler_builtins = { version = "0.1.123", features = ['rustc-dep-of-std'] }
13+
compiler_builtins = { version = "0.1.125", features = ['rustc-dep-of-std'] }
1414

1515
[dev-dependencies]
1616
rand = { version = "0.8.5", default-features = false, features = ["alloc"] }

alloc/src/alloc.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ pub use std::alloc::Global;
8989
#[stable(feature = "global_alloc", since = "1.28.0")]
9090
#[must_use = "losing the pointer will leak memory"]
9191
#[inline]
92+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
9293
pub unsafe fn alloc(layout: Layout) -> *mut u8 {
9394
unsafe {
9495
// Make sure we don't accidentally allow omitting the allocator shim in
@@ -113,6 +114,7 @@ pub unsafe fn alloc(layout: Layout) -> *mut u8 {
113114
/// See [`GlobalAlloc::dealloc`].
114115
#[stable(feature = "global_alloc", since = "1.28.0")]
115116
#[inline]
117+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
116118
pub unsafe fn dealloc(ptr: *mut u8, layout: Layout) {
117119
unsafe { __rust_dealloc(ptr, layout.size(), layout.align()) }
118120
}
@@ -132,6 +134,7 @@ pub unsafe fn dealloc(ptr: *mut u8, layout: Layout) {
132134
#[stable(feature = "global_alloc", since = "1.28.0")]
133135
#[must_use = "losing the pointer will leak memory"]
134136
#[inline]
137+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
135138
pub unsafe fn realloc(ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 {
136139
unsafe { __rust_realloc(ptr, layout.size(), layout.align(), new_size) }
137140
}
@@ -166,13 +169,15 @@ pub unsafe fn realloc(ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8
166169
#[stable(feature = "global_alloc", since = "1.28.0")]
167170
#[must_use = "losing the pointer will leak memory"]
168171
#[inline]
172+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
169173
pub unsafe fn alloc_zeroed(layout: Layout) -> *mut u8 {
170174
unsafe { __rust_alloc_zeroed(layout.size(), layout.align()) }
171175
}
172176

173177
#[cfg(not(test))]
174178
impl Global {
175179
#[inline]
180+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
176181
fn alloc_impl(&self, layout: Layout, zeroed: bool) -> Result<NonNull<[u8]>, AllocError> {
177182
match layout.size() {
178183
0 => Ok(NonNull::slice_from_raw_parts(layout.dangling(), 0)),
@@ -187,6 +192,7 @@ impl Global {
187192

188193
// SAFETY: Same as `Allocator::grow`
189194
#[inline]
195+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
190196
unsafe fn grow_impl(
191197
&self,
192198
ptr: NonNull<u8>,
@@ -237,16 +243,19 @@ impl Global {
237243
#[cfg(not(test))]
238244
unsafe impl Allocator for Global {
239245
#[inline]
246+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
240247
fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> {
241248
self.alloc_impl(layout, false)
242249
}
243250

244251
#[inline]
252+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
245253
fn allocate_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> {
246254
self.alloc_impl(layout, true)
247255
}
248256

249257
#[inline]
258+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
250259
unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout) {
251260
if layout.size() != 0 {
252261
// SAFETY: `layout` is non-zero in size,
@@ -256,6 +265,7 @@ unsafe impl Allocator for Global {
256265
}
257266

258267
#[inline]
268+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
259269
unsafe fn grow(
260270
&self,
261271
ptr: NonNull<u8>,
@@ -267,6 +277,7 @@ unsafe impl Allocator for Global {
267277
}
268278

269279
#[inline]
280+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
270281
unsafe fn grow_zeroed(
271282
&self,
272283
ptr: NonNull<u8>,
@@ -278,6 +289,7 @@ unsafe impl Allocator for Global {
278289
}
279290

280291
#[inline]
292+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
281293
unsafe fn shrink(
282294
&self,
283295
ptr: NonNull<u8>,
@@ -325,6 +337,7 @@ unsafe impl Allocator for Global {
325337
#[cfg(all(not(no_global_oom_handling), not(test)))]
326338
#[lang = "exchange_malloc"]
327339
#[inline]
340+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
328341
unsafe fn exchange_malloc(size: usize, align: usize) -> *mut u8 {
329342
let layout = unsafe { Layout::from_size_align_unchecked(size, align) };
330343
match Global.allocate(layout) {

alloc/src/boxed.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ impl<T> Box<T> {
250250
#[stable(feature = "rust1", since = "1.0.0")]
251251
#[must_use]
252252
#[rustc_diagnostic_item = "box_new"]
253+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
253254
pub fn new(x: T) -> Self {
254255
#[rustc_box]
255256
Box::new(x)

alloc/src/collections/vec_deque/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,8 +554,8 @@ impl<T> VecDeque<T> {
554554
#[rustc_const_stable(feature = "const_vec_deque_new", since = "1.68.0")]
555555
#[must_use]
556556
pub const fn new() -> VecDeque<T> {
557-
// FIXME: This should just be `VecDeque::new_in(Global)` once that hits stable.
558-
VecDeque { head: 0, len: 0, buf: RawVec::NEW }
557+
// FIXME(const-hack): This should just be `VecDeque::new_in(Global)` once that hits stable.
558+
VecDeque { head: 0, len: 0, buf: RawVec::new() }
559559
}
560560

561561
/// Creates an empty deque with space for at least `capacity` elements.

alloc/src/raw_vec.rs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,6 @@ struct RawVecInner<A: Allocator = Global> {
9696
}
9797

9898
impl<T> RawVec<T, Global> {
99-
/// HACK(Centril): This exists because stable `const fn` can only call stable `const fn`, so
100-
/// they cannot call `Self::new()`.
101-
///
102-
/// If you change `RawVec<T>::new` or dependencies, please take care to not introduce anything
103-
/// that would truly const-call something unstable.
104-
pub const NEW: Self = Self::new();
105-
10699
/// Creates the biggest possible `RawVec` (on the system heap)
107100
/// without allocating. If `T` has positive size, then this makes a
108101
/// `RawVec` with capacity `0`. If `T` is zero-sized, then it makes a
@@ -111,7 +104,7 @@ impl<T> RawVec<T, Global> {
111104
#[must_use]
112105
#[rustc_const_stable(feature = "raw_vec_internals_const", since = "1.81")]
113106
pub const fn new() -> Self {
114-
Self { inner: RawVecInner::new::<T>(), _marker: PhantomData }
107+
Self::new_in(Global)
115108
}
116109

117110
/// Creates a `RawVec` (on the system heap) with exactly the
@@ -149,12 +142,6 @@ impl<T> RawVec<T, Global> {
149142
}
150143

151144
impl RawVecInner<Global> {
152-
#[must_use]
153-
#[rustc_const_stable(feature = "raw_vec_internals_const", since = "1.81")]
154-
const fn new<T>() -> Self {
155-
Self::new_in(Global, core::mem::align_of::<T>())
156-
}
157-
158145
#[cfg(not(any(no_global_oom_handling, test)))]
159146
#[must_use]
160147
#[inline]

alloc/src/vec/in_place_collect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ const fn in_place_collectible<DEST, SRC>(
191191

192192
const fn needs_realloc<SRC, DEST>(src_cap: usize, dst_cap: usize) -> bool {
193193
if const { mem::align_of::<SRC>() != mem::align_of::<DEST>() } {
194-
// FIXME: use unreachable! once that works in const
194+
// FIXME(const-hack): use unreachable! once that works in const
195195
panic!("in_place_collectible() prevents this");
196196
}
197197

alloc/src/vec/into_iter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ impl<T, A: Allocator> IntoIter<T, A> {
142142
// struct and then overwriting &mut self.
143143
// this creates less assembly
144144
self.cap = 0;
145-
self.buf = RawVec::NEW.non_null();
145+
self.buf = RawVec::new().non_null();
146146
self.ptr = self.buf;
147147
self.end = self.buf.as_ptr();
148148

alloc/src/vec/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ impl<T> Vec<T> {
419419
#[stable(feature = "rust1", since = "1.0.0")]
420420
#[must_use]
421421
pub const fn new() -> Self {
422-
Vec { buf: RawVec::NEW, len: 0 }
422+
Vec { buf: RawVec::new(), len: 0 }
423423
}
424424

425425
/// Constructs a new, empty `Vec<T>` with at least the specified capacity.

core/src/char/convert.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::ub_checks::assert_unsafe_precondition;
1111
#[must_use]
1212
#[inline]
1313
pub(super) const fn from_u32(i: u32) -> Option<char> {
14-
// FIXME: once Result::ok is const fn, use it here
14+
// FIXME(const-hack): once Result::ok is const fn, use it here
1515
match char_try_from_u32(i) {
1616
Ok(c) => Some(c),
1717
Err(_) => None,

0 commit comments

Comments
 (0)