Skip to content

Commit

Permalink
Migrate to workspace lints
Browse files Browse the repository at this point in the history
  • Loading branch information
jedel1043 committed Nov 16, 2023
1 parent af1a918 commit 24d5598
Show file tree
Hide file tree
Showing 48 changed files with 194 additions and 620 deletions.
57 changes: 56 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
3 changes: 3 additions & 0 deletions boa_ast/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions boa_ast/src/position.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions boa_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ jemallocator.workspace = true
name = "boa"
doc = false
path = "src/main.rs"

[lints]
workspace = true
57 changes: 2 additions & 55 deletions boa_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -305,7 +252,7 @@ fn generate_flowgraph(
fn evaluate_files(
args: &Opt,
context: &mut Context,
loader: Rc<SimpleModuleLoader>,
loader: &SimpleModuleLoader,
) -> Result<(), io::Error> {
for file in &args.files {
let buffer = read(file)?;
Expand Down Expand Up @@ -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(())
Expand Down
3 changes: 3 additions & 0 deletions boa_engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,6 @@ bench = false
[[bench]]
name = "full"
harness = false

[lints]
workspace = true
4 changes: 3 additions & 1 deletion boa_engine/benches/full.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(unused_crate_dependencies, missing_docs)]

//! Benchmarks of the whole execution engine in Boa.

use boa_engine::{
Expand All @@ -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));
});
}

Expand Down
2 changes: 1 addition & 1 deletion boa_engine/src/builtins/function/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
4 changes: 2 additions & 2 deletions boa_engine/src/builtins/intl/locale/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -499,8 +499,8 @@ fn lookup_supported_locales<M: KeyedDataMarker>(
// 3. Return subset.
requested_locales
.iter()
.cloned()
.filter(|loc| best_available_locale(loc.id.clone(), provider).is_some())
.cloned()
.collect()
}

Expand All @@ -517,8 +517,8 @@ fn best_fit_supported_locales<M: KeyedDataMarker>(
) -> Vec<Locale> {
requested_locales
.iter()
.cloned()
.filter(|loc| best_locale_for_provider(loc.id.clone(), provider).is_some())
.cloned()
.collect()
}

Expand Down
2 changes: 1 addition & 1 deletion boa_engine/src/builtins/temporal/duration/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions boa_engine/src/builtins/typed_array/element/mod.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
54 changes: 1 addition & 53 deletions boa_engine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion boa_engine/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
38 changes: 38 additions & 0 deletions boa_examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion boa_examples/src/bin/classes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion boa_examples/src/bin/closures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
Loading

0 comments on commit 24d5598

Please sign in to comment.