From 9faf8dd69a819e50b9c973857fe324d7605e2d24 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 8 Mar 2021 22:14:52 +0300 Subject: Hygiene is an internal implementation detail of the compiler --- crates/hir/src/lib.rs | 7 +++++-- .../ide_assists/src/handlers/extract_struct_from_enum_variant.rs | 4 ++-- crates/ide_assists/src/handlers/qualify_path.rs | 6 ++++-- docs/dev/architecture.md | 2 +- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index a38e20300..62692c2c1 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -96,7 +96,7 @@ pub use { visibility::Visibility, }, hir_expand::{ - name::{known, AsName, Name}, + name::{known, Name}, ExpandResult, HirFileId, InFile, MacroCallId, MacroCallLoc, /* FIXME */ MacroDefId, MacroFile, Origin, }, @@ -106,7 +106,10 @@ pub use { // These are negative re-exports: pub using these names is forbidden, they // should remain private to hir internals. #[allow(unused)] -use {hir_def::path::Path, hir_expand::hygiene::Hygiene}; +use { + hir_def::path::Path, + hir_expand::{hygiene::Hygiene, name::AsName}, +}; /// hir::Crate describes a single crate. It's the main interface with which /// a crate's dependencies interact. Mostly, it should be just a proxy for the diff --git a/crates/ide_assists/src/handlers/extract_struct_from_enum_variant.rs b/crates/ide_assists/src/handlers/extract_struct_from_enum_variant.rs index 4f0422e96..335e0ed95 100644 --- a/crates/ide_assists/src/handlers/extract_struct_from_enum_variant.rs +++ b/crates/ide_assists/src/handlers/extract_struct_from_enum_variant.rs @@ -1,7 +1,7 @@ use std::iter; use either::Either; -use hir::{AsName, Module, ModuleDef, Name, Variant}; +use hir::{Module, ModuleDef, Name, Variant}; use ide_db::{ defs::Definition, helpers::{ @@ -133,7 +133,7 @@ fn existing_definition(db: &RootDatabase, variant_name: &ast::Name, variant: &Va ), _ => false, }) - .any(|(name, _)| name == variant_name.as_name()) + .any(|(name, _)| name.to_string() == variant_name.to_string()) } fn insert_import( diff --git a/crates/ide_assists/src/handlers/qualify_path.rs b/crates/ide_assists/src/handlers/qualify_path.rs index b0b0d31b4..d84ca0e55 100644 --- a/crates/ide_assists/src/handlers/qualify_path.rs +++ b/crates/ide_assists/src/handlers/qualify_path.rs @@ -1,6 +1,6 @@ use std::iter; -use hir::{AsAssocItem, AsName}; +use hir::AsAssocItem; use ide_db::helpers::{import_assets::ImportCandidate, mod_path_to_ast}; use ide_db::RootDatabase; use syntax::{ @@ -160,7 +160,9 @@ fn find_trait_method( ) -> Option { if let Some(hir::AssocItem::Function(method)) = trait_.items(db).into_iter().find(|item: &hir::AssocItem| { - item.name(db).map(|name| name == trait_method_name.as_name()).unwrap_or(false) + item.name(db) + .map(|name| name.to_string() == trait_method_name.to_string()) + .unwrap_or(false) }) { Some(method) diff --git a/docs/dev/architecture.md b/docs/dev/architecture.md index 0a3fd4285..e2237ca95 100644 --- a/docs/dev/architecture.md +++ b/docs/dev/architecture.md @@ -46,7 +46,7 @@ This is *the* entry point, but it front-loads a lot of complexity, so its fine t `crates/rust-analyzer/src/handlers.rs` implements all LSP requests and is a great place to start if you are already familiar with LSP. -`Analysis` and `AnalysisHost` types define the main API. +`Analysis` and `AnalysisHost` types define the main API for consumers of IDE services. ## Code Map -- cgit v1.2.3