From 2090b534fc249a493823bb8e9039c0123aa0b90e Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 6 Oct 2020 16:19:18 +0200 Subject: Move ModPath->ast::Path function to IDE layer closes #6092 --- crates/hir_def/src/path.rs | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) (limited to 'crates/hir_def') diff --git a/crates/hir_def/src/path.rs b/crates/hir_def/src/path.rs index 209b18e78..5b8c1e449 100644 --- a/crates/hir_def/src/path.rs +++ b/crates/hir_def/src/path.rs @@ -13,7 +13,7 @@ use hir_expand::{ hygiene::Hygiene, name::{AsName, Name}, }; -use syntax::ast::{self, make}; +use syntax::ast::{self}; use crate::{ type_ref::{TypeBound, TypeRef}, @@ -100,26 +100,6 @@ impl ModPath { } self.segments.first() } - - pub fn to_ast_path(&self) -> ast::Path { - let mut segments = Vec::new(); - let mut is_abs = false; - match self.kind { - PathKind::Plain => {} - PathKind::Super(0) => segments.push(make::path_segment_self()), - PathKind::Super(n) => segments.extend((0..n).map(|_| make::path_segment_super())), - PathKind::Crate => segments.push(make::path_segment_crate()), - PathKind::Abs => is_abs = true, - PathKind::DollarCrate(_) => (), - } - - segments.extend( - self.segments - .iter() - .map(|segment| make::path_segment(make::name_ref(&segment.to_string()))), - ); - make::path_from_segments(segments, is_abs) - } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] -- cgit v1.2.3