mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 04:08:41 +00:00
chore: clippy::allow_attributes (#5521)
https://blog.rust-lang.org/2024/09/05/Rust-1.81.0.html#expectlint https://rust-lang.github.io/rust-clippy/master/index.html#/allow_attributes
This commit is contained in:
parent
088733b3c8
commit
c3cfbfb480
20 changed files with 32 additions and 36 deletions
11
Cargo.toml
11
Cargo.toml
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
@ -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>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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!"),
|
||||
|
|
@ -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,
|
||||
|
|
@ -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>>,
|
||||
|
|
|
|||
|
|
@ -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! */
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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!");
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ impl KnownLayout {
|
|||
self.niches
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
#[expect(unused)]
|
||||
#[inline]
|
||||
pub fn offsets(&self) -> Option<&Vec<usize>> {
|
||||
self.offsets.as_ref()
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
}
|
||||
|
|
@ -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")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ impl AstType {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
#[expect(unused)]
|
||||
pub fn visitable(&self) -> bool {
|
||||
match self {
|
||||
AstType::Enum(it) => it.meta.visitable,
|
||||
|
|
@ -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)?;
|
||||
|
|
|
|||
|
|
@ -116,8 +116,6 @@ impl<'a> TypeIdentResult<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: remove me
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, PartialEq, Clone, Serialize)]
|
||||
pub enum TypeWrapper {
|
||||
None,
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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>,
|
||||
|
|
|
|||
|
|
@ -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__`
|
||||
|
|
|
|||
Loading…
Reference in a new issue