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

https://gcc.gnu.org/g:09b2be24391d7543fe76c24c3cf790e915e0ff1a

commit 09b2be24391d7543fe76c24c3cf790e915e0ff1a
Author: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Date:   Tue Feb 21 12:35:42 2023 +0100

    libproc_macro: Minor refactor
    
    Change some bits to make the code more idiomatic/clearer.
    
    ChangeLog:
    
            * librust/proc_macro/rust/bridge/literal.rs: Make byte range
            clearer.
            * librust/proc_macro/rust/bridge/token_stream.rs: Remove old
            comment.
            * librust/proc_macro/rust/token_stream.rs: Remove useless return
            statement.
    
    Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>

Diff:
---
 librust/proc_macro/rust/bridge/literal.rs      | 2 +-
 librust/proc_macro/rust/bridge/token_stream.rs | 4 ----
 librust/proc_macro/rust/token_stream.rs        | 2 +-
 3 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/librust/proc_macro/rust/bridge/literal.rs b/librust/proc_macro/rust/bridge/literal.rs
index 32514035723..c2017ac4d94 100644
--- a/librust/proc_macro/rust/bridge/literal.rs
+++ b/librust/proc_macro/rust/bridge/literal.rs
@@ -252,7 +252,7 @@ impl fmt::Display for Literal {
                 let slice =
                     unsafe { std::slice::from_raw_parts(*data, (*size).try_into().unwrap()) };
                 for &byte in slice {
-                    if byte != b'"' && byte >= b' ' && byte <= b'z' {
+                    if byte != b'"' && (b' '..=b'z').contains(&byte) {
                         char::try_from(byte).unwrap().fmt(f)?;
                     } else {
                         write!(f, "\\x{byte:02x}")?;
diff --git a/librust/proc_macro/rust/bridge/token_stream.rs b/librust/proc_macro/rust/bridge/token_stream.rs
index 1c9825f4af6..56f6679a822 100644
--- a/librust/proc_macro/rust/bridge/token_stream.rs
+++ b/librust/proc_macro/rust/bridge/token_stream.rs
@@ -17,10 +17,6 @@ extern "C" {
     fn TokenStream__clone(ts: *const TokenStream) -> TokenStream;
 }
 
-// TODO: There surely is a better way to achieve this. I don't like this
-// "duplication" of the TokenTree enumeration. But I cannot use the public
-// one since it's underlying types (public Group, Ident...) are not ffi safe.
-// Flattening all those struct might be a solution.
 #[repr(C)]
 #[derive(Clone)]
 pub enum TokenTree {
diff --git a/librust/proc_macro/rust/token_stream.rs b/librust/proc_macro/rust/token_stream.rs
index c4caf9f9ff8..9333e3ea2fc 100644
--- a/librust/proc_macro/rust/token_stream.rs
+++ b/librust/proc_macro/rust/token_stream.rs
@@ -17,7 +17,7 @@ impl Iterator for IntoIter {
 
     fn next(&mut self) -> Option<TokenTree> {
         if self.current == self.end {
-            return None;
+            None
         } else {
             let result = self.current;
             self.current = unsafe { self.current.add(1) };

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

only message in thread, other threads:[~2023-04-06 21:33 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:33 [gcc/devel/rust/master] libproc_macro: Minor refactor 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).