mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 11:07:42 +00:00
Auto merge of #60182 - matklad:lexer-cleanup, r=petrochenkov
Lexer cleanup another couple of tiny cleanups
This commit is contained in:
commit
c7fcbfbf1f
@ -446,9 +446,7 @@ impl<'a> StringReader<'a> {
|
|||||||
self.with_str_from_to(start, self.pos, f)
|
self.with_str_from_to(start, self.pos, f)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a Name from a given offset to the current offset, each
|
/// Creates a Name from a given offset to the current offset.
|
||||||
/// adjusted 1 towards each other (assumes that on either side there is a
|
|
||||||
/// single-byte delimiter).
|
|
||||||
fn name_from(&self, start: BytePos) -> ast::Name {
|
fn name_from(&self, start: BytePos) -> ast::Name {
|
||||||
debug!("taking an ident from {:?} to {:?}", start, self.pos);
|
debug!("taking an ident from {:?} to {:?}", start, self.pos);
|
||||||
self.with_str_from(start, Symbol::intern)
|
self.with_str_from(start, Symbol::intern)
|
||||||
@ -1420,8 +1418,8 @@ impl<'a> StringReader<'a> {
|
|||||||
// Include the leading `'` in the real identifier, for macro
|
// Include the leading `'` in the real identifier, for macro
|
||||||
// expansion purposes. See #12512 for the gory details of why
|
// expansion purposes. See #12512 for the gory details of why
|
||||||
// this is necessary.
|
// this is necessary.
|
||||||
let ident = self.with_str_from(start, |lifetime_name| {
|
let ident = self.with_str_from(start_with_quote, |lifetime_name| {
|
||||||
self.mk_ident(&format!("'{}", lifetime_name))
|
self.mk_ident(lifetime_name)
|
||||||
});
|
});
|
||||||
|
|
||||||
if c2.is_numeric() {
|
if c2.is_numeric() {
|
||||||
|
@ -366,7 +366,7 @@ fn char_lit(lit: &str, diag: Option<(Span, &Handler)>) -> (char, isize) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Parses a string representing a string literal into its final form. Does unescaping.
|
/// Parses a string representing a string literal into its final form. Does unescaping.
|
||||||
pub fn str_lit(lit: &str, diag: Option<(Span, &Handler)>) -> String {
|
fn str_lit(lit: &str, diag: Option<(Span, &Handler)>) -> String {
|
||||||
debug!("str_lit: given {}", lit.escape_default());
|
debug!("str_lit: given {}", lit.escape_default());
|
||||||
let mut res = String::with_capacity(lit.len());
|
let mut res = String::with_capacity(lit.len());
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user