Skip to content

Commit 3f359d6

Browse files
committed
fix miri test and docs
1 parent 6689a37 commit 3f359d6

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

library/core/src/alloc/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ pub unsafe trait Allocator {
366366

367367
/// The mode of error handling for types using this allocator.
368368
///
369-
/// [`Infallible`] means that any allocation failures should be handled
369+
/// [`Fatal`] means that any allocation failures should be handled
370370
/// globally, often by panicking or aborting. Functions performing
371371
/// allocation will simply return the value or nothing.
372372
///
@@ -381,7 +381,7 @@ pub unsafe trait Allocator {
381381
#[cfg(not(no_global_oom_handling))]
382382
#[unstable(feature = "allocator_api", issue = "32838")]
383383
pub trait HandleAllocError {
384-
/// Globally handle this allocation error, using [`handle_alloc_error`]
384+
/// Globally handle this allocation error
385385
fn handle_alloc_error(self) -> !;
386386
}
387387

@@ -399,7 +399,7 @@ pub trait ErrorHandling {
399399

400400
/// Function to map allocation results into `Self::Result`.
401401
///
402-
/// - For "Infallible" allocators, this should call [`handle_alloc_error`]
402+
/// - For "Infallible" allocators, this should call [`HandleAllocError::handle_alloc_error`]
403403
/// - For "Fallible" allocators, this is just the identity function
404404
#[cfg(not(no_global_oom_handling))]
405405
#[must_use]

src/tools/miri/tests/pass/box-custom-alloc.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#![feature(allocator_api, trait_upcasting)]
55

66
use std::alloc::Layout;
7-
use std::alloc::{AllocError, Allocator};
7+
use std::alloc::{AllocError, Allocator, Fatal};
88
use std::cell::Cell;
99
use std::mem::MaybeUninit;
1010
use std::ptr::{self, NonNull};
@@ -28,6 +28,8 @@ unsafe impl<'shared, 'a: 'shared> Allocator for &'shared OnceAlloc<'a> {
2828
}
2929

3030
unsafe fn deallocate(&self, _ptr: NonNull<u8>, _layout: Layout) {}
31+
32+
type ErrorHandling = Fatal;
3133
}
3234

3335
trait MyTrait {
@@ -68,6 +70,8 @@ unsafe impl<'shared, 'a: 'shared> Allocator for OnceAllocRef<'shared, 'a> {
6870
unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout) {
6971
self.0.deallocate(ptr, layout)
7072
}
73+
74+
type ErrorHandling = Fatal;
7175
}
7276

7377
/// `Box<T, G>` is an `Aggregate`.

0 commit comments

Comments
 (0)