aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorNick Spain <[email protected]>2021-01-02 05:25:36 +0000
committerNick Spain <[email protected]>2021-01-02 10:53:52 +0000
commit887028fcf52bf7f3af55114f112123c902989bed (patch)
treeff129d5891de09502ada5eccab45e42fbec9ea82 /crates
parent5c659c21dda26311be584d0bb89b80f8ae3d7bae (diff)
Remove old_source now we've fully migrated
Fixes #6913
Diffstat (limited to 'crates')
-rw-r--r--crates/hir/src/has_source.rs68
1 files changed, 0 insertions, 68 deletions
diff --git a/crates/hir/src/has_source.rs b/crates/hir/src/has_source.rs
index 8a7306def..57baeb3cf 100644
--- a/crates/hir/src/has_source.rs
+++ b/crates/hir/src/has_source.rs
@@ -16,8 +16,6 @@ use crate::{
16 16
17pub trait HasSource { 17pub trait HasSource {
18 type Ast; 18 type Ast;
19 #[deprecated = "migrating to source() method that returns an Option"]
20 fn source_old(self, db: &dyn HirDatabase) -> InFile<Self::Ast>;
21 fn source(self, db: &dyn HirDatabase) -> Option<InFile<Self::Ast>>; 19 fn source(self, db: &dyn HirDatabase) -> Option<InFile<Self::Ast>>;
22} 20}
23 21
@@ -48,15 +46,6 @@ impl Module {
48 46
49impl HasSource for Field { 47impl HasSource for Field {
50 type Ast = FieldSource; 48 type Ast = FieldSource;
51 fn source_old(self, db: &dyn HirDatabase) -> InFile<FieldSource> {
52 let var = VariantId::from(self.parent);
53 let src = var.child_source(db.upcast());
54 src.map(|it| match it[self.id].clone() {
55 Either::Left(it) => FieldSource::Pos(it),
56 Either::Right(it) => FieldSource::Named(it),
57 })
58 }
59
60 fn source(self, db: &dyn HirDatabase) -> Option<InFile<Self::Ast>> { 49 fn source(self, db: &dyn HirDatabase) -> Option<InFile<Self::Ast>> {
61 let var = VariantId::from(self.parent); 50 let var = VariantId::from(self.parent);
62 let src = var.child_source(db.upcast()); 51 let src = var.child_source(db.upcast());
@@ -69,103 +58,60 @@ impl HasSource for Field {
69} 58}
70impl HasSource for Struct { 59impl HasSource for Struct {
71 type Ast = ast::Struct; 60 type Ast = ast::Struct;
72 fn source_old(self, db: &dyn HirDatabase) -> InFile<ast::Struct> {
73 self.id.lookup(db.upcast()).source(db.upcast())
74 }
75
76 fn source(self, db: &dyn HirDatabase) -> Option<InFile<Self::Ast>> { 61 fn source(self, db: &dyn HirDatabase) -> Option<InFile<Self::Ast>> {
77 Some(self.id.lookup(db.upcast()).source(db.upcast())) 62 Some(self.id.lookup(db.upcast()).source(db.upcast()))
78 } 63 }
79} 64}
80impl HasSource for Union { 65impl HasSource for Union {
81 type Ast = ast::Union; 66 type Ast = ast::Union;
82 fn source_old(self, db: &dyn HirDatabase) -> InFile<ast::Union> {
83 self.id.lookup(db.upcast()).source(db.upcast())
84 }
85
86 fn source(self, db: &dyn HirDatabase) -> Option<InFile<Self::Ast>> { 67 fn source(self, db: &dyn HirDatabase) -> Option<InFile<Self::Ast>> {
87 Some(self.id.lookup(db.upcast()).source(db.upcast())) 68 Some(self.id.lookup(db.upcast()).source(db.upcast()))
88 } 69 }
89} 70}
90impl HasSource for Enum { 71impl HasSource for Enum {
91 type Ast = ast::Enum; 72 type Ast = ast::Enum;
92 fn source_old(self, db: &dyn HirDatabase) -> InFile<ast::Enum> {
93 self.id.lookup(db.upcast()).source(db.upcast())
94 }
95
96 fn source(self, db: &dyn HirDatabase) -> Option<InFile<Self::Ast>> { 73 fn source(self, db: &dyn HirDatabase) -> Option<InFile<Self::Ast>> {
97 Some(self.id.lookup(db.upcast()).source(db.upcast())) 74 Some(self.id.lookup(db.upcast()).source(db.upcast()))
98 } 75 }
99} 76}
100impl HasSource for Variant { 77impl HasSource for Variant {
101 type Ast = ast::Variant; 78 type Ast = ast::Variant;
102 fn source_old(self, db: &dyn HirDatabase) -> InFile<ast::Variant> {
103 self.parent.id.child_source(db.upcast()).map(|map| map[self.id].clone())
104 }
105
106 fn source(self, db: &dyn HirDatabase) -> Option<InFile<ast::Variant>> { 79 fn source(self, db: &dyn HirDatabase) -> Option<InFile<ast::Variant>> {
107 Some(self.parent.id.child_source(db.upcast()).map(|map| map[self.id].clone())) 80 Some(self.parent.id.child_source(db.upcast()).map(|map| map[self.id].clone()))
108 } 81 }
109} 82}
110impl HasSource for Function { 83impl HasSource for Function {
111 type Ast = ast::Fn; 84 type Ast = ast::Fn;
112 fn source_old(self, db: &dyn HirDatabase) -> InFile<ast::Fn> {
113 self.id.lookup(db.upcast()).source(db.upcast())
114 }
115
116 fn source(self, db: &dyn HirDatabase) -> Option<InFile<Self::Ast>> { 85 fn source(self, db: &dyn HirDatabase) -> Option<InFile<Self::Ast>> {
117 Some(self.id.lookup(db.upcast()).source(db.upcast())) 86 Some(self.id.lookup(db.upcast()).source(db.upcast()))
118 } 87 }
119} 88}
120impl HasSource for Const { 89impl HasSource for Const {
121 type Ast = ast::Const; 90 type Ast = ast::Const;
122 fn source_old(self, db: &dyn HirDatabase) -> InFile<ast::Const> {
123 self.id.lookup(db.upcast()).source(db.upcast())
124 }
125
126 fn source(self, db: &dyn HirDatabase) -> Option<InFile<Self::Ast>> { 91 fn source(self, db: &dyn HirDatabase) -> Option<InFile<Self::Ast>> {
127 Some(self.id.lookup(db.upcast()).source(db.upcast())) 92 Some(self.id.lookup(db.upcast()).source(db.upcast()))
128 } 93 }
129} 94}
130impl HasSource for Static { 95impl HasSource for Static {
131 type Ast = ast::Static; 96 type Ast = ast::Static;
132 fn source_old(self, db: &dyn HirDatabase) -> InFile<ast::Static> {
133 self.id.lookup(db.upcast()).source(db.upcast())
134 }
135
136 fn source(self, db: &dyn HirDatabase) -> Option<InFile<Self::Ast>> { 97 fn source(self, db: &dyn HirDatabase) -> Option<InFile<Self::Ast>> {
137 Some(self.id.lookup(db.upcast()).source(db.upcast())) 98 Some(self.id.lookup(db.upcast()).source(db.upcast()))
138 } 99 }
139} 100}
140impl HasSource for Trait { 101impl HasSource for Trait {
141 type Ast = ast::Trait; 102 type Ast = ast::Trait;
142 fn source_old(self, db: &dyn HirDatabase) -> InFile<ast::Trait> {
143 self.id.lookup(db.upcast()).source(db.upcast())
144 }
145
146 fn source(self, db: &dyn HirDatabase) -> Option<InFile<Self::Ast>> { 103 fn source(self, db: &dyn HirDatabase) -> Option<InFile<Self::Ast>> {
147 Some(self.id.lookup(db.upcast()).source(db.upcast())) 104 Some(self.id.lookup(db.upcast()).source(db.upcast()))
148 } 105 }
149} 106}
150impl HasSource for TypeAlias { 107impl HasSource for TypeAlias {
151 type Ast = ast::TypeAlias; 108 type Ast = ast::TypeAlias;
152 fn source_old(self, db: &dyn HirDatabase) -> InFile<ast::TypeAlias> {
153 self.id.lookup(db.upcast()).source(db.upcast())
154 }
155
156 fn source(self, db: &dyn HirDatabase) -> Option<InFile<Self::Ast>> { 109 fn source(self, db: &dyn HirDatabase) -> Option<InFile<Self::Ast>> {
157 Some(self.id.lookup(db.upcast()).source(db.upcast())) 110 Some(self.id.lookup(db.upcast()).source(db.upcast()))
158 } 111 }
159} 112}
160impl HasSource for MacroDef { 113impl HasSource for MacroDef {
161 type Ast = ast::Macro; 114 type Ast = ast::Macro;
162 fn source_old(self, db: &dyn HirDatabase) -> InFile<ast::Macro> {
163 InFile {
164 file_id: self.id.ast_id.expect("MacroDef without ast_id").file_id,
165 value: self.id.ast_id.expect("MacroDef without ast_id").to_node(db.upcast()),
166 }
167 }
168
169 fn source(self, db: &dyn HirDatabase) -> Option<InFile<Self::Ast>> { 115 fn source(self, db: &dyn HirDatabase) -> Option<InFile<Self::Ast>> {
170 let ast_id = self.id.ast_id?; 116 let ast_id = self.id.ast_id?;
171 Some(InFile { file_id: ast_id.file_id, value: ast_id.to_node(db.upcast()) }) 117 Some(InFile { file_id: ast_id.file_id, value: ast_id.to_node(db.upcast()) })
@@ -173,10 +119,6 @@ impl HasSource for MacroDef {
173} 119}
174impl HasSource for Impl { 120impl HasSource for Impl {
175 type Ast = ast::Impl; 121 type Ast = ast::Impl;
176 fn source_old(self, db: &dyn HirDatabase) -> InFile<ast::Impl> {
177 self.id.lookup(db.upcast()).source(db.upcast())
178 }
179
180 fn source(self, db: &dyn HirDatabase) -> Option<InFile<Self::Ast>> { 122 fn source(self, db: &dyn HirDatabase) -> Option<InFile<Self::Ast>> {
181 Some(self.id.lookup(db.upcast()).source(db.upcast())) 123 Some(self.id.lookup(db.upcast()).source(db.upcast()))
182 } 124 }
@@ -184,11 +126,6 @@ impl HasSource for Impl {
184 126
185impl HasSource for TypeParam { 127impl HasSource for TypeParam {
186 type Ast = Either<ast::Trait, ast::TypeParam>; 128 type Ast = Either<ast::Trait, ast::TypeParam>;
187 fn source_old(self, db: &dyn HirDatabase) -> InFile<Self::Ast> {
188 let child_source = self.id.parent.child_source(db.upcast());
189 child_source.map(|it| it[self.id.local_id].clone())
190 }
191
192 fn source(self, db: &dyn HirDatabase) -> Option<InFile<Self::Ast>> { 129 fn source(self, db: &dyn HirDatabase) -> Option<InFile<Self::Ast>> {
193 let child_source = self.id.parent.child_source(db.upcast()); 130 let child_source = self.id.parent.child_source(db.upcast());
194 Some(child_source.map(|it| it[self.id.local_id].clone())) 131 Some(child_source.map(|it| it[self.id.local_id].clone()))
@@ -197,11 +134,6 @@ impl HasSource for TypeParam {
197 134
198impl HasSource for LifetimeParam { 135impl HasSource for LifetimeParam {
199 type Ast = ast::LifetimeParam; 136 type Ast = ast::LifetimeParam;
200 fn source_old(self, db: &dyn HirDatabase) -> InFile<Self::Ast> {
201 let child_source = self.id.parent.child_source(db.upcast());
202 child_source.map(|it| it[self.id.local_id].clone())
203 }
204
205 fn source(self, db: &dyn HirDatabase) -> Option<InFile<Self::Ast>> { 137 fn source(self, db: &dyn HirDatabase) -> Option<InFile<Self::Ast>> {
206 let child_source = self.id.parent.child_source(db.upcast()); 138 let child_source = self.id.parent.child_source(db.upcast());
207 Some(child_source.map(|it| it[self.id.local_id].clone())) 139 Some(child_source.map(|it| it[self.id.local_id].clone()))