aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src/path.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_def/src/path.rs')
-rw-r--r--crates/ra_hir_def/src/path.rs14
1 files changed, 6 insertions, 8 deletions
diff --git a/crates/ra_hir_def/src/path.rs b/crates/ra_hir_def/src/path.rs
index 7dd1939b9..9f93a5424 100644
--- a/crates/ra_hir_def/src/path.rs
+++ b/crates/ra_hir_def/src/path.rs
@@ -1,7 +1,11 @@
1//! A desugared representation of paths like `crate::foo` or `<Type as Trait>::bar`. 1//! A desugared representation of paths like `crate::foo` or `<Type as Trait>::bar`.
2mod lower; 2mod lower;
3 3
4use std::{fmt::Display, iter, sync::Arc}; 4use std::{
5 fmt::{self, Display},
6 iter,
7 sync::Arc,
8};
5 9
6use hir_expand::{ 10use hir_expand::{
7 hygiene::Hygiene, 11 hygiene::Hygiene,
@@ -78,12 +82,6 @@ impl ModPath {
78 } 82 }
79 self.segments.first() 83 self.segments.first()
80 } 84 }
81
82 pub fn to_ast(&self) -> ast::Path {
83 use ast::AstNode;
84 let parse = ast::SourceFile::parse(&self.to_string());
85 parse.tree().syntax().descendants().find_map(ast::Path::cast).unwrap()
86 }
87} 85}
88 86
89#[derive(Debug, Clone, PartialEq, Eq, Hash)] 87#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -255,7 +253,7 @@ impl From<Name> for ModPath {
255} 253}
256 254
257impl Display for ModPath { 255impl Display for ModPath {
258 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 256 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
259 let mut first_segment = true; 257 let mut first_segment = true;
260 let mut add_segment = |s| { 258 let mut add_segment = |s| {
261 if !first_segment { 259 if !first_segment {