@@ -62,7 +62,7 @@ pub(super) fn apply_mark(
6262 transparency : Transparency ,
6363) -> SyntaxContextId {
6464 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) ;
6666 }
6767
6868 let call_site_ctxt = db. lookup_intern_macro_call ( call_id) . call_site . ctx ;
@@ -73,7 +73,7 @@ pub(super) fn apply_mark(
7373 } ;
7474
7575 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) ;
7777 }
7878
7979 // 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(
8888 for ( call_id, transparency) in ctxt. marks ( db) {
8989 call_site_ctxt = apply_mark_internal ( db, call_site_ctxt, call_id, transparency) ;
9090 }
91- apply_mark_internal ( db, call_site_ctxt, Some ( call_id) , transparency)
91+ apply_mark_internal ( db, call_site_ctxt, call_id, transparency)
9292}
9393
9494fn apply_mark_internal (
9595 db : & dyn ExpandDatabase ,
9696 ctxt : SyntaxContextId ,
97- call_id : Option < MacroCallId > ,
97+ call_id : MacroCallId ,
9898 transparency : Transparency ,
9999) -> SyntaxContextId {
100100 use base_db:: salsa;
101101
102+ let call_id = Some ( call_id) ;
103+
102104 let syntax_context_data = db. lookup_intern_syntax_context ( ctxt) ;
103105 let mut opaque = syntax_context_data. opaque ;
104106 let mut opaque_and_semitransparent = syntax_context_data. opaque_and_semitransparent ;
@@ -148,7 +150,7 @@ pub trait SyntaxContextExt {
148150 fn parent_ctxt ( self , db : & dyn ExpandDatabase ) -> Self ;
149151 fn remove_mark ( & mut self , db : & dyn ExpandDatabase ) -> ( Option < MacroCallId > , Transparency ) ;
150152 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 ) > ;
152154}
153155
154156impl SyntaxContextExt for SyntaxContextId {
@@ -170,7 +172,7 @@ impl SyntaxContextExt for SyntaxContextId {
170172 * self = data. parent ;
171173 ( data. outer_expn , data. outer_transparency )
172174 }
173- fn marks ( self , db : & dyn ExpandDatabase ) -> Vec < ( Option < MacroCallId > , Transparency ) > {
175+ fn marks ( self , db : & dyn ExpandDatabase ) -> Vec < ( MacroCallId , Transparency ) > {
174176 let mut marks = marks_rev ( self , db) . collect :: < Vec < _ > > ( ) ;
175177 marks. reverse ( ) ;
176178 marks
@@ -181,11 +183,15 @@ impl SyntaxContextExt for SyntaxContextId {
181183pub fn marks_rev (
182184 ctxt : SyntaxContextId ,
183185 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+ } )
189195}
190196
191197pub ( crate ) fn dump_syntax_contexts ( db : & dyn ExpandDatabase ) -> String {
@@ -224,7 +230,7 @@ pub(crate) fn dump_syntax_contexts(db: &dyn ExpandDatabase) -> String {
224230 }
225231 }
226232
227- pub fn fancy_debug (
233+ fn fancy_debug (
228234 this : & SyntaxContextData ,
229235 self_id : SyntaxContextId ,
230236 db : & dyn ExpandDatabase ,
0 commit comments