From 1e2a4c1bdbc72b6cf5cc894d96fdbf8d5709e44a Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Wed, 23 Mar 2022 15:09:39 +0100 Subject: [PATCH] Return the first span from `Span::join` --- crates/proc_macro_srv/src/abis/abi_1_47/rustc_server.rs | 5 +++-- crates/proc_macro_srv/src/abis/abi_1_54/rustc_server.rs | 5 +++-- crates/proc_macro_srv/src/abis/abi_1_56/rustc_server.rs | 5 +++-- crates/proc_macro_srv/src/abis/abi_1_57/rustc_server.rs | 5 +++-- crates/proc_macro_srv/src/abis/abi_1_58/rustc_server.rs | 5 +++-- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/crates/proc_macro_srv/src/abis/abi_1_47/rustc_server.rs b/crates/proc_macro_srv/src/abis/abi_1_47/rustc_server.rs index 1ef137029d1..4dc506e0f19 100644 --- a/crates/proc_macro_srv/src/abis/abi_1_47/rustc_server.rs +++ b/crates/proc_macro_srv/src/abis/abi_1_47/rustc_server.rs @@ -662,8 +662,9 @@ impl server::Span for Rustc { // FIXME handle span LineColumn { line: 0, column: 0 } } - fn join(&mut self, _first: Self::Span, _second: Self::Span) -> Option { - None + fn join(&mut self, first: Self::Span, _second: Self::Span) -> Option { + // Just return the first span again, because some macros will unwrap the result. + Some(first) } fn resolved_at(&mut self, _span: Self::Span, _at: Self::Span) -> Self::Span { // FIXME handle span diff --git a/crates/proc_macro_srv/src/abis/abi_1_54/rustc_server.rs b/crates/proc_macro_srv/src/abis/abi_1_54/rustc_server.rs index 3904cb8f3ea..7b333836b11 100644 --- a/crates/proc_macro_srv/src/abis/abi_1_54/rustc_server.rs +++ b/crates/proc_macro_srv/src/abis/abi_1_54/rustc_server.rs @@ -665,8 +665,9 @@ impl server::Span for Rustc { // FIXME handle span LineColumn { line: 0, column: 0 } } - fn join(&mut self, _first: Self::Span, _second: Self::Span) -> Option { - None + fn join(&mut self, first: Self::Span, _second: Self::Span) -> Option { + // Just return the first span again, because some macros will unwrap the result. + Some(first) } fn resolved_at(&mut self, _span: Self::Span, _at: Self::Span) -> Self::Span { // FIXME handle span diff --git a/crates/proc_macro_srv/src/abis/abi_1_56/rustc_server.rs b/crates/proc_macro_srv/src/abis/abi_1_56/rustc_server.rs index cf797752310..8517eddf991 100644 --- a/crates/proc_macro_srv/src/abis/abi_1_56/rustc_server.rs +++ b/crates/proc_macro_srv/src/abis/abi_1_56/rustc_server.rs @@ -677,8 +677,9 @@ impl server::Span for Rustc { // FIXME handle span LineColumn { line: 0, column: 0 } } - fn join(&mut self, _first: Self::Span, _second: Self::Span) -> Option { - None + fn join(&mut self, first: Self::Span, _second: Self::Span) -> Option { + // Just return the first span again, because some macros will unwrap the result. + Some(first) } fn resolved_at(&mut self, _span: Self::Span, _at: Self::Span) -> Self::Span { // FIXME handle span diff --git a/crates/proc_macro_srv/src/abis/abi_1_57/rustc_server.rs b/crates/proc_macro_srv/src/abis/abi_1_57/rustc_server.rs index 00077ebc5bf..48597e894c6 100644 --- a/crates/proc_macro_srv/src/abis/abi_1_57/rustc_server.rs +++ b/crates/proc_macro_srv/src/abis/abi_1_57/rustc_server.rs @@ -677,8 +677,9 @@ impl server::Span for Rustc { // FIXME handle span LineColumn { line: 0, column: 0 } } - fn join(&mut self, _first: Self::Span, _second: Self::Span) -> Option { - None + fn join(&mut self, first: Self::Span, _second: Self::Span) -> Option { + // Just return the first span again, because some macros will unwrap the result. + Some(first) } fn resolved_at(&mut self, _span: Self::Span, _at: Self::Span) -> Self::Span { // FIXME handle span diff --git a/crates/proc_macro_srv/src/abis/abi_1_58/rustc_server.rs b/crates/proc_macro_srv/src/abis/abi_1_58/rustc_server.rs index 5c3f4da0014..6c57ac92dc6 100644 --- a/crates/proc_macro_srv/src/abis/abi_1_58/rustc_server.rs +++ b/crates/proc_macro_srv/src/abis/abi_1_58/rustc_server.rs @@ -681,8 +681,9 @@ impl server::Span for Rustc { // FIXME handle span LineColumn { line: 0, column: 0 } } - fn join(&mut self, _first: Self::Span, _second: Self::Span) -> Option { - None + fn join(&mut self, first: Self::Span, _second: Self::Span) -> Option { + // Just return the first span again, because some macros will unwrap the result. + Some(first) } fn resolved_at(&mut self, _span: Self::Span, _at: Self::Span) -> Self::Span { // FIXME handle span