diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index da50959278..9c51af9ba9 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -122,9 +122,15 @@ jobs: with: key: clippy - name: Clippy (All features) - run: cargo workspaces exec cargo clippy --all-features --all-targets -- -D warnings + run: cargo workspaces exec cargo clippy --all-features --all-targets - name: Clippy (No features) - run: cargo workspaces exec cargo clippy --no-default-features --all-targets -- -D warnings + run: cargo workspaces exec cargo clippy --no-default-features --all-targets + - name: Clippy (Intl) + run: cargo clippy -p boa_engine --features intl + - name: Clippy (Annex-B) + run: cargo clippy -p boa_engine --features annex-b + - name: Clippy (Experimental) + run: cargo clippy -p boa_engine --features experimental docs: name: Documentation diff --git a/Cargo.toml b/Cargo.toml index 251c88f536..d79e7b4014 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,7 @@ members = [ [workspace.package] edition = "2021" version = "0.17.0" -rust-version = "1.73.0" +rust-version = "1.74.0" authors = ["boa-dev"] repository = "https://github.com/boa-dev/boa" license = "Unlicense OR MIT" @@ -116,3 +116,58 @@ opt-level = 1 lto = "fat" # Makes sure that all code is compiled together, for LTO codegen-units = 1 + +[workspace.lints.rust] +# rustc lint groups https://doc.rust-lang.org/rustc/lints/groups.html +warnings = "warn" +future_incompatible = "warn" +let_underscore = "warn" +nonstandard_style = "warn" +rust_2018_compatibility = "warn" +rust_2018_idioms = "warn" +rust_2021_compatibility = "warn" +unused = "warn" + +# rustc allowed-by-default lints https://doc.rust-lang.org/rustc/lints/listing/allowed-by-default.html +missing_docs = "warn" +macro_use_extern_crate = "warn" +meta_variable_misuse = "warn" +missing_abi = "warn" +missing_copy_implementations = "warn" +missing_debug_implementations = "warn" +non_ascii_idents = "warn" +noop_method_call = "warn" +single_use_lifetimes = "warn" +trivial_casts = "warn" +trivial_numeric_casts = "warn" +unreachable_pub = "warn" +unsafe_op_in_unsafe_fn = "warn" +unused_crate_dependencies = "warn" +unused_import_braces = "warn" +unused_lifetimes = "warn" +unused_qualifications = "warn" +unused_tuple_struct_fields = "warn" +variant_size_differences = "warn" + +[workspace.lints.rustdoc] +# rustdoc lints https://doc.rust-lang.org/rustdoc/lints.html +broken_intra_doc_links = "warn" +private_intra_doc_links = "warn" +missing_crate_level_docs = "warn" +private_doc_tests = "warn" +invalid_codeblock_attributes = "warn" +invalid_rust_codeblocks = "warn" +bare_urls = "warn" + +[workspace.lints.clippy] +# clippy allowed by default +dbg_macro = "warn" + +# clippy categories https://doc.rust-lang.org/clippy/ +all = "warn" +correctness = "warn" +suspicious = "warn" +style = "warn" +complexity = "warn" +perf = "warn" +pedantic = "warn" diff --git a/boa_ast/Cargo.toml b/boa_ast/Cargo.toml index 40d371fc52..1945d56222 100644 --- a/boa_ast/Cargo.toml +++ b/boa_ast/Cargo.toml @@ -24,3 +24,6 @@ num-bigint.workspace = true serde = { workspace = true, features = ["derive"], optional = true } arbitrary = { workspace = true, features = ["derive"], optional = true } indexmap.workspace = true + +[lints] +workspace = true diff --git a/boa_ast/src/position.rs b/boa_ast/src/position.rs index 8e8afa3eb1..a42a176810 100644 --- a/boa_ast/src/position.rs +++ b/boa_ast/src/position.rs @@ -141,14 +141,14 @@ mod tests { /// Checks that we cannot create a position with 0 as the column. #[test] - #[should_panic] + #[should_panic(expected = "column number cannot be 0")] fn invalid_position_column() { Position::new(10, 0); } /// Checks that we cannot create a position with 0 as the line. #[test] - #[should_panic] + #[should_panic(expected = "line number cannot be 0")] fn invalid_position_line() { Position::new(0, 10); } @@ -195,7 +195,7 @@ mod tests { /// Checks that we cannot create an invalid span. #[test] - #[should_panic] + #[should_panic(expected = "a span cannot start after its end")] fn invalid_span() { let a = Position::new(10, 30); let b = Position::new(10, 50); diff --git a/boa_cli/Cargo.toml b/boa_cli/Cargo.toml index d62f21b553..7c1e34b3c3 100644 --- a/boa_cli/Cargo.toml +++ b/boa_cli/Cargo.toml @@ -37,3 +37,6 @@ jemallocator.workspace = true name = "boa" doc = false path = "src/main.rs" + +[lints] +workspace = true diff --git a/boa_cli/src/main.rs b/boa_cli/src/main.rs index a8187739c0..f2fa0c5f9c 100644 --- a/boa_cli/src/main.rs +++ b/boa_cli/src/main.rs @@ -5,59 +5,6 @@ html_favicon_url = "https://raw.githubusercontent.com/boa-dev/boa/main/assets/logo.svg" )] #![cfg_attr(not(test), deny(clippy::unwrap_used))] -#![warn( - // rustc lint groups https://doc.rust-lang.org/rustc/lints/groups.html - warnings, - future_incompatible, - let_underscore, - nonstandard_style, - rust_2018_compatibility, - rust_2018_idioms, - rust_2021_compatibility, - unused, - - // rustc allowed-by-default lints https://doc.rust-lang.org/rustc/lints/listing/allowed-by-default.html - missing_docs, - macro_use_extern_crate, - meta_variable_misuse, - missing_abi, - missing_copy_implementations, - missing_debug_implementations, - non_ascii_idents, - noop_method_call, - single_use_lifetimes, - trivial_casts, - trivial_numeric_casts, - unreachable_pub, - unsafe_op_in_unsafe_fn, - unused_crate_dependencies, - unused_import_braces, - unused_lifetimes, - unused_qualifications, - unused_tuple_struct_fields, - variant_size_differences, - - // rustdoc lints https://doc.rust-lang.org/rustdoc/lints.html - rustdoc::broken_intra_doc_links, - rustdoc::private_intra_doc_links, - rustdoc::missing_crate_level_docs, - rustdoc::private_doc_tests, - rustdoc::invalid_codeblock_attributes, - rustdoc::invalid_rust_codeblocks, - rustdoc::bare_urls, - - // clippy allowed by default - clippy::dbg_macro, - - // clippy categories https://doc.rust-lang.org/clippy/ - clippy::all, - clippy::correctness, - clippy::suspicious, - clippy::style, - clippy::complexity, - clippy::perf, - clippy::pedantic, -)] mod debug; mod helper; @@ -305,7 +252,7 @@ fn generate_flowgraph( fn evaluate_files( args: &Opt, context: &mut Context, - loader: Rc, + loader: &SimpleModuleLoader, ) -> Result<(), io::Error> { for file in &args.files { let buffer = read(file)?; @@ -485,7 +432,7 @@ fn main() -> Result<(), io::Error> { .save_history(CLI_HISTORY) .expect("could not save CLI history"); } else { - evaluate_files(&args, &mut context, loader)?; + evaluate_files(&args, &mut context, &loader)?; } Ok(()) diff --git a/boa_engine/Cargo.toml b/boa_engine/Cargo.toml index cb9a15a241..4052c8cf32 100644 --- a/boa_engine/Cargo.toml +++ b/boa_engine/Cargo.toml @@ -133,3 +133,6 @@ bench = false [[bench]] name = "full" harness = false + +[lints] +workspace = true diff --git a/boa_engine/benches/full.rs b/boa_engine/benches/full.rs index 2478f187fb..c0df062855 100644 --- a/boa_engine/benches/full.rs +++ b/boa_engine/benches/full.rs @@ -1,3 +1,5 @@ +#![allow(unused_crate_dependencies, missing_docs)] + //! Benchmarks of the whole execution engine in Boa. use boa_engine::{ @@ -17,7 +19,7 @@ static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; fn create_realm(c: &mut Criterion) { c.bench_function("Create Realm", move |b| { let root_shape = RootShape::default(); - b.iter(|| Realm::create(&DefaultHooks, &root_shape)) + b.iter(|| Realm::create(&DefaultHooks, &root_shape)); }); } diff --git a/boa_engine/src/builtins/function/mod.rs b/boa_engine/src/builtins/function/mod.rs index 3fdaef9bf3..7b12288f16 100644 --- a/boa_engine/src/builtins/function/mod.rs +++ b/boa_engine/src/builtins/function/mod.rs @@ -253,7 +253,7 @@ impl OrdinaryFunction { &self.realm } - /// Check if function is [`FunctionKind::Ordinary`]. + /// Checks if this function is an ordinary function. pub(crate) fn is_ordinary(&self) -> bool { self.code.is_ordinary() } diff --git a/boa_engine/src/builtins/intl/locale/utils.rs b/boa_engine/src/builtins/intl/locale/utils.rs index e2879c2278..8b3d46cdb0 100644 --- a/boa_engine/src/builtins/intl/locale/utils.rs +++ b/boa_engine/src/builtins/intl/locale/utils.rs @@ -499,8 +499,8 @@ fn lookup_supported_locales( // 3. Return subset. requested_locales .iter() - .cloned() .filter(|loc| best_available_locale(loc.id.clone(), provider).is_some()) + .cloned() .collect() } @@ -517,8 +517,8 @@ fn best_fit_supported_locales( ) -> Vec { requested_locales .iter() - .cloned() .filter(|loc| best_locale_for_provider(loc.id.clone(), provider).is_some()) + .cloned() .collect() } diff --git a/boa_engine/src/builtins/options.rs b/boa_engine/src/builtins/options.rs index b2a99f5559..4628f0eee4 100644 --- a/boa_engine/src/builtins/options.rs +++ b/boa_engine/src/builtins/options.rs @@ -124,53 +124,6 @@ pub(crate) enum RoundingMode { HalfEven, } -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub(crate) enum UnsignedRoundingMode { - Infinity, - Zero, - HalfInfinity, - HalfZero, - HalfEven, -} - -impl RoundingMode { - pub(crate) const fn negate(self) -> Self { - use RoundingMode::{ - Ceil, Expand, Floor, HalfCeil, HalfEven, HalfExpand, HalfFloor, HalfTrunc, Trunc, - }; - - match self { - Ceil => Self::Floor, - Floor => Self::Ceil, - HalfCeil => Self::HalfFloor, - HalfFloor => Self::HalfCeil, - Trunc => Self::Trunc, - Expand => Self::Expand, - HalfTrunc => Self::HalfTrunc, - HalfExpand => Self::HalfExpand, - HalfEven => Self::HalfEven, - } - } - - pub(crate) const fn get_unsigned_round_mode(self, is_negative: bool) -> UnsignedRoundingMode { - use RoundingMode::{ - Ceil, Expand, Floor, HalfCeil, HalfEven, HalfExpand, HalfFloor, HalfTrunc, Trunc, - }; - - match self { - Ceil if !is_negative => UnsignedRoundingMode::Infinity, - Ceil => UnsignedRoundingMode::Zero, - Floor if !is_negative => UnsignedRoundingMode::Zero, - Floor | Trunc | Expand => UnsignedRoundingMode::Infinity, - HalfCeil if !is_negative => UnsignedRoundingMode::HalfInfinity, - HalfCeil | HalfTrunc => UnsignedRoundingMode::HalfZero, - HalfFloor if !is_negative => UnsignedRoundingMode::HalfZero, - HalfFloor | HalfExpand => UnsignedRoundingMode::HalfInfinity, - HalfEven => UnsignedRoundingMode::HalfEven, - } - } -} - #[derive(Debug)] pub(crate) struct ParseRoundingModeError; @@ -217,3 +170,53 @@ impl fmt::Display for RoundingMode { .fmt(f) } } + +#[cfg(feature = "temporal")] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub(crate) enum UnsignedRoundingMode { + Infinity, + Zero, + HalfInfinity, + HalfZero, + HalfEven, +} + +impl RoundingMode { + #[cfg(feature = "temporal")] + pub(crate) const fn negate(self) -> Self { + use RoundingMode::{ + Ceil, Expand, Floor, HalfCeil, HalfEven, HalfExpand, HalfFloor, HalfTrunc, Trunc, + }; + + match self { + Ceil => Self::Floor, + Floor => Self::Ceil, + HalfCeil => Self::HalfFloor, + HalfFloor => Self::HalfCeil, + Trunc => Self::Trunc, + Expand => Self::Expand, + HalfTrunc => Self::HalfTrunc, + HalfExpand => Self::HalfExpand, + HalfEven => Self::HalfEven, + } + } + + #[cfg(feature = "temporal")] + pub(crate) const fn get_unsigned_round_mode(self, is_negative: bool) -> UnsignedRoundingMode { + use RoundingMode::{ + Ceil, Expand, Floor, HalfCeil, HalfEven, HalfExpand, HalfFloor, HalfTrunc, Trunc, + }; + + match self { + Ceil if !is_negative => UnsignedRoundingMode::Infinity, + Ceil => UnsignedRoundingMode::Zero, + Floor if !is_negative => UnsignedRoundingMode::Zero, + Floor | Trunc | Expand => UnsignedRoundingMode::Infinity, + HalfCeil if !is_negative => UnsignedRoundingMode::HalfInfinity, + HalfCeil | HalfTrunc => UnsignedRoundingMode::HalfZero, + HalfFloor if !is_negative => UnsignedRoundingMode::HalfZero, + HalfFloor | HalfExpand => UnsignedRoundingMode::HalfInfinity, + HalfEven => UnsignedRoundingMode::HalfEven, + } + } +} diff --git a/boa_engine/src/builtins/temporal/duration/record.rs b/boa_engine/src/builtins/temporal/duration/record.rs index 18266c1e7e..cd29c089a6 100644 --- a/boa_engine/src/builtins/temporal/duration/record.rs +++ b/boa_engine/src/builtins/temporal/duration/record.rs @@ -1425,7 +1425,7 @@ impl DurationRecord { // 2. If zonedRelativeTo is not present, set zonedRelativeTo to undefined. let zoned_relative_to = relative_targets.1; // 3. If precalculatedPlainDateTime is not present, set precalculatedPlainDateTime to undefined. - let _precalc_pdt = relative_targets.2; + let _ = relative_targets.2; let (frac_days, frac_secs) = match unit { // 4. If unit is "year", "month", or "week", and plainRelativeTo is undefined, then diff --git a/boa_engine/src/builtins/typed_array/element/mod.rs b/boa_engine/src/builtins/typed_array/element/mod.rs index 3137816f4b..1d0383766a 100644 --- a/boa_engine/src/builtins/typed_array/element/mod.rs +++ b/boa_engine/src/builtins/typed_array/element/mod.rs @@ -1,5 +1,6 @@ #![deny(unsafe_op_in_unsafe_fn)] #![allow(clippy::cast_ptr_alignment)] // Invariants are checked by the caller. +#![allow(unused_tuple_struct_fields)] // Weird false-positive with `boa_macros_tests` mod atomic; diff --git a/boa_engine/src/lib.rs b/boa_engine/src/lib.rs index d7bb7cf770..a9bb3af0dd 100644 --- a/boa_engine/src/lib.rs +++ b/boa_engine/src/lib.rs @@ -50,60 +50,8 @@ html_logo_url = "https://raw.githubusercontent.com/boa-dev/boa/main/assets/logo.svg", html_favicon_url = "https://raw.githubusercontent.com/boa-dev/boa/main/assets/logo.svg" )] +#![cfg_attr(test, allow(clippy::needless_raw_string_hashes))] // Makes strings a bit more copy-pastable #![cfg_attr(not(test), forbid(clippy::unwrap_used))] -#![warn( - // rustc lint groups https://doc.rust-lang.org/rustc/lints/groups.html - warnings, - future_incompatible, - let_underscore, - nonstandard_style, - rust_2018_compatibility, - rust_2018_idioms, - rust_2021_compatibility, - unused, - - // rustc allowed-by-default lints https://doc.rust-lang.org/rustc/lints/listing/allowed-by-default.html - missing_docs, - macro_use_extern_crate, - meta_variable_misuse, - missing_abi, - missing_copy_implementations, - missing_debug_implementations, - non_ascii_idents, - noop_method_call, - single_use_lifetimes, - trivial_casts, - trivial_numeric_casts, - unreachable_pub, - unsafe_op_in_unsafe_fn, - unused_crate_dependencies, - unused_import_braces, - unused_lifetimes, - unused_qualifications, - unused_tuple_struct_fields, - variant_size_differences, - - // rustdoc lints https://doc.rust-lang.org/rustdoc/lints.html - rustdoc::broken_intra_doc_links, - rustdoc::private_intra_doc_links, - rustdoc::missing_crate_level_docs, - rustdoc::private_doc_tests, - rustdoc::invalid_codeblock_attributes, - rustdoc::invalid_rust_codeblocks, - rustdoc::bare_urls, - - // clippy allowed by default - clippy::dbg_macro, - - // clippy categories https://doc.rust-lang.org/clippy/ - clippy::all, - clippy::correctness, - clippy::suspicious, - clippy::style, - clippy::complexity, - clippy::perf, - clippy::pedantic, -)] #![allow( // Currently throws a false positive regarding dependencies that are only used in benchmarks. unused_crate_dependencies, diff --git a/boa_engine/src/symbol.rs b/boa_engine/src/symbol.rs index d6a6b6c180..7514a69088 100644 --- a/boa_engine/src/symbol.rs +++ b/boa_engine/src/symbol.rs @@ -151,7 +151,7 @@ unsafe impl Trace for JsSymbol { macro_rules! well_known_symbols { ( $( $(#[$attr:meta])* ($name:ident, $variant:path) ),+$(,)? ) => { $( - $(#[$attr])* pub const fn $name() -> JsSymbol { + $(#[$attr])* #[must_use] pub const fn $name() -> JsSymbol { JsSymbol { // the cast shouldn't matter since we only have 127 const symbols repr: Tagged::from_tag($variant.hash() as usize), diff --git a/boa_examples/Cargo.toml b/boa_examples/Cargo.toml index 5be71d7cd7..72c2711326 100644 --- a/boa_examples/Cargo.toml +++ b/boa_examples/Cargo.toml @@ -19,3 +19,41 @@ boa_runtime.workspace = true chrono.workspace = true smol = "1.3.0" futures-util = "0.3.29" + + +# use explicit lints for examples, since we don't need to lint for docs +[lints.rust] +# rustc lint groups https://doc.rust-lang.org/rustc/lints/groups.html +warnings = "warn" +future_incompatible = "warn" +let_underscore = "warn" +nonstandard_style = "warn" +rust_2018_compatibility = "warn" +rust_2018_idioms = "warn" +rust_2021_compatibility = "warn" +unused = "warn" +macro_use_extern_crate = "warn" +meta_variable_misuse = "warn" +missing_abi = "warn" +missing_copy_implementations = "warn" +missing_debug_implementations = "warn" +non_ascii_idents = "warn" +noop_method_call = "warn" +single_use_lifetimes = "warn" +trivial_casts = "warn" +trivial_numeric_casts = "warn" +unreachable_pub = "warn" +unsafe_op_in_unsafe_fn = "warn" +unused_import_braces = "warn" +unused_lifetimes = "warn" +unused_qualifications = "warn" +unused_tuple_struct_fields = "warn" +variant_size_differences = "warn" + +[lints.clippy] +all = "warn" +correctness = "warn" +suspicious = "warn" +style = "warn" +complexity = "warn" +perf = "warn" diff --git a/boa_examples/src/bin/classes.rs b/boa_examples/src/bin/classes.rs index 2c62e2521c..c23d3da2bd 100644 --- a/boa_examples/src/bin/classes.rs +++ b/boa_examples/src/bin/classes.rs @@ -85,7 +85,7 @@ impl Class for Person { } /// Here is where the class is initialized. - fn init(class: &mut ClassBuilder) -> JsResult<()> { + fn init(class: &mut ClassBuilder<'_>) -> JsResult<()> { // We add a inheritable method `sayHello` with `0` arguments of length. // // This function is added to the `Person` prototype. diff --git a/boa_examples/src/bin/closures.rs b/boa_examples/src/bin/closures.rs index 8548f79a5e..9740882763 100644 --- a/boa_examples/src/bin/closures.rs +++ b/boa_examples/src/bin/closures.rs @@ -161,7 +161,7 @@ fn main() -> Result<(), JsError> { // We return the moved variable as a `JsValue`. Ok(JsArray::from_iter( - numbers.borrow().iter().cloned().map(JsValue::from), + numbers.borrow().iter().copied().map(JsValue::from), context, ) .into()) diff --git a/boa_examples/src/bin/commuter_visitor.rs b/boa_examples/src/bin/commuter_visitor.rs index 17fdff8da7..e6fb2cc9e0 100644 --- a/boa_examples/src/bin/commuter_visitor.rs +++ b/boa_examples/src/bin/commuter_visitor.rs @@ -53,7 +53,7 @@ impl<'ast> VisitorMut<'ast> for CommutorVisitor { let mut exchanger = OpExchanger::default(); assert!(matches!( exchanger.visit_binary_mut(node), - ControlFlow::Break(_) + ControlFlow::Break(()) )); } _ => {} @@ -74,7 +74,7 @@ fn main() { assert!(matches!( visitor.visit_statement_list_mut(script.statements_mut()), - ControlFlow::Continue(_) + ControlFlow::Continue(()) )); println!("{}", script.to_interned_string(ctx.interner())); diff --git a/boa_examples/src/bin/futures.rs b/boa_examples/src/bin/futures.rs index 060d410abc..d677a761af 100644 --- a/boa_examples/src/bin/futures.rs +++ b/boa_examples/src/bin/futures.rs @@ -34,16 +34,16 @@ impl<'a> Queue<'a> { } } -impl<'a> JobQueue for Queue<'a> { - fn enqueue_promise_job(&self, job: NativeJob, _context: &mut boa_engine::Context) { +impl JobQueue for Queue<'_> { + fn enqueue_promise_job(&self, job: NativeJob, _context: &mut Context) { self.jobs.borrow_mut().push_back(job); } - fn enqueue_future_job(&self, future: FutureJob, _context: &mut boa_engine::Context) { - self.futures.borrow().push(future) + fn enqueue_future_job(&self, future: FutureJob, _context: &mut Context) { + self.futures.borrow().push(future); } - fn run_jobs(&self, context: &mut boa_engine::Context) { + fn run_jobs(&self, context: &mut Context) { // Early return in case there were no jobs scheduled. if self.jobs.borrow().is_empty() && self.futures.borrow().is_empty() { return; @@ -55,7 +55,7 @@ impl<'a> JobQueue for Queue<'a> { // Used to sync the finalization of both tasks let finished = Cell::new(0b00u8); - let fqueue = async { + let fut_queue = async { loop { if self.futures.borrow().is_empty() { finished.set(finished.get() | 0b01); @@ -82,7 +82,7 @@ impl<'a> JobQueue for Queue<'a> { } }; - let jqueue = async { + let job_queue = async { loop { if self.jobs.borrow().is_empty() { finished.set(finished.get() | 0b10); @@ -109,8 +109,8 @@ impl<'a> JobQueue for Queue<'a> { }; // Wait for both queues to complete - future::zip(fqueue, jqueue).await; - })) + future::zip(fut_queue, job_queue).await; + })); } } @@ -126,7 +126,7 @@ fn delay( let millis = millis?; println!("Delaying for {millis} milliseconds ..."); let now = Instant::now(); - smol::Timer::after(Duration::from_millis(millis as u64)).await; + smol::Timer::after(Duration::from_millis(u64::from(millis))).await; let elapsed = now.elapsed().as_secs_f64(); Ok(elapsed.into()) } @@ -163,7 +163,7 @@ fn main() { add_runtime(context); // Multiple calls to multiple async timers. - let script = r#" + let script = r" function print(elapsed) { console.log(`Finished. elapsed time: ${elapsed * 1000} ms`) } @@ -172,7 +172,7 @@ fn main() { delay(200).then(print); delay(600).then(print); delay(30).then(print); - "#; + "; let now = Instant::now(); context.eval(Source::from_bytes(script)).unwrap(); diff --git a/boa_examples/src/bin/jsarraybuffer.rs b/boa_examples/src/bin/jsarraybuffer.rs index 26df61bac8..2614ffd7e7 100644 --- a/boa_examples/src/bin/jsarraybuffer.rs +++ b/boa_examples/src/bin/jsarraybuffer.rs @@ -17,7 +17,7 @@ fn main() -> JsResult<()> { // We can now create an typed array to access the data. let uint32_typed_array = JsUint32Array::from_array_buffer(array_buffer, context)?; - let value = 0x12345678u32; + let value = 0x1234_5678_u32; uint32_typed_array.set(0_u64, value, true, context)?; assert_eq!(uint32_typed_array.get(0_u64, context)?, JsValue::new(value)); diff --git a/boa_examples/src/bin/jsdate.rs b/boa_examples/src/bin/jsdate.rs index b1da16f25f..04df85acda 100644 --- a/boa_examples/src/bin/jsdate.rs +++ b/boa_examples/src/bin/jsdate.rs @@ -40,7 +40,7 @@ fn main() -> JsResult<()> { .as_number() .unwrap(); - assert_eq!(timestamp, 823230245000.0); + assert_eq!(timestamp, 823_230_245_000.0); // Gets the current time in UTC time. let date = JsDate::new(context); diff --git a/boa_examples/src/bin/modules.rs b/boa_examples/src/bin/modules.rs index 65af1470a4..68037590f3 100644 --- a/boa_examples/src/bin/modules.rs +++ b/boa_examples/src/bin/modules.rs @@ -93,7 +93,7 @@ fn main() -> Result<(), Box> { match promise_result.state() { PromiseState::Pending => return Err("module didn't execute!".into()), PromiseState::Fulfilled(v) => { - assert_eq!(v, JsValue::undefined()) + assert_eq!(v, JsValue::undefined()); } PromiseState::Rejected(err) => { return Err(JsError::from_opaque(err).try_native(context)?.into()) diff --git a/boa_examples/src/bin/synthetic.rs b/boa_examples/src/bin/synthetic.rs index ea3e23fe8d..48f1784489 100644 --- a/boa_examples/src/bin/synthetic.rs +++ b/boa_examples/src/bin/synthetic.rs @@ -68,7 +68,7 @@ fn main() -> Result<(), Box> { match promise_result.state() { PromiseState::Pending => return Err("module didn't execute!".into()), PromiseState::Fulfilled(v) => { - assert_eq!(v, JsValue::undefined()) + assert_eq!(v, JsValue::undefined()); } PromiseState::Rejected(err) => { return Err(JsError::from_opaque(err).try_native(context)?.into()) diff --git a/boa_gc/Cargo.toml b/boa_gc/Cargo.toml index 6e91cf05d0..2f682112e7 100644 --- a/boa_gc/Cargo.toml +++ b/boa_gc/Cargo.toml @@ -20,3 +20,6 @@ boa_macros.workspace = true thin-vec = { workspace = true, optional = true } hashbrown = { workspace = true, features = ["ahash", "raw"] } + +[lints] +workspace = true diff --git a/boa_gc/src/lib.rs b/boa_gc/src/lib.rs index 698f6001bd..2d1808b425 100644 --- a/boa_gc/src/lib.rs +++ b/boa_gc/src/lib.rs @@ -9,60 +9,6 @@ html_favicon_url = "https://raw.githubusercontent.com/boa-dev/boa/main/assets/logo.svg" )] #![cfg_attr(not(test), forbid(clippy::unwrap_used))] -#![warn( - // rustc lint groups https://doc.rust-lang.org/rustc/lints/groups.html - warnings, - future_incompatible, - let_underscore, - nonstandard_style, - rust_2018_compatibility, - rust_2018_idioms, - rust_2021_compatibility, - unused, - - // rustc allowed-by-default lints https://doc.rust-lang.org/rustc/lints/listing/allowed-by-default.html - missing_docs, - macro_use_extern_crate, - meta_variable_misuse, - missing_abi, - missing_copy_implementations, - missing_debug_implementations, - non_ascii_idents, - noop_method_call, - single_use_lifetimes, - trivial_casts, - trivial_numeric_casts, - unreachable_pub, - unsafe_op_in_unsafe_fn, - unused_crate_dependencies, - unused_import_braces, - unused_lifetimes, - unused_qualifications, - unused_tuple_struct_fields, - variant_size_differences, - - // rustdoc lints https://doc.rust-lang.org/rustdoc/lints.html - rustdoc::broken_intra_doc_links, - rustdoc::private_intra_doc_links, - rustdoc::missing_crate_level_docs, - rustdoc::private_doc_tests, - rustdoc::invalid_codeblock_attributes, - rustdoc::invalid_rust_codeblocks, - rustdoc::bare_urls, - - // clippy allowed by default - clippy::dbg_macro, - clippy::undocumented_unsafe_blocks, - - // clippy categories https://doc.rust-lang.org/clippy/ - clippy::all, - clippy::correctness, - clippy::suspicious, - clippy::style, - clippy::complexity, - clippy::perf, - clippy::pedantic, -)] #![allow( clippy::module_name_repetitions, clippy::redundant_pub_crate, diff --git a/boa_icu_provider/Cargo.toml b/boa_icu_provider/Cargo.toml index d679e1b578..309fab6015 100644 --- a/boa_icu_provider/Cargo.toml +++ b/boa_icu_provider/Cargo.toml @@ -31,3 +31,6 @@ bin = ["dep:icu_datagen", "dep:simple_logger", "dep:log"] name = "boa_datagen" path = "src/bin/datagen.rs" required-features = ["bin"] + +[lints] +workspace = true diff --git a/boa_icu_provider/src/bin/datagen.rs b/boa_icu_provider/src/bin/datagen.rs index b791581f3c..22cf441aa8 100644 --- a/boa_icu_provider/src/bin/datagen.rs +++ b/boa_icu_provider/src/bin/datagen.rs @@ -2,6 +2,11 @@ html_logo_url = "https://raw.githubusercontent.com/boa-dev/boa/main/assets/logo.svg", html_favicon_url = "https://raw.githubusercontent.com/boa-dev/boa/main/assets/logo.svg" )] +#![allow( + unused_crate_dependencies, + missing_docs, + rustdoc::missing_crate_level_docs +)] use std::{error::Error, fs::File}; diff --git a/boa_icu_provider/src/lib.rs b/boa_icu_provider/src/lib.rs index 0a9aa072dd..abf29ee919 100644 --- a/boa_icu_provider/src/lib.rs +++ b/boa_icu_provider/src/lib.rs @@ -19,60 +19,8 @@ html_logo_url = "https://raw.githubusercontent.com/boa-dev/boa/main/assets/logo.svg", html_favicon_url = "https://raw.githubusercontent.com/boa-dev/boa/main/assets/logo.svg" )] -#![warn( - // rustc lint groups https://doc.rust-lang.org/rustc/lints/groups.html - warnings, - future_incompatible, - let_underscore, - nonstandard_style, - rust_2018_compatibility, - rust_2018_idioms, - rust_2021_compatibility, - unused, - - // rustc allowed-by-default lints https://doc.rust-lang.org/rustc/lints/listing/allowed-by-default.html - missing_docs, - macro_use_extern_crate, - meta_variable_misuse, - missing_abi, - missing_copy_implementations, - missing_debug_implementations, - non_ascii_idents, - noop_method_call, - single_use_lifetimes, - trivial_casts, - trivial_numeric_casts, - unreachable_pub, - unsafe_op_in_unsafe_fn, - unused_import_braces, - unused_lifetimes, - unused_qualifications, - unused_tuple_struct_fields, - variant_size_differences, - - // rustdoc lints https://doc.rust-lang.org/rustdoc/lints.html - rustdoc::broken_intra_doc_links, - rustdoc::private_intra_doc_links, - rustdoc::missing_crate_level_docs, - rustdoc::private_doc_tests, - rustdoc::invalid_codeblock_attributes, - rustdoc::invalid_rust_codeblocks, - rustdoc::bare_urls, - - // clippy allowed by default - clippy::dbg_macro, - - // clippy categories https://doc.rust-lang.org/clippy/ - clippy::all, - clippy::correctness, - clippy::suspicious, - clippy::style, - clippy::complexity, - clippy::perf, - clippy::pedantic, -)] -#![allow(elided_lifetimes_in_paths)] #![cfg_attr(not(feature = "bin"), no_std)] +#![allow(unused_crate_dependencies)] /// Gets the path to the directory where the generated data is stored. #[cfg(feature = "bin")] diff --git a/boa_interner/Cargo.toml b/boa_interner/Cargo.toml index 4bc9909d61..cdd433aecf 100644 --- a/boa_interner/Cargo.toml +++ b/boa_interner/Cargo.toml @@ -25,3 +25,6 @@ indexmap.workspace = true serde = { workspace = true, features = ["derive"], optional = true } arbitrary = { workspace = true, features = ["derive"], optional = true } hashbrown = { workspace = true, default-features = false, features = ["inline-more"] } + +[lints] +workspace = true diff --git a/boa_interner/src/lib.rs b/boa_interner/src/lib.rs index 9ac053b421..115d5b497e 100644 --- a/boa_interner/src/lib.rs +++ b/boa_interner/src/lib.rs @@ -15,59 +15,6 @@ html_favicon_url = "https://raw.githubusercontent.com/boa-dev/boa/main/assets/logo.svg" )] #![cfg_attr(not(test), forbid(clippy::unwrap_used))] -#![warn( - // rustc lint groups https://doc.rust-lang.org/rustc/lints/groups.html - warnings, - future_incompatible, - let_underscore, - nonstandard_style, - rust_2018_compatibility, - rust_2018_idioms, - rust_2021_compatibility, - unused, - - // rustc allowed-by-default lints https://doc.rust-lang.org/rustc/lints/listing/allowed-by-default.html - missing_docs, - macro_use_extern_crate, - meta_variable_misuse, - missing_abi, - missing_copy_implementations, - missing_debug_implementations, - non_ascii_idents, - noop_method_call, - single_use_lifetimes, - trivial_casts, - trivial_numeric_casts, - unreachable_pub, - unsafe_op_in_unsafe_fn, - unused_crate_dependencies, - unused_import_braces, - unused_lifetimes, - unused_qualifications, - unused_tuple_struct_fields, - variant_size_differences, - - // rustdoc lints https://doc.rust-lang.org/rustdoc/lints.html - rustdoc::broken_intra_doc_links, - rustdoc::private_intra_doc_links, - rustdoc::missing_crate_level_docs, - rustdoc::private_doc_tests, - rustdoc::invalid_codeblock_attributes, - rustdoc::invalid_rust_codeblocks, - rustdoc::bare_urls, - - // clippy allowed by default - clippy::dbg_macro, - - // clippy categories https://doc.rust-lang.org/clippy/ - clippy::all, - clippy::correctness, - clippy::suspicious, - clippy::style, - clippy::complexity, - clippy::perf, - clippy::pedantic, -)] #![allow( clippy::redundant_pub_crate, // TODO deny once false positive is fixed (https://github.com/rust-lang/rust-clippy/issues/9626). diff --git a/boa_macros/Cargo.toml b/boa_macros/Cargo.toml index 6c8741dce5..ac70c27195 100644 --- a/boa_macros/Cargo.toml +++ b/boa_macros/Cargo.toml @@ -16,3 +16,6 @@ quote = "1.0.33" syn = { version = "2.0.39", features = ["full"] } proc-macro2 = "1.0" synstructure = "0.13" + +[lints] +workspace = true diff --git a/boa_macros/src/lib.rs b/boa_macros/src/lib.rs index c56fb5f1e0..42b32d4c89 100644 --- a/boa_macros/src/lib.rs +++ b/boa_macros/src/lib.rs @@ -5,59 +5,6 @@ html_favicon_url = "https://raw.githubusercontent.com/boa-dev/boa/main/assets/logo.svg" )] #![cfg_attr(not(test), forbid(clippy::unwrap_used))] -#![warn( - // rustc lint groups https://doc.rust-lang.org/rustc/lints/groups.html - warnings, - future_incompatible, - let_underscore, - nonstandard_style, - rust_2018_compatibility, - rust_2018_idioms, - rust_2021_compatibility, - unused, - - // rustc allowed-by-default lints https://doc.rust-lang.org/rustc/lints/listing/allowed-by-default.html - missing_docs, - macro_use_extern_crate, - meta_variable_misuse, - missing_abi, - missing_copy_implementations, - missing_debug_implementations, - non_ascii_idents, - noop_method_call, - single_use_lifetimes, - trivial_casts, - trivial_numeric_casts, - unreachable_pub, - unsafe_op_in_unsafe_fn, - unused_crate_dependencies, - unused_import_braces, - unused_lifetimes, - unused_qualifications, - unused_tuple_struct_fields, - variant_size_differences, - - // rustdoc lints https://doc.rust-lang.org/rustdoc/lints.html - rustdoc::broken_intra_doc_links, - rustdoc::private_intra_doc_links, - rustdoc::missing_crate_level_docs, - rustdoc::private_doc_tests, - rustdoc::invalid_codeblock_attributes, - rustdoc::invalid_rust_codeblocks, - rustdoc::bare_urls, - - // clippy allowed by default - clippy::dbg_macro, - - // clippy categories https://doc.rust-lang.org/clippy/ - clippy::all, - clippy::correctness, - clippy::suspicious, - clippy::style, - clippy::complexity, - clippy::perf, - clippy::pedantic, -)] use proc_macro::TokenStream; use quote::{quote, ToTokens}; diff --git a/boa_macros/tests/tests.rs b/boa_macros/tests/tests.rs index c3ece6489b..f0888e0c61 100644 --- a/boa_macros/tests/tests.rs +++ b/boa_macros/tests/tests.rs @@ -1,3 +1,5 @@ +#![allow(unused_crate_dependencies)] + use boa_macros::utf16; #[test] diff --git a/boa_macros_tests/Cargo.toml b/boa_macros_tests/Cargo.toml index 9dca444385..a4da3ee7ab 100644 --- a/boa_macros_tests/Cargo.toml +++ b/boa_macros_tests/Cargo.toml @@ -14,3 +14,6 @@ rust-version.workspace = true trybuild = "1.0.85" boa_macros.workspace = true boa_engine.workspace = true + +[lints] +workspace = true diff --git a/boa_macros_tests/tests/derive/from_js_with.rs b/boa_macros_tests/tests/derive/from_js_with.rs index a40bba62a6..2fd5184d27 100644 --- a/boa_macros_tests/tests/derive/from_js_with.rs +++ b/boa_macros_tests/tests/derive/from_js_with.rs @@ -1,3 +1,5 @@ +#![allow(unused, unused_tuple_struct_fields)] + use boa_engine::{value::TryFromJs, Context, JsNativeError, JsResult, JsValue}; #[derive(TryFromJs)] diff --git a/boa_macros_tests/tests/derive/simple_struct.rs b/boa_macros_tests/tests/derive/simple_struct.rs index f9ea0c97b2..5249412bb6 100644 --- a/boa_macros_tests/tests/derive/simple_struct.rs +++ b/boa_macros_tests/tests/derive/simple_struct.rs @@ -1,3 +1,5 @@ +#![allow(unused, unused_tuple_struct_fields)] + use boa_engine::value::TryFromJs; #[derive(TryFromJs)] diff --git a/boa_macros_tests/tests/tests.rs b/boa_macros_tests/tests/tests.rs index 16de9065e0..d94f31d8b6 100644 --- a/boa_macros_tests/tests/tests.rs +++ b/boa_macros_tests/tests/tests.rs @@ -1,3 +1,5 @@ +#![allow(unused_crate_dependencies, unused_tuple_struct_fields)] + #[test] fn try_from_js() { let t = trybuild::TestCases::new(); diff --git a/boa_parser/Cargo.toml b/boa_parser/Cargo.toml index 3ca20507b2..0207b59d84 100644 --- a/boa_parser/Cargo.toml +++ b/boa_parser/Cargo.toml @@ -26,3 +26,6 @@ icu_properties.workspace = true [features] annex-b = [] temporal = ["boa_ast/temporal"] + +[lints] +workspace = true diff --git a/boa_parser/src/lib.rs b/boa_parser/src/lib.rs index 13aa2e56c0..ab6370c516 100644 --- a/boa_parser/src/lib.rs +++ b/boa_parser/src/lib.rs @@ -14,60 +14,8 @@ html_logo_url = "https://raw.githubusercontent.com/boa-dev/boa/main/assets/logo.svg", html_favicon_url = "https://raw.githubusercontent.com/boa-dev/boa/main/assets/logo.svg" )] +#![cfg_attr(test, allow(clippy::needless_raw_string_hashes))] // Makes strings a bit more copy-pastable #![cfg_attr(not(test), forbid(clippy::unwrap_used))] -#![warn( - // rustc lint groups https://doc.rust-lang.org/rustc/lints/groups.html - warnings, - future_incompatible, - let_underscore, - nonstandard_style, - rust_2018_compatibility, - rust_2018_idioms, - rust_2021_compatibility, - unused, - - // rustc allowed-by-default lints https://doc.rust-lang.org/rustc/lints/listing/allowed-by-default.html - missing_docs, - macro_use_extern_crate, - meta_variable_misuse, - missing_abi, - missing_copy_implementations, - missing_debug_implementations, - non_ascii_idents, - noop_method_call, - single_use_lifetimes, - trivial_casts, - trivial_numeric_casts, - unreachable_pub, - unsafe_op_in_unsafe_fn, - unused_crate_dependencies, - unused_import_braces, - unused_lifetimes, - unused_qualifications, - unused_tuple_struct_fields, - variant_size_differences, - - // rustdoc lints https://doc.rust-lang.org/rustdoc/lints.html - rustdoc::broken_intra_doc_links, - rustdoc::private_intra_doc_links, - rustdoc::missing_crate_level_docs, - rustdoc::private_doc_tests, - rustdoc::invalid_codeblock_attributes, - rustdoc::invalid_rust_codeblocks, - rustdoc::bare_urls, - - // clippy allowed by default - clippy::dbg_macro, - - // clippy categories https://doc.rust-lang.org/clippy/ - clippy::all, - clippy::correctness, - clippy::suspicious, - clippy::style, - clippy::complexity, - clippy::perf, - clippy::pedantic, -)] #![allow( clippy::module_name_repetitions, clippy::too_many_lines, diff --git a/boa_parser/src/parser/tests/test.js b/boa_parser/src/parser/tests/test.js new file mode 100644 index 0000000000..e292865b73 --- /dev/null +++ b/boa_parser/src/parser/tests/test.js @@ -0,0 +1 @@ +"Hello" + "World"; diff --git a/boa_parser/src/source.rs b/boa_parser/src/source.rs index af60e9467e..fb37e50ce1 100644 --- a/boa_parser/src/source.rs +++ b/boa_parser/src/source.rs @@ -90,7 +90,7 @@ impl<'path, R: Read> Source<'path, R> { #[cfg(test)] mod tests { use super::*; - use std::{fs, io::Cursor}; + use std::io::Cursor; #[test] fn from_bytes() { @@ -106,15 +106,16 @@ mod tests { #[test] fn from_filepath() { - fs::write("test.js", "'Hello' + 'World';").unwrap(); - let mut source = Source::from_filepath("test.js".as_ref()).unwrap(); + let manifest_path = Path::new(env!("CARGO_MANIFEST_DIR")); + let filepath = manifest_path.join("src/parser/tests/test.js"); + let mut source = Source::from_filepath(&filepath).unwrap(); - assert_eq!(source.path, Some("test.js".as_ref())); + assert_eq!(source.path, Some(&*filepath)); let mut content = String::new(); source.reader.read_to_string(&mut content).unwrap(); - assert_eq!(content, "'Hello' + 'World';"); + assert_eq!(content, "\"Hello\" + \"World\";\n"); } #[test] diff --git a/boa_profiler/Cargo.toml b/boa_profiler/Cargo.toml index 28eec85eb1..86edbf43c5 100644 --- a/boa_profiler/Cargo.toml +++ b/boa_profiler/Cargo.toml @@ -17,3 +17,6 @@ profiler = ["dep:measureme", "dep:once_cell", "dep:rustc-hash"] measureme = { version = "10.1.1", optional = true } once_cell = { workspace = true, optional = true, features = ["std"] } rustc-hash = { workspace = true, optional = true } + +[lints] +workspace = true diff --git a/boa_profiler/src/lib.rs b/boa_profiler/src/lib.rs index 2723c958c0..69d1927cab 100644 --- a/boa_profiler/src/lib.rs +++ b/boa_profiler/src/lib.rs @@ -12,59 +12,6 @@ html_favicon_url = "https://raw.githubusercontent.com/boa-dev/boa/main/assets/logo.svg" )] #![cfg_attr(not(test), forbid(clippy::unwrap_used))] -#![warn( - // rustc lint groups https://doc.rust-lang.org/rustc/lints/groups.html - warnings, - future_incompatible, - let_underscore, - nonstandard_style, - rust_2018_compatibility, - rust_2018_idioms, - rust_2021_compatibility, - unused, - - // rustc allowed-by-default lints https://doc.rust-lang.org/rustc/lints/listing/allowed-by-default.html - missing_docs, - macro_use_extern_crate, - meta_variable_misuse, - missing_abi, - missing_copy_implementations, - missing_debug_implementations, - non_ascii_idents, - noop_method_call, - single_use_lifetimes, - trivial_casts, - trivial_numeric_casts, - unreachable_pub, - unsafe_op_in_unsafe_fn, - unused_crate_dependencies, - unused_import_braces, - unused_lifetimes, - unused_qualifications, - unused_tuple_struct_fields, - variant_size_differences, - - // rustdoc lints https://doc.rust-lang.org/rustdoc/lints.html - rustdoc::broken_intra_doc_links, - rustdoc::private_intra_doc_links, - rustdoc::missing_crate_level_docs, - rustdoc::private_doc_tests, - rustdoc::invalid_codeblock_attributes, - rustdoc::invalid_rust_codeblocks, - rustdoc::bare_urls, - - // clippy allowed by default - clippy::dbg_macro, - - // clippy categories https://doc.rust-lang.org/clippy/ - clippy::all, - clippy::correctness, - clippy::suspicious, - clippy::style, - clippy::complexity, - clippy::perf, - clippy::pedantic, -)] #![cfg_attr(not(feature = "profiler"), no_std)] use core::fmt::{self, Debug}; diff --git a/boa_runtime/Cargo.toml b/boa_runtime/Cargo.toml index 655f9bc767..f9e0ee974b 100644 --- a/boa_runtime/Cargo.toml +++ b/boa_runtime/Cargo.toml @@ -18,3 +18,6 @@ rustc-hash = { workspace = true, features = ["std"] } [dev-dependencies] indoc.workspace = true textwrap.workspace = true + +[lints] +workspace = true diff --git a/boa_runtime/src/lib.rs b/boa_runtime/src/lib.rs index d3e71b29c5..93ff44feff 100644 --- a/boa_runtime/src/lib.rs +++ b/boa_runtime/src/lib.rs @@ -43,60 +43,8 @@ html_logo_url = "https://raw.githubusercontent.com/boa-dev/boa/main/assets/logo.svg", html_favicon_url = "https://raw.githubusercontent.com/boa-dev/boa/main/assets/logo.svg" )] +#![cfg_attr(test, allow(clippy::needless_raw_string_hashes))] // Makes strings a bit more copy-pastable #![cfg_attr(not(test), forbid(clippy::unwrap_used))] -#![warn( - // rustc lint groups https://doc.rust-lang.org/rustc/lints/groups.html - warnings, - future_incompatible, - let_underscore, - nonstandard_style, - rust_2018_compatibility, - rust_2018_idioms, - rust_2021_compatibility, - unused, - - // rustc allowed-by-default lints https://doc.rust-lang.org/rustc/lints/listing/allowed-by-default.html - missing_docs, - macro_use_extern_crate, - meta_variable_misuse, - missing_abi, - missing_copy_implementations, - missing_debug_implementations, - non_ascii_idents, - noop_method_call, - single_use_lifetimes, - trivial_casts, - trivial_numeric_casts, - unreachable_pub, - unsafe_op_in_unsafe_fn, - unused_crate_dependencies, - unused_import_braces, - unused_lifetimes, - unused_qualifications, - unused_tuple_struct_fields, - variant_size_differences, - - // rustdoc lints https://doc.rust-lang.org/rustdoc/lints.html - rustdoc::broken_intra_doc_links, - rustdoc::private_intra_doc_links, - rustdoc::missing_crate_level_docs, - rustdoc::private_doc_tests, - rustdoc::invalid_codeblock_attributes, - rustdoc::invalid_rust_codeblocks, - rustdoc::bare_urls, - - // clippy allowed by default - clippy::dbg_macro, - - // clippy categories https://doc.rust-lang.org/clippy/ - clippy::all, - clippy::correctness, - clippy::suspicious, - clippy::style, - clippy::complexity, - clippy::perf, - clippy::pedantic, -)] #![allow( clippy::module_name_repetitions, clippy::redundant_pub_crate, diff --git a/boa_tester/Cargo.toml b/boa_tester/Cargo.toml index d4e2d45d94..c4d95a11df 100644 --- a/boa_tester/Cargo.toml +++ b/boa_tester/Cargo.toml @@ -34,3 +34,6 @@ bus = "2.4.1" [features] default = ["boa_engine/intl", "boa_engine/experimental", "boa_engine/annex-b"] + +[lints] +workspace = true diff --git a/boa_tester/src/main.rs b/boa_tester/src/main.rs index 1271f396bb..0305d2f4b7 100644 --- a/boa_tester/src/main.rs +++ b/boa_tester/src/main.rs @@ -8,59 +8,6 @@ html_favicon_url = "https://raw.githubusercontent.com/boa-dev/boa/main/assets/logo.svg" )] #![cfg_attr(not(test), deny(clippy::unwrap_used))] -#![warn( - // rustc lint groups https://doc.rust-lang.org/rustc/lints/groups.html - warnings, - future_incompatible, - let_underscore, - nonstandard_style, - rust_2018_compatibility, - rust_2018_idioms, - rust_2021_compatibility, - unused, - - // rustc allowed-by-default lints https://doc.rust-lang.org/rustc/lints/listing/allowed-by-default.html - missing_docs, - macro_use_extern_crate, - meta_variable_misuse, - missing_abi, - missing_copy_implementations, - missing_debug_implementations, - non_ascii_idents, - noop_method_call, - single_use_lifetimes, - trivial_casts, - trivial_numeric_casts, - unreachable_pub, - unsafe_op_in_unsafe_fn, - unused_crate_dependencies, - unused_import_braces, - unused_lifetimes, - unused_qualifications, - unused_tuple_struct_fields, - variant_size_differences, - - // rustdoc lints https://doc.rust-lang.org/rustdoc/lints.html - rustdoc::broken_intra_doc_links, - rustdoc::private_intra_doc_links, - rustdoc::missing_crate_level_docs, - rustdoc::private_doc_tests, - rustdoc::invalid_codeblock_attributes, - rustdoc::invalid_rust_codeblocks, - rustdoc::bare_urls, - - // clippy allowed by default - clippy::dbg_macro, - - // clippy categories https://doc.rust-lang.org/clippy/ - clippy::all, - clippy::correctness, - clippy::suspicious, - clippy::style, - clippy::complexity, - clippy::perf, - clippy::pedantic, -)] #![allow( clippy::too_many_lines, clippy::redundant_pub_crate, diff --git a/boa_wasm/Cargo.toml b/boa_wasm/Cargo.toml index 7c0b2f571e..8dcdd89312 100644 --- a/boa_wasm/Cargo.toml +++ b/boa_wasm/Cargo.toml @@ -25,3 +25,6 @@ default = ["boa_engine/annex-b", "boa_engine/intl", "boa_engine/experimental"] crate-type = ["cdylib", "lib"] name = "boa_wasm" bench = false + +[lints] +workspace = true diff --git a/boa_wasm/src/lib.rs b/boa_wasm/src/lib.rs index 45027194b3..57e1837955 100644 --- a/boa_wasm/src/lib.rs +++ b/boa_wasm/src/lib.rs @@ -5,59 +5,6 @@ html_favicon_url = "https://raw.githubusercontent.com/boa-dev/boa/main/assets/logo.svg" )] #![cfg_attr(not(test), forbid(clippy::unwrap_used))] -#![warn( - // rustc lint groups https://doc.rust-lang.org/rustc/lints/groups.html - warnings, - future_incompatible, - let_underscore, - nonstandard_style, - rust_2018_compatibility, - rust_2018_idioms, - rust_2021_compatibility, - unused, - - // rustc allowed-by-default lints https://doc.rust-lang.org/rustc/lints/listing/allowed-by-default.html - missing_docs, - macro_use_extern_crate, - meta_variable_misuse, - missing_abi, - missing_copy_implementations, - missing_debug_implementations, - non_ascii_idents, - noop_method_call, - single_use_lifetimes, - trivial_casts, - trivial_numeric_casts, - unreachable_pub, - unsafe_op_in_unsafe_fn, - unused_crate_dependencies, - unused_import_braces, - unused_lifetimes, - unused_qualifications, - unused_tuple_struct_fields, - variant_size_differences, - - // rustdoc lints https://doc.rust-lang.org/rustdoc/lints.html - rustdoc::broken_intra_doc_links, - rustdoc::private_intra_doc_links, - rustdoc::missing_crate_level_docs, - rustdoc::private_doc_tests, - rustdoc::invalid_codeblock_attributes, - rustdoc::invalid_rust_codeblocks, - rustdoc::bare_urls, - - // clippy allowed by default - clippy::dbg_macro, - - // clippy categories https://doc.rust-lang.org/clippy/ - clippy::all, - clippy::correctness, - clippy::suspicious, - clippy::style, - clippy::complexity, - clippy::perf, - clippy::pedantic, -)] use boa_engine::{Context, Source}; use chrono as _; @@ -70,6 +17,10 @@ fn main() { } /// Evaluate the given ECMAScript code. +/// +/// # Errors +/// +/// If the execution of the script throws, returns a `JsValue` with the error string. #[wasm_bindgen] pub fn evaluate(src: &str) -> Result { // Setup the executor