|
22 | 22 | // FIXME: Move this into the span crate? Not quite possible today as that depends on `MacroCallLoc`
|
23 | 23 | // which contains a bunch of unrelated things
|
24 | 24 |
|
25 |
| -use std::{convert::identity, iter}; |
| 25 | +use std::convert::identity; |
26 | 26 |
|
27 | 27 | use span::{Edition, MacroCallId, Span, SyntaxContext};
|
28 | 28 |
|
@@ -141,61 +141,3 @@ fn apply_mark_internal(
|
141 | 141 | |_| opaque_and_semitransparent,
|
142 | 142 | )
|
143 | 143 | }
|
144 |
| - |
145 |
| -pub trait SyntaxContextExt { |
146 |
| - fn normalize_to_macro_rules(self, db: &dyn ExpandDatabase) -> span::SyntaxContext; |
147 |
| - fn normalize_to_macros_2_0(self, db: &dyn ExpandDatabase) -> span::SyntaxContext; |
148 |
| - fn parent_ctxt(self, db: &dyn ExpandDatabase) -> span::SyntaxContext; |
149 |
| - fn remove_mark(&mut self, db: &dyn ExpandDatabase) |
150 |
| - -> (Option<span::MacroCallId>, Transparency); |
151 |
| - fn outer_mark(self, db: &dyn ExpandDatabase) -> (Option<span::MacroCallId>, Transparency); |
152 |
| - fn marks(self, db: &dyn ExpandDatabase) -> Vec<(span::MacroCallId, Transparency)>; |
153 |
| - fn is_opaque(self, db: &dyn ExpandDatabase) -> bool; |
154 |
| -} |
155 |
| - |
156 |
| -impl SyntaxContextExt for SyntaxContext { |
157 |
| - fn normalize_to_macro_rules(self, db: &dyn ExpandDatabase) -> span::SyntaxContext { |
158 |
| - self.opaque_and_semitransparent(db) |
159 |
| - } |
160 |
| - fn normalize_to_macros_2_0(self, db: &dyn ExpandDatabase) -> span::SyntaxContext { |
161 |
| - self.opaque(db) |
162 |
| - } |
163 |
| - fn parent_ctxt(self, db: &dyn ExpandDatabase) -> span::SyntaxContext { |
164 |
| - self.parent(db) |
165 |
| - } |
166 |
| - fn outer_mark(self, db: &dyn ExpandDatabase) -> (Option<span::MacroCallId>, Transparency) { |
167 |
| - let data = self; |
168 |
| - (data.outer_expn(db), data.outer_transparency(db)) |
169 |
| - } |
170 |
| - fn remove_mark( |
171 |
| - &mut self, |
172 |
| - db: &dyn ExpandDatabase, |
173 |
| - ) -> (Option<span::MacroCallId>, Transparency) { |
174 |
| - let data = *self; |
175 |
| - *self = data.parent(db); |
176 |
| - (data.outer_expn(db), data.outer_transparency(db)) |
177 |
| - } |
178 |
| - fn marks(self, db: &dyn ExpandDatabase) -> Vec<(span::MacroCallId, Transparency)> { |
179 |
| - let mut marks = marks_rev(self, db).collect::<Vec<_>>(); |
180 |
| - marks.reverse(); |
181 |
| - marks |
182 |
| - } |
183 |
| - fn is_opaque(self, db: &dyn ExpandDatabase) -> bool { |
184 |
| - !self.is_root() && self.outer_transparency(db).is_opaque() |
185 |
| - } |
186 |
| -} |
187 |
| - |
188 |
| -// FIXME: Make this a SyntaxContextExt method once we have RPIT |
189 |
| -pub fn marks_rev( |
190 |
| - ctxt: SyntaxContext, |
191 |
| - db: &dyn ExpandDatabase, |
192 |
| -) -> impl Iterator<Item = (span::MacroCallId, Transparency)> + '_ { |
193 |
| - iter::successors(Some(ctxt), move |&mark| Some(mark.parent_ctxt(db))) |
194 |
| - .take_while(|&it| !it.is_root()) |
195 |
| - .map(|ctx| { |
196 |
| - let mark = ctx.outer_mark(db); |
197 |
| - // We stop before taking the root expansion, as such we cannot encounter a `None` outer |
198 |
| - // expansion, as only the ROOT has it. |
199 |
| - (mark.0.unwrap(), mark.1) |
200 |
| - }) |
201 |
| -} |
0 commit comments