@@ -650,6 +650,20 @@ impl Span {
650650 self . with_ctxt ( data. apply_mark ( SyntaxContext :: root ( ) , expn_id, transparency) )
651651 } )
652652 }
653+
654+ /// Reuses the span but adds information like the kind of the desugaring and features that are
655+ /// allowed inside this span.
656+ pub fn mark_with_reason (
657+ self ,
658+ allow_internal_unstable : Option < Lrc < [ Symbol ] > > ,
659+ reason : DesugaringKind ,
660+ edition : Edition ,
661+ ) -> Span {
662+ self . fresh_expansion ( ExpnData {
663+ allow_internal_unstable,
664+ ..ExpnData :: default ( ExpnKind :: Desugaring ( reason) , self , edition, None )
665+ } )
666+ }
653667}
654668
655669/// A subset of properties from both macro definition and macro call available through global data.
@@ -699,21 +713,47 @@ pub struct ExpnData {
699713 /// created locally - when our serialized metadata is decoded,
700714 /// foreign `ExpnId`s will have their `ExpnData` looked up
701715 /// from the crate specified by `Crate
702- pub krate : CrateNum ,
716+ krate : CrateNum ,
703717 /// The raw that this `ExpnData` had in its original crate.
704718 /// An `ExpnData` can be created before being assigned an `ExpnId`,
705719 /// so this might be `None` until `set_expn_data` is called
706720 // This is used only for serialization/deserialization purposes:
707721 // two `ExpnData`s that differ only in their `orig_id` should
708722 // be considered equivalent.
709723 #[ stable_hasher( ignore) ]
710- pub orig_id : Option < u32 > ,
724+ orig_id : Option < u32 > ,
711725}
712726
713727// This would require special handling of `orig_id` and `parent`
714728impl !PartialEq for ExpnData { }
715729
716730impl ExpnData {
731+ pub fn new (
732+ kind : ExpnKind ,
733+ parent : ExpnId ,
734+ call_site : Span ,
735+ def_site : Span ,
736+ allow_internal_unstable : Option < Lrc < [ Symbol ] > > ,
737+ allow_internal_unsafe : bool ,
738+ local_inner_macros : bool ,
739+ edition : Edition ,
740+ macro_def_id : Option < DefId > ,
741+ ) -> ExpnData {
742+ ExpnData {
743+ kind,
744+ parent,
745+ call_site,
746+ def_site,
747+ allow_internal_unstable,
748+ allow_internal_unsafe,
749+ local_inner_macros,
750+ edition,
751+ macro_def_id,
752+ krate : LOCAL_CRATE ,
753+ orig_id : None ,
754+ }
755+ }
756+
717757 /// Constructs expansion data with default properties.
718758 pub fn default (
719759 kind : ExpnKind ,
0 commit comments