public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] libproc_macro: Change Punct internal size type
@ 2023-04-06 21:31 Thomas Schwinge
  0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2023-04-06 21:31 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:896533bfff4b29042000d7b4813e6fa3cf30a1c6

commit 896533bfff4b29042000d7b4813e6fa3cf30a1c6
Author: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Date:   Thu Feb 16 17:09:10 2023 +0100

    libproc_macro: Change Punct internal size type
    
    The rust Punct type was using a 1 byte c_char, incompatible with rust
    char.
    
    ChangeLog:
    
            * librust/proc_macro/rust/bridge/punct.rs: Change value getter.
            * librust/proc_macro/rust/punct.rs: Change structure size.
    
    Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>

Diff:
---
 librust/proc_macro/rust/bridge/punct.rs | 8 ++------
 librust/proc_macro/rust/punct.rs        | 6 +++++-
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/librust/proc_macro/rust/bridge/punct.rs b/librust/proc_macro/rust/bridge/punct.rs
index f1bb9141ed0..20b03c58101 100644
--- a/librust/proc_macro/rust/bridge/punct.rs
+++ b/librust/proc_macro/rust/bridge/punct.rs
@@ -1,21 +1,17 @@
 use bridge::span::Span;
-use std::convert::TryInto;
-use std::ffi::c_uchar;
 use Spacing;
 
 #[repr(C)]
 #[derive(Clone, Debug)]
 pub struct Punct {
-    pub(crate) ch: c_uchar,
+    pub(crate) ch: u32,
     pub(crate) spacing: Spacing,
 }
 
 impl Punct {
     pub fn new(ch: char, spacing: Spacing) -> Self {
         Punct {
-            ch: ch
-                .try_into()
-                .expect("Failed to convert rust char to c char"),
+            ch: ch.into(),
             spacing,
         }
     }
diff --git a/librust/proc_macro/rust/punct.rs b/librust/proc_macro/rust/punct.rs
index 7320a1e6514..e7001e62127 100644
--- a/librust/proc_macro/rust/punct.rs
+++ b/librust/proc_macro/rust/punct.rs
@@ -1,4 +1,5 @@
 use bridge;
+use std::convert::TryInto;
 use std::fmt;
 use Span;
 
@@ -38,7 +39,10 @@ impl Punct {
 
     /// Get the value for this punctuation character as `char`.
     pub fn as_char(&self) -> char {
-        self.0.ch.into()
+        self.0
+            .ch
+            .try_into()
+            .expect("Cannot convert from u32 to char")
     }
 
     /// Get the [`Spacing`] of this punctuation character, indicating whether

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-04-06 21:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-06 21:31 [gcc/devel/rust/master] libproc_macro: Change Punct internal size type Thomas Schwinge

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).