Skip to content

Commit

Permalink
Fix new lints for Rust 1.73 (#3361)
Browse files Browse the repository at this point in the history
  • Loading branch information
jedel1043 authored Oct 6, 2023
1 parent 8ae39af commit a56ce51
Show file tree
Hide file tree
Showing 21 changed files with 34 additions and 54 deletions.
1 change: 0 additions & 1 deletion boa_ast/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
clippy::complexity,
clippy::perf,
clippy::pedantic,
clippy::nursery,
)]
#![allow(
clippy::module_name_repetitions,
Expand Down
1 change: 0 additions & 1 deletion boa_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
clippy::complexity,
clippy::perf,
clippy::pedantic,
clippy::nursery,
)]

mod debug;
Expand Down
2 changes: 1 addition & 1 deletion boa_engine/src/builtins/string/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ impl String {
Ok(js_string!(result).into())
}
// 5. If n is 0, return the empty String.
IntegerOrInfinity::Integer(n) if n == 0 => Ok(js_string!().into()),
IntegerOrInfinity::Integer(0) => Ok(js_string!().into()),
// 4. If n < 0 or n is +∞, throw a RangeError exception.
_ => Err(JsNativeError::range()
.with_message(
Expand Down
2 changes: 0 additions & 2 deletions boa_engine/src/bytecompiler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,6 @@ impl<'ctx, 'host> ByteCompiler<'ctx, 'host> {
for variable in decl.0.as_ref() {
match variable.binding() {
Binding::Identifier(ident) => {
let ident = ident;
if let Some(expr) = variable.init() {
self.compile_expr(expr, true);
self.emit_binding(BindingOpcode::InitVar, *ident);
Expand Down Expand Up @@ -1126,7 +1125,6 @@ impl<'ctx, 'host> ByteCompiler<'ctx, 'host> {
for variable in decls.as_ref() {
match variable.binding() {
Binding::Identifier(ident) => {
let ident = ident;
if let Some(expr) = variable.init() {
self.compile_expr(expr, true);
} else {
Expand Down
1 change: 0 additions & 1 deletion boa_engine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@
clippy::complexity,
clippy::perf,
clippy::pedantic,
clippy::nursery,
)]
#![allow(
// Currently throws a false positive regarding dependencies that are only used in benchmarks.
Expand Down
2 changes: 1 addition & 1 deletion boa_engine/src/string/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ impl PartialEq<JsString> for str {

impl PartialOrd for JsString {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self[..].partial_cmp(other)
Some(self.cmp(other))
}
}

Expand Down
2 changes: 1 addition & 1 deletion boa_engine/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ impl PartialEq for JsSymbol {
impl PartialOrd for JsSymbol {
#[inline]
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.hash().partial_cmp(&other.hash())
Some(self.cmp(other))
}
}

Expand Down
1 change: 1 addition & 0 deletions boa_engine/src/value/conversions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ impl From<JsObject> for JsValue {

impl From<()> for JsValue {
#[inline]
#[allow(clippy::pedantic)] // didn't want to increase our MSRV for just a lint.
fn from(_: ()) -> Self {
let _timer = Profiler::global().start_event("From<()>", "value");

Expand Down
2 changes: 1 addition & 1 deletion boa_engine/src/value/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ impl JsValue {
),
Self::String(ref str) => Self::new(-str.to_number()),
Self::Rational(num) => Self::new(-num),
Self::Integer(num) if num == 0 => Self::new(-f64::from(0)),
Self::Integer(0) => Self::new(-f64::from(0)),
Self::Integer(num) => Self::new(-num),
Self::Boolean(true) => Self::new(1),
Self::Boolean(false) | Self::Null => Self::new(0),
Expand Down
5 changes: 2 additions & 3 deletions boa_gc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
clippy::complexity,
clippy::perf,
clippy::pedantic,
clippy::nursery,
)]
#![allow(
clippy::module_name_repetitions,
Expand Down Expand Up @@ -329,7 +328,7 @@ impl Collector {
}
}

fn trace_non_roots(gc: &mut BoaGc) {
fn trace_non_roots(gc: &BoaGc) {
// Count all the handles located in GC heap.
// Then, we can find whether there is a reference from other places, and they are the roots.
let mut strong = &gc.strong_start;
Expand Down Expand Up @@ -522,7 +521,7 @@ impl Collector {
}

// Clean up the heap when BoaGc is dropped
fn dump(gc: &mut BoaGc) {
fn dump(gc: &BoaGc) {
// Weak maps have to be dropped first, since the process dereferences GcBoxes.
// This can be done without initializing a dropguard since no GcBox's are being dropped.
let weak_map_head = &gc.weak_map_start;
Expand Down
1 change: 0 additions & 1 deletion boa_icu_provider/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
clippy::complexity,
clippy::perf,
clippy::pedantic,
clippy::nursery,
)]
#![allow(elided_lifetimes_in_paths)]
#![cfg_attr(not(feature = "bin"), no_std)]
Expand Down
1 change: 0 additions & 1 deletion boa_interner/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
clippy::complexity,
clippy::perf,
clippy::pedantic,
clippy::nursery,
)]
#![allow(
clippy::redundant_pub_crate,
Expand Down
1 change: 0 additions & 1 deletion boa_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
clippy::complexity,
clippy::perf,
clippy::pedantic,
clippy::nursery,
)]

use proc_macro::TokenStream;
Expand Down
57 changes: 25 additions & 32 deletions boa_parser/src/error/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,38 +183,31 @@ impl fmt::Display for Error {
found,
span,
context,
} => write!(
f,
"expected {}, got '{found}' in {context} at line {}, col {}",
if expected.len() == 1 {
format!(
"token '{}'",
expected.first().expect("already checked that length is 1")
)
} else {
format!(
"one of {}",
expected
.iter()
.enumerate()
.map(|(i, t)| {
format!(
"{}'{t}'",
if i == 0 {
""
} else if i == expected.len() - 1 {
" or "
} else {
", "
},
)
})
.collect::<String>()
)
},
span.start().line_number(),
span.start().column_number()
),
} => {
write!(f, "expected ")?;
match &**expected {
[single] => write!(f, "token '{single}'")?,
expected => {
write!(f, "one of ")?;
for (i, token) in expected.iter().enumerate() {
let prefix = if i == 0 {
""
} else if i == expected.len() - 1 {
" or "
} else {
", "
};
write!(f, "{prefix}'{token}'")?;
}
}
}
write!(
f,
", got '{found}' in {context} at line {}, col {}",
span.start().line_number(),
span.start().column_number()
)
}
Self::Unexpected {
found,
span,
Expand Down
1 change: 0 additions & 1 deletion boa_parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
clippy::complexity,
clippy::perf,
clippy::pedantic,
clippy::nursery,
)]
#![allow(
clippy::module_name_repetitions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ where
fn parse(self, cursor: &mut Cursor<R>, interner: &mut Interner) -> ParseResult<Self::Output> {
fn parse_const_access(
token: &Token,
interner: &mut Interner,
interner: &Interner,
) -> ParseResult<OptionalOperationKind> {
let item = match token.kind() {
TokenKind::IdentifierName((name, _)) => {
Expand Down
1 change: 0 additions & 1 deletion boa_profiler/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
clippy::complexity,
clippy::perf,
clippy::pedantic,
clippy::nursery,
)]
#![cfg_attr(not(feature = "profiler"), no_std)]

Expand Down
1 change: 0 additions & 1 deletion boa_runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@
clippy::complexity,
clippy::perf,
clippy::pedantic,
clippy::nursery,
)]
#![allow(
clippy::module_name_repetitions,
Expand Down
2 changes: 1 addition & 1 deletion boa_tester/src/exec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ fn register_print_fn(context: &mut Context<'_>, async_result: AsyncResult) {
let mut result = async_result.inner.borrow_mut();

match *result {
UninitResult::Uninit | UninitResult::Ok(_) => {
UninitResult::Uninit | UninitResult::Ok(()) => {
if message == "Test262:AsyncTestComplete" {
*result = UninitResult::Ok(());
} else {
Expand Down
1 change: 0 additions & 1 deletion boa_tester/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
clippy::complexity,
clippy::perf,
clippy::pedantic,
clippy::nursery,
)]
#![allow(
clippy::too_many_lines,
Expand Down
1 change: 0 additions & 1 deletion boa_wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
clippy::complexity,
clippy::perf,
clippy::pedantic,
clippy::nursery,
)]

use boa_engine::{Context, Source};
Expand Down

0 comments on commit a56ce51

Please sign in to comment.