fix: various clippy lints

This commit is contained in:
Alexis (Poliorcetics) Bourget 2023-05-07 09:43:37 +02:00
parent 900d6030e7
commit d7fdf141a4
5 changed files with 10 additions and 14 deletions

View file

@ -35,11 +35,10 @@ pub(super) fn print_body_hir(db: &dyn DefDatabase, body: &Body, owner: DefWithBo
DefWithBodyId::VariantId(it) => {
let src = it.parent.child_source(db);
let variant = &src.value[it.local_id];
let name = match &variant.name() {
match &variant.name() {
Some(name) => name.to_string(),
None => "_".to_string(),
};
format!("{name}")
}
}
};
@ -445,7 +444,7 @@ impl<'a> Printer<'a> {
fn print_block(
&mut self,
label: Option<&str>,
statements: &Box<[Statement]>,
statements: &[Statement],
tail: &Option<la_arena::Idx<Expr>>,
) {
self.whitespace();
@ -455,7 +454,7 @@ impl<'a> Printer<'a> {
w!(self, "{{");
if !statements.is_empty() || tail.is_some() {
self.indented(|p| {
for stmt in &**statements {
for stmt in statements {
p.print_stmt(stmt);
}
if let Some(tail) = tail {

View file

@ -205,7 +205,7 @@ impl<'t> Parser<'t> {
marker.bomb.defuse();
marker = new_marker;
};
self.pos += 1 as usize;
self.pos += 1;
self.push_event(Event::FloatSplitHack { ends_in_dot });
(ends_in_dot, marker)
}

View file

@ -46,12 +46,10 @@ impl<'a> LexedStr<'a> {
// Tag the token as joint if it is float with a fractional part
// we use this jointness to inform the parser about what token split
// event to emit when we encounter a float literal in a field access
if kind == SyntaxKind::FLOAT_NUMBER {
if !self.text(i).ends_with('.') {
if kind == SyntaxKind::FLOAT_NUMBER && !self.text(i).ends_with('.') {
res.was_joint();
}
}
}
was_joint = true;
}

View file

@ -366,8 +366,7 @@ impl ast::BlockExpr {
match parent.kind() {
FOR_EXPR | IF_EXPR => parent
.children()
.filter(|it| ast::Expr::can_cast(it.kind()))
.next()
.find(|it| ast::Expr::can_cast(it.kind()))
.map_or(true, |it| it == *self.syntax()),
LET_ELSE | FN | WHILE_EXPR | LOOP_EXPR | CONST_BLOCK_PAT => false,
_ => true,

View file

@ -195,7 +195,7 @@ pub fn ty_alias(
}
}
s.push_str(";");
s.push(';');
ast_from_text(&s)
}
@ -399,7 +399,7 @@ pub fn hacky_block_expr(
format_to!(buf, " {t}\n")
} else if kind == SyntaxKind::WHITESPACE {
let content = t.text().trim_matches(|c| c != '\n');
if content.len() >= 1 {
if !content.is_empty() {
format_to!(buf, "{}", &content[1..])
}
}