Browse Source

Fix clippy on Nightly (#668)

pull/734/head
David 4 years ago committed by GitHub
parent
commit
01b5cec04f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 19
      boa/src/builtins/string/mod.rs
  2. 5
      boa/src/environment/function_environment_record.rs
  3. 16
      boa/src/environment/lexical_environment.rs
  4. 8
      boa/src/syntax/lexer/mod.rs
  5. 18
      boa/src/syntax/parser/expression/assignment/exponentiation.rs
  6. 6
      boa/src/syntax/parser/expression/assignment/mod.rs
  7. 5
      boa/src/value/mod.rs

19
boa/src/builtins/string/mod.rs

@ -788,15 +788,16 @@ impl String {
// `\u{0085}' (next line) // `\u{0085}' (next line)
// And does not include: // And does not include:
// '\u{FEFF}' (zero width non-breaking space) // '\u{FEFF}' (zero width non-breaking space)
match c { // Explicit whitespace: https://tc39.es/ecma262/#sec-white-space
// Explicit whitespace: https://tc39.es/ecma262/#sec-white-space matches!(
'\u{0009}' | '\u{000B}' | '\u{000C}' | '\u{0020}' | '\u{00A0}' | '\u{FEFF}' | c,
// Unicode Space_Seperator category '\u{0009}' | '\u{000B}' | '\u{000C}' | '\u{0020}' | '\u{00A0}' | '\u{FEFF}' |
'\u{1680}' | '\u{2000}'..='\u{200A}' | '\u{202F}' | '\u{205F}' | '\u{3000}' | // Unicode Space_Seperator category
// Line terminators: https://tc39.es/ecma262/#sec-line-terminators '\u{1680}' | '\u{2000}'
'\u{000A}' | '\u{000D}' | '\u{2028}' | '\u{2029}' => true, ..='\u{200A}' | '\u{202F}' | '\u{205F}' | '\u{3000}' |
_ => false, // Line terminators: https://tc39.es/ecma262/#sec-line-terminators
} '\u{000A}' | '\u{000D}' | '\u{2028}' | '\u{2029}'
)
} }
/// String.prototype.trim() /// String.prototype.trim()

5
boa/src/environment/function_environment_record.rs

@ -218,10 +218,7 @@ impl EnvironmentRecordTrait for FunctionEnvironmentRecord {
} }
fn has_this_binding(&self) -> bool { fn has_this_binding(&self) -> bool {
match self.this_binding_status { !matches!(self.this_binding_status, BindingStatus::Lexical)
BindingStatus::Lexical => false,
_ => true,
}
} }
fn with_base_object(&self) -> Value { fn with_base_object(&self) -> Value {

16
boa/src/environment/lexical_environment.rs

@ -130,9 +130,11 @@ impl LexicalEnvironment {
// Find the first function or global environment (from the top of the stack) // Find the first function or global environment (from the top of the stack)
let env = self let env = self
.environments() .environments()
.find(|env| match env.borrow().get_environment_type() { .find(|env| {
EnvironmentType::Function | EnvironmentType::Global => true, matches!(
_ => false, env.borrow().get_environment_type(),
EnvironmentType::Function | EnvironmentType::Global
)
}) })
.expect("No function or global environment"); .expect("No function or global environment");
@ -156,9 +158,11 @@ impl LexicalEnvironment {
// Find the first function or global environment (from the top of the stack) // Find the first function or global environment (from the top of the stack)
let env = self let env = self
.environments() .environments()
.find(|env| match env.borrow().get_environment_type() { .find(|env| {
EnvironmentType::Function | EnvironmentType::Global => true, matches!(
_ => false, env.borrow().get_environment_type(),
EnvironmentType::Function | EnvironmentType::Global
)
}) })
.expect("No function or global environment"); .expect("No function or global environment");

8
boa/src/syntax/lexer/mod.rs

@ -70,12 +70,12 @@ impl<R> Lexer<R> {
/// ///
/// [More information](https://tc39.es/ecma262/#table-32) /// [More information](https://tc39.es/ecma262/#table-32)
fn is_whitespace(ch: char) -> bool { fn is_whitespace(ch: char) -> bool {
match ch { matches!(
ch,
'\u{0020}' | '\u{0009}' | '\u{000B}' | '\u{000C}' | '\u{00A0}' | '\u{FEFF}' | '\u{0020}' | '\u{0009}' | '\u{000B}' | '\u{000C}' | '\u{00A0}' | '\u{FEFF}' |
// Unicode Space_Seperator category (minus \u{0020} and \u{00A0} which are allready stated above) // Unicode Space_Seperator category (minus \u{0020} and \u{00A0} which are allready stated above)
'\u{1680}' | '\u{2000}'..='\u{200A}' | '\u{202F}' | '\u{205F}' | '\u{3000}' => true, '\u{1680}' | '\u{2000}'..='\u{200A}' | '\u{202F}' | '\u{205F}' | '\u{3000}'
_ => false, )
}
} }
/// Sets the goal symbol for the lexer. /// Sets the goal symbol for the lexer.

18
boa/src/syntax/parser/expression/assignment/exponentiation.rs

@ -60,16 +60,16 @@ where
R: Read, R: Read,
{ {
Ok(if let Some(tok) = cursor.peek(0)? { Ok(if let Some(tok) = cursor.peek(0)? {
match tok.kind() { matches!(
tok.kind(),
TokenKind::Keyword(Keyword::Delete) TokenKind::Keyword(Keyword::Delete)
| TokenKind::Keyword(Keyword::Void) | TokenKind::Keyword(Keyword::Void)
| TokenKind::Keyword(Keyword::TypeOf) | TokenKind::Keyword(Keyword::TypeOf)
| TokenKind::Punctuator(Punctuator::Add) | TokenKind::Punctuator(Punctuator::Add)
| TokenKind::Punctuator(Punctuator::Sub) | TokenKind::Punctuator(Punctuator::Sub)
| TokenKind::Punctuator(Punctuator::Not) | TokenKind::Punctuator(Punctuator::Not)
| TokenKind::Punctuator(Punctuator::Neg) => true, | TokenKind::Punctuator(Punctuator::Neg)
_ => false, )
}
} else { } else {
false false
}) })

6
boa/src/syntax/parser/expression/assignment/mod.rs

@ -217,9 +217,5 @@ where
/// [spec]: https://tc39.es/ecma262/#sec-assignment-operators-static-semantics-early-errors /// [spec]: https://tc39.es/ecma262/#sec-assignment-operators-static-semantics-early-errors
#[inline] #[inline]
pub(crate) fn is_assignable(node: &Node) -> bool { pub(crate) fn is_assignable(node: &Node) -> bool {
if let Node::Const(_) | Node::ArrayDecl(_) = node { !matches!(node, Node::Const(_) | Node::ArrayDecl(_))
false
} else {
true
}
} }

5
boa/src/value/mod.rs

@ -292,10 +292,7 @@ impl Value {
/// Returns true if the value the global for a Realm /// Returns true if the value the global for a Realm
pub fn is_global(&self) -> bool { pub fn is_global(&self) -> bool {
match self { match self {
Value::Object(object) => match object.borrow().data { Value::Object(object) => matches!(object.borrow().data, ObjectData::Global),
ObjectData::Global => true,
_ => false,
},
_ => false, _ => false,
} }
} }

Loading…
Cancel
Save