Skip to content

Commit d7fdf14

Browse files
committed
fix: various clippy lints
1 parent 900d603 commit d7fdf14

File tree

5 files changed

+10
-14
lines changed

5 files changed

+10
-14
lines changed

crates/hir-def/src/body/pretty.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,10 @@ pub(super) fn print_body_hir(db: &dyn DefDatabase, body: &Body, owner: DefWithBo
3535
DefWithBodyId::VariantId(it) => {
3636
let src = it.parent.child_source(db);
3737
let variant = &src.value[it.local_id];
38-
let name = match &variant.name() {
38+
match &variant.name() {
3939
Some(name) => name.to_string(),
4040
None => "_".to_string(),
41-
};
42-
format!("{name}")
41+
}
4342
}
4443
};
4544

@@ -445,7 +444,7 @@ impl<'a> Printer<'a> {
445444
fn print_block(
446445
&mut self,
447446
label: Option<&str>,
448-
statements: &Box<[Statement]>,
447+
statements: &[Statement],
449448
tail: &Option<la_arena::Idx<Expr>>,
450449
) {
451450
self.whitespace();
@@ -455,7 +454,7 @@ impl<'a> Printer<'a> {
455454
w!(self, "{{");
456455
if !statements.is_empty() || tail.is_some() {
457456
self.indented(|p| {
458-
for stmt in &**statements {
457+
for stmt in statements {
459458
p.print_stmt(stmt);
460459
}
461460
if let Some(tail) = tail {

crates/parser/src/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ impl<'t> Parser<'t> {
205205
marker.bomb.defuse();
206206
marker = new_marker;
207207
};
208-
self.pos += 1 as usize;
208+
self.pos += 1;
209209
self.push_event(Event::FloatSplitHack { ends_in_dot });
210210
(ends_in_dot, marker)
211211
}

crates/parser/src/shortcuts.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,8 @@ impl<'a> LexedStr<'a> {
4646
// Tag the token as joint if it is float with a fractional part
4747
// we use this jointness to inform the parser about what token split
4848
// event to emit when we encounter a float literal in a field access
49-
if kind == SyntaxKind::FLOAT_NUMBER {
50-
if !self.text(i).ends_with('.') {
51-
res.was_joint();
52-
}
49+
if kind == SyntaxKind::FLOAT_NUMBER && !self.text(i).ends_with('.') {
50+
res.was_joint();
5351
}
5452
}
5553

crates/syntax/src/ast/expr_ext.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,7 @@ impl ast::BlockExpr {
366366
match parent.kind() {
367367
FOR_EXPR | IF_EXPR => parent
368368
.children()
369-
.filter(|it| ast::Expr::can_cast(it.kind()))
370-
.next()
369+
.find(|it| ast::Expr::can_cast(it.kind()))
371370
.map_or(true, |it| it == *self.syntax()),
372371
LET_ELSE | FN | WHILE_EXPR | LOOP_EXPR | CONST_BLOCK_PAT => false,
373372
_ => true,

crates/syntax/src/ast/make.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ pub fn ty_alias(
195195
}
196196
}
197197

198-
s.push_str(";");
198+
s.push(';');
199199
ast_from_text(&s)
200200
}
201201

@@ -399,7 +399,7 @@ pub fn hacky_block_expr(
399399
format_to!(buf, " {t}\n")
400400
} else if kind == SyntaxKind::WHITESPACE {
401401
let content = t.text().trim_matches(|c| c != '\n');
402-
if content.len() >= 1 {
402+
if !content.is_empty() {
403403
format_to!(buf, "{}", &content[1..])
404404
}
405405
}

0 commit comments

Comments
 (0)