Unnamed repository; edit this file 'description' to name the repository.
Merge #11801
11801: fix: avoid returning `None` from `Span::join` to fix some proc macros r=jonas-schievink a=jonas-schievink Some proc macros, notably rocket, `.unwrap()` the result of `Span::join` (and correctly so, it should never be `None`). We don't have a proper implementation of that API, so we always returned `None`. This changes our stub impl to return the first span instead. Does not fully fix rocket's macros, they need other stuff to work too. bors r+ Co-authored-by: Jonas Schievink <[email protected]>
bors[bot] 2022-03-23
parent 83b4329 · parent 1e2a4c1 · commit de5925d
-rw-r--r--crates/proc_macro_srv/src/abis/abi_1_47/rustc_server.rs5
-rw-r--r--crates/proc_macro_srv/src/abis/abi_1_54/rustc_server.rs5
-rw-r--r--crates/proc_macro_srv/src/abis/abi_1_56/rustc_server.rs5
-rw-r--r--crates/proc_macro_srv/src/abis/abi_1_57/rustc_server.rs5
-rw-r--r--crates/proc_macro_srv/src/abis/abi_1_58/rustc_server.rs5
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 1ef137029d..4dc506e0f1 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<Self::Span> {
- None
+ fn join(&mut self, first: Self::Span, _second: Self::Span) -> Option<Self::Span> {
+ // 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 3904cb8f3e..7b333836b1 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<Self::Span> {
- None
+ fn join(&mut self, first: Self::Span, _second: Self::Span) -> Option<Self::Span> {
+ // 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 cf79775231..8517eddf99 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<Self::Span> {
- None
+ fn join(&mut self, first: Self::Span, _second: Self::Span) -> Option<Self::Span> {
+ // 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 00077ebc5b..48597e894c 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<Self::Span> {
- None
+ fn join(&mut self, first: Self::Span, _second: Self::Span) -> Option<Self::Span> {
+ // 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 5c3f4da001..6c57ac92dc 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<Self::Span> {
- None
+ fn join(&mut self, first: Self::Span, _second: Self::Span) -> Option<Self::Span> {
+ // 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