Skip to content

Commit afbb8f3

Browse files
committed
Auto merge of #16184 - Veykril:completion-panic, r=Veykril
fix: Fix completions analysis not caching all nodes in Semantics Fixes #16161
2 parents 3643c37 + 91046e9 commit afbb8f3

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

crates/ide-completion/src/context/analysis.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Module responsible for analyzing the code surrounding the cursor for completion.
22
use std::iter;
33

4-
use hir::{HasSource, Semantics, Type, TypeInfo, Variant};
4+
use hir::{Semantics, Type, TypeInfo, Variant};
55
use ide_db::{active_parameter::ActiveParameter, RootDatabase};
66
use syntax::{
77
algo::{find_node_at_offset, non_trivia_sibling},
@@ -742,13 +742,13 @@ fn classify_name_ref(
742742
match sema.resolve_path(&segment.parent_path().top_path())? {
743743
hir::PathResolution::Def(def) => match def {
744744
hir::ModuleDef::Function(func) => {
745-
func.source(sema.db)?.value.generic_param_list()
745+
sema.source(func)?.value.generic_param_list()
746746
}
747747
hir::ModuleDef::Adt(adt) => {
748-
adt.source(sema.db)?.value.generic_param_list()
748+
sema.source(adt)?.value.generic_param_list()
749749
}
750750
hir::ModuleDef::Variant(variant) => {
751-
variant.parent_enum(sema.db).source(sema.db)?.value.generic_param_list()
751+
sema.source(variant.parent_enum(sema.db))?.value.generic_param_list()
752752
}
753753
hir::ModuleDef::Trait(trait_) => {
754754
if let ast::GenericArg::AssocTypeArg(arg) = &arg {
@@ -774,14 +774,14 @@ fn classify_name_ref(
774774
return None;
775775
} else {
776776
in_trait = Some(trait_);
777-
trait_.source(sema.db)?.value.generic_param_list()
777+
sema.source(trait_)?.value.generic_param_list()
778778
}
779779
}
780780
hir::ModuleDef::TraitAlias(trait_) => {
781-
trait_.source(sema.db)?.value.generic_param_list()
781+
sema.source(trait_)?.value.generic_param_list()
782782
}
783783
hir::ModuleDef::TypeAlias(ty_) => {
784-
ty_.source(sema.db)?.value.generic_param_list()
784+
sema.source(ty_)?.value.generic_param_list()
785785
}
786786
_ => None,
787787
},
@@ -790,7 +790,7 @@ fn classify_name_ref(
790790
},
791791
ast::MethodCallExpr(call) => {
792792
let func = sema.resolve_method_call(&call)?;
793-
func.source(sema.db)?.value.generic_param_list()
793+
sema.source(func)?.value.generic_param_list()
794794
},
795795
ast::AssocTypeArg(arg) => {
796796
let trait_ = ast::PathSegment::cast(arg.syntax().parent()?.parent()?)?;
@@ -807,7 +807,7 @@ fn classify_name_ref(
807807
},
808808
_ => None,
809809
})?;
810-
assoc_ty.source(sema.db)?.value.generic_param_list()
810+
sema.source(*assoc_ty)?.value.generic_param_list()
811811
}
812812
_ => None,
813813
},

0 commit comments

Comments
 (0)