mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-31 20:09:01 +00:00
Fix IDE resolution of use inside a body
We stopped the expression search too early because `use` is an item.
This commit is contained in:
parent
0fd4fc3522
commit
134b6f2228
2 changed files with 23 additions and 1 deletions
|
|
@ -1252,7 +1252,11 @@ fn scope_for(
|
|||
node: InFile<&SyntaxNode>,
|
||||
) -> Option<ScopeId> {
|
||||
node.ancestors_with_macros(db.upcast())
|
||||
.take_while(|it| !ast::Item::can_cast(it.kind()) || ast::MacroCall::can_cast(it.kind()))
|
||||
.take_while(|it| {
|
||||
!ast::Item::can_cast(it.kind())
|
||||
|| ast::MacroCall::can_cast(it.kind())
|
||||
|| ast::Use::can_cast(it.kind())
|
||||
})
|
||||
.filter_map(|it| it.map(ast::Expr::cast).transpose())
|
||||
.filter_map(|it| source_map.node_expr(it.as_ref())?.as_expr())
|
||||
.find_map(|it| scopes.scope_for(it))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue