Skip to content

Commit 3ccf8b7

Browse files
Also consider associated constants
1 parent f65daf2 commit 3ccf8b7

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

crates/ra_assists/src/handlers/auto_import.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ impl AutoImportAssets {
115115
match &self.import_candidate {
116116
ImportCandidate::UnqualifiedName(name) => name,
117117
ImportCandidate::QualifierStart(qualifier_start) => qualifier_start,
118-
ImportCandidate::TraitFunction(_, trait_function_name) => trait_function_name,
118+
ImportCandidate::TraitAssocItem(_, trait_function_name) => trait_function_name,
119119
ImportCandidate::TraitMethod(_, trait_method_name) => trait_method_name,
120120
}
121121
}
@@ -126,8 +126,8 @@ impl AutoImportAssets {
126126
ImportCandidate::QualifierStart(qualifier_start) => {
127127
format!("Import {}", qualifier_start)
128128
}
129-
ImportCandidate::TraitFunction(_, trait_function_name) => {
130-
format!("Import a trait for function {}", trait_function_name)
129+
ImportCandidate::TraitAssocItem(_, trait_function_name) => {
130+
format!("Import a trait for item {}", trait_function_name)
131131
}
132132
ImportCandidate::TraitMethod(_, trait_method_name) => {
133133
format!("Import a trait for method {}", trait_method_name)
@@ -142,7 +142,7 @@ impl AutoImportAssets {
142142
.find_imports(&self.get_search_query())
143143
.into_iter()
144144
.map(|module_def| match &self.import_candidate {
145-
ImportCandidate::TraitFunction(function_callee, _) => {
145+
ImportCandidate::TraitAssocItem(function_callee, _) => {
146146
let mut applicable_traits = Vec::new();
147147
if let ModuleDef::Function(located_function) = module_def {
148148
let trait_candidates: FxHashSet<_> =
@@ -255,10 +255,10 @@ enum ImportCandidate {
255255
/// First part of the qualified name.
256256
/// For 'std::collections::HashMap', that will be 'std'.
257257
QualifierStart(String),
258-
/// A trait function that has no self parameter.
258+
/// A trait associated function (with no self parameter) or associated constant.
259259
/// For 'test_mod::TestEnum::test_function', `Type` is the `test_mod::TestEnum` expression type
260-
/// and `String`is the `test_function`
261-
TraitFunction(Type, String),
260+
/// and `String` is the `test_function`
261+
TraitAssocItem(Type, String),
262262
/// A trait method with self parameter.
263263
/// For 'test_enum.test_method()', `Type` is the `test_enum` expression type
264264
/// and `String` is the `test_method`
@@ -303,7 +303,7 @@ impl ImportCandidate {
303303
source_analyzer.resolve_path(db, &qualifier)?
304304
};
305305
if let PathResolution::Def(ModuleDef::Adt(function_callee)) = qualifier_resolution {
306-
Some(ImportCandidate::TraitFunction(
306+
Some(ImportCandidate::TraitAssocItem(
307307
function_callee.ty(db),
308308
segment.syntax().to_string(),
309309
))

0 commit comments

Comments
 (0)