Lint fixes (#99)

* Replace a single-character string literal with a character literal.

* Use is_some() instead of comparing with Some(_).

* Add code-quotes around type names in comments.

* Use !...is_empty() instead of len() != 0.

* Tidy up redundant returns.

* Remove redundant .clone() calls.

* Remove unnecessary explicit lifetime parameters.

* Tidy up unnecessary '&'s.

* Add parens to make operator precedence explicit.

* Use debug_assert_eq instead of debug_assert with ==.

* Replace a &Vec argument with a &[...].

* Replace `a = a op b` with `a op= b`.

* Avoid unnecessary closures.

* Avoid .iter() and .iter_mut() for iterating over containers.

* Remove unneeded qualification.
This commit is contained in:
Dan Gohman
2017-06-19 16:24:10 -07:00
committed by Jakob Stoklund Olesen
parent 3693735874
commit 0c7316ae28
24 changed files with 132 additions and 137 deletions

View File

@@ -171,7 +171,7 @@ impl<'a> Lexer<'a> {
// Scan a single-char token.
fn scan_char(&mut self, tok: Token<'a>) -> Result<LocatedToken<'a>, LocatedError> {
assert!(self.lookahead != None);
assert_ne!(self.lookahead, None);
let loc = self.loc();
self.next_ch();
token(tok, loc)
@@ -184,7 +184,7 @@ impl<'a> Lexer<'a> {
-> Result<LocatedToken<'a>, LocatedError> {
let loc = self.loc();
for _ in 0..count {
assert!(self.lookahead != None);
assert_ne!(self.lookahead, None);
self.next_ch();
}
token(tok, loc)
@@ -206,7 +206,7 @@ impl<'a> Lexer<'a> {
fn scan_comment(&mut self) -> Result<LocatedToken<'a>, LocatedError> {
let loc = self.loc();
let text = self.rest_of_line();
return token(Token::Comment(text), loc);
token(Token::Comment(text), loc)
}
// Scan a number token which can represent either an integer or floating point number.
@@ -305,8 +305,8 @@ impl<'a> Lexer<'a> {
// decoded token.
fn numbered_entity(prefix: &str, number: u32) -> Option<Token<'a>> {
match prefix {
"v" => Value::with_number(number).map(|v| Token::Value(v)),
"ebb" => Ebb::with_number(number).map(|ebb| Token::Ebb(ebb)),
"v" => Value::with_number(number).map(Token::Value),
"ebb" => Ebb::with_number(number).map(Token::Ebb),
"ss" => Some(Token::StackSlot(number)),
"jt" => Some(Token::JumpTable(number)),
"fn" => Some(Token::FuncRef(number)),
@@ -339,7 +339,7 @@ impl<'a> Lexer<'a> {
};
if is_vector {
if number <= u16::MAX as u32 {
base_type.by(number as u16).map(|t| Token::Type(t))
base_type.by(number as u16).map(Token::Type)
} else {
None
}
@@ -352,7 +352,7 @@ impl<'a> Lexer<'a> {
let loc = self.loc();
let begin = self.pos + 1;
assert!(self.lookahead == Some('%'));
assert_eq!(self.lookahead, Some('%'));
while let Some(c) = self.next_ch() {
if !(c.is_ascii() && c.is_alphanumeric() || c == '_') {
@@ -368,7 +368,7 @@ impl<'a> Lexer<'a> {
let loc = self.loc();
let begin = self.pos + 1;
assert!(self.lookahead == Some('#'));
assert_eq!(self.lookahead, Some('#'));
while let Some(c) = self.next_ch() {
if !char::is_digit(c, 16) {