Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
magurotuna committed May 5, 2024
1 parent 7a2f56c commit fdafc59
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/js_regex/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl Reader {
u_flag: bool,
) {
self.unicode = u_flag;
self.src = source.to_owned();
source.clone_into(&mut self.src);
self.end = end;
self.rewind(start);
}
Expand Down
4 changes: 2 additions & 2 deletions src/js_regex/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1319,9 +1319,9 @@ impl EcmaRegexValidator {

// UnicodePropertyName `=` UnicodePropertyValue
if self.eat_unicode_property_name() && self.eat('=') {
self.last_key_value = self.last_str_value.clone();
self.last_key_value.clone_from(&self.last_str_value);
if self.eat_unicode_property_value() {
self.last_val_value = self.last_str_value.clone();
self.last_val_value.clone_from(&self.last_str_value);
if is_valid_unicode_property(
self.ecma_version,
&self.last_key_value,
Expand Down
4 changes: 2 additions & 2 deletions src/linter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ impl LinterBuilder {
///
/// Defaults to "deno-lint-ignore-file".
pub fn ignore_file_directive(mut self, directive: &str) -> Self {
self.ignore_file_directive = directive.to_owned();
directive.clone_into(&mut self.ignore_file_directive);
self
}

/// Set name for directive that can be used to ignore next line.
///
/// Defaults to "deno-lint-ignore".
pub fn ignore_diagnostic_directive(mut self, directive: &str) -> Self {
self.ignore_diagnostic_directive = directive.to_owned();
directive.clone_into(&mut self.ignore_diagnostic_directive);
self
}

Expand Down
20 changes: 10 additions & 10 deletions src/rules/prefer_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use deno_ast::swc::ast::{
ArrayPat, ArrowExpr, AssignExpr, AssignPat, AssignTarget, AssignTargetPat,
BindingIdent, BlockStmt, BlockStmtOrExpr, CatchClause, Class, Constructor,
DoWhileStmt, Expr, ExprStmt, ForHead, ForInStmt, ForOfStmt, ForStmt,
Function, Ident, IfStmt, Invalid, Module, ObjectPat, ObjectPatProp,
Function, Ident, IfStmt, Module, ObjectPat, ObjectPatProp,
ParamOrTsParamProp, Pat, RestPat, Script, SimpleAssignTarget, Stmt,
SwitchStmt, TsParamPropParam, UpdateExpr, VarDecl, VarDeclKind,
VarDeclOrExpr, WhileStmt, WithStmt,
Expand Down Expand Up @@ -124,7 +124,7 @@ fn get_decl_by_ident(scope: Scope, ident: &Ident) -> Option<DeclInfo> {
in_other_scope: !is_current_scope,
});
}
cur_scope = cur.borrow().parent.as_ref().map(Rc::clone);
cur_scope = cur.borrow().parent.as_ref().cloned();
is_current_scope = false;
}
None
Expand Down Expand Up @@ -319,7 +319,7 @@ impl VariableCollector {
F: FnOnce(&mut VariableCollector),
{
let parent_scope_range = self.cur_scope;
let parent_scope = self.scopes.get(&parent_scope_range).map(Rc::clone);
let parent_scope = self.scopes.get(&parent_scope_range).cloned();
let child_scope = RawScope::new(parent_scope);
self.scopes.insert(
ScopeRange::Block(node.range()),
Expand Down Expand Up @@ -635,8 +635,8 @@ enum PatRef<'a> {
Rest(&'a RestPat),
Object(&'a ObjectPat),
Assign(&'a AssignPat),
Invalid(&'a Invalid),
Expr(&'a Expr),
Invalid,
Expr,
}

impl<'a> From<&'a Pat> for PatRef<'a> {
Expand All @@ -647,8 +647,8 @@ impl<'a> From<&'a Pat> for PatRef<'a> {
Pat::Rest(rest_pat) => PatRef::Rest(rest_pat),
Pat::Object(object_pat) => PatRef::Object(object_pat),
Pat::Assign(assign_pat) => PatRef::Assign(assign_pat),
Pat::Invalid(invalid) => PatRef::Invalid(invalid),
Pat::Expr(expr) => PatRef::Expr(expr),
Pat::Invalid(_invalid) => PatRef::Invalid,
Pat::Expr(_expr) => PatRef::Expr,
}
}
}
Expand All @@ -658,7 +658,7 @@ impl<'a> From<&'a AssignTargetPat> for PatRef<'a> {
match pat {
AssignTargetPat::Array(array_pat) => PatRef::Array(array_pat),
AssignTargetPat::Object(object_pat) => PatRef::Object(object_pat),
AssignTargetPat::Invalid(invalid) => PatRef::Invalid(invalid),
AssignTargetPat::Invalid(_invalid) => PatRef::Invalid,
}
}
}
Expand Down Expand Up @@ -696,7 +696,7 @@ where
PatRef::Assign(assign_pat) => {
extract_idents_from_pat_with((&*assign_pat.left).into(), op)
}
PatRef::Expr(_) => {
PatRef::Expr => {
op(ExtractIdentsArgs::MemberExpr);
}
_ => {}
Expand Down Expand Up @@ -740,7 +740,7 @@ impl<'c, 'view> PreferConstVisitor<'c, 'view> {
}

fn get_scope(&self) -> Option<Scope> {
self.scopes.get(&self.cur_scope).map(Rc::clone)
self.scopes.get(&self.cur_scope).cloned()
}

fn extract_assign_idents<'a>(
Expand Down

0 comments on commit fdafc59

Please sign in to comment.