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

[Merged by Bors] - Fixing build for changes in clippy for Rust 1.61 #2082

Closed
wants to merge 1 commit into from
Closed
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
60 changes: 24 additions & 36 deletions boa_engine/src/builtins/intl/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fn best_avail_loc() {
);

let locale_part = "fr".to_string();
let no_extensions_locale = JsString::new(locale_part.clone() + &"-CA".to_string());
let no_extensions_locale = JsString::new(locale_part.clone() + "-CA");
let available_locales = vec![JsString::new(locale_part.clone())];
assert_eq!(
best_available_locale(&available_locales, &no_extensions_locale,),
Expand All @@ -38,7 +38,7 @@ fn best_avail_loc() {
let ja_kana_t = JsString::new("ja-Kana-JP-t");
let ja_kana = JsString::new("ja-Kana-JP");
let no_extensions_locale = JsString::new("ja-Kana-JP-t-it-latn-it");
let available_locales = vec![ja_kana_t.clone(), ja_kana.clone()];
let available_locales = vec![ja_kana_t, ja_kana.clone()];
assert_eq!(
best_available_locale(&available_locales, &no_extensions_locale,),
Some(ja_kana)
Expand Down Expand Up @@ -108,7 +108,7 @@ fn insert_unicode_ext() {
fn uni_ext_comp() {
let ext = JsString::new("-u-ca-japanese-hc-h12");
let components = unicode_extension_components(&ext);
assert_eq!(components.attributes.is_empty(), true);
assert!(components.attributes.is_empty());
assert_eq!(components.keywords.len(), 2);
assert_eq!(components.keywords[0].key, "ca");
assert_eq!(components.keywords[0].value, "japanese");
Expand All @@ -126,7 +126,7 @@ fn uni_ext_comp() {

let ext = JsString::new("-u-ca-buddhist-kk-nu-thai");
let components = unicode_extension_components(&ext);
assert_eq!(components.attributes.is_empty(), true);
assert!(components.attributes.is_empty());
assert_eq!(components.keywords.len(), 3);
assert_eq!(components.keywords[0].key, "ca");
assert_eq!(components.keywords[0].value, "buddhist");
Expand All @@ -137,7 +137,7 @@ fn uni_ext_comp() {

let ext = JsString::new("-u-ca-islamic-civil");
let components = unicode_extension_components(&ext);
assert_eq!(components.attributes.is_empty(), true);
assert!(components.attributes.is_empty());
assert_eq!(components.keywords.len(), 1);
assert_eq!(components.keywords[0].key, "ca");
assert_eq!(components.keywords[0].value, "islamic-civil");
Expand Down Expand Up @@ -167,7 +167,7 @@ fn locale_resolution() {
);
assert_eq!(locale_record.locale, default_locale());
assert_eq!(locale_record.data_locale, default_locale());
assert_eq!(locale_record.properties.is_empty(), true);
assert!(locale_record.properties.is_empty());

// test best fit
let available_locales = Vec::<JsString>::new();
Expand All @@ -189,7 +189,7 @@ fn locale_resolution() {
);
assert_eq!(locale_record.locale, default_locale());
assert_eq!(locale_record.data_locale, default_locale());
assert_eq!(locale_record.properties.is_empty(), true);
assert!(locale_record.properties.is_empty());

// available: [es-ES], requested: [es-ES]
let available_locales = vec![JsString::new("es-ES")];
Expand All @@ -211,7 +211,7 @@ fn locale_resolution() {
);
assert_eq!(locale_record.locale, "es-ES");
assert_eq!(locale_record.data_locale, "es-ES");
assert_eq!(locale_record.properties.is_empty(), true);
assert!(locale_record.properties.is_empty());

// available: [zh-CN], requested: []
let available_locales = vec![JsString::new("zh-CN")];
Expand All @@ -233,7 +233,7 @@ fn locale_resolution() {
);
assert_eq!(locale_record.locale, default_locale());
assert_eq!(locale_record.data_locale, default_locale());
assert_eq!(locale_record.properties.is_empty(), true);
assert!(locale_record.properties.is_empty());
}

#[test]
Expand Down Expand Up @@ -319,7 +319,7 @@ fn get_opt() {
let other_locale_str = JsString::new("de-DE");
let values = vec![other_locale_str];
options_obj
.set("Locale", locale_value.clone(), true, &mut context)
.set("Locale", locale_value, true, &mut context)
.expect("Setting a property should not fail");
let option_type = GetOptionType::String;
let get_option_result = get_option(
Expand All @@ -330,7 +330,7 @@ fn get_opt() {
&fallback,
&mut context,
);
assert_eq!(get_option_result.is_err(), true);
assert!(get_option_result.is_err());

let value = JsValue::undefined();
let minimum = 1.0;
Expand All @@ -345,21 +345,21 @@ fn get_opt() {
let maximum = 10.0;
let fallback = Some(5.0);
let get_option_result = default_number_option(&value, minimum, maximum, fallback, &mut context);
assert_eq!(get_option_result.is_err(), true);
assert!(get_option_result.is_err());

let value = JsValue::new(0);
let minimum = 1.0;
let maximum = 10.0;
let fallback = Some(5.0);
let get_option_result = default_number_option(&value, minimum, maximum, fallback, &mut context);
assert_eq!(get_option_result.is_err(), true);
assert!(get_option_result.is_err());

let value = JsValue::new(11);
let minimum = 1.0;
let maximum = 10.0;
let fallback = Some(5.0);
let get_option_result = default_number_option(&value, minimum, maximum, fallback, &mut context);
assert_eq!(get_option_result.is_err(), true);
assert!(get_option_result.is_err());

let value_f64 = 7.0;
let value = JsValue::new(value_f64);
Expand All @@ -375,34 +375,22 @@ fn get_opt() {
let maximum = 10.0;
let fallback_val = 5.0;
let fallback = Some(fallback_val);
let get_option_result = get_number_option(
&options,
&property,
minimum,
maximum,
fallback,
&mut context,
);
let get_option_result =
get_number_option(&options, property, minimum, maximum, fallback, &mut context);
assert_eq!(get_option_result, Ok(fallback));

let options = JsObject::empty();
let value_f64 = 8.0;
let value = JsValue::new(value_f64);
let property = "fractionalSecondDigits";
options
.set(property, value.clone(), true, &mut context)
.set(property, value, true, &mut context)
.expect("Setting a property should not fail");
let minimum = 1.0;
let maximum = 10.0;
let fallback = Some(5.0);
let get_option_result = get_number_option(
&options,
&property,
minimum,
maximum,
fallback,
&mut context,
);
let get_option_result =
get_number_option(&options, property, minimum, maximum, fallback, &mut context);
assert_eq!(get_option_result, Ok(Some(value_f64)));
}

Expand All @@ -420,7 +408,7 @@ fn to_date_time_opts() {
&DateTimeReqs::Date,
&mut context,
);
assert_eq!(date_time_opts.is_err(), true);
assert!(date_time_opts.is_err());

let options_obj = JsObject::empty();
options_obj
Expand All @@ -432,7 +420,7 @@ fn to_date_time_opts() {
&DateTimeReqs::Time,
&mut context,
);
assert_eq!(date_time_opts.is_err(), true);
assert!(date_time_opts.is_err());

let date_time_opts = to_date_time_options(
&JsValue::undefined(),
Expand All @@ -453,7 +441,7 @@ fn to_date_time_opts() {
);
assert_eq!(
date_time_opts.get("day", &mut context),
Ok(numeric_jsstring.clone())
Ok(numeric_jsstring)
);

let date_time_opts = to_date_time_options(
Expand All @@ -475,7 +463,7 @@ fn to_date_time_opts() {
);
assert_eq!(
date_time_opts.get("second", &mut context),
Ok(numeric_jsstring.clone())
Ok(numeric_jsstring)
);

let date_time_opts = to_date_time_options(
Expand Down Expand Up @@ -509,6 +497,6 @@ fn to_date_time_opts() {
);
assert_eq!(
date_time_opts.get("second", &mut context),
Ok(numeric_jsstring.clone())
Ok(numeric_jsstring)
);
}
24 changes: 12 additions & 12 deletions boa_engine/src/builtins/typed_array/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3438,22 +3438,22 @@ impl TypedArrayKind {
#[inline]
pub(crate) const fn name(&self) -> &str {
match self {
TypedArrayKind::Int8 => "Int8Array",
TypedArrayKind::Uint8 => "Uint8Array",
TypedArrayKind::Uint8Clamped => "Uint8ClampedArray",
TypedArrayKind::Int16 => "Int16Array",
TypedArrayKind::Uint16 => "Uint16Array",
TypedArrayKind::Int32 => "Int32Array",
TypedArrayKind::Uint32 => "Uint32Array",
TypedArrayKind::BigInt64 => "BigInt64Array",
TypedArrayKind::BigUint64 => "BigUint64Array",
TypedArrayKind::Float32 => "Float32Array",
TypedArrayKind::Float64 => "Float64Array",
Self::Int8 => "Int8Array",
Self::Uint8 => "Uint8Array",
Self::Uint8Clamped => "Uint8ClampedArray",
Self::Int16 => "Int16Array",
Self::Uint16 => "Uint16Array",
Self::Int32 => "Int32Array",
Self::Uint32 => "Uint32Array",
Self::BigInt64 => "BigInt64Array",
Self::BigUint64 => "BigUint64Array",
Self::Float32 => "Float32Array",
Self::Float64 => "Float64Array",
}
}

pub(crate) fn is_big_int_element_type(self) -> bool {
matches!(self, TypedArrayKind::BigUint64 | TypedArrayKind::BigInt64)
matches!(self, Self::BigUint64 | Self::BigInt64)
}
}

Expand Down
3 changes: 1 addition & 2 deletions boa_engine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
clippy::all,
clippy::cast_lossless,
clippy::redundant_closure_for_method_calls,
clippy::use_self,
clippy::unnested_or_patterns,
clippy::trivially_copy_pass_by_ref,
clippy::needless_pass_by_value,
Expand All @@ -49,6 +48,7 @@
nonstandard_style,
)]
#![allow(
clippy::use_self, // TODO: deny once false positives are fixed
clippy::module_name_repetitions,
clippy::cast_possible_truncation,
clippy::cast_sign_loss,
Expand Down Expand Up @@ -99,7 +99,6 @@ pub use crate::{
};

/// The result of a Javascript expression is represented like this so it can succeed (`Ok`) or fail (`Err`)
#[must_use]
pub type JsResult<T> = StdResult<T, JsValue>;

/// Execute the code using an existing `Context`.
Expand Down
4 changes: 2 additions & 2 deletions boa_engine/src/syntax/ast/keyword.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,8 @@ impl Keyword {
/// Gets the keyword as a binary operation, if this keyword is the `in` keyword.
pub fn as_binop(self) -> Option<BinOp> {
match self {
Keyword::In => Some(BinOp::Comp(CompOp::In)),
Keyword::InstanceOf => Some(BinOp::Comp(CompOp::InstanceOf)),
Self::In => Some(BinOp::Comp(CompOp::In)),
Self::InstanceOf => Some(BinOp::Comp(CompOp::InstanceOf)),
_ => None,
}
}
Expand Down
30 changes: 15 additions & 15 deletions boa_engine/src/syntax/ast/node/declaration/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -546,8 +546,8 @@ pub enum BindingPatternTypeObject {
impl ToInternedString for BindingPatternTypeObject {
fn to_interned_string(&self, interner: &Interner) -> String {
match self {
BindingPatternTypeObject::Empty => String::new(),
BindingPatternTypeObject::SingleName {
Self::Empty => String::new(),
Self::SingleName {
ident,
property_name,
default_init,
Expand Down Expand Up @@ -576,18 +576,18 @@ impl ToInternedString for BindingPatternTypeObject {
}
buf
}
BindingPatternTypeObject::RestProperty {
Self::RestProperty {
ident: property_name,
excluded_keys: _,
} => {
format!(" ... {}", interner.resolve_expect(*property_name))
}
BindingPatternTypeObject::RestGetConstField {
Self::RestGetConstField {
get_const_field, ..
} => {
format!(" ... {}", get_const_field.to_interned_string(interner))
}
BindingPatternTypeObject::BindingPattern {
Self::BindingPattern {
ident: property_name,
pattern,
default_init,
Expand Down Expand Up @@ -733,9 +733,9 @@ pub enum BindingPatternTypeArray {
impl ToInternedString for BindingPatternTypeArray {
fn to_interned_string(&self, interner: &Interner) -> String {
match self {
BindingPatternTypeArray::Empty => String::new(),
BindingPatternTypeArray::Elision => " ".to_owned(),
BindingPatternTypeArray::SingleName {
Self::Empty => String::new(),
Self::Elision => " ".to_owned(),
Self::SingleName {
ident,
default_init,
} => {
Expand All @@ -745,25 +745,25 @@ impl ToInternedString for BindingPatternTypeArray {
}
buf
}
BindingPatternTypeArray::GetField { get_field } => {
Self::GetField { get_field } => {
format!(" {}", get_field.to_interned_string(interner))
}
BindingPatternTypeArray::GetConstField { get_const_field } => {
Self::GetConstField { get_const_field } => {
format!(" {}", get_const_field.to_interned_string(interner))
}
BindingPatternTypeArray::BindingPattern { pattern } => {
Self::BindingPattern { pattern } => {
format!(" {}", pattern.to_interned_string(interner))
}
BindingPatternTypeArray::SingleNameRest { ident } => {
Self::SingleNameRest { ident } => {
format!(" ... {}", interner.resolve_expect(*ident))
}
BindingPatternTypeArray::GetFieldRest { get_field } => {
Self::GetFieldRest { get_field } => {
format!(" ... {}", get_field.to_interned_string(interner))
}
BindingPatternTypeArray::GetConstFieldRest { get_const_field } => {
Self::GetConstFieldRest { get_const_field } => {
format!(" ... {}", get_const_field.to_interned_string(interner))
}
BindingPatternTypeArray::BindingPatternRest { pattern } => {
Self::BindingPatternRest { pattern } => {
format!(" ... {}", pattern.to_interned_string(interner))
}
}
Expand Down
10 changes: 5 additions & 5 deletions boa_engine/src/value/equality.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,11 @@ impl JsValue {
fn same_value_non_numeric(x: &Self, y: &Self) -> bool {
debug_assert!(x.get_type() == y.get_type());
match (x, y) {
(JsValue::Null, JsValue::Null) | (JsValue::Undefined, JsValue::Undefined) => true,
(JsValue::String(ref x), JsValue::String(ref y)) => x == y,
(JsValue::Boolean(x), JsValue::Boolean(y)) => x == y,
(JsValue::Object(ref x), JsValue::Object(ref y)) => JsObject::equals(x, y),
(JsValue::Symbol(ref x), JsValue::Symbol(ref y)) => x == y,
(Self::Null, Self::Null) | (Self::Undefined, Self::Undefined) => true,
(Self::String(ref x), Self::String(ref y)) => x == y,
(Self::Boolean(x), Self::Boolean(y)) => x == y,
(Self::Object(ref x), Self::Object(ref y)) => JsObject::equals(x, y),
(Self::Symbol(ref x), Self::Symbol(ref y)) => x == y,
_ => false,
}
}
Expand Down
Loading