diff options
| author | Zack M. Davis <code@zackmdavis.net> | 2016-07-03 14:38:37 -0700 |
|---|---|---|
| committer | Zack M. Davis <code@zackmdavis.net> | 2016-07-03 16:27:02 -0700 |
| commit | d37edef9dd088d953c5e272db37686a338c31778 (patch) | |
| tree | 294c125abc99a5d3e7d788c2cc0b056ecd35a26e /src/libsyntax/parse/lexer | |
| parent | 5e858f34df6ac9ae9d2fbc40c84db9d4bcd29eff (diff) | |
| download | rust-d37edef9dd088d953c5e272db37686a338c31778.tar.gz rust-d37edef9dd088d953c5e272db37686a338c31778.zip | |
prefer `if let` to match with `None => {}` arm in some places
This is a spiritual succesor to #34268/8531d581, in which we replaced a number of matches of None to the unit value with `if let` conditionals where it was judged that this made for clearer/simpler code (as would be recommended by Manishearth/rust-clippy's `single_match` lint). The same rationale applies to matches of None to the empty block.
Diffstat (limited to 'src/libsyntax/parse/lexer')
| -rw-r--r-- | src/libsyntax/parse/lexer/mod.rs | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index 809f4daa361..77b5c10899a 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -470,15 +470,12 @@ impl<'a> StringReader<'a> { /// PRECONDITION: self.curr is not whitespace /// Eats any kind of comment. fn scan_comment(&mut self) -> Option<TokenAndSpan> { - match self.curr { - Some(c) => { - if c.is_whitespace() { - self.span_diagnostic.span_err(syntax_pos::mk_sp(self.last_pos, self.last_pos), - "called consume_any_line_comment, but there \ - was whitespace"); - } + if let Some(c) = self.curr { + if c.is_whitespace() { + self.span_diagnostic.span_err(syntax_pos::mk_sp(self.last_pos, self.last_pos), + "called consume_any_line_comment, but there \ + was whitespace"); } - None => {} } if self.curr_is('/') { |
