mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 11:31:15 +00:00
Early exit in search properly
This commit is contained in:
parent
d82e1a2472
commit
2a89e4a051
@ -1756,7 +1756,7 @@ impl<'db> SemanticsImpl<'db> {
|
||||
let file_id = self.lookup(&root_node).unwrap_or_else(|| {
|
||||
panic!(
|
||||
"\n\nFailed to lookup {:?} in this Semantics.\n\
|
||||
Make sure to use only query nodes, derived from this instance of Semantics.\n\
|
||||
Make sure to only query nodes derived from this instance of Semantics.\n\
|
||||
root node: {:?}\n\
|
||||
known nodes: {}\n\n",
|
||||
node,
|
||||
|
@ -953,14 +953,19 @@ impl<'a> FindUsages<'a> {
|
||||
|
||||
// Search for occurrences of the items name
|
||||
for offset in Self::match_indices(&text, finder, search_range) {
|
||||
tree.token_at_offset(offset).for_each(|token| {
|
||||
let Some(str_token) = ast::String::cast(token.clone()) else { return };
|
||||
let ret = tree.token_at_offset(offset).any(|token| {
|
||||
let Some(str_token) = ast::String::cast(token.clone()) else { return false };
|
||||
if let Some((range, Some(nameres))) =
|
||||
sema.check_for_format_args_template(token, offset)
|
||||
{
|
||||
if self.found_format_args_ref(file_id, range, str_token, nameres, sink) {}
|
||||
return self
|
||||
.found_format_args_ref(file_id, range, str_token, nameres, sink);
|
||||
}
|
||||
false
|
||||
});
|
||||
if ret {
|
||||
return;
|
||||
}
|
||||
|
||||
for name in
|
||||
Self::find_nodes(sema, name, &tree, offset).filter_map(ast::NameLike::cast)
|
||||
|
Loading…
x
Reference in New Issue
Block a user