Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix clippy on Nightly #668

Merged
merged 2 commits into from
Sep 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions boa/src/builtins/string/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
5 changes: 1 addition & 4 deletions boa/src/environment/function_environment_record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
16 changes: 10 additions & 6 deletions boa/src/environment/lexical_environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand All @@ -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");

Expand Down
8 changes: 4 additions & 4 deletions boa/src/syntax/lexer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
18 changes: 9 additions & 9 deletions boa/src/syntax/parser/expression/assignment/exponentiation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
Expand Down
6 changes: 1 addition & 5 deletions boa/src/syntax/parser/expression/assignment/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 1 addition & 4 deletions boa/src/value/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
Expand Down