diff options
author | Kirill Bulatov <[email protected]> | 2021-01-05 08:34:03 +0000 |
---|---|---|
committer | Kirill Bulatov <[email protected]> | 2021-01-16 18:44:12 +0000 |
commit | db335a1bbf1d1bea2c761f67efb4b49831738e31 (patch) | |
tree | 910963c004c460d2f0c322a0e643947aaf7132b8 /crates/ide | |
parent | 9a349f280ff1c6d0b57df80aa3d6720474e4b00a (diff) |
Add flyimport completion for trait assoc items
Diffstat (limited to 'crates/ide')
-rw-r--r-- | crates/ide/src/doc_links.rs | 8 | ||||
-rw-r--r-- | crates/ide/src/lib.rs | 2 |
2 files changed, 6 insertions, 4 deletions
diff --git a/crates/ide/src/doc_links.rs b/crates/ide/src/doc_links.rs index de10406bc..1f08d7810 100644 --- a/crates/ide/src/doc_links.rs +++ b/crates/ide/src/doc_links.rs | |||
@@ -438,10 +438,10 @@ fn get_symbol_fragment(db: &dyn HirDatabase, field_or_assoc: &FieldOrAssocItem) | |||
438 | FieldOrAssocItem::Field(field) => format!("#structfield.{}", field.name(db)), | 438 | FieldOrAssocItem::Field(field) => format!("#structfield.{}", field.name(db)), |
439 | FieldOrAssocItem::AssocItem(assoc) => match assoc { | 439 | FieldOrAssocItem::AssocItem(assoc) => match assoc { |
440 | AssocItem::Function(function) => { | 440 | AssocItem::Function(function) => { |
441 | let is_trait_method = matches!( | 441 | let is_trait_method = function |
442 | function.as_assoc_item(db).map(|assoc| assoc.container(db)), | 442 | .as_assoc_item(db) |
443 | Some(AssocItemContainer::Trait(..)) | 443 | .and_then(|assoc| assoc.containing_trait(db)) |
444 | ); | 444 | .is_some(); |
445 | // This distinction may get more complicated when specialization is available. | 445 | // This distinction may get more complicated when specialization is available. |
446 | // Rustdoc makes this decision based on whether a method 'has defaultness'. | 446 | // Rustdoc makes this decision based on whether a method 'has defaultness'. |
447 | // Currently this is only the case for provided trait methods. | 447 | // Currently this is only the case for provided trait methods. |
diff --git a/crates/ide/src/lib.rs b/crates/ide/src/lib.rs index f8d69382e..07f52613f 100644 --- a/crates/ide/src/lib.rs +++ b/crates/ide/src/lib.rs | |||
@@ -481,6 +481,7 @@ impl Analysis { | |||
481 | position: FilePosition, | 481 | position: FilePosition, |
482 | full_import_path: &str, | 482 | full_import_path: &str, |
483 | imported_name: String, | 483 | imported_name: String, |
484 | import_for_trait_assoc_item: bool, | ||
484 | ) -> Cancelable<Vec<TextEdit>> { | 485 | ) -> Cancelable<Vec<TextEdit>> { |
485 | Ok(self | 486 | Ok(self |
486 | .with_db(|db| { | 487 | .with_db(|db| { |
@@ -490,6 +491,7 @@ impl Analysis { | |||
490 | position, | 491 | position, |
491 | full_import_path, | 492 | full_import_path, |
492 | imported_name, | 493 | imported_name, |
494 | import_for_trait_assoc_item, | ||
493 | ) | 495 | ) |
494 | })? | 496 | })? |
495 | .unwrap_or_default()) | 497 | .unwrap_or_default()) |