From 766813898f7901736d82bfc103874474177e7aca Mon Sep 17 00:00:00 2001 From: Andrea Pretto Date: Tue, 19 Feb 2019 22:32:00 +0100 Subject: auto_import: make auto import working with target as a list of SmolStr instead of ast::Path --- crates/ra_hir/src/name.rs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'crates/ra_hir/src/name.rs') diff --git a/crates/ra_hir/src/name.rs b/crates/ra_hir/src/name.rs index 283f37845..331da6027 100644 --- a/crates/ra_hir/src/name.rs +++ b/crates/ra_hir/src/name.rs @@ -46,6 +46,10 @@ impl Name { Name::new(idx.to_string().into()) } + pub fn to_smolstr(&self) -> SmolStr { + self.text.clone() + } + pub(crate) fn as_known_name(&self) -> Option { let name = match self.text.as_str() { "isize" => KnownName::Isize, -- cgit v1.2.3 From e01052d1f0b8bf70a418a10538528923c5f400d5 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 22 Apr 2019 15:56:28 +0300 Subject: move auto-imoprter into IDE auto-import is purely an IDE concern, so it should be done outside of HIR --- crates/ra_hir/src/name.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'crates/ra_hir/src/name.rs') diff --git a/crates/ra_hir/src/name.rs b/crates/ra_hir/src/name.rs index 331da6027..9a999e66c 100644 --- a/crates/ra_hir/src/name.rs +++ b/crates/ra_hir/src/name.rs @@ -46,8 +46,17 @@ impl Name { Name::new(idx.to_string().into()) } - pub fn to_smolstr(&self) -> SmolStr { - self.text.clone() + // There's should be no way to extract a string out of `Name`: `Name` in the + // future, `Name` will include hygiene information, and you can't encode + // hygiene into a String. + // + // If you need to compare something with `Name`, compare `Name`s directly. + // + // If you need to render `Name` for the user, use the `Display` impl, but be + // aware that it strips hygiene info. + #[deprecated(note = "use to_string instead")] + pub fn as_smolstr(&self) -> &SmolStr { + &self.text } pub(crate) fn as_known_name(&self) -> Option { -- cgit v1.2.3