]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: libproc_macro: Drop function shall take a mutable
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Fri, 7 Apr 2023 11:52:04 +0000 (13:52 +0200)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 17:34:10 +0000 (18:34 +0100)
The rust API requires a mut reference, hence having a mutable pointer
seems to match better. Furthermore the implementation is now modifying
the struct in order to set the size to 0 instead of simply freeing the
data, this will allow us to easily identify mistaken manual call to this
function.

libgrust/ChangeLog:

* libproc_macro/rust/bridge/literal.rs: Make the
pointer mutable.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
libgrust/libproc_macro/rust/bridge/literal.rs

index 080cc1b21d8193ecd8bfd0e6177d9e983019e609..740ed1fccac7dd9e9402c113f480e7a3b1bfb7e5 100644 (file)
@@ -6,7 +6,7 @@ use std::str::FromStr;
 use LexError;
 
 extern "C" {
-    fn Literal__drop(literal: *const Literal);
+    fn Literal__drop(literal: *mut Literal);
     fn Literal__string(str: *const c_uchar, len: u64) -> Literal;
     fn Literal__byte_string(bytes: *const u8, len: u64) -> Literal;
     fn Literal__from_string(str: *const c_uchar, len: u64, lit: *mut Literal) -> bool;
@@ -230,7 +230,7 @@ impl Drop for Literal {
     fn drop(&mut self) {
         match self {
             Literal::String { .. } | Literal::ByteString { .. } => unsafe {
-                Literal__drop(self as *const Literal)
+                Literal__drop(self as *mut Literal)
             },
             _ => (),
         }