redundant_pattern_matching

This commit is contained in:
Johann Hemmann 2024-01-19 16:51:08 +01:00
parent 5a62a0db46
commit 71d4dba960
17 changed files with 39 additions and 46 deletions

View file

@ -271,13 +271,13 @@ fn fold_range_for_where_clause(where_clause: ast::WhereClause) -> Option<TextRan
}
fn fold_range_for_multiline_match_arm(match_arm: ast::MatchArm) -> Option<TextRange> {
if let Some(_) = fold_kind(match_arm.expr()?.syntax().kind()) {
return None;
if fold_kind(match_arm.expr()?.syntax().kind()).is_some() {
None
} else if match_arm.expr()?.syntax().text().contains_char('\n') {
Some(match_arm.expr()?.syntax().text_range())
} else {
None
}
if match_arm.expr()?.syntax().text().contains_char('\n') {
return Some(match_arm.expr()?.syntax().text_range());
}
None
}
#[cfg(test)]

View file

@ -98,15 +98,13 @@ pub(super) fn hints(
};
{
let mut potential_lt_refs = potential_lt_refs.iter().filter(|&&(.., is_elided)| is_elided);
if let Some(_) = &self_param {
if let Some(_) = potential_lt_refs.next() {
allocated_lifetimes.push(if config.param_names_for_lifetime_elision_hints {
// self can't be used as a lifetime, so no need to check for collisions
"'self".into()
} else {
gen_idx_name()
});
}
if self_param.is_some() && potential_lt_refs.next().is_some() {
allocated_lifetimes.push(if config.param_names_for_lifetime_elision_hints {
// self can't be used as a lifetime, so no need to check for collisions
"'self".into()
} else {
gen_idx_name()
});
}
potential_lt_refs.for_each(|(name, ..)| {
let name = match name {

View file

@ -47,7 +47,7 @@ pub(super) fn hints(
if let Some(name) = param {
if let hir::CallableKind::Function(f) = callable.kind() {
// assert the file is cached so we can map out of macros
if let Some(_) = sema.source(f) {
if sema.source(f).is_some() {
linked_location = sema.original_range_opt(name.syntax());
}
}