From 793a10035f101a93268b24be9d4167a5406e9203 Mon Sep 17 00:00:00 2001 From: raskad <32105367+raskad@users.noreply.github.com> Date: Tue, 3 Dec 2024 05:30:35 +0000 Subject: [PATCH] Fix rust 1.83.0 lints (#4060) * Fix rust 1.83.0 lints * Allow missing docs in wasm tests * Run tarpaulin on 1.82.0 --- .github/workflows/rust.yml | 4 +++- cli/src/main.rs | 9 ++++----- core/ast/src/expression/operator/assign/op.rs | 3 ++- core/engine/src/builtins/iterable/mod.rs | 1 - core/engine/src/builtins/temporal/mod.rs | 4 ++-- core/engine/src/object/mod.rs | 2 -- core/engine/src/property/mod.rs | 5 ++--- core/engine/tests/macros.rs | 3 +++ core/interop/src/lib.rs | 2 +- core/interop/tests/embedded.rs | 2 ++ core/macros/tests/tests.rs | 2 ++ core/parser/src/lexer/comment.rs | 1 - core/profiler/src/lib.rs | 2 ++ core/runtime/src/url.rs | 8 ++++---- ffi/wasm/tests/web.rs | 3 +++ tests/macros/tests/derive.rs | 2 ++ tests/macros/tests/optional.rs | 2 ++ 17 files changed, 34 insertions(+), 21 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 41eae2a4fcf..b7689fb3299 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -32,7 +32,9 @@ jobs: - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable with: - toolchain: stable + # TODO: There seems to be an issue with the 1.83.0 toolchain and tarpaulin. + # See: https://github.com/xd009642/tarpaulin/issues/1642 + toolchain: 1.82.0 - uses: Swatinem/rust-cache@v2 with: diff --git a/cli/src/main.rs b/cli/src/main.rs index 899b73f3139..8d5312a92b3 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -135,24 +135,23 @@ impl Opt { } } +/// The different types of format available for dumping. #[derive(Debug, Copy, Clone, Default, ValueEnum)] enum DumpFormat { - /// The different types of format available for dumping. // NOTE: This can easily support other formats just by // adding a field to this enum and adding the necessary // implementation. Example: Toml, Html, etc. // // NOTE: The fields of this enum are not doc comments because // arg_enum! macro does not support it. - - // This is the default format that you get from std::fmt::Debug. + /// This is the default format that you get from `std::fmt::Debug`. #[default] Debug, - // This is a minified json format. + /// This is a minified json format. Json, - // This is a pretty printed json format. + /// This is a pretty printed json format. JsonPretty, } diff --git a/core/ast/src/expression/operator/assign/op.rs b/core/ast/src/expression/operator/assign/op.rs index 6d32335c1d5..e71019d6bee 100644 --- a/core/ast/src/expression/operator/assign/op.rs +++ b/core/ast/src/expression/operator/assign/op.rs @@ -18,7 +18,7 @@ pub enum AssignOp { /// The assignment operator assigns the value of the right operand to the left operand. /// /// Syntax: `x = y` - + /// /// More information: /// - [ECMAScript reference][spec] /// - [MDN documentation][mdn] @@ -26,6 +26,7 @@ pub enum AssignOp { /// [spec]: https://tc39.es/ecma262/#prod-AssignmentOperator /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Assignment Assign, + /// The addition assignment operator adds the value of the right operand to a variable and assigns the result to the variable. /// /// Syntax: `x += y` diff --git a/core/engine/src/builtins/iterable/mod.rs b/core/engine/src/builtins/iterable/mod.rs index b2de198516f..ba5a1d6ad57 100644 --- a/core/engine/src/builtins/iterable/mod.rs +++ b/core/engine/src/builtins/iterable/mod.rs @@ -155,7 +155,6 @@ impl IteratorPrototypes { /// - [ECMA reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-%iteratorprototype%-object - pub(crate) struct Iterator; impl IntrinsicObject for Iterator { diff --git a/core/engine/src/builtins/temporal/mod.rs b/core/engine/src/builtins/temporal/mod.rs index bd4128b3a3b..5ef37ebca61 100644 --- a/core/engine/src/builtins/temporal/mod.rs +++ b/core/engine/src/builtins/temporal/mod.rs @@ -223,10 +223,10 @@ pub(crate) fn _iterator_to_list_of_types( // 13.6 `GetOption ( options, property, type, values, default )` // Implemented in builtin/options.rs -/// 13.7 `ToTemporalOverflow (options)` +// 13.7 `ToTemporalOverflow (options)` // Now implemented in temporal/options.rs -/// 13.10 `ToTemporalRoundingMode ( normalizedOptions, fallback )` +// 13.10 `ToTemporalRoundingMode ( normalizedOptions, fallback )` // Now implemented in builtin/options.rs // 13.11 `NegateTemporalRoundingMode ( roundingMode )` diff --git a/core/engine/src/object/mod.rs b/core/engine/src/object/mod.rs index 3d8fb63bafc..31657c97f1a 100644 --- a/core/engine/src/object/mod.rs +++ b/core/engine/src/object/mod.rs @@ -55,8 +55,6 @@ pub const CONSTRUCTOR: JsString = js_string!("constructor"); /// Const `prototype`, usually set on constructors as a key to point to their respective prototype object. pub const PROTOTYPE: JsString = js_string!("prototype"); -/// Common field names. - /// A type alias for an object prototype. /// /// A `None` values means that the prototype is the `null` value. diff --git a/core/engine/src/property/mod.rs b/core/engine/src/property/mod.rs index bb095142f2a..2ef676abd39 100644 --- a/core/engine/src/property/mod.rs +++ b/core/engine/src/property/mod.rs @@ -669,15 +669,14 @@ where impl From> for PropertyKey { #[inline] fn from(string: JsStr<'_>) -> Self { - return parse_u32_index(string.iter()) - .map_or_else(|| Self::String(string.into()), Self::Index); + parse_u32_index(string.iter()).map_or_else(|| Self::String(string.into()), Self::Index) } } impl From for PropertyKey { #[inline] fn from(string: JsString) -> Self { - return parse_u32_index(string.as_str().iter()).map_or(Self::String(string), Self::Index); + parse_u32_index(string.as_str().iter()).map_or(Self::String(string), Self::Index) } } diff --git a/core/engine/tests/macros.rs b/core/engine/tests/macros.rs index 85ec2a27ad7..7a891acc95f 100644 --- a/core/engine/tests/macros.rs +++ b/core/engine/tests/macros.rs @@ -1,4 +1,7 @@ +//! Tests for the macros in this crate. + #![allow(unused_crate_dependencies)] + use boa_engine::value::TryFromJs; use boa_engine::{js_string, Context, JsResult, JsValue, Source}; use boa_string::JsString; diff --git a/core/interop/src/lib.rs b/core/interop/src/lib.rs index af282f77d33..722f3e99b87 100644 --- a/core/interop/src/lib.rs +++ b/core/interop/src/lib.rs @@ -473,7 +473,7 @@ mod into_js_function_impls; #[test] #[allow(clippy::missing_panics_doc)] -pub fn into_js_module() { +fn into_js_module() { use boa_engine::{js_string, JsValue, Source}; use boa_gc::{Gc, GcRefCell}; use std::cell::RefCell; diff --git a/core/interop/tests/embedded.rs b/core/interop/tests/embedded.rs index 1ef0c4c4516..04b35a9f6ad 100644 --- a/core/interop/tests/embedded.rs +++ b/core/interop/tests/embedded.rs @@ -1,3 +1,5 @@ +//! Tests for the embedded module loader. + #![allow(unused_crate_dependencies)] use std::rc::Rc; diff --git a/core/macros/tests/tests.rs b/core/macros/tests/tests.rs index f0888e0c61d..fe350d3511a 100644 --- a/core/macros/tests/tests.rs +++ b/core/macros/tests/tests.rs @@ -1,3 +1,5 @@ +//! Tests for the macros in this crate. + #![allow(unused_crate_dependencies)] use boa_macros::utf16; diff --git a/core/parser/src/lexer/comment.rs b/core/parser/src/lexer/comment.rs index aca752df1f0..bfb8969c544 100644 --- a/core/parser/src/lexer/comment.rs +++ b/core/parser/src/lexer/comment.rs @@ -104,7 +104,6 @@ impl Tokenizer for MultiLineComment { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-ecmascript-language-lexical-grammar - pub(super) struct HashbangComment; impl Tokenizer for HashbangComment { diff --git a/core/profiler/src/lib.rs b/core/profiler/src/lib.rs index 69d1927cab1..66e4c802356 100644 --- a/core/profiler/src/lib.rs +++ b/core/profiler/src/lib.rs @@ -93,6 +93,7 @@ impl Profiler { /// Return the global instance of the profiler. #[must_use] + #[allow(static_mut_refs)] pub fn global() -> &'static Self { unsafe { INSTANCE.get_or_init(Self::default) } } @@ -102,6 +103,7 @@ impl Profiler { /// # Panics /// /// Calling `drop` will panic if `INSTANCE` cannot be taken back. + #[allow(static_mut_refs)] 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/core/runtime/src/url.rs b/core/runtime/src/url.rs index f634ef96f88..2e07b8c19dc 100644 --- a/core/runtime/src/url.rs +++ b/core/runtime/src/url.rs @@ -40,7 +40,7 @@ impl Url { /// /// # Errors /// Any errors that might occur during URL parsing. - fn js_new(Convert(ref url): Convert, base: &Option>) -> JsResult { + fn js_new(Convert(ref url): Convert, base: Option<&Convert>) -> JsResult { if let Some(Convert(base)) = base { let base_url = url::Url::parse(base) .map_err(|e| js_error!(TypeError: "Failed to parse base URL: {}", e))?; @@ -194,7 +194,7 @@ js_class! { } constructor(url: Convert, base: Option>) { - Self::js_new(url, &base) + Self::js_new(url, base.as_ref()) } init(class: &mut ClassBuilder) -> JsResult<()> { @@ -203,11 +203,11 @@ js_class! { }) .into_js_function_copied(class.context()); let can_parse = (|url: Convert, base: Option>| { - Url::js_new(url, &base).is_ok() + Url::js_new(url, base.as_ref()).is_ok() }) .into_js_function_copied(class.context()); let parse = (|url: Convert, base: Option>, context: &mut Context| { - Url::js_new(url, &base) + Url::js_new(url, base.as_ref()) .map_or(Ok(JsValue::null()), |u| Url::from_data(u, context).map(JsValue::from)) }) .into_js_function_copied(class.context()); diff --git a/ffi/wasm/tests/web.rs b/ffi/wasm/tests/web.rs index d3ea23b9f4d..566bca5c75f 100644 --- a/ffi/wasm/tests/web.rs +++ b/ffi/wasm/tests/web.rs @@ -1,3 +1,5 @@ +//! Tests for the wasm module. + #![expect( unused_crate_dependencies, reason = "https://github.com/rust-lang/rust/issues/95513" @@ -6,6 +8,7 @@ any(target_arch = "wasm32", target_arch = "wasm64"), target_os = "unknown" ))] +#![allow(missing_docs)] use wasm_bindgen_test::*; diff --git a/tests/macros/tests/derive.rs b/tests/macros/tests/derive.rs index 1cef0d90770..fd786e7e1f9 100644 --- a/tests/macros/tests/derive.rs +++ b/tests/macros/tests/derive.rs @@ -1,3 +1,5 @@ +//! Tests for the `TryFromJs` derive macro. + #![allow(unused_crate_dependencies)] #[test] diff --git a/tests/macros/tests/optional.rs b/tests/macros/tests/optional.rs index 8c1b4ab0bcf..15893e4ee5e 100644 --- a/tests/macros/tests/optional.rs +++ b/tests/macros/tests/optional.rs @@ -1,3 +1,5 @@ +//! Tests for optional values in `TryFromJs` derive. + #![allow(unused_crate_dependencies)] use boa_engine::value::TryFromJs;