We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 21c276f + d06384a commit ff3c85fCopy full SHA for ff3c85f
library/core/src/alloc/mod.rs
@@ -342,7 +342,10 @@ pub unsafe trait Allocator {
342
///
343
/// The returned adaptor also implements `Allocator` and will simply borrow this.
344
#[inline(always)]
345
- fn by_ref(&self) -> &Self {
+ fn by_ref(&self) -> &Self
346
+ where
347
+ Self: Sized,
348
+ {
349
self
350
}
351
src/test/ui/allocator/object-safe.rs
@@ -0,0 +1,13 @@
1
+// run-pass
2
+
3
+// Check that `Allocator` is object safe, this allows for polymorphic allocators
4
5
+#![feature(allocator_api)]
6
7
+use std::alloc::{Allocator, System};
8
9
+fn ensure_object_safe(_: &dyn Allocator) {}
10
11
+fn main() {
12
+ ensure_object_safe(&System);
13
+}
0 commit comments