From 0950da97ae12ff30367dda482e73e9e3f4bf07b3 Mon Sep 17 00:00:00 2001 From: Keith-Cancel Date: Sat, 22 Nov 2025 16:59:32 -0800 Subject: [PATCH 1/2] Make `proc_macro::Group` take up less space remove redundant field. The field `entire` is redundant. This saves 4 bytes and makes the DelimSpan match up with what the compiler uses. --- compiler/rustc_expand/src/proc_macro_server.rs | 6 +----- library/proc_macro/src/bridge/mod.rs | 5 ++--- library/proc_macro/src/lib.rs | 3 ++- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/compiler/rustc_expand/src/proc_macro_server.rs b/compiler/rustc_expand/src/proc_macro_server.rs index 0e063011eea49..cd17b6e2ed028 100644 --- a/compiler/rustc_expand/src/proc_macro_server.rs +++ b/compiler/rustc_expand/src/proc_macro_server.rs @@ -151,11 +151,7 @@ impl FromInternal<(TokenStream, &mut Rustc<'_, '_>)> for Vec { pub open: Span, pub close: Span, - pub entire: Span, } impl DelimSpan { pub fn from_single(span: Span) -> Self { - DelimSpan { open: span, close: span, entire: span } + DelimSpan { open: span, close: span } } } -compound_traits!(struct DelimSpan { open, close, entire }); +compound_traits!(struct DelimSpan { open, close }); #[derive(Clone)] pub struct Group { diff --git a/library/proc_macro/src/lib.rs b/library/proc_macro/src/lib.rs index 4efdfcad924b5..d4e5e458e723c 100644 --- a/library/proc_macro/src/lib.rs +++ b/library/proc_macro/src/lib.rs @@ -847,7 +847,8 @@ impl Group { /// ``` #[stable(feature = "proc_macro_lib2", since = "1.29.0")] pub fn span(&self) -> Span { - Span(self.0.span.entire) + let sp = self.0.span; + Span(sp.open.join(sp.close).unwrap_or(sp.open)) } /// Returns the span pointing to the opening delimiter of this group. From b02300eacab8613f7c023c305f4007ac7fe575d6 Mon Sep 17 00:00:00 2001 From: Keith-Cancel Date: Sat, 22 Nov 2025 18:38:08 -0800 Subject: [PATCH 2/2] Update to match. --- .../crates/proc-macro-srv/src/server_impl/token_stream.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl/token_stream.rs b/src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl/token_stream.rs index c5019a5917221..8a9a22b6a044d 100644 --- a/src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl/token_stream.rs +++ b/src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl/token_stream.rs @@ -104,7 +104,6 @@ impl TokenStream { span: bridge::DelimSpan { open: subtree.delimiter.open, close: subtree.delimiter.close, - entire: join_spans(subtree.delimiter.open, subtree.delimiter.close), }, })) }