From c29a98e40d825c7f0f6a1d9013747266e835d0be Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 23 Apr 2019 00:03:57 +0300 Subject: [PATCH 1/3] remove obsolete and incorrect comment --- src/libsyntax/parse/lexer/mod.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index aad2acfd6d4..61322985b9a 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -446,9 +446,7 @@ impl<'a> StringReader<'a> { self.with_str_from_to(start, self.pos, f) } - /// Creates a Name from a given offset to the current offset, each - /// adjusted 1 towards each other (assumes that on either side there is a - /// single-byte delimiter). + /// Creates a Name from a given offset to the current offset. fn name_from(&self, start: BytePos) -> ast::Name { debug!("taking an ident from {:?} to {:?}", start, self.pos); self.with_str_from(start, Symbol::intern) From 28ce23fe8bfee55a0810b4347423e66c7621650a Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 23 Apr 2019 00:05:06 +0300 Subject: [PATCH 2/3] simplify and avoid allocation --- src/libsyntax/parse/lexer/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index 61322985b9a..cf8f8abe2ab 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -1418,8 +1418,8 @@ impl<'a> StringReader<'a> { // Include the leading `'` in the real identifier, for macro // expansion purposes. See #12512 for the gory details of why // this is necessary. - let ident = self.with_str_from(start, |lifetime_name| { - self.mk_ident(&format!("'{}", lifetime_name)) + let ident = self.with_str_from(start_with_quote, |lifetime_name| { + self.mk_ident(lifetime_name) }); if c2.is_numeric() { From b83ea7f91799fd2178de1cc4e897c5b605697965 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 23 Apr 2019 00:51:38 +0300 Subject: [PATCH 3/3] reduce visibility --- src/libsyntax/parse/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 371e8fe5cf6..1abc7832ffa 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -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. -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()); let mut res = String::with_capacity(lit.len());