about summary refs log tree commit diff
path: root/library/core/src/alloc
diff options
context:
space:
mode:
authorRustyYato <krishna.sd.2012@gmail.com>2021-02-03 16:59:28 -0500
committerRustyYato <krishna.sd.2012@gmail.com>2021-02-03 20:46:16 -0500
commitd06384ac29098c3a4b3e21eb2f70093e800bd1b6 (patch)
treefcb742f4ff19d13b36e8b3ccd340acbcf6b309f6 /library/core/src/alloc
parent120b2a704a60d4341286bd82f6e638c65ca169b6 (diff)
downloadrust-d06384ac29098c3a4b3e21eb2f70093e800bd1b6.tar.gz
rust-d06384ac29098c3a4b3e21eb2f70093e800bd1b6.zip
make Allocator object-safe
add test to ensure object-safety
This allows for runtime polymorphic allocators
Diffstat (limited to 'library/core/src/alloc')
-rw-r--r--library/core/src/alloc/mod.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/library/core/src/alloc/mod.rs b/library/core/src/alloc/mod.rs
index 045eb58d013..9c2a0146e2c 100644
--- a/library/core/src/alloc/mod.rs
+++ b/library/core/src/alloc/mod.rs
@@ -342,7 +342,10 @@ pub unsafe trait Allocator {
     ///
     /// The returned adaptor also implements `Allocator` and will simply borrow this.
     #[inline(always)]
-    fn by_ref(&self) -> &Self {
+    fn by_ref(&self) -> &Self
+    where
+        Self: Sized,
+    {
         self
     }
 }