From 032eb3d68e07f087ac531d48f956a79948baa4b9 Mon Sep 17 00:00:00 2001 From: ice1000 Date: Tue, 3 Dec 2019 15:58:38 -0500 Subject: Remove almost unused `ModuleSource::new` --- crates/ra_hir/src/from_source.rs | 2 +- crates/ra_hir_def/src/nameres.rs | 20 +------------------- 2 files changed, 2 insertions(+), 20 deletions(-) (limited to 'crates') diff --git a/crates/ra_hir/src/from_source.rs b/crates/ra_hir/src/from_source.rs index 94a5e0b0d..67b127ba5 100644 --- a/crates/ra_hir/src/from_source.rs +++ b/crates/ra_hir/src/from_source.rs @@ -238,7 +238,7 @@ impl Module { _ => { let src_parent = InFile { file_id: src.file_id, - value: ModuleSource::new(db, Some(src.file_id.original_file(db)), None), + value: ModuleSource::from_file_id(db, src.file_id.original_file(db)), }; Module::from_definition(db, src_parent) } diff --git a/crates/ra_hir_def/src/nameres.rs b/crates/ra_hir_def/src/nameres.rs index e356515cb..ce318571c 100644 --- a/crates/ra_hir_def/src/nameres.rs +++ b/crates/ra_hir_def/src/nameres.rs @@ -356,6 +356,7 @@ impl ModuleData { } } +#[derive(Debug, Clone, PartialEq, Eq)] pub enum ModuleSource { SourceFile(ast::SourceFile), Module(ast::Module), @@ -363,25 +364,6 @@ pub enum ModuleSource { } impl ModuleSource { - pub fn new( - db: &impl DefDatabase, - file_id: Option, - decl_id: Option>, - ) -> ModuleSource { - match (file_id, decl_id) { - (Some(file_id), _) => { - let source_file = db.parse(file_id).tree(); - ModuleSource::SourceFile(source_file) - } - (None, Some(item_id)) => { - let module = item_id.to_node(db); - assert!(module.item_list().is_some(), "expected inline module"); - ModuleSource::Module(module) - } - (None, None) => panic!(), - } - } - // FIXME: this methods do not belong here pub fn from_position(db: &impl DefDatabase, position: FilePosition) -> ModuleSource { let parse = db.parse(position.file_id); -- cgit v1.2.3