From d06384ac29098c3a4b3e21eb2f70093e800bd1b6 Mon Sep 17 00:00:00 2001 From: RustyYato Date: Wed, 3 Feb 2021 16:59:28 -0500 Subject: make Allocator object-safe add test to ensure object-safety This allows for runtime polymorphic allocators --- library/core/src/alloc/mod.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'library/core/src/alloc') 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 } } -- cgit 1.4.1-3-g733a5