Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 7402366

Browse files
author
Tiddo Langerak
committed
Avoid cloning IMPL node if we don't have to
1 parent 7c56896 commit 7402366

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

crates/ide-assists/src/handlers/extract_function.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,13 +1288,19 @@ fn last_impl_member(impl_node: &SyntaxNode) -> Option<SyntaxNode> {
12881288
}
12891289

12901290
fn is_trait_impl(node: &SyntaxNode) -> bool {
1291+
if !ast::Impl::can_cast(node.kind()) {
1292+
return false;
1293+
}
12911294
match ast::Impl::cast(node.clone()) {
12921295
Some(c) => c.trait_().is_some(),
12931296
None => false,
12941297
}
12951298
}
12961299

12971300
fn impl_type_name(impl_node: &SyntaxNode) -> Option<String> {
1301+
if !ast::Impl::can_cast(impl_node.kind()) {
1302+
return None;
1303+
}
12981304
Some(ast::Impl::cast(impl_node.clone())?.self_ty()?.to_string())
12991305
}
13001306

0 commit comments

Comments
 (0)