From 263401bf751c66fadd4e9a46cce29dd724cc0985 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 15 Jan 2020 17:44:12 +0100 Subject: Rename --- crates/ra_hir_def/src/find_path.rs | 12 ++++++------ crates/ra_hir_def/src/path.rs | 11 ++++------- crates/ra_hir_def/src/path/lower/lower_use.rs | 8 ++++---- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/crates/ra_hir_def/src/find_path.rs b/crates/ra_hir_def/src/find_path.rs index f7dc8acb7..8cc2fb160 100644 --- a/crates/ra_hir_def/src/find_path.rs +++ b/crates/ra_hir_def/src/find_path.rs @@ -35,7 +35,7 @@ fn find_path_inner( let def_map = db.crate_def_map(from.krate); let from_scope: &crate::item_scope::ItemScope = &def_map.modules[from.local_id].scope; if let Some((name, _)) = from_scope.name_of(item) { - return Some(ModPath::from_simple_segments(PathKind::Plain, vec![name.clone()])); + return Some(ModPath::from_segments(PathKind::Plain, vec![name.clone()])); } // - if the item is the crate root, return `crate` @@ -45,12 +45,12 @@ fn find_path_inner( local_id: def_map.root, })) { - return Some(ModPath::from_simple_segments(PathKind::Crate, Vec::new())); + return Some(ModPath::from_segments(PathKind::Crate, Vec::new())); } // - if the item is the module we're in, use `self` if item == ItemInNs::Types(from.into()) { - return Some(ModPath::from_simple_segments(PathKind::Super(0), Vec::new())); + return Some(ModPath::from_segments(PathKind::Super(0), Vec::new())); } // - if the item is the parent module, use `super` (this is not used recursively, since `super::super` is ugly) @@ -61,14 +61,14 @@ fn find_path_inner( local_id: parent_id, })) { - return Some(ModPath::from_simple_segments(PathKind::Super(1), Vec::new())); + return Some(ModPath::from_segments(PathKind::Super(1), Vec::new())); } } // - if the item is the crate root of a dependency crate, return the name from the extern prelude for (name, def_id) in &def_map.extern_prelude { if item == ItemInNs::Types(*def_id) { - return Some(ModPath::from_simple_segments(PathKind::Plain, vec![name.clone()])); + return Some(ModPath::from_segments(PathKind::Plain, vec![name.clone()])); } } @@ -79,7 +79,7 @@ fn find_path_inner( &prelude_def_map.modules[prelude_module.local_id].scope; if let Some((name, vis)) = prelude_scope.name_of(item) { if vis.is_visible_from(db, from) { - return Some(ModPath::from_simple_segments(PathKind::Plain, vec![name.clone()])); + return Some(ModPath::from_segments(PathKind::Plain, vec![name.clone()])); } } } diff --git a/crates/ra_hir_def/src/path.rs b/crates/ra_hir_def/src/path.rs index 9f93a5424..ab290e2c9 100644 --- a/crates/ra_hir_def/src/path.rs +++ b/crates/ra_hir_def/src/path.rs @@ -39,10 +39,7 @@ impl ModPath { lower::lower_path(path, hygiene).map(|it| it.mod_path) } - pub fn from_simple_segments( - kind: PathKind, - segments: impl IntoIterator, - ) -> ModPath { + pub fn from_segments(kind: PathKind, segments: impl IntoIterator) -> ModPath { let segments = segments.into_iter().collect::>(); ModPath { kind, segments } } @@ -240,7 +237,7 @@ impl From for Path { fn from(name: Name) -> Path { Path { type_anchor: None, - mod_path: ModPath::from_simple_segments(PathKind::Plain, iter::once(name)), + mod_path: ModPath::from_segments(PathKind::Plain, iter::once(name)), generic_args: vec![None], } } @@ -248,7 +245,7 @@ impl From for Path { impl From for ModPath { fn from(name: Name) -> ModPath { - ModPath::from_simple_segments(PathKind::Plain, iter::once(name)) + ModPath::from_segments(PathKind::Plain, iter::once(name)) } } @@ -311,7 +308,7 @@ macro_rules! __known_path { macro_rules! __path { ($start:ident $(:: $seg:ident)*) => ({ $crate::__known_path!($start $(:: $seg)*); - $crate::path::ModPath::from_simple_segments($crate::path::PathKind::Abs, vec![ + $crate::path::ModPath::from_segments($crate::path::PathKind::Abs, vec![ $crate::path::__name![$start], $($crate::path::__name![$seg],)* ]) }); diff --git a/crates/ra_hir_def/src/path/lower/lower_use.rs b/crates/ra_hir_def/src/path/lower/lower_use.rs index 3218eaf0a..531878174 100644 --- a/crates/ra_hir_def/src/path/lower/lower_use.rs +++ b/crates/ra_hir_def/src/path/lower/lower_use.rs @@ -84,7 +84,7 @@ fn convert_path(prefix: Option, path: ast::Path, hygiene: &Hygiene) -> res } Either::Right(crate_id) => { - return Some(ModPath::from_simple_segments( + return Some(ModPath::from_segments( PathKind::DollarCrate(crate_id), iter::empty(), )) @@ -95,19 +95,19 @@ fn convert_path(prefix: Option, path: ast::Path, hygiene: &Hygiene) -> if prefix.is_some() { return None; } - ModPath::from_simple_segments(PathKind::Crate, iter::empty()) + ModPath::from_segments(PathKind::Crate, iter::empty()) } ast::PathSegmentKind::SelfKw => { if prefix.is_some() { return None; } - ModPath::from_simple_segments(PathKind::Super(0), iter::empty()) + ModPath::from_segments(PathKind::Super(0), iter::empty()) } ast::PathSegmentKind::SuperKw => { if prefix.is_some() { return None; } - ModPath::from_simple_segments(PathKind::Super(1), iter::empty()) + ModPath::from_segments(PathKind::Super(1), iter::empty()) } ast::PathSegmentKind::Type { .. } => { // not allowed in imports -- cgit v1.2.3