@@ -62,7 +62,7 @@ pub(super) fn apply_mark(
62
62
transparency : Transparency ,
63
63
) -> SyntaxContextId {
64
64
if transparency == Transparency :: Opaque {
65
- return apply_mark_internal ( db, ctxt, Some ( call_id) , transparency) ;
65
+ return apply_mark_internal ( db, ctxt, call_id, transparency) ;
66
66
}
67
67
68
68
let call_site_ctxt = db. lookup_intern_macro_call ( call_id) . call_site . ctx ;
@@ -73,7 +73,7 @@ pub(super) fn apply_mark(
73
73
} ;
74
74
75
75
if call_site_ctxt. is_root ( ) {
76
- return apply_mark_internal ( db, ctxt, Some ( call_id) , transparency) ;
76
+ return apply_mark_internal ( db, ctxt, call_id, transparency) ;
77
77
}
78
78
79
79
// Otherwise, `expn_id` is a macros 1.0 definition and the call site is in a
@@ -88,17 +88,19 @@ pub(super) fn apply_mark(
88
88
for ( call_id, transparency) in ctxt. marks ( db) {
89
89
call_site_ctxt = apply_mark_internal ( db, call_site_ctxt, call_id, transparency) ;
90
90
}
91
- apply_mark_internal ( db, call_site_ctxt, Some ( call_id) , transparency)
91
+ apply_mark_internal ( db, call_site_ctxt, call_id, transparency)
92
92
}
93
93
94
94
fn apply_mark_internal (
95
95
db : & dyn ExpandDatabase ,
96
96
ctxt : SyntaxContextId ,
97
- call_id : Option < MacroCallId > ,
97
+ call_id : MacroCallId ,
98
98
transparency : Transparency ,
99
99
) -> SyntaxContextId {
100
100
use base_db:: salsa;
101
101
102
+ let call_id = Some ( call_id) ;
103
+
102
104
let syntax_context_data = db. lookup_intern_syntax_context ( ctxt) ;
103
105
let mut opaque = syntax_context_data. opaque ;
104
106
let mut opaque_and_semitransparent = syntax_context_data. opaque_and_semitransparent ;
@@ -148,7 +150,7 @@ pub trait SyntaxContextExt {
148
150
fn parent_ctxt ( self , db : & dyn ExpandDatabase ) -> Self ;
149
151
fn remove_mark ( & mut self , db : & dyn ExpandDatabase ) -> ( Option < MacroCallId > , Transparency ) ;
150
152
fn outer_mark ( self , db : & dyn ExpandDatabase ) -> ( Option < MacroCallId > , Transparency ) ;
151
- fn marks ( self , db : & dyn ExpandDatabase ) -> Vec < ( Option < MacroCallId > , Transparency ) > ;
153
+ fn marks ( self , db : & dyn ExpandDatabase ) -> Vec < ( MacroCallId , Transparency ) > ;
152
154
}
153
155
154
156
impl SyntaxContextExt for SyntaxContextId {
@@ -170,7 +172,7 @@ impl SyntaxContextExt for SyntaxContextId {
170
172
* self = data. parent ;
171
173
( data. outer_expn , data. outer_transparency )
172
174
}
173
- fn marks ( self , db : & dyn ExpandDatabase ) -> Vec < ( Option < MacroCallId > , Transparency ) > {
175
+ fn marks ( self , db : & dyn ExpandDatabase ) -> Vec < ( MacroCallId , Transparency ) > {
174
176
let mut marks = marks_rev ( self , db) . collect :: < Vec < _ > > ( ) ;
175
177
marks. reverse ( ) ;
176
178
marks
@@ -181,11 +183,15 @@ impl SyntaxContextExt for SyntaxContextId {
181
183
pub fn marks_rev (
182
184
ctxt : SyntaxContextId ,
183
185
db : & dyn ExpandDatabase ,
184
- ) -> impl Iterator < Item = ( Option < MacroCallId > , Transparency ) > + ' _ {
185
- iter:: successors ( Some ( ctxt) , move |& mark| {
186
- Some ( mark. parent_ctxt ( db) ) . filter ( |& it| it != SyntaxContextId :: ROOT )
187
- } )
188
- . map ( |ctx| ctx. outer_mark ( db) )
186
+ ) -> impl Iterator < Item = ( MacroCallId , Transparency ) > + ' _ {
187
+ iter:: successors ( Some ( ctxt) , move |& mark| Some ( mark. parent_ctxt ( db) ) )
188
+ . take_while ( |& it| !it. is_root ( ) )
189
+ . map ( |ctx| {
190
+ let mark = ctx. outer_mark ( db) ;
191
+ // We stop before taking the root expansion, as such we cannot encounter a `None` outer
192
+ // expansion, as only the ROOT has it.
193
+ ( mark. 0 . unwrap ( ) , mark. 1 )
194
+ } )
189
195
}
190
196
191
197
pub ( crate ) fn dump_syntax_contexts ( db : & dyn ExpandDatabase ) -> String {
@@ -224,7 +230,7 @@ pub(crate) fn dump_syntax_contexts(db: &dyn ExpandDatabase) -> String {
224
230
}
225
231
}
226
232
227
- pub fn fancy_debug (
233
+ fn fancy_debug (
228
234
this : & SyntaxContextData ,
229
235
self_id : SyntaxContextId ,
230
236
db : & dyn ExpandDatabase ,
0 commit comments