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 <jonas.schievink@ferrous-systems.com>
This commit is contained in:
bors[bot] 2022-03-23 14:11:42 +00:00 committed by GitHub
commit de5925da5c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 10 deletions

View file

@ -662,8 +662,9 @@ impl server::Span for Rustc {
// FIXME handle span // FIXME handle span
LineColumn { line: 0, column: 0 } LineColumn { line: 0, column: 0 }
} }
fn join(&mut self, _first: Self::Span, _second: Self::Span) -> Option<Self::Span> { fn join(&mut self, first: Self::Span, _second: Self::Span) -> Option<Self::Span> {
None // 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 { fn resolved_at(&mut self, _span: Self::Span, _at: Self::Span) -> Self::Span {
// FIXME handle span // FIXME handle span

View file

@ -665,8 +665,9 @@ impl server::Span for Rustc {
// FIXME handle span // FIXME handle span
LineColumn { line: 0, column: 0 } LineColumn { line: 0, column: 0 }
} }
fn join(&mut self, _first: Self::Span, _second: Self::Span) -> Option<Self::Span> { fn join(&mut self, first: Self::Span, _second: Self::Span) -> Option<Self::Span> {
None // 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 { fn resolved_at(&mut self, _span: Self::Span, _at: Self::Span) -> Self::Span {
// FIXME handle span // FIXME handle span

View file

@ -677,8 +677,9 @@ impl server::Span for Rustc {
// FIXME handle span // FIXME handle span
LineColumn { line: 0, column: 0 } LineColumn { line: 0, column: 0 }
} }
fn join(&mut self, _first: Self::Span, _second: Self::Span) -> Option<Self::Span> { fn join(&mut self, first: Self::Span, _second: Self::Span) -> Option<Self::Span> {
None // 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 { fn resolved_at(&mut self, _span: Self::Span, _at: Self::Span) -> Self::Span {
// FIXME handle span // FIXME handle span

View file

@ -677,8 +677,9 @@ impl server::Span for Rustc {
// FIXME handle span // FIXME handle span
LineColumn { line: 0, column: 0 } LineColumn { line: 0, column: 0 }
} }
fn join(&mut self, _first: Self::Span, _second: Self::Span) -> Option<Self::Span> { fn join(&mut self, first: Self::Span, _second: Self::Span) -> Option<Self::Span> {
None // 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 { fn resolved_at(&mut self, _span: Self::Span, _at: Self::Span) -> Self::Span {
// FIXME handle span // FIXME handle span

View file

@ -681,8 +681,9 @@ impl server::Span for Rustc {
// FIXME handle span // FIXME handle span
LineColumn { line: 0, column: 0 } LineColumn { line: 0, column: 0 }
} }
fn join(&mut self, _first: Self::Span, _second: Self::Span) -> Option<Self::Span> { fn join(&mut self, first: Self::Span, _second: Self::Span) -> Option<Self::Span> {
None // 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 { fn resolved_at(&mut self, _span: Self::Span, _at: Self::Span) -> Self::Span {
// FIXME handle span // FIXME handle span