From 26753f0e4931e2980f008015cbd709a77d71c0f3 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 11 Jun 2019 18:07:42 +0300 Subject: remove unneded From(..) impl --- crates/ra_hir/src/code_model/src.rs | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) (limited to 'crates/ra_hir/src/code_model') diff --git a/crates/ra_hir/src/code_model/src.rs b/crates/ra_hir/src/code_model/src.rs index 7484faf04..7d8abb39e 100644 --- a/crates/ra_hir/src/code_model/src.rs +++ b/crates/ra_hir/src/code_model/src.rs @@ -11,12 +11,6 @@ pub struct Source { pub ast: T, } -impl From<(HirFileId, T)> for Source { - fn from((file_id, ast): (HirFileId, T)) -> Self { - Source { file_id, ast } - } -} - pub trait HasSource { type Ast; fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source; @@ -30,9 +24,9 @@ impl Module { let def_map = db.crate_def_map(self.krate); let decl_id = def_map[self.module_id].declaration; let file_id = def_map[self.module_id].definition; - let module_source = ModuleSource::new(db, file_id, decl_id); + let ast = ModuleSource::new(db, file_id, decl_id); let file_id = file_id.map(HirFileId::from).unwrap_or_else(|| decl_id.unwrap().file_id()); - (file_id, module_source).into() + Source { file_id, ast } } /// Returns a node which declares this module, either a `mod foo;` or a `mod foo {}`. @@ -44,32 +38,32 @@ impl Module { let def_map = db.crate_def_map(self.krate); let decl = def_map[self.module_id].declaration?; let ast = decl.to_node(db); - Some((decl.file_id(), ast).into()) + Some(Source { file_id: decl.file_id(), ast }) } } impl HasSource for StructField { type Ast = FieldSource; fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source { - self.source_impl(db).into() + self.source_impl(db) } } impl HasSource for Struct { type Ast = TreeArc; fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source> { - self.id.source(db).into() + self.id.source(db) } } impl HasSource for Union { type Ast = TreeArc; fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source> { - self.id.source(db).into() + self.id.source(db) } } impl HasSource for Enum { type Ast = TreeArc; fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source> { - self.id.source(db).into() + self.id.source(db) } } impl HasSource for EnumVariant { @@ -82,39 +76,39 @@ impl HasSource for Function { type Ast = TreeArc; fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source> { - self.id.source(db).into() + self.id.source(db) } } impl HasSource for Const { type Ast = TreeArc; fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source> { - self.id.source(db).into() + self.id.source(db) } } impl HasSource for Static { type Ast = TreeArc; fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source> { - self.id.source(db).into() + self.id.source(db) } } impl HasSource for Trait { type Ast = TreeArc; fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source> { - self.id.source(db).into() + self.id.source(db) } } impl HasSource for TypeAlias { type Ast = TreeArc; fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source> { - self.id.source(db).into() + self.id.source(db) } } impl HasSource for MacroDef { type Ast = TreeArc; fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source> { - (self.id.0.file_id(), self.id.0.to_node(db)).into() + Source { file_id: self.id.0.file_id(), ast: self.id.0.to_node(db) } } } -- cgit v1.2.3