Fix clippy::single_char_pattern

This commit is contained in:
Alan Du 2019-06-04 02:38:13 -04:00
parent 682bf04bf4
commit ed3d93b875
4 changed files with 6 additions and 9 deletions

View file

@ -57,9 +57,9 @@ pub(crate) fn introduce_variable(mut ctx: AssistCtx<impl HirDatabase>) -> Option
if text.starts_with("\r\n") {
buf.push_str("\r\n");
buf.push_str(text.trim_start_matches("\r\n"));
} else if text.starts_with("\n") {
} else if text.starts_with('\n') {
buf.push_str("\n");
buf.push_str(text.trim_start_matches("\n"));
buf.push_str(text.trim_start_matches('\n'));
} else {
buf.push_str(text);
}

View file

@ -31,11 +31,8 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
pub(crate) fn validate_body(&mut self, db: &impl HirDatabase) {
let body = self.func.body(db);
for e in body.exprs() {
match e {
(id, Expr::StructLit { path, fields, spread }) => {
self.validate_struct_literal(id, path, fields, spread, db)
}
_ => (),
if let (id, Expr::StructLit { path, fields, spread }) = e {
self.validate_struct_literal(id, path, fields, spread, db);
}
}
}

View file

@ -70,7 +70,7 @@ impl ProjectRoot {
})
};
let hidden = dir_path.components().any(|c| c.as_str().starts_with("."));
let hidden = dir_path.components().any(|c| c.as_str().starts_with('.'));
!is_ignored && !hidden
}

View file

@ -78,7 +78,7 @@ impl ast::Attr {
if attr.kind() == IDENT {
let key = attr.as_token()?.text().clone();
let val_node = tt_node.children_with_tokens().find(|t| t.kind() == STRING)?;
let val = val_node.as_token()?.text().trim_start_matches("\"").trim_end_matches("\"");
let val = val_node.as_token()?.text().trim_start_matches('"').trim_end_matches('"');
Some((key, SmolStr::new(val)))
} else {
None