Skip to content

Commit

Permalink
Fix rust 1.83.0 lints (#4060)
Browse files Browse the repository at this point in the history
* Fix rust 1.83.0 lints

* Allow missing docs in wasm tests

* Run tarpaulin on 1.82.0
  • Loading branch information
raskad authored Dec 3, 2024
1 parent 1c4f455 commit 793a100
Show file tree
Hide file tree
Showing 17 changed files with 34 additions and 21 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 4 additions & 5 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand Down
3 changes: 2 additions & 1 deletion core/ast/src/expression/operator/assign/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ 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]
///
/// [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`
Expand Down
1 change: 0 additions & 1 deletion core/engine/src/builtins/iterable/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions core/engine/src/builtins/temporal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 )`
Expand Down
2 changes: 0 additions & 2 deletions core/engine/src/object/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 2 additions & 3 deletions core/engine/src/property/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -669,15 +669,14 @@ where
impl From<JsStr<'_>> 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<JsString> 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)
}
}

Expand Down
3 changes: 3 additions & 0 deletions core/engine/tests/macros.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion core/interop/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions core/interop/tests/embedded.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Tests for the embedded module loader.
#![allow(unused_crate_dependencies)]

use std::rc::Rc;
Expand Down
2 changes: 2 additions & 0 deletions core/macros/tests/tests.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Tests for the macros in this crate.
#![allow(unused_crate_dependencies)]

use boa_macros::utf16;
Expand Down
1 change: 0 additions & 1 deletion core/parser/src/lexer/comment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ impl<R> Tokenizer<R> for MultiLineComment {
/// - [ECMAScript reference][spec]
///
/// [spec]: https://tc39.es/ecma262/#sec-ecmascript-language-lexical-grammar
pub(super) struct HashbangComment;

impl<R> Tokenizer<R> for HashbangComment {
Expand Down
2 changes: 2 additions & 0 deletions core/profiler/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
}
Expand All @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions core/runtime/src/url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl Url {
///
/// # Errors
/// Any errors that might occur during URL parsing.
fn js_new(Convert(ref url): Convert<String>, base: &Option<Convert<String>>) -> JsResult<Self> {
fn js_new(Convert(ref url): Convert<String>, base: Option<&Convert<String>>) -> JsResult<Self> {
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))?;
Expand Down Expand Up @@ -194,7 +194,7 @@ js_class! {
}

constructor(url: Convert<String>, base: Option<Convert<String>>) {
Self::js_new(url, &base)
Self::js_new(url, base.as_ref())
}

init(class: &mut ClassBuilder) -> JsResult<()> {
Expand All @@ -203,11 +203,11 @@ js_class! {
})
.into_js_function_copied(class.context());
let can_parse = (|url: Convert<String>, base: Option<Convert<String>>| {
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<String>, base: Option<Convert<String>>, 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());
Expand Down
3 changes: 3 additions & 0 deletions ffi/wasm/tests/web.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Tests for the wasm module.
#![expect(
unused_crate_dependencies,
reason = "https://github.com/rust-lang/rust/issues/95513"
Expand All @@ -6,6 +8,7 @@
any(target_arch = "wasm32", target_arch = "wasm64"),
target_os = "unknown"
))]
#![allow(missing_docs)]

use wasm_bindgen_test::*;

Expand Down
2 changes: 2 additions & 0 deletions tests/macros/tests/derive.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Tests for the `TryFromJs` derive macro.
#![allow(unused_crate_dependencies)]

#[test]
Expand Down
2 changes: 2 additions & 0 deletions tests/macros/tests/optional.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Tests for optional values in `TryFromJs` derive.
#![allow(unused_crate_dependencies)]

use boa_engine::value::TryFromJs;
Expand Down

0 comments on commit 793a100

Please sign in to comment.