mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 04:53:34 +00:00
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 <jonas.schievink@ferrous-systems.com>
This commit is contained in:
commit
de5925da5c
5 changed files with 15 additions and 10 deletions
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue