diff options
author | Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com> | 2023-02-16 17:09:10 +0100 |
---|---|---|
committer | Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com> | 2023-03-30 13:52:30 +0200 |
commit | 896533bfff4b29042000d7b4813e6fa3cf30a1c6 (patch) | |
tree | 9b8a4b320e59a5b4be7aa41d4c1b55f306100749 | |
parent | 20578ae77461ad57abfa29823213e29bfa51e670 (diff) | |
download | gcc-896533bfff4b29042000d7b4813e6fa3cf30a1c6.zip gcc-896533bfff4b29042000d7b4813e6fa3cf30a1c6.tar.gz gcc-896533bfff4b29042000d7b4813e6fa3cf30a1c6.tar.bz2 |
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>
-rw-r--r-- | librust/proc_macro/rust/bridge/punct.rs | 8 | ||||
-rw-r--r-- | 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 f1bb914..20b03c5 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 7320a1e..e7001e6 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 |