Skip to content

Commit de5925d

Browse files
bors[bot]Jonas Schievink
and
Jonas Schievink
authored
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]>
2 parents 83b4329 + 1e2a4c1 commit de5925d

File tree

5 files changed

+15
-10
lines changed

5 files changed

+15
-10
lines changed

crates/proc_macro_srv/src/abis/abi_1_47/rustc_server.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -662,8 +662,9 @@ impl server::Span for Rustc {
662662
// FIXME handle span
663663
LineColumn { line: 0, column: 0 }
664664
}
665-
fn join(&mut self, _first: Self::Span, _second: Self::Span) -> Option<Self::Span> {
666-
None
665+
fn join(&mut self, first: Self::Span, _second: Self::Span) -> Option<Self::Span> {
666+
// Just return the first span again, because some macros will unwrap the result.
667+
Some(first)
667668
}
668669
fn resolved_at(&mut self, _span: Self::Span, _at: Self::Span) -> Self::Span {
669670
// FIXME handle span

crates/proc_macro_srv/src/abis/abi_1_54/rustc_server.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -665,8 +665,9 @@ impl server::Span for Rustc {
665665
// FIXME handle span
666666
LineColumn { line: 0, column: 0 }
667667
}
668-
fn join(&mut self, _first: Self::Span, _second: Self::Span) -> Option<Self::Span> {
669-
None
668+
fn join(&mut self, first: Self::Span, _second: Self::Span) -> Option<Self::Span> {
669+
// Just return the first span again, because some macros will unwrap the result.
670+
Some(first)
670671
}
671672
fn resolved_at(&mut self, _span: Self::Span, _at: Self::Span) -> Self::Span {
672673
// FIXME handle span

crates/proc_macro_srv/src/abis/abi_1_56/rustc_server.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -677,8 +677,9 @@ impl server::Span for Rustc {
677677
// FIXME handle span
678678
LineColumn { line: 0, column: 0 }
679679
}
680-
fn join(&mut self, _first: Self::Span, _second: Self::Span) -> Option<Self::Span> {
681-
None
680+
fn join(&mut self, first: Self::Span, _second: Self::Span) -> Option<Self::Span> {
681+
// Just return the first span again, because some macros will unwrap the result.
682+
Some(first)
682683
}
683684
fn resolved_at(&mut self, _span: Self::Span, _at: Self::Span) -> Self::Span {
684685
// FIXME handle span

crates/proc_macro_srv/src/abis/abi_1_57/rustc_server.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -677,8 +677,9 @@ impl server::Span for Rustc {
677677
// FIXME handle span
678678
LineColumn { line: 0, column: 0 }
679679
}
680-
fn join(&mut self, _first: Self::Span, _second: Self::Span) -> Option<Self::Span> {
681-
None
680+
fn join(&mut self, first: Self::Span, _second: Self::Span) -> Option<Self::Span> {
681+
// Just return the first span again, because some macros will unwrap the result.
682+
Some(first)
682683
}
683684
fn resolved_at(&mut self, _span: Self::Span, _at: Self::Span) -> Self::Span {
684685
// FIXME handle span

crates/proc_macro_srv/src/abis/abi_1_58/rustc_server.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -681,8 +681,9 @@ impl server::Span for Rustc {
681681
// FIXME handle span
682682
LineColumn { line: 0, column: 0 }
683683
}
684-
fn join(&mut self, _first: Self::Span, _second: Self::Span) -> Option<Self::Span> {
685-
None
684+
fn join(&mut self, first: Self::Span, _second: Self::Span) -> Option<Self::Span> {
685+
// Just return the first span again, because some macros will unwrap the result.
686+
Some(first)
686687
}
687688
fn resolved_at(&mut self, _span: Self::Span, _at: Self::Span) -> Self::Span {
688689
// FIXME handle span

0 commit comments

Comments
 (0)