Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ suspicious_operation_groupings = "warn"
redundant_clone = "warn"
redundant_pub_crate = "allow" # FIXME
debug_assert_with_mut_call = "allow" # FIXME
needless_pass_by_ref_mut = "allow" # FIXME
# cargo
cargo = { level = "warn", priority = -1 }
multiple_crate_versions = "allow"
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_isolated_declarations/src/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::{

impl<'a> IsolatedDeclarations<'a> {
pub(crate) fn transform_function(
&mut self,
&self,
func: &Function<'a>,
declare: Option<bool>,
) -> Box<'a, Function<'a>> {
Expand Down
8 changes: 4 additions & 4 deletions crates/oxc_isolated_declarations/src/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl<'a> IsolatedDeclarations<'a> {
))
}

pub(crate) fn create_unique_name(&mut self, name: &str) -> Atom<'a> {
pub(crate) fn create_unique_name(&self, name: &str) -> Atom<'a> {
let mut binding = self.ast.atom(name);
let mut i = 1;
while self.scope.has_reference(&binding) {
Expand All @@ -32,7 +32,7 @@ impl<'a> IsolatedDeclarations<'a> {
}

pub(crate) fn transform_export_default_declaration(
&mut self,
&self,
decl: &ExportDefaultDeclaration<'a>,
) -> Option<(Option<Statement<'a>>, Statement<'a>)> {
let declaration = match &decl.declaration {
Expand Down Expand Up @@ -69,7 +69,7 @@ impl<'a> IsolatedDeclarations<'a> {
}

fn transform_export_expression(
&mut self,
&self,
expr: &Expression<'a>,
) -> Option<(Option<Statement<'a>>, Expression<'a>)> {
if matches!(expr, Expression::Identifier(_)) {
Expand Down Expand Up @@ -102,7 +102,7 @@ impl<'a> IsolatedDeclarations<'a> {
}

pub(crate) fn transform_ts_export_assignment(
&mut self,
&self,
decl: &TSExportAssignment<'a>,
) -> Option<(Option<Statement<'a>>, Statement<'a>)> {
self.transform_export_expression(&decl.expression).map(|(var_decl, expr)| {
Expand Down
2 changes: 2 additions & 0 deletions crates/oxc_minifier/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! ECMAScript Minifier

#![allow(clippy::needless_pass_by_ref_mut)]

mod compressor;
mod ctx;
mod keep_var;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1104,7 +1104,7 @@ impl<'a> LatePeepholeOptimizations {
DELIMITERS.into_iter().find(|&delimiter| strings.clone().all(|s| !s.contains(delimiter)))
}

pub fn substitute_catch_clause(&mut self, catch: &mut CatchClause<'a>, ctx: Ctx<'a, '_>) {
pub fn substitute_catch_clause(&self, catch: &mut CatchClause<'a>, ctx: Ctx<'a, '_>) {
if self.target >= ESTarget::ES2019 {
if let Some(param) = &catch.param {
if let BindingPatternKind::BindingIdentifier(ident) = &param.pattern.kind {
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_parser/src/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ impl<'a> ParserImpl<'a> {
}

/// # Errors
pub(crate) fn expect_without_advance(&mut self, kind: Kind) -> Result<()> {
pub(crate) fn expect_without_advance(&self, kind: Kind) -> Result<()> {
if !self.at(kind) {
let range = self.cur_token().span();
return Err(diagnostics::expect_token(kind.to_str(), self.cur_kind().to_str(), range));
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_parser/src/js/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ impl<'a> ParserImpl<'a> {
/// Elision :
/// ,
/// Elision ,
pub(crate) fn parse_elision(&mut self) -> ArrayExpressionElement<'a> {
pub(crate) fn parse_elision(&self) -> ArrayExpressionElement<'a> {
self.ast.array_expression_element_elision(self.cur_token().span())
}

Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_parser/src/modifiers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ impl<'a> ParserImpl<'a> {
self.can_follow_export_modifier()
}

fn can_follow_export_modifier(&mut self) -> bool {
fn can_follow_export_modifier(&self) -> bool {
let kind = self.cur_kind();
kind == Kind::At
&& kind != Kind::Star
Expand All @@ -516,7 +516,7 @@ impl<'a> ParserImpl<'a> {
&& self.can_follow_modifier()
}

fn can_follow_modifier(&mut self) -> bool {
fn can_follow_modifier(&self) -> bool {
match self.cur_kind() {
Kind::PrivateIdentifier | Kind::LBrack | Kind::LCurly | Kind::Star | Kind::Dot3 => true,
kind => kind.is_identifier_or_keyword(),
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_parser/src/ts/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1367,7 +1367,7 @@ impl<'a> ParserImpl<'a> {
))
}

fn is_binary_operator(&mut self) -> bool {
fn is_binary_operator(&self) -> bool {
if self.ctx.has_in() && self.at(Kind::In) {
return false;
}
Expand Down
12 changes: 6 additions & 6 deletions crates/oxc_prettier/src/comments/print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use super::{CommentFlags, DanglingCommentsPrintOptions};
impl<'a> Prettier<'a> {
#[must_use]
pub(crate) fn print_comments(
&mut self,
&self,
before: Option<Doc<'a>>,
doc: Doc<'a>,
after: Option<Doc<'a>>,
Expand All @@ -27,28 +27,28 @@ impl<'a> Prettier<'a> {
doc
}

pub(crate) fn has_comment(&mut self, _span: Span, _flags: CommentFlags) -> bool {
pub(crate) fn has_comment(&self, _span: Span, _flags: CommentFlags) -> bool {
false
}

#[must_use]
pub(crate) fn print_leading_comments(&mut self, _span: Span) -> Option<Doc<'a>> {
pub(crate) fn print_leading_comments(&self, _span: Span) -> Option<Doc<'a>> {
None
}

#[must_use]
pub(crate) fn print_trailing_comments(&mut self, _span: Span) -> Option<Doc<'a>> {
pub(crate) fn print_trailing_comments(&self, _span: Span) -> Option<Doc<'a>> {
None
}

#[must_use]
pub(crate) fn print_inner_comment(&mut self, _span: Span) -> Vec<'a, Doc<'a>> {
pub(crate) fn print_inner_comment(&self, _span: Span) -> Vec<'a, Doc<'a>> {
Vec::new_in(self.allocator)
}

#[must_use]
pub(crate) fn print_dangling_comments(
&mut self,
&self,
_span: Span,
_dangling_options: Option<&DanglingCommentsPrintOptions>,
) -> Option<Doc<'a>> {
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_prettier/src/format/print/arrow_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub fn print_arrow_function<'a>(
}

pub fn should_print_params_without_parens<'a>(
p: &mut Prettier<'a>,
p: &Prettier<'a>,
expr: &ArrowFunctionExpression<'a>,
) -> bool {
match p.options.arrow_parens {
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_prettier/src/format/print/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ impl<'a> ClassPropertyLike<'a, '_> {
}
}

fn format_accessibility(&self, p: &mut Prettier<'a>) -> Option<Doc<'a>> {
fn format_accessibility(&self, p: &Prettier<'a>) -> Option<Doc<'a>> {
match self {
ClassPropertyLike::AccessorProperty(def) => {
def.accessibility.map(|v| text!(v.as_str()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
};

pub fn should_hug_the_only_function_parameter(
p: &mut Prettier<'_>,
p: &Prettier<'_>,
params: &FormalParameters<'_>,
) -> bool {
if params.parameters_count() != 1 {
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_prettier/src/format/print/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ pub fn print_object<'a>(p: &mut Prettier<'a>, obj: &ObjectLike<'a, '_>) -> Doc<'
group!(p, parts, should_break, None)
}

fn should_hug_the_only_parameter(p: &mut Prettier<'_>, kind: AstKind<'_>) -> bool {
fn should_hug_the_only_parameter(p: &Prettier<'_>, kind: AstKind<'_>) -> bool {
match kind {
AstKind::FormalParameters(params) => {
function_parameters::should_hug_the_only_function_parameter(p, params)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -517,16 +517,16 @@ impl Parser {
self.offset
}

fn peek_nth(&mut self, n: usize) -> Option<char> {
fn peek_nth(&self, n: usize) -> Option<char> {
let nth = self.index + n;
self.chars.get(nth).copied()
}

fn peek(&mut self) -> Option<char> {
fn peek(&self) -> Option<char> {
self.peek_nth(0)
}

fn peek2(&mut self) -> Option<char> {
fn peek2(&self) -> Option<char> {
self.peek_nth(1)
}
}
2 changes: 2 additions & 0 deletions crates/oxc_transformer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
//! * <https://babel.dev/docs/presets>
//! * <https://github.com/microsoft/TypeScript/blob/v5.6.3/src/compiler/transformer.ts>

#![allow(clippy::needless_pass_by_ref_mut)]

use std::path::Path;

use oxc_allocator::{Allocator, Vec as ArenaVec};
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 @@ -425,7 +425,7 @@ impl TraverseScoping {
///
/// Once this set is created, generating a UID is a relatively quick operation, rather than
/// iterating over all symbols and unresolved references every time generate a UID.
fn get_uid_names(&mut self) -> FxHashSet<CompactStr> {
fn get_uid_names(&self) -> FxHashSet<CompactStr> {
self.scopes
.root_unresolved_references()
.keys()
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ impl Oxc {
}

fn run_linter(
&mut self,
&self,
run_options: &OxcRunOptions,
path: &Path,
program: &Program,
Expand Down
8 changes: 4 additions & 4 deletions tasks/ast_tools/src/parse/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ impl<'c> Parser<'c> {
}

/// Get type name for a [`TypeId`].
fn type_name(&mut self, type_id: TypeId) -> &str {
fn type_name(&self, type_id: TypeId) -> &str {
&self.type_names[type_id.index()]
}

Expand Down Expand Up @@ -516,7 +516,7 @@ impl<'c> Parser<'c> {
///
/// [`Derive`]: crate::Derive
/// [`Generator`]: crate::Generator
fn parse_type_attrs(&mut self, type_def: &mut TypeDef, attrs: &[Attribute]) {
fn parse_type_attrs(&self, type_def: &mut TypeDef, attrs: &[Attribute]) {
for attr in attrs {
if !matches!(attr.style, AttrStyle::Outer) {
continue;
Expand Down Expand Up @@ -600,7 +600,7 @@ impl<'c> Parser<'c> {
///
/// [`Derive`]: crate::Derive
/// [`Generator`]: crate::Generator
fn parse_ast_attr(&mut self, type_def: &mut TypeDef, attr: &Attribute) {
fn parse_ast_attr(&self, type_def: &mut TypeDef, attr: &Attribute) {
let parts = match &attr.meta {
Meta::Path(_) => return,
Meta::List(meta_list) => meta_list
Expand Down Expand Up @@ -687,7 +687,7 @@ impl<'c> Parser<'c> {
}

/// Parse [`Skeleton`] to yield a [`MetaType`].
fn parse_meta_type(&mut self, meta_id: MetaId, skeleton: Skeleton) -> MetaType {
fn parse_meta_type(&self, meta_id: MetaId, skeleton: Skeleton) -> MetaType {
let (type_name, file_id, attrs) = match skeleton {
Skeleton::Struct(skeleton) => (skeleton.name, skeleton.file_id, skeleton.item.attrs),
Skeleton::Enum(skeleton) => (skeleton.name, skeleton.file_id, skeleton.item.attrs),
Expand Down
2 changes: 1 addition & 1 deletion tasks/transform_conformance/src/test_case.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ impl TestCase {
}
}

fn test_exec(&mut self, filtered: bool) {
fn test_exec(&self, filtered: bool) {
if filtered {
println!("input_path: {:?}", &self.path);
println!("Input:\n{}\n", fs::read_to_string(&self.path).unwrap());
Expand Down
Loading