Browse Source

Fix new lints for Rust 1.73 (#3361)

pull/3366/head
José Julián Espina 1 year ago committed by GitHub
parent
commit
a56ce510d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      boa_ast/src/lib.rs
  2. 1
      boa_cli/src/main.rs
  3. 2
      boa_engine/src/builtins/string/mod.rs
  4. 2
      boa_engine/src/bytecompiler/mod.rs
  5. 1
      boa_engine/src/lib.rs
  6. 2
      boa_engine/src/string/mod.rs
  7. 2
      boa_engine/src/symbol.rs
  8. 1
      boa_engine/src/value/conversions/mod.rs
  9. 2
      boa_engine/src/value/operations.rs
  10. 5
      boa_gc/src/lib.rs
  11. 1
      boa_icu_provider/src/lib.rs
  12. 1
      boa_interner/src/lib.rs
  13. 1
      boa_macros/src/lib.rs
  14. 57
      boa_parser/src/error/mod.rs
  15. 1
      boa_parser/src/lib.rs
  16. 2
      boa_parser/src/parser/expression/left_hand_side/optional/mod.rs
  17. 1
      boa_profiler/src/lib.rs
  18. 1
      boa_runtime/src/lib.rs
  19. 2
      boa_tester/src/exec/mod.rs
  20. 1
      boa_tester/src/main.rs
  21. 1
      boa_wasm/src/lib.rs

1
boa_ast/src/lib.rs

@ -70,7 +70,6 @@
clippy::complexity, clippy::complexity,
clippy::perf, clippy::perf,
clippy::pedantic, clippy::pedantic,
clippy::nursery,
)] )]
#![allow( #![allow(
clippy::module_name_repetitions, clippy::module_name_repetitions,

1
boa_cli/src/main.rs

@ -57,7 +57,6 @@
clippy::complexity, clippy::complexity,
clippy::perf, clippy::perf,
clippy::pedantic, clippy::pedantic,
clippy::nursery,
)] )]
mod debug; mod debug;

2
boa_engine/src/builtins/string/mod.rs

@ -730,7 +730,7 @@ impl String {
Ok(js_string!(result).into()) Ok(js_string!(result).into())
} }
// 5. If n is 0, return the empty String. // 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. // 4. If n < 0 or n is +∞, throw a RangeError exception.
_ => Err(JsNativeError::range() _ => Err(JsNativeError::range()
.with_message( .with_message(

2
boa_engine/src/bytecompiler/mod.rs

@ -1098,7 +1098,6 @@ impl<'ctx, 'host> ByteCompiler<'ctx, 'host> {
for variable in decl.0.as_ref() { for variable in decl.0.as_ref() {
match variable.binding() { match variable.binding() {
Binding::Identifier(ident) => { Binding::Identifier(ident) => {
let ident = ident;
if let Some(expr) = variable.init() { if let Some(expr) = variable.init() {
self.compile_expr(expr, true); self.compile_expr(expr, true);
self.emit_binding(BindingOpcode::InitVar, *ident); self.emit_binding(BindingOpcode::InitVar, *ident);
@ -1126,7 +1125,6 @@ impl<'ctx, 'host> ByteCompiler<'ctx, 'host> {
for variable in decls.as_ref() { for variable in decls.as_ref() {
match variable.binding() { match variable.binding() {
Binding::Identifier(ident) => { Binding::Identifier(ident) => {
let ident = ident;
if let Some(expr) = variable.init() { if let Some(expr) = variable.init() {
self.compile_expr(expr, true); self.compile_expr(expr, true);
} else { } else {

1
boa_engine/src/lib.rs

@ -103,7 +103,6 @@
clippy::complexity, clippy::complexity,
clippy::perf, clippy::perf,
clippy::pedantic, clippy::pedantic,
clippy::nursery,
)] )]
#![allow( #![allow(
// Currently throws a false positive regarding dependencies that are only used in benchmarks. // Currently throws a false positive regarding dependencies that are only used in benchmarks.

2
boa_engine/src/string/mod.rs

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

2
boa_engine/src/symbol.rs

@ -340,7 +340,7 @@ impl PartialEq for JsSymbol {
impl PartialOrd for JsSymbol { impl PartialOrd for JsSymbol {
#[inline] #[inline]
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> { fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.hash().partial_cmp(&other.hash()) Some(self.cmp(other))
} }
} }

1
boa_engine/src/value/conversions/mod.rs

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

2
boa_engine/src/value/operations.rs

@ -477,7 +477,7 @@ impl JsValue {
), ),
Self::String(ref str) => Self::new(-str.to_number()), Self::String(ref str) => Self::new(-str.to_number()),
Self::Rational(num) => Self::new(-num), 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::Integer(num) => Self::new(-num),
Self::Boolean(true) => Self::new(1), Self::Boolean(true) => Self::new(1),
Self::Boolean(false) | Self::Null => Self::new(0), Self::Boolean(false) | Self::Null => Self::new(0),

5
boa_gc/src/lib.rs

@ -62,7 +62,6 @@
clippy::complexity, clippy::complexity,
clippy::perf, clippy::perf,
clippy::pedantic, clippy::pedantic,
clippy::nursery,
)] )]
#![allow( #![allow(
clippy::module_name_repetitions, clippy::module_name_repetitions,
@ -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. // 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. // Then, we can find whether there is a reference from other places, and they are the roots.
let mut strong = &gc.strong_start; let mut strong = &gc.strong_start;
@ -522,7 +521,7 @@ impl Collector {
} }
// Clean up the heap when BoaGc is dropped // 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. // 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. // This can be done without initializing a dropguard since no GcBox's are being dropped.
let weak_map_head = &gc.weak_map_start; let weak_map_head = &gc.weak_map_start;

1
boa_icu_provider/src/lib.rs

@ -70,7 +70,6 @@
clippy::complexity, clippy::complexity,
clippy::perf, clippy::perf,
clippy::pedantic, clippy::pedantic,
clippy::nursery,
)] )]
#![allow(elided_lifetimes_in_paths)] #![allow(elided_lifetimes_in_paths)]
#![cfg_attr(not(feature = "bin"), no_std)] #![cfg_attr(not(feature = "bin"), no_std)]

1
boa_interner/src/lib.rs

@ -67,7 +67,6 @@
clippy::complexity, clippy::complexity,
clippy::perf, clippy::perf,
clippy::pedantic, clippy::pedantic,
clippy::nursery,
)] )]
#![allow( #![allow(
clippy::redundant_pub_crate, clippy::redundant_pub_crate,

1
boa_macros/src/lib.rs

@ -57,7 +57,6 @@
clippy::complexity, clippy::complexity,
clippy::perf, clippy::perf,
clippy::pedantic, clippy::pedantic,
clippy::nursery,
)] )]
use proc_macro::TokenStream; use proc_macro::TokenStream;

57
boa_parser/src/error/mod.rs

@ -183,38 +183,31 @@ impl fmt::Display for Error {
found, found,
span, span,
context, context,
} => write!( } => {
f, write!(f, "expected ")?;
"expected {}, got '{found}' in {context} at line {}, col {}", match &**expected {
if expected.len() == 1 { [single] => write!(f, "token '{single}'")?,
format!( expected => {
"token '{}'", write!(f, "one of ")?;
expected.first().expect("already checked that length is 1") for (i, token) in expected.iter().enumerate() {
) let prefix = if i == 0 {
} else { ""
format!( } else if i == expected.len() - 1 {
"one of {}", " or "
expected } else {
.iter() ", "
.enumerate() };
.map(|(i, t)| { write!(f, "{prefix}'{token}'")?;
format!( }
"{}'{t}'", }
if i == 0 { }
"" write!(
} else if i == expected.len() - 1 { f,
" or " ", got '{found}' in {context} at line {}, col {}",
} else { span.start().line_number(),
", " span.start().column_number()
}, )
) }
})
.collect::<String>()
)
},
span.start().line_number(),
span.start().column_number()
),
Self::Unexpected { Self::Unexpected {
found, found,
span, span,

1
boa_parser/src/lib.rs

@ -67,7 +67,6 @@
clippy::complexity, clippy::complexity,
clippy::perf, clippy::perf,
clippy::pedantic, clippy::pedantic,
clippy::nursery,
)] )]
#![allow( #![allow(
clippy::module_name_repetitions, clippy::module_name_repetitions,

2
boa_parser/src/parser/expression/left_hand_side/optional/mod.rs

@ -62,7 +62,7 @@ where
fn parse(self, cursor: &mut Cursor<R>, interner: &mut Interner) -> ParseResult<Self::Output> { fn parse(self, cursor: &mut Cursor<R>, interner: &mut Interner) -> ParseResult<Self::Output> {
fn parse_const_access( fn parse_const_access(
token: &Token, token: &Token,
interner: &mut Interner, interner: &Interner,
) -> ParseResult<OptionalOperationKind> { ) -> ParseResult<OptionalOperationKind> {
let item = match token.kind() { let item = match token.kind() {
TokenKind::IdentifierName((name, _)) => { TokenKind::IdentifierName((name, _)) => {

1
boa_profiler/src/lib.rs

@ -64,7 +64,6 @@
clippy::complexity, clippy::complexity,
clippy::perf, clippy::perf,
clippy::pedantic, clippy::pedantic,
clippy::nursery,
)] )]
#![cfg_attr(not(feature = "profiler"), no_std)] #![cfg_attr(not(feature = "profiler"), no_std)]

1
boa_runtime/src/lib.rs

@ -96,7 +96,6 @@
clippy::complexity, clippy::complexity,
clippy::perf, clippy::perf,
clippy::pedantic, clippy::pedantic,
clippy::nursery,
)] )]
#![allow( #![allow(
clippy::module_name_repetitions, clippy::module_name_repetitions,

2
boa_tester/src/exec/mod.rs

@ -634,7 +634,7 @@ fn register_print_fn(context: &mut Context<'_>, async_result: AsyncResult) {
let mut result = async_result.inner.borrow_mut(); let mut result = async_result.inner.borrow_mut();
match *result { match *result {
UninitResult::Uninit | UninitResult::Ok(_) => { UninitResult::Uninit | UninitResult::Ok(()) => {
if message == "Test262:AsyncTestComplete" { if message == "Test262:AsyncTestComplete" {
*result = UninitResult::Ok(()); *result = UninitResult::Ok(());
} else { } else {

1
boa_tester/src/main.rs

@ -60,7 +60,6 @@
clippy::complexity, clippy::complexity,
clippy::perf, clippy::perf,
clippy::pedantic, clippy::pedantic,
clippy::nursery,
)] )]
#![allow( #![allow(
clippy::too_many_lines, clippy::too_many_lines,

1
boa_wasm/src/lib.rs

@ -57,7 +57,6 @@
clippy::complexity, clippy::complexity,
clippy::perf, clippy::perf,
clippy::pedantic, clippy::pedantic,
clippy::nursery,
)] )]
use boa_engine::{Context, Source}; use boa_engine::{Context, Source};

Loading…
Cancel
Save