mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 21:35:20 +00:00
Avoid cloning IMPL node if we don't have to
This commit is contained in:
parent
7c568961fd
commit
7402366877
1 changed files with 6 additions and 0 deletions
|
@ -1288,6 +1288,9 @@ fn last_impl_member(impl_node: &SyntaxNode) -> Option<SyntaxNode> {
|
|||
}
|
||||
|
||||
fn is_trait_impl(node: &SyntaxNode) -> bool {
|
||||
if !ast::Impl::can_cast(node.kind()) {
|
||||
return false;
|
||||
}
|
||||
match ast::Impl::cast(node.clone()) {
|
||||
Some(c) => c.trait_().is_some(),
|
||||
None => false,
|
||||
|
@ -1295,6 +1298,9 @@ fn is_trait_impl(node: &SyntaxNode) -> bool {
|
|||
}
|
||||
|
||||
fn impl_type_name(impl_node: &SyntaxNode) -> Option<String> {
|
||||
if !ast::Impl::can_cast(impl_node.kind()) {
|
||||
return None;
|
||||
}
|
||||
Some(ast::Impl::cast(impl_node.clone())?.self_ty()?.to_string())
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue