Skip to content

Commit

Permalink
refactor(traverse): remove unnecessary #[allow] (#8518)
Browse files Browse the repository at this point in the history
Pure refactor. Remove unnecessary `#[allow]` attrs. Replace remaining ones with `#[expect]`.
  • Loading branch information
overlookmotel committed Jan 15, 2025
1 parent 209e313 commit 04bc259
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 25 deletions.
5 changes: 1 addition & 4 deletions crates/oxc_traverse/scripts/lib/ancestor.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,7 @@ export default function generateAncestorsCode(types) {
}

return `
#![allow(
unsafe_code,
clippy::missing_safety_doc,
#![expect(
clippy::ptr_as_ptr,
clippy::undocumented_unsafe_blocks,
clippy::cast_ptr_alignment,
Expand All @@ -131,7 +129,6 @@ export default function generateAncestorsCode(types) {
/// Used in [\`crate::TraverseCtx::retag_stack\`].
#[repr(u16)]
#[derive(Clone, Copy)]
#[allow(dead_code)]
pub(crate) enum AncestorType {
None = 0,
${ancestorTypeEnumVariants}
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_traverse/scripts/lib/traverse.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function generateTraverseTraitCode(types) {
use crate::TraverseCtx;
#[allow(unused_variables)]
#[expect(unused_variables)]
pub trait Traverse<'a> {
${traverseMethods}
}
Expand Down
7 changes: 1 addition & 6 deletions crates/oxc_traverse/scripts/lib/walk.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,10 @@ export default function generateWalkFunctionsCode(types) {
}

return `
#![allow(
unsafe_code,
clippy::missing_safety_doc,
clippy::missing_panics_doc,
clippy::undocumented_unsafe_blocks,
#![expect(
clippy::semicolon_if_nothing_returned,
clippy::ptr_as_ptr,
clippy::ref_as_ptr,
clippy::borrow_as_ptr,
clippy::cast_ptr_alignment
)]
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_traverse/src/context/ancestry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ impl<'a> TraverseAncestry<'a> {
/// # SAFETY
/// This method must not be public outside this crate, or consumer could break safety invariants.
#[inline]
#[allow(unused_variables, clippy::needless_pass_by_value)]
#[expect(unused_variables, clippy::needless_pass_by_value)]
pub(crate) fn pop_stack(&mut self, token: PopToken) {
// SAFETY: `PopToken`s are only created in `push_stack`, so the fact that caller provides one
// guarantees that a push has happened. This method consumes the token which guarantees another
Expand Down Expand Up @@ -191,7 +191,7 @@ impl<'a> TraverseAncestry<'a> {
///
/// This method must not be public outside this crate, or consumer could break safety invariants.
#[inline]
#[allow(unsafe_code, clippy::ptr_as_ptr, clippy::ref_as_ptr)]
#[expect(clippy::ptr_as_ptr, clippy::ref_as_ptr)]
pub(crate) unsafe fn retag_stack(&mut self, ty: AncestorType) {
debug_assert!(self.stack.len() >= 2);
*(self.stack.last_mut() as *mut _ as *mut AncestorType) = ty;
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_traverse/src/context/scoping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ impl TraverseScoping {
/// what was found in AST.
/// i.e. if source contains identifiers `_foo` and `__bar`, create UIDs names `___0`, `___1`,
/// `___2` etc. They'll all be unique within the program.
#[allow(clippy::missing_panics_doc)]
#[expect(clippy::missing_panics_doc)]
pub fn generate_uid_name(&mut self, name: &str) -> CompactStr {
// If `uid_names` is not already populated, initialize it
if self.uid_names.is_none() {
Expand Down
5 changes: 1 addition & 4 deletions crates/oxc_traverse/src/generated/ancestor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
// Generated by `oxc_traverse/scripts/build.mjs`.
// To alter this generated file you have to edit the codegen.

#![allow(
unsafe_code,
clippy::missing_safety_doc,
#![expect(
clippy::ptr_as_ptr,
clippy::undocumented_unsafe_blocks,
clippy::cast_ptr_alignment,
Expand All @@ -21,7 +19,6 @@ use oxc_syntax::scope::ScopeId;
/// Used in [`crate::TraverseCtx::retag_stack`].
#[repr(u16)]
#[derive(Clone, Copy)]
#[allow(dead_code)]
pub(crate) enum AncestorType {
None = 0,
ProgramHashbang = 1,
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_traverse/src/generated/traverse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use oxc_ast::ast::*;

use crate::TraverseCtx;

#[allow(unused_variables)]
#[expect(unused_variables)]
pub trait Traverse<'a> {
#[inline]
fn enter_program(&mut self, node: &mut Program<'a>, ctx: &mut TraverseCtx<'a>) {}
Expand Down
7 changes: 1 addition & 6 deletions crates/oxc_traverse/src/generated/walk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,10 @@
// Generated by `oxc_traverse/scripts/build.mjs`.
// To alter this generated file you have to edit the codegen.

#![allow(
unsafe_code,
clippy::missing_safety_doc,
clippy::missing_panics_doc,
clippy::undocumented_unsafe_blocks,
#![expect(
clippy::semicolon_if_nothing_returned,
clippy::ptr_as_ptr,
clippy::ref_as_ptr,
clippy::borrow_as_ptr,
clippy::cast_ptr_alignment
)]

Expand Down

0 comments on commit 04bc259

Please sign in to comment.