mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-08-21 11:00:26 +00:00
show error offsets in tests
This commit is contained in:
parent
7a1cae59ac
commit
2e722ec54b
46 changed files with 299 additions and 290 deletions
|
@ -13,7 +13,7 @@ pub struct SyntaxError {
|
|||
location: Location,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
#[derive(Clone, PartialEq, Eq, Hash)]
|
||||
pub enum Location {
|
||||
Offset(TextUnit),
|
||||
Range(TextRange),
|
||||
|
@ -31,6 +31,15 @@ impl Into<Location> for TextRange {
|
|||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for Location {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self {
|
||||
Location::Offset(it) => fmt::Debug::fmt(it, f),
|
||||
Location::Range(it) => fmt::Debug::fmt(it, f),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl SyntaxError {
|
||||
pub fn new<L: Into<Location>>(kind: SyntaxErrorKind, loc: L) -> SyntaxError {
|
||||
SyntaxError { kind, location: loc.into() }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue