mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-31 20:09:01 +00:00
resolve_bind_pat_to_const does not early return if expr
This commit is contained in:
parent
574ea0296c
commit
18f90a9d2a
2 changed files with 29 additions and 100 deletions
|
|
@ -686,10 +686,19 @@ impl SourceAnalyzer {
|
|||
) -> Option<ModuleDef> {
|
||||
let pat_id = self.pat_id(&pat.clone().into())?;
|
||||
let body = self.body()?;
|
||||
let path = match &body[pat_id.as_pat()?] {
|
||||
Pat::Path(path) => path,
|
||||
_ => return None,
|
||||
|
||||
let path = if pat_id.is_pat() {
|
||||
match &body[pat_id.as_pat()?] {
|
||||
Pat::Path(path) => path,
|
||||
_ => return None,
|
||||
}
|
||||
} else {
|
||||
match &body[pat_id.as_expr()?] {
|
||||
Expr::Path(path) => path,
|
||||
_ => return None,
|
||||
}
|
||||
};
|
||||
|
||||
let res = resolve_hir_path(db, &self.resolver, path, HygieneId::ROOT, TypesMap::EMPTY)?;
|
||||
match res {
|
||||
PathResolution::Def(def) => Some(def),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue