Skip to content

Commit a5bc0c1

Browse files
committed
chore: fix cargo clippy run
1 parent 9d18315 commit a5bc0c1

File tree

4 files changed

+19
-28
lines changed

4 files changed

+19
-28
lines changed

packages/qwik/src/optimizer/core/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ pub struct TransformModulesOptions {
7575
pub fn transform_modules(config: TransformModulesOptions) -> Result<TransformOutput, Error> {
7676
let core_module = config
7777
.core_module
78-
.map_or(BUILDER_IO_QWIK.clone(), |s| s.into());
78+
.map_or_else(|| BUILDER_IO_QWIK.clone(), |s| s.into());
7979
let src_dir = std::path::Path::new(&config.src_dir);
8080
let root_dir = config.root_dir.as_ref().map(Path::new);
8181

packages/qwik/src/optimizer/core/src/parse.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ pub fn parse_path(src: &str, base_dir: &Path) -> Result<PathData, Error> {
759759
}
760760

761761
pub fn normalize_path<P: AsRef<Path>>(path: P) -> PathBuf {
762-
let ends_with_slash = path.as_ref().to_str().map_or(false, |s| s.ends_with('/'));
762+
let ends_with_slash = path.as_ref().to_str().is_some_and(|s| s.ends_with('/'));
763763
let mut normalized = PathBuf::new();
764764
for component in path.as_ref().components() {
765765
match &component {

packages/qwik/src/optimizer/core/src/props_destructuring.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ impl<'a> PropsDestructuring<'a> {
6161
{
6262
if let Some(rest_id) = rest_id_opt {
6363
let omit_fn = self.global_collect.import(&_REST_PROPS, self.core_module);
64-
let omit: Vec<JsWord> = local.iter().map(|(_, id, _)| id.clone()).collect();
64+
let omit: Vec<Atom> = local.iter().map(|(_, id, _)| id.clone()).collect();
6565
transform_rest(
6666
arrow,
6767
&omit_fn,

packages/qwik/src/optimizer/core/src/transform.rs

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,7 @@ impl<'a> QwikTransform<'a> {
292292
}
293293
}
294294

295-
fn register_context_name(
296-
&mut self,
297-
custom_symbol: Option<Atom>,
298-
) -> (Atom, Atom, Atom, u64) {
295+
fn register_context_name(&mut self, custom_symbol: Option<Atom>) -> (Atom, Atom, Atom, u64) {
299296
if let Some(custom_symbol) = custom_symbol {
300297
return (
301298
custom_symbol.clone(),
@@ -310,7 +307,7 @@ impl<'a> QwikTransform<'a> {
310307
}
311308
display_name = escape_sym(&display_name);
312309
let first_char = display_name.chars().next();
313-
if first_char.map_or(false, |c| c.is_ascii_digit()) {
310+
if first_char.is_some_and(|c| c.is_ascii_digit()) {
314311
display_name = format!("_{}", display_name);
315312
}
316313
let index = match self.segment_names.get_mut(&display_name) {
@@ -2030,7 +2027,7 @@ impl<'a> Fold for QwikTransform<'a> {
20302027
let is_const = node.kind == ast::VarDeclKind::Const;
20312028

20322029
for ident in identifiers {
2033-
let is_static = static_identifiers.iter().any(|id| *id == ident.0);
2030+
let is_static = static_identifiers.contains(&ident.0);
20342031
current_scope.push((ident.0, IdentType::Var(is_const && is_static)));
20352032
}
20362033
}
@@ -2039,11 +2036,12 @@ impl<'a> Fold for QwikTransform<'a> {
20392036
}
20402037

20412038
fn fold_var_declarator(&mut self, node: ast::VarDeclarator) -> ast::VarDeclarator {
2042-
let mut stacked = false;
2043-
if let ast::Pat::Ident(ref ident) = node.name {
2039+
let stacked = if let ast::Pat::Ident(ref ident) = node.name {
20442040
self.stack_ctxt.push(ident.id.sym.to_string());
2045-
stacked = true;
2046-
}
2041+
true
2042+
} else {
2043+
false
2044+
};
20472045
let o = node.fold_children_with(self);
20482046
if stacked {
20492047
self.stack_ctxt.pop();
@@ -2234,12 +2232,12 @@ impl<'a> Fold for QwikTransform<'a> {
22342232
}
22352233

22362234
fn fold_jsx_element(&mut self, node: ast::JSXElement) -> ast::JSXElement {
2237-
let mut stacked = false;
2238-
2239-
if let ast::JSXElementName::Ident(ref ident) = node.opening.name {
2235+
let stacked = if let ast::JSXElementName::Ident(ref ident) = node.opening.name {
22402236
self.stack_ctxt.push(ident.sym.to_string());
2241-
stacked = true;
2242-
}
2237+
true
2238+
} else {
2239+
false
2240+
};
22432241
let o = node.fold_children_with(self);
22442242
if stacked {
22452243
self.stack_ctxt.pop();
@@ -2504,15 +2502,11 @@ fn compute_scoped_idents(all_idents: &[Id], all_decl: &[IdPlusType]) -> (Vec<Id>
25042502
}
25052503

25062504
fn get_canonical_filename(display_name: &Atom, symbol_name: &Atom) -> Atom {
2507-
let hash = symbol_name.split('_').last().unwrap();
2505+
let hash = symbol_name.split('_').next_back().unwrap();
25082506
Atom::from(format!("{}_{}", display_name, hash))
25092507
}
25102508

2511-
fn parse_symbol_name(
2512-
symbol_name: Atom,
2513-
dev: bool,
2514-
file_name: &String,
2515-
) -> (Atom, Atom, Atom) {
2509+
fn parse_symbol_name(symbol_name: Atom, dev: bool, file_name: &String) -> (Atom, Atom, Atom) {
25162510
let mut splitter = symbol_name.rsplitn(2, '_');
25172511
let hash = splitter
25182512
.next()
@@ -2556,10 +2550,7 @@ fn get_qrl_dev_obj(abs_path: Atom, segment: &SegmentData, span: &Span) -> ast::E
25562550
}))),
25572551
}))),
25582552
ast::PropOrSpread::Prop(Box::new(ast::Prop::KeyValue(ast::KeyValueProp {
2559-
key: ast::PropName::Ident(ast::IdentName::new(
2560-
Atom::from("displayName"),
2561-
DUMMY_SP,
2562-
)),
2553+
key: ast::PropName::Ident(ast::IdentName::new(Atom::from("displayName"), DUMMY_SP)),
25632554
value: Box::new(ast::Expr::Lit(ast::Lit::Str(ast::Str {
25642555
span: DUMMY_SP,
25652556
value: segment.display_name.clone(),

0 commit comments

Comments
 (0)