diff --git a/ABOUT.md b/ABOUT.md index 0deb7c9a49..3cde6cc603 100644 --- a/ABOUT.md +++ b/ABOUT.md @@ -8,7 +8,7 @@ website][boa-web]. Try out the most recent release with Boa's live demo [playground][boa-playground]. -# Boa Crates +## Boa Crates - [**`boa_ast`**][ast] - Boa's ECMAScript Abstract Syntax Tree. - [**`boa_engine`**][engine] - Boa's implementation of ECMAScript builtin objects and diff --git a/Cargo.toml b/Cargo.toml index c9e9b54641..644088cec2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,4 +1,5 @@ [workspace] +resolver = "2" members = [ "boa_ast", "boa_cli", diff --git a/boa_ast/src/declaration/variable.rs b/boa_ast/src/declaration/variable.rs index 3ab8d13a47..d010c8eb73 100644 --- a/boa_ast/src/declaration/variable.rs +++ b/boa_ast/src/declaration/variable.rs @@ -199,7 +199,7 @@ impl VisitWith for VariableList { where V: Visitor<'a>, { - for variable in self.list.iter() { + for variable in &*self.list { try_break!(visitor.visit_variable(variable)); } ControlFlow::Continue(()) @@ -209,7 +209,7 @@ impl VisitWith for VariableList { where V: VisitorMut<'a>, { - for variable in self.list.iter_mut() { + for variable in &mut *self.list { try_break!(visitor.visit_variable_mut(variable)); } ControlFlow::Continue(()) diff --git a/boa_ast/src/expression/call.rs b/boa_ast/src/expression/call.rs index 8954d9e021..083b182031 100644 --- a/boa_ast/src/expression/call.rs +++ b/boa_ast/src/expression/call.rs @@ -78,7 +78,7 @@ impl VisitWith for Call { V: Visitor<'a>, { try_break!(visitor.visit_expression(&self.function)); - for expr in self.args.iter() { + for expr in &*self.args { try_break!(visitor.visit_expression(expr)); } ControlFlow::Continue(()) @@ -89,7 +89,7 @@ impl VisitWith for Call { V: VisitorMut<'a>, { try_break!(visitor.visit_expression_mut(&mut self.function)); - for expr in self.args.iter_mut() { + for expr in &mut *self.args { try_break!(visitor.visit_expression_mut(expr)); } ControlFlow::Continue(()) @@ -146,7 +146,7 @@ impl VisitWith for SuperCall { where V: Visitor<'a>, { - for expr in self.args.iter() { + for expr in &*self.args { try_break!(visitor.visit_expression(expr)); } ControlFlow::Continue(()) @@ -156,7 +156,7 @@ impl VisitWith for SuperCall { where V: VisitorMut<'a>, { - for expr in self.args.iter_mut() { + for expr in &mut *self.args { try_break!(visitor.visit_expression_mut(expr)); } ControlFlow::Continue(()) diff --git a/boa_ast/src/expression/literal/object.rs b/boa_ast/src/expression/literal/object.rs index cca61e63f5..578deadbf0 100644 --- a/boa_ast/src/expression/literal/object.rs +++ b/boa_ast/src/expression/literal/object.rs @@ -206,7 +206,7 @@ impl ToIndentedString for ObjectLiteral { fn to_indented_string(&self, interner: &Interner, indent_n: usize) -> String { let mut buf = "{\n".to_owned(); let indentation = " ".repeat(indent_n + 1); - for property in self.properties().iter() { + for property in &*self.properties { buf.push_str(&match property { PropertyDefinition::IdentifierReference(ident) => { format!("{indentation}{},\n", interner.resolve_expect(ident.sym())) @@ -324,7 +324,7 @@ impl VisitWith for ObjectLiteral { where V: Visitor<'a>, { - for pd in self.properties.iter() { + for pd in &*self.properties { try_break!(visitor.visit_property_definition(pd)); } ControlFlow::Continue(()) @@ -334,7 +334,7 @@ impl VisitWith for ObjectLiteral { where V: VisitorMut<'a>, { - for pd in self.properties.iter_mut() { + for pd in &mut *self.properties { try_break!(visitor.visit_property_definition_mut(pd)); } ControlFlow::Continue(()) diff --git a/boa_ast/src/expression/literal/template.rs b/boa_ast/src/expression/literal/template.rs index 692bb9fa4a..1bc6d487b7 100644 --- a/boa_ast/src/expression/literal/template.rs +++ b/boa_ast/src/expression/literal/template.rs @@ -70,7 +70,7 @@ impl ToInternedString for TemplateLiteral { fn to_interned_string(&self, interner: &Interner) -> String { let mut buf = "`".to_owned(); - for elt in self.elements.iter() { + for elt in &*self.elements { match elt { TemplateElement::String(s) => buf.push_str(&interner.resolve_expect(*s).join( Cow::Borrowed, @@ -93,7 +93,7 @@ impl VisitWith for TemplateLiteral { where V: Visitor<'a>, { - for element in self.elements.iter() { + for element in &*self.elements { try_break!(visitor.visit_template_element(element)); } ControlFlow::Continue(()) @@ -103,7 +103,7 @@ impl VisitWith for TemplateLiteral { where V: VisitorMut<'a>, { - for element in self.elements.iter_mut() { + for element in &mut *self.elements { try_break!(visitor.visit_template_element_mut(element)); } ControlFlow::Continue(()) diff --git a/boa_ast/src/expression/optional.rs b/boa_ast/src/expression/optional.rs index 94c615d07c..814233ee48 100644 --- a/boa_ast/src/expression/optional.rs +++ b/boa_ast/src/expression/optional.rs @@ -186,7 +186,7 @@ impl VisitWith for Optional { V: Visitor<'a>, { try_break!(visitor.visit_expression(&self.target)); - for op in self.chain.iter() { + for op in &*self.chain { try_break!(visitor.visit_optional_operation(op)); } ControlFlow::Continue(()) @@ -197,7 +197,7 @@ impl VisitWith for Optional { V: VisitorMut<'a>, { try_break!(visitor.visit_expression_mut(&mut self.target)); - for op in self.chain.iter_mut() { + for op in &mut *self.chain { try_break!(visitor.visit_optional_operation_mut(op)); } ControlFlow::Continue(()) diff --git a/boa_ast/src/expression/tagged_template.rs b/boa_ast/src/expression/tagged_template.rs index b463ce5724..75eaf0554f 100644 --- a/boa_ast/src/expression/tagged_template.rs +++ b/boa_ast/src/expression/tagged_template.rs @@ -111,13 +111,13 @@ impl VisitWith for TaggedTemplate { V: Visitor<'a>, { try_break!(visitor.visit_expression(&self.tag)); - for raw in self.raws.iter() { + for raw in &*self.raws { try_break!(visitor.visit_sym(raw)); } for cooked in self.cookeds.iter().flatten() { try_break!(visitor.visit_sym(cooked)); } - for expr in self.exprs.iter() { + for expr in &*self.exprs { try_break!(visitor.visit_expression(expr)); } ControlFlow::Continue(()) @@ -128,13 +128,13 @@ impl VisitWith for TaggedTemplate { V: VisitorMut<'a>, { try_break!(visitor.visit_expression_mut(&mut self.tag)); - for raw in self.raws.iter_mut() { + for raw in &mut *self.raws { try_break!(visitor.visit_sym_mut(raw)); } for cooked in self.cookeds.iter_mut().flatten() { try_break!(visitor.visit_sym_mut(cooked)); } - for expr in self.exprs.iter_mut() { + for expr in &mut *self.exprs { try_break!(visitor.visit_expression_mut(expr)); } ControlFlow::Continue(()) diff --git a/boa_ast/src/function/class.rs b/boa_ast/src/function/class.rs index e1f8155d89..c7375ae8d0 100644 --- a/boa_ast/src/function/class.rs +++ b/boa_ast/src/function/class.rs @@ -124,7 +124,7 @@ impl ToIndentedString for Class { block_to_string(expr.body().statements(), interner, indent_n + 1) )); } - for element in self.elements.iter() { + for element in &*self.elements { buf.push_str(&match element { ClassElement::MethodDefinition(name, method) => { format!( @@ -394,7 +394,7 @@ impl VisitWith for Class { if let Some(func) = &self.constructor { try_break!(visitor.visit_function(func)); } - for elem in self.elements.iter() { + for elem in &*self.elements { try_break!(visitor.visit_class_element(elem)); } ControlFlow::Continue(()) @@ -413,7 +413,7 @@ impl VisitWith for Class { if let Some(func) = &mut self.constructor { try_break!(visitor.visit_function_mut(func)); } - for elem in self.elements.iter_mut() { + for elem in &mut *self.elements { try_break!(visitor.visit_class_element_mut(elem)); } ControlFlow::Continue(()) diff --git a/boa_ast/src/function/parameters.rs b/boa_ast/src/function/parameters.rs index c48b5d37b8..197801fc6c 100644 --- a/boa_ast/src/function/parameters.rs +++ b/boa_ast/src/function/parameters.rs @@ -148,9 +148,10 @@ impl VisitWith for FormalParameterList { where V: Visitor<'a>, { - for parameter in self.parameters.iter() { + for parameter in &*self.parameters { try_break!(visitor.visit_formal_parameter(parameter)); } + ControlFlow::Continue(()) } @@ -158,9 +159,10 @@ impl VisitWith for FormalParameterList { where V: VisitorMut<'a>, { - for parameter in self.parameters.iter_mut() { + for parameter in &mut *self.parameters { try_break!(visitor.visit_formal_parameter_mut(parameter)); } + // TODO recompute flags ControlFlow::Continue(()) } diff --git a/boa_ast/src/pattern.rs b/boa_ast/src/pattern.rs index 2d4e133550..4cfc4b50be 100644 --- a/boa_ast/src/pattern.rs +++ b/boa_ast/src/pattern.rs @@ -171,7 +171,7 @@ impl VisitWith for ObjectPattern { where V: Visitor<'a>, { - for elem in self.0.iter() { + for elem in &*self.0 { try_break!(visitor.visit_object_pattern_element(elem)); } ControlFlow::Continue(()) @@ -181,7 +181,7 @@ impl VisitWith for ObjectPattern { where V: VisitorMut<'a>, { - for elem in self.0.iter_mut() { + for elem in &mut *self.0 { try_break!(visitor.visit_object_pattern_element_mut(elem)); } ControlFlow::Continue(()) @@ -249,7 +249,7 @@ impl VisitWith for ArrayPattern { where V: Visitor<'a>, { - for elem in self.0.iter() { + for elem in &*self.0 { try_break!(visitor.visit_array_pattern_element(elem)); } ControlFlow::Continue(()) @@ -259,7 +259,7 @@ impl VisitWith for ArrayPattern { where V: VisitorMut<'a>, { - for elem in self.0.iter_mut() { + for elem in &mut *self.0 { try_break!(visitor.visit_array_pattern_element_mut(elem)); } ControlFlow::Continue(()) diff --git a/boa_ast/src/position.rs b/boa_ast/src/position.rs index 76634c3c4e..8e8afa3eb1 100644 --- a/boa_ast/src/position.rs +++ b/boa_ast/src/position.rs @@ -16,7 +16,11 @@ pub struct Position { } impl Position { - /// Creates a new `Position`. + /// Creates a new `Position` from Non-Zero values. + /// + /// # Panics + /// + /// Will panic if the line number or column number is zero. #[inline] #[track_caller] #[must_use] diff --git a/boa_ast/src/statement/switch.rs b/boa_ast/src/statement/switch.rs index 8f30038911..5543e7af04 100644 --- a/boa_ast/src/statement/switch.rs +++ b/boa_ast/src/statement/switch.rs @@ -158,7 +158,7 @@ impl ToIndentedString for Switch { fn to_indented_string(&self, interner: &Interner, indentation: usize) -> String { let indent = " ".repeat(indentation); let mut buf = format!("switch ({}) {{\n", self.val().to_interned_string(interner)); - for e in self.cases().iter() { + for e in &*self.cases { if let Some(condition) = e.condition() { buf.push_str(&format!( "{indent} case {}:\n{}", @@ -192,7 +192,7 @@ impl VisitWith for Switch { V: Visitor<'a>, { try_break!(visitor.visit_expression(&self.val)); - for case in self.cases.iter() { + for case in &*self.cases { try_break!(visitor.visit_case(case)); } ControlFlow::Continue(()) @@ -203,7 +203,7 @@ impl VisitWith for Switch { V: VisitorMut<'a>, { try_break!(visitor.visit_expression_mut(&mut self.val)); - for case in self.cases.iter_mut() { + for case in &mut *self.cases { try_break!(visitor.visit_case_mut(case)); } ControlFlow::Continue(()) diff --git a/boa_ast/src/statement_list.rs b/boa_ast/src/statement_list.rs index f4ac4da3af..bae91c1055 100644 --- a/boa_ast/src/statement_list.rs +++ b/boa_ast/src/statement_list.rs @@ -162,7 +162,7 @@ impl ToIndentedString for StatementList { fn to_indented_string(&self, interner: &Interner, indentation: usize) -> String { let mut buf = String::new(); // Print statements - for item in self.statements.iter() { + for item in &*self.statements { // We rely on the node to add the correct indent. buf.push_str(&item.to_indented_string(interner, indentation)); @@ -177,7 +177,7 @@ impl VisitWith for StatementList { where V: Visitor<'a>, { - for statement in self.statements.iter() { + for statement in &*self.statements { try_break!(visitor.visit_statement_list_item(statement)); } ControlFlow::Continue(()) @@ -187,7 +187,7 @@ impl VisitWith for StatementList { where V: VisitorMut<'a>, { - for statement in self.statements.iter_mut() { + for statement in &mut *self.statements { try_break!(visitor.visit_statement_list_item_mut(statement)); } ControlFlow::Continue(()) diff --git a/boa_engine/src/builtins/json/mod.rs b/boa_engine/src/builtins/json/mod.rs index 67fd9a41bc..f2616c1e8e 100644 --- a/boa_engine/src/builtins/json/mod.rs +++ b/boa_engine/src/builtins/json/mod.rs @@ -684,7 +684,7 @@ impl Json { partial.iter().map(Vec::as_slice), &separator, )) - .chain([utf16!("\n"), &stepback[..], utf16!("}")].into_iter()) + .chain([utf16!("\n"), &stepback[..], utf16!("}")]) .flatten() .copied() .collect::>(); @@ -797,7 +797,7 @@ impl Json { partial.iter().map(Cow::as_ref), &separator, )) - .chain([utf16!("\n"), &stepback[..], utf16!("]")].into_iter()) + .chain([utf16!("\n"), &stepback[..], utf16!("]")]) .flatten() .copied() .collect::>(); diff --git a/boa_engine/src/builtins/map/ordered_map.rs b/boa_engine/src/builtins/map/ordered_map.rs index 2c2884bccd..812d5c68ba 100644 --- a/boa_engine/src/builtins/map/ordered_map.rs +++ b/boa_engine/src/builtins/map/ordered_map.rs @@ -45,7 +45,7 @@ pub struct OrderedMap { impl Finalize for OrderedMap {} unsafe impl Trace for OrderedMap { custom_trace!(this, { - for (k, v) in this.map.iter() { + for (k, v) in &this.map { if let MapKey::Key(key) = k { mark(key); } diff --git a/boa_engine/src/builtins/regexp/tests.rs b/boa_engine/src/builtins/regexp/tests.rs index 3ce05fc6e9..4de0035216 100644 --- a/boa_engine/src/builtins/regexp/tests.rs +++ b/boa_engine/src/builtins/regexp/tests.rs @@ -97,10 +97,10 @@ fn last_index() { fn exec() { run_test_actions([ TestAction::run_harness(), - TestAction::run(indoc! {r#" + TestAction::run(indoc! {r" var re = /quick\s(brown).+?(jumps)/ig; var result = re.exec('The Quick Brown Fox Jumps Over The Lazy Dog'); - "#}), + "}), TestAction::assert(indoc! {r#" arrayEquals( result, diff --git a/boa_engine/src/builtins/set/ordered_set.rs b/boa_engine/src/builtins/set/ordered_set.rs index 137896f3ca..db6c56a8d9 100644 --- a/boa_engine/src/builtins/set/ordered_set.rs +++ b/boa_engine/src/builtins/set/ordered_set.rs @@ -15,7 +15,7 @@ pub struct OrderedSet { unsafe impl Trace for OrderedSet { custom_trace!(this, { - for v in this.inner.iter() { + for v in &this.inner { if let MapKey::Key(v) = v { mark(v); } diff --git a/boa_engine/src/builtins/string/mod.rs b/boa_engine/src/builtins/string/mod.rs index ade4f914ae..b625a69b7f 100644 --- a/boa_engine/src/builtins/string/mod.rs +++ b/boa_engine/src/builtins/string/mod.rs @@ -322,7 +322,7 @@ impl String { let mut buf = [0; 2]; // 2. For each element next of codePoints, do - for arg in args.iter() { + for arg in args { // a. Let nextCP be ? ToNumber(next). let nextcp = arg.to_number(context)?; diff --git a/boa_engine/src/builtins/string/tests.rs b/boa_engine/src/builtins/string/tests.rs index 7983eec6c5..5a1e918496 100644 --- a/boa_engine/src/builtins/string/tests.rs +++ b/boa_engine/src/builtins/string/tests.rs @@ -6,12 +6,12 @@ use crate::{js_string, run_test_actions, JsNativeErrorKind, JsValue, TestAction} fn length() { //TEST262: https://github.com/tc39/test262/blob/master/test/built-ins/String/length.js run_test_actions([ - TestAction::run(indoc! {r#" + TestAction::run(indoc! {r" const a = new String(' '); const b = new String('\ud834\udf06'); const c = new String(' \b '); const d = new String('中文长度') - "#}), + "}), // unicode surrogate pair length should be 1 // utf16/usc2 length should be 2 // utf8 length should be 4 @@ -307,12 +307,12 @@ fn includes_with_regex_arg() { fn match_all_one() { run_test_actions([ TestAction::run_harness(), - TestAction::run(indoc! {r#" + TestAction::run(indoc! {r" var groupMatches = 'test1test2'.matchAll(/t(e)(st(\d?))/g); var m1 = groupMatches.next(); var m2 = groupMatches.next(); var m3 = groupMatches.next(); - "#}), + "}), TestAction::assert("!m1.done"), TestAction::assert("!m2.done"), TestAction::assert("m3.done"), @@ -553,12 +553,12 @@ fn split() { [''] ) "#}), - TestAction::assert(indoc! {r#" + TestAction::assert(indoc! {r" arrayEquals( '\u{1D7D8}\u{1D7D9}\u{1D7DA}\u{1D7DB}'.split(''), ['\uD835', '\uDFD8', '\uD835', '\uDFD9', '\uD835', '\uDFDA', '\uD835', '\uDFDB'] ) - "#}), + "}), ]); } diff --git a/boa_engine/src/lib.rs b/boa_engine/src/lib.rs index fdb23518e7..9a7eb0c60a 100644 --- a/boa_engine/src/lib.rs +++ b/boa_engine/src/lib.rs @@ -119,6 +119,10 @@ clippy::cast_sign_loss, clippy::cast_precision_loss, clippy::cast_possible_wrap, + + // Add temporarily - Needs addressing + clippy::missing_panics_doc, + clippy::arc_with_non_send_sync, )] extern crate static_assertions as sa; diff --git a/boa_engine/src/object/property_map.rs b/boa_engine/src/object/property_map.rs index 9a06080a13..1bea280e09 100644 --- a/boa_engine/src/object/property_map.rs +++ b/boa_engine/src/object/property_map.rs @@ -26,7 +26,7 @@ impl Default for OrderedHashMap { unsafe impl Trace for OrderedHashMap { custom_trace!(this, { - for (k, v) in this.0.iter() { + for (k, v) in &this.0 { mark(k); mark(v); } diff --git a/boa_engine/src/symbol.rs b/boa_engine/src/symbol.rs index 925dd6f9e0..1112d8ab94 100644 --- a/boa_engine/src/symbol.rs +++ b/boa_engine/src/symbol.rs @@ -109,6 +109,7 @@ impl WellKnown { } } +// TODO: Address below clippy::arc_with_non_send_sync below. /// The inner representation of a JavaScript symbol. #[derive(Debug, Clone)] struct Inner { diff --git a/boa_engine/src/tagged.rs b/boa_engine/src/tagged.rs index 1be420eeff..83ec17c24b 100644 --- a/boa_engine/src/tagged.rs +++ b/boa_engine/src/tagged.rs @@ -33,7 +33,7 @@ pub(crate) struct Tagged(NonNull); impl Clone for Tagged { fn clone(&self) -> Self { - Self(self.0) + *self } } diff --git a/boa_gc/src/cell.rs b/boa_gc/src/cell.rs index bf2cf2c97e..3196f678bc 100644 --- a/boa_gc/src/cell.rs +++ b/boa_gc/src/cell.rs @@ -491,12 +491,12 @@ impl Debug for GcRefCell { .debug_struct("GcCell") .field("flags", &self.flags.get()) .field("value", &self.borrow()) - .finish(), + .finish_non_exhaustive(), BorrowState::Writing => f .debug_struct("GcCell") .field("flags", &self.flags.get()) .field("value", &"") - .finish(), + .finish_non_exhaustive(), } } } diff --git a/boa_gc/src/internals/gc_box.rs b/boa_gc/src/internals/gc_box.rs index 982b3b8a9f..4938d0b6aa 100644 --- a/boa_gc/src/internals/gc_box.rs +++ b/boa_gc/src/internals/gc_box.rs @@ -80,7 +80,7 @@ impl fmt::Debug for GcBoxHeader { .field("marked", &self.is_marked()) .field("ref_count", &self.ref_count.get()) .field("non_root_count", &self.get_non_root_count()) - .finish() + .finish_non_exhaustive() } } diff --git a/boa_gc/src/trace.rs b/boa_gc/src/trace.rs index ff63210f98..a1b5717168 100644 --- a/boa_gc/src/trace.rs +++ b/boa_gc/src/trace.rs @@ -265,7 +265,7 @@ impl Finalize for Box<[T]> {} // SAFETY: All the inner elements of the `Box` array are correctly marked. unsafe impl Trace for Box<[T]> { custom_trace!(this, { - for e in this.iter() { + for e in &**this { mark(e); } }); @@ -319,7 +319,7 @@ impl Finalize for BinaryHeap {} // SAFETY: All the elements of the `BinaryHeap` are correctly marked. unsafe impl Trace for BinaryHeap { custom_trace!(this, { - for v in this.iter() { + for v in this { mark(v); } }); @@ -350,7 +350,7 @@ impl Finalize for HashMap Trace for HashMap { custom_trace!(this, { - for (k, v) in this.iter() { + for (k, v) in this { mark(k); mark(v); } @@ -361,7 +361,7 @@ impl Finalize for HashSet {} // SAFETY: All the elements of the `HashSet` are correctly marked. unsafe impl Trace for HashSet { custom_trace!(this, { - for v in this.iter() { + for v in this { mark(v); } }); @@ -371,6 +371,7 @@ impl Finalize for LinkedList {} // SAFETY: All the elements of the `LinkedList` are correctly marked. unsafe impl Trace for LinkedList { custom_trace!(this, { + #[allow(clippy::explicit_iter_loop)] for v in this.iter() { mark(v); } @@ -387,7 +388,7 @@ impl Finalize for VecDeque {} // SAFETY: All the elements of the `VecDeque` are correctly marked. unsafe impl Trace for VecDeque { custom_trace!(this, { - for v in this.iter() { + for v in this { mark(v); } }); diff --git a/boa_interner/src/interned_str.rs b/boa_interner/src/interned_str.rs index 35839808b8..bdc58e68ff 100644 --- a/boa_interner/src/interned_str.rs +++ b/boa_interner/src/interned_str.rs @@ -46,7 +46,7 @@ impl InternedStr { impl Clone for InternedStr { fn clone(&self) -> Self { - Self { ptr: self.ptr } + *self } } diff --git a/boa_interner/src/lib.rs b/boa_interner/src/lib.rs index 346d62a822..b220ec8658 100644 --- a/boa_interner/src/lib.rs +++ b/boa_interner/src/lib.rs @@ -355,6 +355,11 @@ impl Interner { } /// Returns the string for the given symbol if any. + /// + /// # Panics + /// + /// Panics if the size of both statics is not equal or the interners do + /// not have the same size #[must_use] pub fn resolve(&self, symbol: Sym) -> Option> { let index = symbol.get() - 1; diff --git a/boa_parser/src/lexer/cursor.rs b/boa_parser/src/lexer/cursor.rs index 52185a0d19..b191781136 100644 --- a/boa_parser/src/lexer/cursor.rs +++ b/boa_parser/src/lexer/cursor.rs @@ -313,7 +313,7 @@ where /// This expects for the buffer to be fully filled. If it's not, it will fail with an /// `UnexpectedEof` I/O error. fn fill_bytes(&mut self, buf: &mut [u8]) -> io::Result<()> { - for byte in buf.iter_mut() { + for byte in &mut *buf { *byte = self.next_byte()?.ok_or_else(|| { io::Error::new( io::ErrorKind::UnexpectedEof, diff --git a/boa_parser/src/lexer/tests.rs b/boa_parser/src/lexer/tests.rs index 1d0aba274c..ff363d2621 100644 --- a/boa_parser/src/lexer/tests.rs +++ b/boa_parser/src/lexer/tests.rs @@ -18,7 +18,7 @@ fn expect_tokens(lexer: &mut Lexer, expected: &[TokenKind], interner: &mut where R: Read, { - for expect in expected.iter() { + for expect in expected { assert_eq!(&lexer.next(interner).unwrap().unwrap().kind(), &expect); } @@ -933,13 +933,13 @@ fn string_codepoint_with_no_braces() { fn illegal_code_point_following_numeric_literal() { // Checks as per https://tc39.es/ecma262/#sec-literals-numeric-literals that a NumericLiteral cannot // be immediately followed by an IdentifierStart where the IdentifierStart - let mut lexer = Lexer::new(&br#"17.4\u{2764}"#[..]); + let mut lexer = Lexer::new(&br"17.4\u{2764}"[..]); let interner = &mut Interner::default(); assert!( lexer.next(interner).is_err(), "{}", - r#"IdentifierStart \u{2764} following NumericLiteral not rejected as expected"# + r"IdentifierStart \u{2764} following NumericLiteral not rejected as expected" ); } @@ -961,7 +961,7 @@ fn string_unicode() { #[test] fn string_unicode_escape_with_braces() { - let mut lexer = Lexer::new(&br#"'{\u{20ac}\u{a0}\u{a0}}'"#[..]); + let mut lexer = Lexer::new(&br"'{\u{20ac}\u{a0}\u{a0}}'"[..]); let interner = &mut Interner::default(); let sym = @@ -970,7 +970,7 @@ fn string_unicode_escape_with_braces() { expect_tokens(&mut lexer, &expected, interner); - lexer = Lexer::new(&br#"\u{{a0}"#[..]); + lexer = Lexer::new(&br"\u{{a0}"[..]); if let Error::Syntax(_, pos) = lexer .next(interner) @@ -981,7 +981,7 @@ fn string_unicode_escape_with_braces() { panic!("invalid error type"); } - lexer = Lexer::new(&br#"\u{{a0}}"#[..]); + lexer = Lexer::new(&br"\u{{a0}}"[..]); if let Error::Syntax(_, pos) = lexer .next(interner) @@ -995,7 +995,7 @@ fn string_unicode_escape_with_braces() { #[test] fn string_unicode_escape_with_braces_2() { - let s = r#"'\u{20ac}\u{a0}\u{a0}'"#; + let s = r"'\u{20ac}\u{a0}\u{a0}'"; let mut lexer = Lexer::new(s.as_bytes()); let interner = &mut Interner::default(); @@ -1008,7 +1008,7 @@ fn string_unicode_escape_with_braces_2() { #[test] fn string_with_single_escape() { - let s = r#"'\Б'"#; + let s = r"'\Б'"; let mut lexer = Lexer::new(s.as_bytes()); let interner = &mut Interner::default(); @@ -1022,13 +1022,13 @@ fn string_with_single_escape() { #[test] fn string_legacy_octal_escape() { let test_cases = [ - (r#"'\3'"#, "\u{3}"), - (r#"'\03'"#, "\u{3}"), - (r#"'\003'"#, "\u{3}"), - (r#"'\0003'"#, "\u{0}3"), - (r#"'\43'"#, "#"), - (r#"'\043'"#, "#"), - (r#"'\101'"#, "A"), + (r"'\3'", "\u{3}"), + (r"'\03'", "\u{3}"), + (r"'\003'", "\u{3}"), + (r"'\0003'", "\u{0}3"), + (r"'\43'", "#"), + (r"'\043'", "#"), + (r"'\101'", "A"), ]; for (s, expected) in &test_cases { @@ -1062,7 +1062,7 @@ fn string_legacy_octal_escape() { #[test] fn string_zero_escape() { - let test_cases = [(r#"'\0'"#, "\u{0}"), (r#"'\0A'"#, "\u{0}A")]; + let test_cases = [(r"'\0'", "\u{0}"), (r"'\0A'", "\u{0}A")]; for (s, expected) in &test_cases { let mut lexer = Lexer::new(s.as_bytes()); @@ -1077,7 +1077,7 @@ fn string_zero_escape() { #[test] fn string_non_octal_decimal_escape() { - let test_cases = [(r#"'\8'"#, "8"), (r#"'\9'"#, "9")]; + let test_cases = [(r"'\8'", "8"), (r"'\9'", "9")]; for (s, expected) in &test_cases { let mut lexer = Lexer::new(s.as_bytes()); diff --git a/boa_parser/src/parser/tests/format/expression.rs b/boa_parser/src/parser/tests/format/expression.rs index ff882c483c..82f3d0f697 100644 --- a/boa_parser/src/parser/tests/format/expression.rs +++ b/boa_parser/src/parser/tests/format/expression.rs @@ -87,7 +87,7 @@ fn array() { #[test] fn template() { test_formatting( - r#" + r" function tag(t, ...args) { let a = []; a = a.concat([t[0], t[1], t[2]]); @@ -97,7 +97,7 @@ fn template() { } let a = 10; tag`result: ${a} \x26 ${a + 10}`; - "#, + ", ); } diff --git a/boa_profiler/src/lib.rs b/boa_profiler/src/lib.rs index b4a39c3e4a..d5d832f4e6 100644 --- a/boa_profiler/src/lib.rs +++ b/boa_profiler/src/lib.rs @@ -150,6 +150,10 @@ impl Profiler { } /// Drop the global instance of the profiler. + /// + /// # Panics + /// + /// Calling `drop` will panic if `INSTANCE` cannot be taken back. pub fn drop(&self) { // In order to drop the INSTANCE we need to get ownership of it, which isn't possible on a static unless you make it a mutable static // mutating statics is unsafe, so we need to wrap it as so. diff --git a/boa_tester/src/exec/mod.rs b/boa_tester/src/exec/mod.rs index e7a7c1d4ed..f96f3bf500 100644 --- a/boa_tester/src/exec/mod.rs +++ b/boa_tester/src/exec/mod.rs @@ -62,7 +62,7 @@ impl TestSuite { }; let mut features = FxHashSet::default(); - for test_iter in self.tests.iter() { + for test_iter in &*self.tests { features.extend(test_iter.features.iter().map(ToString::to_string)); } diff --git a/boa_tester/src/read.rs b/boa_tester/src/read.rs index 8bbb819d68..1a54c3b283 100644 --- a/boa_tester/src/read.rs +++ b/boa_tester/src/read.rs @@ -211,7 +211,7 @@ fn read_metadata(test: &Path) -> io::Result { /// Regular expression to retrieve the metadata of a test. static META_REGEX: Lazy = Lazy::new(|| { - Regex::new(r#"/\*\-{3}((?:.|\n)*)\-{3}\*/"#) + Regex::new(r"/\*\-{3}((?:.|\n)*)\-{3}\*/") .expect("could not compile metadata regular expression") });