]> git.lizzy.rs Git - rust.git/commitdiff
Small doc improvements.
authorJulian Wollersberger <24991778+Julian-Wollersberger@users.noreply.github.com>
Sat, 25 Apr 2020 18:19:54 +0000 (20:19 +0200)
committerJulian Wollersberger <24991778+Julian-Wollersberger@users.noreply.github.com>
Sat, 9 May 2020 11:46:03 +0000 (13:46 +0200)
The phrasing is from the commit description of 395ee0b79f23b90593b01dd0a78451b8c93b0aa6 by @Matklad.

src/librustc_lexer/src/lib.rs

index 5ccfc1b276bfa0e1c71372aa4f3c99e588d0eff8..e44feee96607a7d4d0eaf669945bf8fa1c29b5d0 100644 (file)
@@ -1,5 +1,11 @@
 //! Low-level Rust lexer.
 //!
+//! The idea with `librustc_lexer` is to make a reusable library,
+//! by separating out pure lexing and rustc-specific concerns, like spans,
+//! error reporting an interning.  So, rustc_lexer operates directly on `&str`,
+//! produces simple tokens which are a pair of type-tag and a bit of original text,
+//! and does not report errors, instead storing them as flags on the token.
+//!
 //! Tokens produced by this lexer are not yet ready for parsing the Rust syntax,
 //! for that see `librustc_parse::lexer`, which converts this basic token stream
 //! into wide tokens used by actual parser.
@@ -719,6 +725,9 @@ fn raw_double_quoted_string(&mut self, prefix_len: usize) -> UnvalidatedRawStr {
 
             // Check that amount of closing '#' symbols
             // is equal to the amount of opening ones.
+            // Note that this will not consume extra trailing `#` characters:
+            // `r###"abcde"####` is lexed as a `LexedRawString { n_hashes: 3 }`
+            // followed by a `#` token.
             let mut hashes_left = n_start_hashes;
             let is_closing_hash = |c| {
                 if c == '#' && hashes_left != 0 {
@@ -739,8 +748,8 @@ fn raw_double_quoted_string(&mut self, prefix_len: usize) -> UnvalidatedRawStr {
                     possible_terminator_offset: None,
                 };
             } else if n_end_hashes > max_hashes {
-                // Keep track of possible terminators to give a hint about where there might be
-                // a missing terminator
+                // Keep track of possible terminators to give a hint about
+                // where there might be a missing terminator
                 possible_terminator_offset =
                     Some(self.len_consumed() - start_pos - n_end_hashes + prefix_len);
                 max_hashes = n_end_hashes;