Browse Source

Fix rust 1.66.0 lints (#2486)

This Pull Request fixes the new lints introduced in clippy 1.66.0.
pull/2484/head
raskad 2 years ago
parent
commit
e3d35e9b36
  1. 2
      Cargo.toml
  2. 4
      boa_cli/src/main.rs
  3. 2
      boa_engine/src/builtins/function/mod.rs
  4. 2
      boa_engine/src/lib.rs
  5. 2
      boa_engine/src/tests.rs
  6. 6
      boa_engine/src/vm/flowgraph/color.rs
  7. 4
      boa_engine/src/vm/flowgraph/graph.rs
  8. 2
      boa_engine/src/vm/flowgraph/mod.rs
  9. 10
      boa_engine/src/vm/opcode/mod.rs
  10. 4
      boa_parser/src/parser/expression/mod.rs

2
Cargo.toml

@ -17,7 +17,7 @@ members = [
[workspace.package] [workspace.package]
edition = "2021" edition = "2021"
version = "0.16.0" version = "0.16.0"
rust-version = "1.65" rust-version = "1.66"
authors = ["boa-dev"] authors = ["boa-dev"]
repository = "https://github.com/boa-dev/boa" repository = "https://github.com/boa-dev/boa"
license = "Unlicense/MIT" license = "Unlicense/MIT"

4
boa_cli/src/main.rs

@ -272,7 +272,7 @@ fn main() -> Result<(), io::Error> {
flowgraph.unwrap_or(FlowgraphFormat::Graphviz), flowgraph.unwrap_or(FlowgraphFormat::Graphviz),
args.flowgraph_direction, args.flowgraph_direction,
) { ) {
Ok(v) => println!("{}", v), Ok(v) => println!("{v}"),
Err(v) => eprintln!("Uncaught {v}"), Err(v) => eprintln!("Uncaught {v}"),
} }
} else { } else {
@ -328,7 +328,7 @@ fn main() -> Result<(), io::Error> {
flowgraph.unwrap_or(FlowgraphFormat::Graphviz), flowgraph.unwrap_or(FlowgraphFormat::Graphviz),
args.flowgraph_direction, args.flowgraph_direction,
) { ) {
Ok(v) => println!("{}", v), Ok(v) => println!("{v}"),
Err(v) => eprintln!("Uncaught {v}"), Err(v) => eprintln!("Uncaught {v}"),
} }
} else { } else {

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

@ -1017,7 +1017,7 @@ fn set_function_name(
) )
} }
PropertyKey::String(string) => string.clone(), PropertyKey::String(string) => string.clone(),
PropertyKey::Index(index) => js_string!(format!("{}", index)), PropertyKey::Index(index) => js_string!(format!("{index}")),
}; };
// 3. Else if name is a Private Name, then // 3. Else if name is a Private Name, then

2
boa_engine/src/lib.rs

@ -160,7 +160,7 @@ where
{ {
context context
.eval(src.as_ref()) .eval(src.as_ref())
.map_or_else(|e| format!("Uncaught {}", e), |v| v.display().to_string()) .map_or_else(|e| format!("Uncaught {e}"), |v| v.display().to_string())
} }
/// Execute the code using an existing Context. /// Execute the code using an existing Context.

2
boa_engine/src/tests.rs

@ -2091,7 +2091,7 @@ fn bigger_switch_example() {
"#, "#,
); );
assert_eq!(&exec(&scenario), val); assert_eq!(&exec(scenario), val);
} }
} }

6
boa_engine/src/vm/flowgraph/color.rs

@ -33,10 +33,10 @@ impl Color {
#[must_use] #[must_use]
pub fn hsv_to_rgb(h: f64, s: f64, v: f64) -> Self { pub fn hsv_to_rgb(h: f64, s: f64, v: f64) -> Self {
let h_i = (h * 6.0) as i64; let h_i = (h * 6.0) as i64;
let f = h * 6.0 - h_i as f64; let f = h.mul_add(6.0, -h_i as f64);
let p = v * (1.0 - s); let p = v * (1.0 - s);
let q = v * (1.0 - f * s); let q = v * f.mul_add(-s, 1.0);
let t = v * (1.0 - (1.0 - f) * s); let t = v * (1.0 - f).mul_add(-s, 1.0);
let (r, g, b) = match h_i { let (r, g, b) = match h_i {
0 => (v, t, p), 0 => (v, t, p),

4
boa_engine/src/vm/flowgraph/graph.rs

@ -175,7 +175,7 @@ impl SubGraph {
self.label.as_ref() self.label.as_ref()
} }
)); ));
result.push_str(&format!(" direction {}\n", rankdir)); result.push_str(&format!(" direction {rankdir}\n"));
result.push_str(&format!(" {prefix}_{}_start{{Start}}\n", self.label)); result.push_str(&format!(" {prefix}_{}_start{{Start}}\n", self.label));
result.push_str(&format!( result.push_str(&format!(
@ -302,7 +302,7 @@ impl Graph {
Direction::LeftToRight => "LR", Direction::LeftToRight => "LR",
Direction::RightToLeft => "RL", Direction::RightToLeft => "RL",
}; };
result += &format!("graph {}\n", rankdir); result += &format!("graph {rankdir}\n");
for subgraph in &self.subgraphs { for subgraph in &self.subgraphs {
subgraph.mermaid_format(&mut result, ""); subgraph.mermaid_format(&mut result, "");

2
boa_engine/src/vm/flowgraph/mod.rs

@ -92,7 +92,7 @@ impl CodeBlock {
pc += size_of::<u32>(); pc += size_of::<u32>();
let operand_str = self.literals[operand as usize].display().to_string(); let operand_str = self.literals[operand as usize].display().to_string();
let operand_str = operand_str.escape_debug(); let operand_str = operand_str.escape_debug();
let label = format!("{opcode_str} {}", operand_str); let label = format!("{opcode_str} {operand_str}");
graph.add_node(previous_pc, NodeShape::None, label.into(), Color::None); graph.add_node(previous_pc, NodeShape::None, label.into(), Color::None);
graph.add_edge(previous_pc, pc, None, Color::None, EdgeStyle::Line); graph.add_edge(previous_pc, pc, None, Color::None, EdgeStyle::Line);

10
boa_engine/src/vm/opcode/mod.rs

@ -439,7 +439,7 @@ generate_impl! {
/// ///
/// Operands: /// Operands:
/// ///
/// Stack: lhs, rhs **=>** (lhs << rhs) /// Stack: lhs, rhs **=>** `(lhs << rhs)`
ShiftLeft, ShiftLeft,
/// Binary `>>>` operator. /// Binary `>>>` operator.
@ -530,14 +530,14 @@ generate_impl! {
/// ///
/// Operands: /// Operands:
/// ///
/// Stack: lhs, rhs **=>** (lhs < rhs) /// Stack: lhs, rhs **=>** `(lhs < rhs)`
LessThan, LessThan,
/// Binary `<=` operator. /// Binary `<=` operator.
/// ///
/// Operands: /// Operands:
/// ///
/// Stack: lhs, rhs **=>** (lhs <= rhs) /// Stack: lhs, rhs **=>** `(lhs <= rhs)`
LessThanOrEq, LessThanOrEq,
/// Binary `instanceof` operator. /// Binary `instanceof` operator.
@ -1418,7 +1418,7 @@ generate_impl! {
/// ///
/// Operands: /// Operands:
/// ///
/// Stack: received **=>** Option<value>, skip_0, skip_1 /// Stack: received **=>** `Option<value>`, skip_0, skip_1
AsyncGeneratorNext, AsyncGeneratorNext,
/// Delegates the current generator function another generator. /// Delegates the current generator function another generator.
@ -1448,7 +1448,7 @@ generate_impl! {
/// ///
/// Stack: **=>** /// Stack: **=>**
// Safety: Must be last in the list since, we use this for range checking // Safety: Must be last in the list since, we use this for range checking
// in TryFrom<u8> impl. // in `TryFrom<u8>` impl.
Nop, Nop,
} }
} }

4
boa_parser/src/parser/expression/mod.rs

@ -65,9 +65,9 @@ pub(in crate::parser) use {
/// - The `$name` identifier is the name of the `TargetExpression` struct that the parser will be implemented for. /// - The `$name` identifier is the name of the `TargetExpression` struct that the parser will be implemented for.
/// - The `$lower` identifier is the name of the `InnerExpression` struct according to the pattern above. /// - The `$lower` identifier is the name of the `InnerExpression` struct according to the pattern above.
/// ///
/// A list of punctuators (operands between the <TargetExpression> and <InnerExpression>) are passed as the third parameter. /// A list of punctuators (operands between the `TargetExpression` and `InnerExpression`) are passed as the third parameter.
/// ///
/// The fifth parameter is an Option<InputElement> which sets the goal symbol to set before parsing (or None to leave it as is). /// The fifth parameter is an `Option<InputElement>` which sets the goal symbol to set before parsing (or None to leave it as is).
macro_rules! expression { macro_rules! expression {
($name:ident, $lower:ident, [$( $op:path ),*], [$( $low_param:ident ),*], $goal:expr ) => { ($name:ident, $lower:ident, [$( $op:path ),*], [$( $low_param:ident ),*], $goal:expr ) => {
impl<R> TokenParser<R> for $name impl<R> TokenParser<R> for $name

Loading…
Cancel
Save