From 3e96ca2bf7f7c558623e372e7a9800ac752faa9c Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 26 Nov 2019 09:24:39 +0100 Subject: abort on BoxMeUp misuse --- src/libcore/panic.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/libcore') diff --git a/src/libcore/panic.rs b/src/libcore/panic.rs index 0abc481f6e5..99b372d92c8 100644 --- a/src/libcore/panic.rs +++ b/src/libcore/panic.rs @@ -266,8 +266,16 @@ impl fmt::Display for Location<'_> { #[unstable(feature = "std_internals", issue = "0")] #[doc(hidden)] pub unsafe trait BoxMeUp { + /// Take full ownership of the contents. /// The return type is actually `Box`, but we cannot use `Box` in libcore. + /// /// After this method got called, only some dummy default value is left in `self`. + /// Calling this method twice, or calling `get` after calling this method, is an error. + /// + /// The argument is borrowed because the panic runtime (`__rust_start_panic`) only + /// gets a borrowed `dyn BoxMeUp`. fn take_box(&mut self) -> *mut (dyn Any + Send); + + /// Just borrow the contents. fn get(&mut self) -> &(dyn Any + Send); } -- cgit 1.4.1-3-g733a5