search_is_some

This commit is contained in:
Johann Hemmann 2024-01-19 17:52:55 +01:00
parent 71d4dba960
commit 159b4c9fe9
3 changed files with 8 additions and 13 deletions

View file

@ -177,7 +177,6 @@ needless_doctest_main = "allow"
new_without_default = "allow" new_without_default = "allow"
non_canonical_clone_impl = "allow" non_canonical_clone_impl = "allow"
non_canonical_partial_ord_impl = "allow" non_canonical_partial_ord_impl = "allow"
search_is_some = "allow"
self_named_constructors = "allow" self_named_constructors = "allow"
single_match = "allow" single_match = "allow"
skip_while_next = "allow" skip_while_next = "allow"

View file

@ -239,8 +239,7 @@ impl Resolver {
db: &dyn DefDatabase, db: &dyn DefDatabase,
visibility: &RawVisibility, visibility: &RawVisibility,
) -> Option<Visibility> { ) -> Option<Visibility> {
let within_impl = let within_impl = self.scopes().any(|scope| matches!(scope, Scope::ImplDefScope(_)));
self.scopes().find(|scope| matches!(scope, Scope::ImplDefScope(_))).is_some();
match visibility { match visibility {
RawVisibility::Module(_, _) => { RawVisibility::Module(_, _) => {
let (item_map, module) = self.item_scope(); let (item_map, module) = self.item_scope();

View file

@ -359,19 +359,16 @@ fn on_left_angle_typed(file: &SourceFile, offset: TextSize) -> Option<ExtendedTe
} }
} }
if ancestors_at_offset(file.syntax(), offset) if ancestors_at_offset(file.syntax(), offset).any(|n| {
.find(|n| { ast::GenericParamList::can_cast(n.kind()) || ast::GenericArgList::can_cast(n.kind())
ast::GenericParamList::can_cast(n.kind()) || ast::GenericArgList::can_cast(n.kind()) }) {
}) Some(ExtendedTextEdit {
.is_some()
{
return Some(ExtendedTextEdit {
edit: TextEdit::replace(range, "<$0>".to_string()), edit: TextEdit::replace(range, "<$0>".to_string()),
is_snippet: true, is_snippet: true,
}); })
} else {
None
} }
None
} }
/// Adds a space after an arrow when `fn foo() { ... }` is turned into `fn foo() -> { ... }` /// Adds a space after an arrow when `fn foo() { ... }` is turned into `fn foo() -> { ... }`