public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Thomas Schwinge <tschwinge@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc/devel/rust/master] libproc_macro: Drop function shall take a mutable
Date: Tue,  2 May 2023 07:08:01 +0000 (GMT)	[thread overview]
Message-ID: <20230502070801.2C5F73858423@sourceware.org> (raw)

https://gcc.gnu.org/g:4d1bb3df100323c664875a09ecce830b179d752f

commit 4d1bb3df100323c664875a09ecce830b179d752f
Author: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Date:   Fri Apr 7 13:52:04 2023 +0200

    libproc_macro: Drop function shall take a mutable
    
    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.
    ChangeLog:
    
            * libgrust/libproc_macro/rust/bridge/literal.rs: Make the
            pointer mutable.
    
    Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>

Diff:
---
 libgrust/libproc_macro/rust/bridge/literal.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libgrust/libproc_macro/rust/bridge/literal.rs b/libgrust/libproc_macro/rust/bridge/literal.rs
index 080cc1b21d8..740ed1fccac 100644
--- a/libgrust/libproc_macro/rust/bridge/literal.rs
+++ b/libgrust/libproc_macro/rust/bridge/literal.rs
@@ -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)
             },
             _ => (),
         }

                 reply	other threads:[~2023-05-02  7:08 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230502070801.2C5F73858423@sourceware.org \
    --to=tschwinge@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).