Skip to content

Commit

Permalink
chore: clippy::allow_attributes (#5521)
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed Sep 6, 2024
1 parent 088733b commit c3cfbfb
Show file tree
Hide file tree
Showing 20 changed files with 32 additions and 36 deletions.
11 changes: 6 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ unexpected_cfgs = { level = "warn", check-cfg = ['cfg(cov
all = { level = "warn", priority = -1 }
empty_docs = { level = "allow", priority = 1 } # From `Tsify`
# restriction
dbg_macro = "warn"
todo = "warn"
unimplemented = "warn"
print_stdout = "warn" # Must be opt-in
print_stderr = "warn" # Must be opt-in
dbg_macro = "warn"
todo = "warn"
unimplemented = "warn"
print_stdout = "warn" # Must be opt-in
print_stderr = "warn" # Must be opt-in
allow_attributes = "warn"
# I like the explicitness of this rule as it removes confusion around `clone`.
# This increases readability, avoids `clone` mindlessly and heap allocating by accident.
clone_on_ref_ptr = "warn"
Expand Down
4 changes: 2 additions & 2 deletions tasks/ast_tools/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl SideEffect {
Ok(())
}

#[allow(clippy::unnecessary_wraps)]
#[expect(clippy::unnecessary_wraps)]
pub fn path(&self) -> Option<String> {
let Self(path, _) = self;
let path = path.to_string_lossy();
Expand All @@ -63,7 +63,7 @@ impl From<GeneratorOutput> for SideEffect {
pub trait Runner {
type Context;
type Output;
#[allow(dead_code)]
#[expect(dead_code)]
fn name(&self) -> &'static str;
fn run(&mut self, ctx: &Self::Context) -> Result<Self::Output>;
}
Expand Down
2 changes: 1 addition & 1 deletion tasks/ast_tools/src/derives/get_span.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl Derive for DeriveGetSpanMut {
}
}

#[allow(clippy::too_many_arguments)]
#[expect(clippy::too_many_arguments)]
fn derive<U, R>(
trait_name: &str,
method_name: &str,
Expand Down
4 changes: 2 additions & 2 deletions tasks/ast_tools/src/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ lazy_static! {
///
/// We use this when inserting outer attributes (`#![allow(unused)]`) or plain comments (`//` not `///`).
/// `quote!` macro ignores plain comments, so it's not possible to produce them otherwise.
#[allow(dead_code)] // `insert!` macro is not currently used
#[expect(dead_code)] // `insert!` macro is not currently used
struct InsertReplacer;

impl Replacer for InsertReplacer {
Expand Down Expand Up @@ -109,7 +109,7 @@ lazy_static! {
///
/// We use `endl!();` because `quote!` macro ignores whitespace,
/// so we have to use another means to generate line breaks.
#[allow(dead_code)] // `endl!` macro is not currently used
#[expect(dead_code)] // `endl!` macro is not currently used
struct EndlReplacer;

impl Replacer for EndlReplacer {
Expand Down
5 changes: 2 additions & 3 deletions tasks/ast_tools/src/generators/ast_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ fn generate_enum_variant_builder_fn(
.or_else(|| var_type.transparent_type_id())
.and_then(|id| ctx.type_def(id))
.expect("type not found!");
#[allow(clippy::single_match_else)]
let (params, inner_builder) = match ty {
TypeDef::Struct(it) => (get_struct_params(it, ctx), struct_builder_name(it)),
TypeDef::Enum(_) => panic!("Unsupported!"),
Expand Down Expand Up @@ -306,7 +305,7 @@ fn generate_struct_builder_fn(ty: &StructDef, ctx: &LateCtx) -> TokenStream {
}

// TODO: remove me
#[allow(dead_code)]
#[expect(dead_code)]
#[derive(Debug)]
struct Param {
is_default: bool,
Expand Down Expand Up @@ -415,7 +414,7 @@ impl<'p> DocComment<'p> {
///
/// Each line will be turned into its own paragraph.
// TODO: remove me
#[allow(dead_code)]
#[expect(dead_code)]
pub fn with_description_lines<L, S>(mut self, description: L) -> Self
where
S: Into<Cow<'static, str>>,
Expand Down
6 changes: 3 additions & 3 deletions tasks/ast_tools/src/generators/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub use ast_kind::AstKindGenerator;
pub use visit::{VisitGenerator, VisitMutGenerator};

/// Inserts a newline in the `TokenStream`.
#[allow(unused)]
#[expect(unused)]
macro_rules! endl {
() => {
/* only works in the context of `quote` macro family! */
Expand Down Expand Up @@ -51,12 +51,12 @@ pub(crate) use define_generator;
/// Similar to how `insert` macro works in the context of `quote` macro family, But this one can be
/// used outside and accepts expressions.
/// Wraps the result of the given expression in `insert!({value here});` and outputs it as `TokenStream`.
#[allow(unused)]
#[expect(unused)]
macro_rules! insert {
($fmt:literal $(, $args:expr)*) => {{
let txt = format!($fmt, $($args)*);
format!(r#"insert!("{}");"#, txt).parse::<proc_macro2::TokenStream>().unwrap()
}};
}
#[allow(unused_imports)]
#[expect(unused_imports)]
pub(crate) use insert;
2 changes: 1 addition & 1 deletion tasks/ast_tools/src/generators/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ impl<'a> VisitBuilder<'a> {
enter_scope_at = ix;
}

#[allow(unreachable_code)]
#[expect(unreachable_code)]
if have_enter_node {
// NOTE: this is disabled intentionally <https://github.com/oxc-project/oxc/pull/4147#issuecomment-2220216905>
unreachable!("`#[visit(enter_before)]` attribute is disabled!");
Expand Down
2 changes: 1 addition & 1 deletion tasks/ast_tools/src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl KnownLayout {
self.niches
}

#[allow(unused)]
#[expect(unused)]
#[inline]
pub fn offsets(&self) -> Option<&Vec<usize>> {
self.offsets.as_ref()
Expand Down
4 changes: 2 additions & 2 deletions tasks/ast_tools/src/markers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ pub fn get_visit_markers<'a, I>(attrs: I) -> crate::Result<VisitMarkers>
where
I: IntoIterator<Item = &'a Attribute>,
{
#[allow(clippy::trivially_copy_pass_by_ref)]
#[expect(clippy::trivially_copy_pass_by_ref)]
fn predicate(it: &&Attribute) -> bool {
it.path().is_ident("visit")
}
Expand Down Expand Up @@ -186,7 +186,7 @@ pub fn get_scope_markers<'a, I>(attrs: I) -> crate::Result<ScopeMarkers>
where
I: IntoIterator<Item = &'a Attribute>,
{
#[allow(clippy::trivially_copy_pass_by_ref)]
#[expect(clippy::trivially_copy_pass_by_ref)]
fn predicate(it: &&Attribute) -> bool {
it.path().is_ident("scope")
}
Expand Down
2 changes: 1 addition & 1 deletion tasks/ast_tools/src/passes/calc_layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ fn calc_enum_layout(ty: &mut Enum, ctx: &EarlyCtx) -> Result<PlatformLayout> {
}
}

#[allow(clippy::needless_pass_by_value)]
#[expect(clippy::needless_pass_by_value)]
fn fold_layout(mut acc: KnownLayout, layout: KnownLayout) -> KnownLayout {
// SAFETY: we are folding valid layouts so it is safe.
unsafe {
Expand Down
2 changes: 1 addition & 1 deletion tasks/ast_tools/src/passes/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub trait Unresolved {
fn unresolved(&self) -> bool;

// TODO: remove me
#[allow(dead_code)]
#[expect(dead_code)]
fn resolved(&self) -> bool {
!self.unresolved()
}
Expand Down
3 changes: 1 addition & 2 deletions tasks/ast_tools/src/rust_ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ impl AstType {
}
}

#[allow(unused)]
#[expect(unused)]
pub fn visitable(&self) -> bool {
match self {
AstType::Enum(it) => it.meta.visitable,
Expand Down Expand Up @@ -450,7 +450,6 @@ pub fn analyze(ast_ref: &AstRef) -> Result<()> {
AstType::Macro(_) => None,
};

#[allow(clippy::match_same_arms)]
match ast_attr {
Some(AstAttr::Visit) => {
ast_ref.borrow_mut().set_ast(true)?;
Expand Down
2 changes: 0 additions & 2 deletions tasks/ast_tools/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ impl<'a> TypeIdentResult<'a> {
}
}

// TODO: remove me
#[allow(dead_code)]
#[derive(Debug, PartialEq, Clone, Serialize)]
pub enum TypeWrapper {
None,
Expand Down
2 changes: 1 addition & 1 deletion tasks/benchmark/benches/sourcemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use oxc_sourcemap::ConcatSourceMapBuilder;
use oxc_span::SourceType;
use oxc_tasks_common::TestFiles;

#[allow(clippy::cast_possible_truncation)]
#[expect(clippy::cast_possible_truncation)]
fn bench_sourcemap(criterion: &mut Criterion) {
let mut group = criterion.benchmark_group("sourcemap");

Expand Down
2 changes: 1 addition & 1 deletion tasks/benchmark/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static GLOBAL: NeverGrowInPlaceAllocator = NeverGrowInPlaceAllocator;
pub struct NeverGrowInPlaceAllocator;

// SAFETY: Methods simply delegate to `System` allocator
#[allow(unsafe_code, clippy::undocumented_unsafe_blocks)]
#[expect(unsafe_code, clippy::undocumented_unsafe_blocks)]
unsafe impl GlobalAlloc for NeverGrowInPlaceAllocator {
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
System.alloc(layout)
Expand Down
5 changes: 2 additions & 3 deletions tasks/coverage/src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ use std::{collections::HashSet, ops::ControlFlow, path::PathBuf};

use oxc::CompilerInterface;

#[allow(clippy::wildcard_imports)]
use oxc::ast::{ast::*, Trivias};
use oxc::ast::{ast::Program, Trivias};
use oxc::codegen::CodegenOptions;
use oxc::diagnostics::OxcDiagnostic;
use oxc::minifier::CompressOptions;
Expand All @@ -17,7 +16,7 @@ use oxc::transformer::{TransformOptions, TransformerReturn};

use crate::suite::TestResult;

#[allow(clippy::struct_excessive_bools)]
#[expect(clippy::struct_excessive_bools)]
#[derive(Default)]
pub struct Driver {
pub path: PathBuf,
Expand Down
2 changes: 1 addition & 1 deletion tasks/coverage/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ impl AppArgs {

// Generate v8 test262 status file, which is used to skip failed tests
// see https://chromium.googlesource.com/v8/v8/+/refs/heads/main/test/test262/test262.status
#[allow(clippy::missing_panics_doc)]
#[expect(clippy::missing_panics_doc)]
pub fn run_sync_v8_test262_status(&self) {
let res = agent()
.get("http://raw.githubusercontent.com/v8/v8/main/test/test262/test262.status")
Expand Down
4 changes: 2 additions & 2 deletions tasks/coverage/src/suite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ pub trait Suite<T: Case> {
}

/// # Errors
#[allow(clippy::cast_precision_loss)]
#[expect(clippy::cast_precision_loss)]
fn print_coverage<W: Write>(
&self,
name: &str,
Expand Down Expand Up @@ -310,7 +310,7 @@ pub trait Case: Sized + Sync + Send + UnwindSafe {
fn run(&mut self);

/// Async version of run
#[allow(clippy::unused_async)]
#[expect(clippy::unused_async)]
async fn run_async(&mut self) {}

/// Execute the parser once and get the test result
Expand Down
2 changes: 1 addition & 1 deletion tasks/coverage/src/typescript/meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ lazy_static::lazy_static! {
static ref TEST_BRACES: Regex = Regex::new(r"^[[:space:]]*[{|}][[:space:]]*$").unwrap();
}

#[allow(unused)]
#[expect(unused)]
#[derive(Debug)]
pub struct CompilerSettings {
pub modules: Vec<String>,
Expand Down
2 changes: 1 addition & 1 deletion tasks/prettier_conformance/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl TestRunner {
}

/// # Panics
#[allow(clippy::cast_precision_loss)]
#[expect(clippy::cast_precision_loss)]
pub fn run(mut self) {
let fixture_root = &self.fixtures_root;
// Read the first level of directories that contain `__snapshots__`
Expand Down

0 comments on commit c3cfbfb

Please sign in to comment.