1
Fork 0

Rollup merge of #109203 - Ezrashaw:refactor-ident-parsing, r=Nilstrieb

refactor/feat: refactor identifier parsing a bit

\+ error recovery for `expected_ident_found`

Prior art: #108854
This commit is contained in:
Matthias Krüger 2023-03-22 22:44:39 +01:00 committed by GitHub
commit 34fa6daa5c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 256 additions and 101 deletions

View file

@ -795,6 +795,18 @@ impl Span {
})
}
/// Splits a span into two composite spans around a certain position.
pub fn split_at(self, pos: u32) -> (Span, Span) {
let len = self.hi().0 - self.lo().0;
debug_assert!(pos <= len);
let split_pos = BytePos(self.lo().0 + pos);
(
Span::new(self.lo(), split_pos, self.ctxt(), self.parent()),
Span::new(split_pos, self.hi(), self.ctxt(), self.parent()),
)
}
/// Returns a `Span` that would enclose both `self` and `end`.
///
/// Note that this can also be used to extend the span "backwards":