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)
// And does not include:
// '\u{FEFF}' (zero width non-breaking space)
match c {
// Explicit whitespace: https://tc39.es/ecma262/#sec-white-space
'\u{0009}' | '\u{000B}' | '\u{000C}' | '\u{0020}' | '\u{00A0}' | '\u{FEFF}' |
// Unicode Space_Seperator category
'\u{1680}' | '\u{2000}'..='\u{200A}' | '\u{202F}' | '\u{205F}' | '\u{3000}' |
// Line terminators: https://tc39.es/ecma262/#sec-line-terminators
'\u{000A}' | '\u{000D}' | '\u{2028}' | '\u{2029}' => true,
_ => false,
}
// Explicit whitespace: https://tc39.es/ecma262/#sec-white-space
matches!(
c,
'\u{0009}' | '\u{000B}' | '\u{000C}' | '\u{0020}' | '\u{00A0}' | '\u{FEFF}' |
// Unicode Space_Seperator category
'\u{1680}' | '\u{2000}'
..='\u{200A}' | '\u{202F}' | '\u{205F}' | '\u{3000}' |
// Line terminators: https://tc39.es/ecma262/#sec-line-terminators
'\u{000A}' | '\u{000D}' | '\u{2028}' | '\u{2029}'
)
}
/// 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 {
match self.this_binding_status {
BindingStatus::Lexical => false,
_ => true,
}
!matches!(self.this_binding_status, BindingStatus::Lexical)
}
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)
let env = self
.environments()
.find(|env| match env.borrow().get_environment_type() {
EnvironmentType::Function | EnvironmentType::Global => true,
_ => false,
.find(|env| {
matches!(
env.borrow().get_environment_type(),
EnvironmentType::Function | EnvironmentType::Global
)
})
.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)
let env = self
.environments()
.find(|env| match env.borrow().get_environment_type() {
EnvironmentType::Function | EnvironmentType::Global => true,
_ => false,
.find(|env| {
matches!(
env.borrow().get_environment_type(),
EnvironmentType::Function | EnvironmentType::Global
)
})
.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)
fn is_whitespace(ch: char) -> bool {
match ch {
matches!(
ch,
'\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)
'\u{1680}' | '\u{2000}'..='\u{200A}' | '\u{202F}' | '\u{205F}' | '\u{3000}' => true,
_ => false,
}
'\u{1680}' | '\u{2000}'..='\u{200A}' | '\u{202F}' | '\u{205F}' | '\u{3000}'
)
}
/// Sets the goal symbol for the lexer.

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

@ -60,16 +60,16 @@ where
R: Read,
{
Ok(if let Some(tok) = cursor.peek(0)? {
match tok.kind() {
matches!(
tok.kind(),
TokenKind::Keyword(Keyword::Delete)
| TokenKind::Keyword(Keyword::Void)
| TokenKind::Keyword(Keyword::TypeOf)
| TokenKind::Punctuator(Punctuator::Add)
| TokenKind::Punctuator(Punctuator::Sub)
| TokenKind::Punctuator(Punctuator::Not)
| TokenKind::Punctuator(Punctuator::Neg) => true,
_ => false,
}
| TokenKind::Keyword(Keyword::Void)
| TokenKind::Keyword(Keyword::TypeOf)
| TokenKind::Punctuator(Punctuator::Add)
| TokenKind::Punctuator(Punctuator::Sub)
| TokenKind::Punctuator(Punctuator::Not)
| TokenKind::Punctuator(Punctuator::Neg)
)
} else {
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
#[inline]
pub(crate) fn is_assignable(node: &Node) -> bool {
if let Node::Const(_) | Node::ArrayDecl(_) = node {
false
} else {
true
}
!matches!(node, Node::Const(_) | Node::ArrayDecl(_))
}

5
boa/src/value/mod.rs

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

Loading…
Cancel
Save