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:
committed by
Jakob Stoklund Olesen
parent
1a480a2578
commit
61a0844b24
@@ -25,7 +25,7 @@ pub enum IsaSpec {
|
||||
impl IsaSpec {
|
||||
/// If the `IsaSpec` contains exactly 1 `TargetIsa` we return a reference to it
|
||||
pub fn unique_isa(&self) -> Option<&TargetIsa> {
|
||||
if let &IsaSpec::Some(ref isa_vec) = self {
|
||||
if let IsaSpec::Some(ref isa_vec) = *self {
|
||||
if isa_vec.len() == 1 {
|
||||
return Some(&*isa_vec[0]);
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -282,7 +282,7 @@ impl<'a> Parser<'a> {
|
||||
None => break,
|
||||
}
|
||||
}
|
||||
return self.lookahead;
|
||||
self.lookahead
|
||||
}
|
||||
|
||||
// Begin gathering comments associated with `entity`.
|
||||
@@ -397,7 +397,7 @@ impl<'a> Parser<'a> {
|
||||
|
||||
fn error(&self, message: &str) -> Error {
|
||||
Error {
|
||||
location: self.loc.clone(),
|
||||
location: self.loc,
|
||||
message: message.to_string(),
|
||||
}
|
||||
}
|
||||
@@ -1066,7 +1066,7 @@ impl<'a> Parser<'a> {
|
||||
self.consume();
|
||||
self.parse_instruction(results, encoding, result_locations, ctx, ebb)?;
|
||||
}
|
||||
_ if results.len() != 0 => return err!(self.loc, "expected -> or ="),
|
||||
_ if !results.is_empty() => return err!(self.loc, "expected -> or ="),
|
||||
_ => self.parse_instruction(results, encoding, result_locations, ctx, ebb)?,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ impl MutableSourceMap for SourceMap {
|
||||
}
|
||||
|
||||
fn def_entity(&mut self, entity: AnyEntity, loc: &Location) -> Result<()> {
|
||||
if self.locations.insert(entity, loc.clone()).is_some() {
|
||||
if self.locations.insert(entity, *loc).is_some() {
|
||||
err!(loc, "duplicate entity: {}", entity)
|
||||
} else {
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user