]> git.lizzy.rs Git - rust.git/commitdiff
Simplify `start_bpos` calculation in scan_comment().
authorNicholas Nethercote <nnethercote@mozilla.com>
Mon, 3 Oct 2016 07:58:35 +0000 (18:58 +1100)
committerNicholas Nethercote <nnethercote@mozilla.com>
Mon, 3 Oct 2016 08:02:33 +0000 (19:02 +1100)
The two branches of this `if` compute the same value. This commit gets
rid of the first branch, which makes this calculation identical to the
one in scan_block_comment().

src/libsyntax/parse/lexer/mod.rs

index 1b326aeb8ea95f88e824d4784ccbc229a13573e5..0ba2db3310cdae9057e7f2c9f5cd6748f394bf46 100644 (file)
@@ -507,11 +507,7 @@ fn scan_comment(&mut self) -> Option<TokenAndSpan> {
 
                     // line comments starting with "///" or "//!" are doc-comments
                     let doc_comment = self.curr_is('/') || self.curr_is('!');
-                    let start_bpos = if doc_comment {
-                        self.pos - BytePos(3)
-                    } else {
-                        self.last_pos - BytePos(2)
-                    };
+                    let start_bpos = self.last_pos - BytePos(2);
 
                     while !self.is_eof() {
                         match self.curr.unwrap() {