From 005bc49d744f6a7c2ef38a4abd3327b0804709d1 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Sat, 20 Feb 2021 23:32:21 +0200 Subject: Test and initial refactoring --- crates/ide_assists/src/handlers/auto_import.rs | 35 ------------------------- crates/ide_assists/src/handlers/qualify_path.rs | 4 +-- 2 files changed, 2 insertions(+), 37 deletions(-) (limited to 'crates/ide_assists') diff --git a/crates/ide_assists/src/handlers/auto_import.rs b/crates/ide_assists/src/handlers/auto_import.rs index 1422224ac..5fe3f47fd 100644 --- a/crates/ide_assists/src/handlers/auto_import.rs +++ b/crates/ide_assists/src/handlers/auto_import.rs @@ -220,41 +220,6 @@ mod tests { ); } - #[test] - fn auto_imports_are_merged() { - check_assist( - auto_import, - r" - use PubMod::PubStruct1; - - struct Test { - test: Pub$0Struct2, - } - - pub mod PubMod { - pub struct PubStruct1; - pub struct PubStruct2 { - _t: T, - } - } - ", - r" - use PubMod::{PubStruct1, PubStruct2}; - - struct Test { - test: PubStruct2, - } - - pub mod PubMod { - pub struct PubStruct1; - pub struct PubStruct2 { - _t: T, - } - } - ", - ); - } - #[test] fn applicable_when_found_multiple_imports() { check_assist( diff --git a/crates/ide_assists/src/handlers/qualify_path.rs b/crates/ide_assists/src/handlers/qualify_path.rs index d3e34e540..1fb4931cd 100644 --- a/crates/ide_assists/src/handlers/qualify_path.rs +++ b/crates/ide_assists/src/handlers/qualify_path.rs @@ -45,7 +45,7 @@ pub(crate) fn qualify_path(acc: &mut Assists, ctx: &AssistContext) -> Option<()> let qualify_candidate = match candidate { ImportCandidate::Path(candidate) => { - if candidate.qualifier.is_some() { + if candidate.unresolved_qualifier.is_some() { cov_mark::hit!(qualify_path_qualifier_start); let path = ast::Path::cast(syntax_under_caret)?; let (prev_segment, segment) = (path.qualifier()?.segment()?, path.segment()?); @@ -192,7 +192,7 @@ fn group_label(candidate: &ImportCandidate) -> GroupLabel { fn label(candidate: &ImportCandidate, import: &hir::ModPath) -> String { match candidate { ImportCandidate::Path(candidate) => { - if candidate.qualifier.is_some() { + if candidate.unresolved_qualifier.is_some() { format!("Qualify with `{}`", &import) } else { format!("Qualify as `{}`", &import) -- cgit v1.2.3 From 309421c117fc20e58b9f30fb28a01a89f50b0086 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Wed, 24 Feb 2021 01:20:00 +0200 Subject: Draft the qualifier import resolution --- crates/ide_assists/src/handlers/qualify_path.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'crates/ide_assists') diff --git a/crates/ide_assists/src/handlers/qualify_path.rs b/crates/ide_assists/src/handlers/qualify_path.rs index 1fb4931cd..c0463311e 100644 --- a/crates/ide_assists/src/handlers/qualify_path.rs +++ b/crates/ide_assists/src/handlers/qualify_path.rs @@ -1,7 +1,10 @@ use std::iter; use hir::AsAssocItem; -use ide_db::helpers::{import_assets::ImportCandidate, mod_path_to_ast}; +use ide_db::helpers::{ + import_assets::{ImportCandidate, Qualifier}, + mod_path_to_ast, +}; use ide_db::RootDatabase; use syntax::{ ast, @@ -45,7 +48,7 @@ pub(crate) fn qualify_path(acc: &mut Assists, ctx: &AssistContext) -> Option<()> let qualify_candidate = match candidate { ImportCandidate::Path(candidate) => { - if candidate.unresolved_qualifier.is_some() { + if !matches!(candidate.qualifier, Qualifier::Absent) { cov_mark::hit!(qualify_path_qualifier_start); let path = ast::Path::cast(syntax_under_caret)?; let (prev_segment, segment) = (path.qualifier()?.segment()?, path.segment()?); @@ -192,7 +195,7 @@ fn group_label(candidate: &ImportCandidate) -> GroupLabel { fn label(candidate: &ImportCandidate, import: &hir::ModPath) -> String { match candidate { ImportCandidate::Path(candidate) => { - if candidate.unresolved_qualifier.is_some() { + if !matches!(candidate.qualifier, Qualifier::Absent) { format!("Qualify with `{}`", &import) } else { format!("Qualify as `{}`", &import) -- cgit v1.2.3 From 582cee2cdf5355b681f14bbb33bd5c431c284d87 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Thu, 25 Feb 2021 01:06:31 +0200 Subject: Return more data about located imports --- crates/ide_assists/src/handlers/auto_import.rs | 10 +++++++--- crates/ide_assists/src/handlers/qualify_path.rs | 17 +++++++++++------ 2 files changed, 18 insertions(+), 9 deletions(-) (limited to 'crates/ide_assists') diff --git a/crates/ide_assists/src/handlers/auto_import.rs b/crates/ide_assists/src/handlers/auto_import.rs index 5fe3f47fd..7188724be 100644 --- a/crates/ide_assists/src/handlers/auto_import.rs +++ b/crates/ide_assists/src/handlers/auto_import.rs @@ -92,14 +92,18 @@ pub(crate) fn auto_import(acc: &mut Assists, ctx: &AssistContext) -> Option<()> let range = ctx.sema.original_range(&syntax_under_caret).range; let group = import_group_message(import_assets.import_candidate()); let scope = ImportScope::find_insert_use_container(&syntax_under_caret, &ctx.sema)?; - for (import, _) in proposed_imports { + for import in proposed_imports { acc.add_group( &group, AssistId("auto_import", AssistKind::QuickFix), - format!("Import `{}`", &import), + format!("Import `{}`", import.display_path()), range, |builder| { - let rewriter = insert_use(&scope, mod_path_to_ast(&import), ctx.config.insert_use); + let rewriter = insert_use( + &scope, + mod_path_to_ast(import.import_path()), + ctx.config.insert_use, + ); builder.rewrite(rewriter); }, ); diff --git a/crates/ide_assists/src/handlers/qualify_path.rs b/crates/ide_assists/src/handlers/qualify_path.rs index c0463311e..a40cdd80e 100644 --- a/crates/ide_assists/src/handlers/qualify_path.rs +++ b/crates/ide_assists/src/handlers/qualify_path.rs @@ -74,17 +74,17 @@ pub(crate) fn qualify_path(acc: &mut Assists, ctx: &AssistContext) -> Option<()> }; let group_label = group_label(candidate); - for (import, item) in proposed_imports { + for import in proposed_imports { acc.add_group( &group_label, AssistId("qualify_path", AssistKind::QuickFix), - label(candidate, &import), + label(candidate, import.display_path()), range, |builder| { qualify_candidate.qualify( |replace_with: String| builder.replace(range, replace_with), - import, - item, + import.import_path(), + import.item_to_import(), ) }, ); @@ -100,8 +100,13 @@ enum QualifyCandidate<'db> { } impl QualifyCandidate<'_> { - fn qualify(&self, mut replacer: impl FnMut(String), import: hir::ModPath, item: hir::ItemInNs) { - let import = mod_path_to_ast(&import); + fn qualify( + &self, + mut replacer: impl FnMut(String), + import: &hir::ModPath, + item: hir::ItemInNs, + ) { + let import = mod_path_to_ast(import); match self { QualifyCandidate::QualifierStart(segment, generics) => { let generics = generics.as_ref().map_or_else(String::new, ToString::to_string); -- cgit v1.2.3 From 9482353fa8e1e88cb720a029b9bb6304819c7399 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Sun, 28 Feb 2021 09:57:54 +0200 Subject: Properly handle turbofishes in qualifiers --- crates/ide_assists/src/handlers/auto_import.rs | 2 +- crates/ide_assists/src/handlers/qualify_path.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/ide_assists') diff --git a/crates/ide_assists/src/handlers/auto_import.rs b/crates/ide_assists/src/handlers/auto_import.rs index 7188724be..e9993a7cc 100644 --- a/crates/ide_assists/src/handlers/auto_import.rs +++ b/crates/ide_assists/src/handlers/auto_import.rs @@ -242,7 +242,7 @@ mod tests { } ", r" - use PubMod3::PubStruct; + use PubMod1::PubStruct; PubStruct diff --git a/crates/ide_assists/src/handlers/qualify_path.rs b/crates/ide_assists/src/handlers/qualify_path.rs index a40cdd80e..261178448 100644 --- a/crates/ide_assists/src/handlers/qualify_path.rs +++ b/crates/ide_assists/src/handlers/qualify_path.rs @@ -313,7 +313,7 @@ mod tests { } ", r" - PubMod3::PubStruct + PubMod1::PubStruct pub mod PubMod1 { pub struct PubStruct; -- cgit v1.2.3 From 89d410cef571f5fa7631b17e2fbe52a8f8f03990 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Sun, 28 Feb 2021 10:32:15 +0200 Subject: Do not propose already imported imports --- crates/ide_assists/src/handlers/auto_import.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'crates/ide_assists') diff --git a/crates/ide_assists/src/handlers/auto_import.rs b/crates/ide_assists/src/handlers/auto_import.rs index e9993a7cc..182547589 100644 --- a/crates/ide_assists/src/handlers/auto_import.rs +++ b/crates/ide_assists/src/handlers/auto_import.rs @@ -111,7 +111,9 @@ pub(crate) fn auto_import(acc: &mut Assists, ctx: &AssistContext) -> Option<()> Some(()) } -pub(super) fn find_importable_node(ctx: &AssistContext) -> Option<(ImportAssets, SyntaxNode)> { +pub(super) fn find_importable_node<'a>( + ctx: &'a AssistContext, +) -> Option<(ImportAssets<'a>, SyntaxNode)> { if let Some(path_under_caret) = ctx.find_node_at_offset_with_descend::() { ImportAssets::for_exact_path(&path_under_caret, &ctx.sema) .zip(Some(path_under_caret.syntax().clone())) -- cgit v1.2.3 From 33c83e72b9b48177a6171fd06a26676679963a4d Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Wed, 3 Mar 2021 01:26:53 +0200 Subject: Work towards better import labels --- crates/ide_assists/src/handlers/auto_import.rs | 13 +++++++------ crates/ide_assists/src/handlers/qualify_path.rs | 22 +++++++++++++--------- .../handlers/replace_derive_with_manual_impl.rs | 10 ++++++---- 3 files changed, 26 insertions(+), 19 deletions(-) (limited to 'crates/ide_assists') diff --git a/crates/ide_assists/src/handlers/auto_import.rs b/crates/ide_assists/src/handlers/auto_import.rs index 182547589..f3c969eee 100644 --- a/crates/ide_assists/src/handlers/auto_import.rs +++ b/crates/ide_assists/src/handlers/auto_import.rs @@ -93,17 +93,18 @@ pub(crate) fn auto_import(acc: &mut Assists, ctx: &AssistContext) -> Option<()> let group = import_group_message(import_assets.import_candidate()); let scope = ImportScope::find_insert_use_container(&syntax_under_caret, &ctx.sema)?; for import in proposed_imports { + let name = match import.original_item_name(ctx.db()) { + Some(name) => name, + None => continue, + }; acc.add_group( &group, AssistId("auto_import", AssistKind::QuickFix), - format!("Import `{}`", import.display_path()), + format!("Import `{}`", name), range, |builder| { - let rewriter = insert_use( - &scope, - mod_path_to_ast(import.import_path()), - ctx.config.insert_use, - ); + let rewriter = + insert_use(&scope, mod_path_to_ast(&import.import_path), ctx.config.insert_use); builder.rewrite(rewriter); }, ); diff --git a/crates/ide_assists/src/handlers/qualify_path.rs b/crates/ide_assists/src/handlers/qualify_path.rs index 261178448..407ba47be 100644 --- a/crates/ide_assists/src/handlers/qualify_path.rs +++ b/crates/ide_assists/src/handlers/qualify_path.rs @@ -2,7 +2,7 @@ use std::iter; use hir::AsAssocItem; use ide_db::helpers::{ - import_assets::{ImportCandidate, Qualifier}, + import_assets::{ImportCandidate, LocatedImport, Qualifier}, mod_path_to_ast, }; use ide_db::RootDatabase; @@ -78,13 +78,13 @@ pub(crate) fn qualify_path(acc: &mut Assists, ctx: &AssistContext) -> Option<()> acc.add_group( &group_label, AssistId("qualify_path", AssistKind::QuickFix), - label(candidate, import.display_path()), + label(ctx.db(), candidate, &import), range, |builder| { qualify_candidate.qualify( |replace_with: String| builder.replace(range, replace_with), - import.import_path(), - import.item_to_import(), + &import.import_path, + import.item_to_import, ) }, ); @@ -197,17 +197,21 @@ fn group_label(candidate: &ImportCandidate) -> GroupLabel { GroupLabel(format!("Qualify {}", name)) } -fn label(candidate: &ImportCandidate, import: &hir::ModPath) -> String { +fn label(db: &RootDatabase, candidate: &ImportCandidate, import: &LocatedImport) -> String { + let display_path = match import.original_item_name(db) { + Some(display_path) => display_path.to_string(), + None => "{unknown}".to_string(), + }; match candidate { ImportCandidate::Path(candidate) => { if !matches!(candidate.qualifier, Qualifier::Absent) { - format!("Qualify with `{}`", &import) + format!("Qualify with `{}`", display_path) } else { - format!("Qualify as `{}`", &import) + format!("Qualify as `{}`", display_path) } } - ImportCandidate::TraitAssocItem(_) => format!("Qualify `{}`", &import), - ImportCandidate::TraitMethod(_) => format!("Qualify with cast as `{}`", &import), + ImportCandidate::TraitAssocItem(_) => format!("Qualify `{}`", display_path), + ImportCandidate::TraitMethod(_) => format!("Qualify with cast as `{}`", display_path), } } diff --git a/crates/ide_assists/src/handlers/replace_derive_with_manual_impl.rs b/crates/ide_assists/src/handlers/replace_derive_with_manual_impl.rs index c69bc5cac..93a03e8b2 100644 --- a/crates/ide_assists/src/handlers/replace_derive_with_manual_impl.rs +++ b/crates/ide_assists/src/handlers/replace_derive_with_manual_impl.rs @@ -1,5 +1,6 @@ +use hir::ModuleDef; use ide_db::helpers::mod_path_to_ast; -use ide_db::imports_locator; +use ide_db::items_locator; use itertools::Itertools; use syntax::{ ast::{self, make, AstNode, NameOwner}, @@ -64,13 +65,14 @@ pub(crate) fn replace_derive_with_manual_impl( let current_module = ctx.sema.scope(annotated_name.syntax()).module()?; let current_crate = current_module.krate(); - let found_traits = imports_locator::find_exact_imports( + let found_traits = items_locator::with_for_exact_name( &ctx.sema, current_crate, trait_token.text().to_string(), ) - .filter_map(|candidate: either::Either| match candidate { - either::Either::Left(hir::ModuleDef::Trait(trait_)) => Some(trait_), + .into_iter() + .filter_map(|item| match ModuleDef::from(item.as_module_def_id()?) { + ModuleDef::Trait(trait_) => Some(trait_), _ => None, }) .flat_map(|trait_| { -- cgit v1.2.3 From 5b7d928075f3bedf71f754444c1532976d52eae4 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Wed, 3 Mar 2021 23:59:56 +0200 Subject: Enforce the located imports' order --- crates/ide_assists/src/handlers/auto_import.rs | 2 +- crates/ide_assists/src/handlers/qualify_path.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/ide_assists') diff --git a/crates/ide_assists/src/handlers/auto_import.rs b/crates/ide_assists/src/handlers/auto_import.rs index f3c969eee..eb8d35e95 100644 --- a/crates/ide_assists/src/handlers/auto_import.rs +++ b/crates/ide_assists/src/handlers/auto_import.rs @@ -245,7 +245,7 @@ mod tests { } ", r" - use PubMod1::PubStruct; + use PubMod3::PubStruct; PubStruct diff --git a/crates/ide_assists/src/handlers/qualify_path.rs b/crates/ide_assists/src/handlers/qualify_path.rs index 407ba47be..b36dd3823 100644 --- a/crates/ide_assists/src/handlers/qualify_path.rs +++ b/crates/ide_assists/src/handlers/qualify_path.rs @@ -317,7 +317,7 @@ mod tests { } ", r" - PubMod1::PubStruct + PubMod3::PubStruct pub mod PubMod1 { pub struct PubStruct; -- cgit v1.2.3 From dccbb38d2e28bfeb53f31c13de3b83e72f1a476c Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Mon, 8 Mar 2021 00:25:45 +0200 Subject: Less lifetines: derive SemanticsScope in place --- crates/ide_assists/src/handlers/auto_import.rs | 4 +-- .../handlers/replace_derive_with_manual_impl.rs | 31 ++++++++++------------ 2 files changed, 15 insertions(+), 20 deletions(-) (limited to 'crates/ide_assists') diff --git a/crates/ide_assists/src/handlers/auto_import.rs b/crates/ide_assists/src/handlers/auto_import.rs index eb8d35e95..5546c3a4e 100644 --- a/crates/ide_assists/src/handlers/auto_import.rs +++ b/crates/ide_assists/src/handlers/auto_import.rs @@ -112,9 +112,7 @@ pub(crate) fn auto_import(acc: &mut Assists, ctx: &AssistContext) -> Option<()> Some(()) } -pub(super) fn find_importable_node<'a>( - ctx: &'a AssistContext, -) -> Option<(ImportAssets<'a>, SyntaxNode)> { +pub(super) fn find_importable_node(ctx: &AssistContext) -> Option<(ImportAssets, SyntaxNode)> { if let Some(path_under_caret) = ctx.find_node_at_offset_with_descend::() { ImportAssets::for_exact_path(&path_under_caret, &ctx.sema) .zip(Some(path_under_caret.syntax().clone())) diff --git a/crates/ide_assists/src/handlers/replace_derive_with_manual_impl.rs b/crates/ide_assists/src/handlers/replace_derive_with_manual_impl.rs index 93a03e8b2..88fe2fe90 100644 --- a/crates/ide_assists/src/handlers/replace_derive_with_manual_impl.rs +++ b/crates/ide_assists/src/handlers/replace_derive_with_manual_impl.rs @@ -65,23 +65,20 @@ pub(crate) fn replace_derive_with_manual_impl( let current_module = ctx.sema.scope(annotated_name.syntax()).module()?; let current_crate = current_module.krate(); - let found_traits = items_locator::with_for_exact_name( - &ctx.sema, - current_crate, - trait_token.text().to_string(), - ) - .into_iter() - .filter_map(|item| match ModuleDef::from(item.as_module_def_id()?) { - ModuleDef::Trait(trait_) => Some(trait_), - _ => None, - }) - .flat_map(|trait_| { - current_module - .find_use_path(ctx.sema.db, hir::ModuleDef::Trait(trait_)) - .as_ref() - .map(mod_path_to_ast) - .zip(Some(trait_)) - }); + let found_traits = + items_locator::with_exact_name(&ctx.sema, current_crate, trait_token.text().to_string()) + .into_iter() + .filter_map(|item| match ModuleDef::from(item.as_module_def_id()?) { + ModuleDef::Trait(trait_) => Some(trait_), + _ => None, + }) + .flat_map(|trait_| { + current_module + .find_use_path(ctx.sema.db, hir::ModuleDef::Trait(trait_)) + .as_ref() + .map(mod_path_to_ast) + .zip(Some(trait_)) + }); let mut no_traits_found = true; for (trait_path, trait_) in found_traits.inspect(|_| no_traits_found = false) { -- cgit v1.2.3 From 5168ab16e14679e16a472c0ab13b1bbc32dc95f3 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Mon, 8 Mar 2021 14:09:20 +0200 Subject: Add rustdocs and use better names --- crates/ide_assists/src/handlers/auto_import.rs | 8 ++++---- crates/ide_assists/src/handlers/qualify_path.rs | 14 ++++++++------ 2 files changed, 12 insertions(+), 10 deletions(-) (limited to 'crates/ide_assists') diff --git a/crates/ide_assists/src/handlers/auto_import.rs b/crates/ide_assists/src/handlers/auto_import.rs index 5546c3a4e..7caee8df0 100644 --- a/crates/ide_assists/src/handlers/auto_import.rs +++ b/crates/ide_assists/src/handlers/auto_import.rs @@ -1,7 +1,7 @@ use ide_db::helpers::{ import_assets::{ImportAssets, ImportCandidate}, insert_use::{insert_use, ImportScope}, - mod_path_to_ast, + item_name, mod_path_to_ast, }; use syntax::{ast, AstNode, SyntaxNode}; @@ -93,7 +93,7 @@ pub(crate) fn auto_import(acc: &mut Assists, ctx: &AssistContext) -> Option<()> let group = import_group_message(import_assets.import_candidate()); let scope = ImportScope::find_insert_use_container(&syntax_under_caret, &ctx.sema)?; for import in proposed_imports { - let name = match import.original_item_name(ctx.db()) { + let name = match item_name(ctx.db(), import.original_item) { Some(name) => name, None => continue, }; @@ -130,10 +130,10 @@ fn import_group_message(import_candidate: &ImportCandidate) -> GroupLabel { let name = match import_candidate { ImportCandidate::Path(candidate) => format!("Import {}", candidate.name.text()), ImportCandidate::TraitAssocItem(candidate) => { - format!("Import a trait for item {}", candidate.name.text()) + format!("Import a trait for item {}", candidate.assoc_item_name.text()) } ImportCandidate::TraitMethod(candidate) => { - format!("Import a trait for method {}", candidate.name.text()) + format!("Import a trait for method {}", candidate.assoc_item_name.text()) } }; GroupLabel(name) diff --git a/crates/ide_assists/src/handlers/qualify_path.rs b/crates/ide_assists/src/handlers/qualify_path.rs index b36dd3823..272874ae3 100644 --- a/crates/ide_assists/src/handlers/qualify_path.rs +++ b/crates/ide_assists/src/handlers/qualify_path.rs @@ -2,8 +2,8 @@ use std::iter; use hir::AsAssocItem; use ide_db::helpers::{ - import_assets::{ImportCandidate, LocatedImport, Qualifier}, - mod_path_to_ast, + import_assets::{ImportCandidate, LocatedImport}, + item_name, mod_path_to_ast, }; use ide_db::RootDatabase; use syntax::{ @@ -48,7 +48,7 @@ pub(crate) fn qualify_path(acc: &mut Assists, ctx: &AssistContext) -> Option<()> let qualify_candidate = match candidate { ImportCandidate::Path(candidate) => { - if !matches!(candidate.qualifier, Qualifier::Absent) { + if candidate.qualifier.is_some() { cov_mark::hit!(qualify_path_qualifier_start); let path = ast::Path::cast(syntax_under_caret)?; let (prev_segment, segment) = (path.qualifier()?.segment()?, path.segment()?); @@ -191,20 +191,22 @@ fn item_as_trait(db: &RootDatabase, item: hir::ItemInNs) -> Option { fn group_label(candidate: &ImportCandidate) -> GroupLabel { let name = match candidate { ImportCandidate::Path(it) => &it.name, - ImportCandidate::TraitAssocItem(it) | ImportCandidate::TraitMethod(it) => &it.name, + ImportCandidate::TraitAssocItem(it) | ImportCandidate::TraitMethod(it) => { + &it.assoc_item_name + } } .text(); GroupLabel(format!("Qualify {}", name)) } fn label(db: &RootDatabase, candidate: &ImportCandidate, import: &LocatedImport) -> String { - let display_path = match import.original_item_name(db) { + let display_path = match item_name(db, import.original_item) { Some(display_path) => display_path.to_string(), None => "{unknown}".to_string(), }; match candidate { ImportCandidate::Path(candidate) => { - if !matches!(candidate.qualifier, Qualifier::Absent) { + if candidate.qualifier.is_some() { format!("Qualify with `{}`", display_path) } else { format!("Qualify as `{}`", display_path) -- cgit v1.2.3