@@ -16,7 +16,7 @@ use rustc_parse::{self, nt_to_tokenstream, parser, MACRO_ARGUMENTS};
16
16
use rustc_session:: { parse:: ParseSess , Limit , Session } ;
17
17
use rustc_span:: def_id:: { CrateNum , DefId } ;
18
18
use rustc_span:: edition:: Edition ;
19
- use rustc_span:: hygiene:: { AstPass , ExpnData , ExpnId , ExpnKind } ;
19
+ use rustc_span:: hygiene:: { AstPass , ExpnData , ExpnKind , LocalExpnId } ;
20
20
use rustc_span:: source_map:: SourceMap ;
21
21
use rustc_span:: symbol:: { kw, sym, Ident , Symbol } ;
22
22
use rustc_span:: { FileName , MultiSpan , Span , DUMMY_SP } ;
@@ -813,15 +813,15 @@ impl SyntaxExtension {
813
813
814
814
pub fn expn_data (
815
815
& self ,
816
- parent : ExpnId ,
816
+ parent : LocalExpnId ,
817
817
call_site : Span ,
818
818
descr : Symbol ,
819
819
macro_def_id : Option < DefId > ,
820
820
parent_module : Option < DefId > ,
821
821
) -> ExpnData {
822
822
ExpnData :: new (
823
823
ExpnKind :: Macro ( self . macro_kind ( ) , descr) ,
824
- parent,
824
+ parent. to_expn_id ( ) ,
825
825
call_site,
826
826
self . span ,
827
827
self . allow_internal_unstable . clone ( ) ,
@@ -843,7 +843,11 @@ pub trait ResolverExpand {
843
843
fn next_node_id ( & mut self ) -> NodeId ;
844
844
845
845
fn resolve_dollar_crates ( & mut self ) ;
846
- fn visit_ast_fragment_with_placeholders ( & mut self , expn_id : ExpnId , fragment : & AstFragment ) ;
846
+ fn visit_ast_fragment_with_placeholders (
847
+ & mut self ,
848
+ expn_id : LocalExpnId ,
849
+ fragment : & AstFragment ,
850
+ ) ;
847
851
fn register_builtin_macro ( & mut self , name : Symbol , ext : SyntaxExtensionKind ) ;
848
852
849
853
fn expansion_for_ast_pass (
@@ -852,37 +856,41 @@ pub trait ResolverExpand {
852
856
pass : AstPass ,
853
857
features : & [ Symbol ] ,
854
858
parent_module_id : Option < NodeId > ,
855
- ) -> ExpnId ;
859
+ ) -> LocalExpnId ;
856
860
857
861
fn resolve_imports ( & mut self ) ;
858
862
859
863
fn resolve_macro_invocation (
860
864
& mut self ,
861
865
invoc : & Invocation ,
862
- eager_expansion_root : ExpnId ,
866
+ eager_expansion_root : LocalExpnId ,
863
867
force : bool ,
864
868
) -> Result < Lrc < SyntaxExtension > , Indeterminate > ;
865
869
866
870
fn check_unused_macros ( & mut self ) ;
867
871
868
872
/// Some parent node that is close enough to the given macro call.
869
- fn lint_node_id ( & self , expn_id : ExpnId ) -> NodeId ;
873
+ fn lint_node_id ( & self , expn_id : LocalExpnId ) -> NodeId ;
870
874
871
875
// Resolver interfaces for specific built-in macros.
872
876
/// Does `#[derive(...)]` attribute with the given `ExpnId` have built-in `Copy` inside it?
873
- fn has_derive_copy ( & self , expn_id : ExpnId ) -> bool ;
877
+ fn has_derive_copy ( & self , expn_id : LocalExpnId ) -> bool ;
874
878
/// Resolve paths inside the `#[derive(...)]` attribute with the given `ExpnId`.
875
879
fn resolve_derives (
876
880
& mut self ,
877
- expn_id : ExpnId ,
881
+ expn_id : LocalExpnId ,
878
882
force : bool ,
879
883
derive_paths : & dyn Fn ( ) -> DeriveResolutions ,
880
884
) -> Result < ( ) , Indeterminate > ;
881
885
/// Take resolutions for paths inside the `#[derive(...)]` attribute with the given `ExpnId`
882
886
/// back from resolver.
883
- fn take_derive_resolutions ( & mut self , expn_id : ExpnId ) -> Option < DeriveResolutions > ;
887
+ fn take_derive_resolutions ( & mut self , expn_id : LocalExpnId ) -> Option < DeriveResolutions > ;
884
888
/// Path resolution logic for `#[cfg_accessible(path)]`.
885
- fn cfg_accessible ( & mut self , expn_id : ExpnId , path : & ast:: Path ) -> Result < bool , Indeterminate > ;
889
+ fn cfg_accessible (
890
+ & mut self ,
891
+ expn_id : LocalExpnId ,
892
+ path : & ast:: Path ,
893
+ ) -> Result < bool , Indeterminate > ;
886
894
887
895
/// Decodes the proc-macro quoted span in the specified crate, with the specified id.
888
896
/// No caching is performed.
@@ -913,7 +921,7 @@ impl ModuleData {
913
921
914
922
#[ derive( Clone ) ]
915
923
pub struct ExpansionData {
916
- pub id : ExpnId ,
924
+ pub id : LocalExpnId ,
917
925
pub depth : usize ,
918
926
pub module : Rc < ModuleData > ,
919
927
pub dir_ownership : DirOwnership ,
@@ -958,7 +966,7 @@ impl<'a> ExtCtxt<'a> {
958
966
extern_mod_loaded,
959
967
root_path : PathBuf :: new ( ) ,
960
968
current_expansion : ExpansionData {
961
- id : ExpnId :: root ( ) ,
969
+ id : LocalExpnId :: ROOT ,
962
970
depth : 0 ,
963
971
module : Default :: default ( ) ,
964
972
dir_ownership : DirOwnership :: Owned { relative : None } ,
@@ -995,19 +1003,19 @@ impl<'a> ExtCtxt<'a> {
995
1003
/// Equivalent of `Span::def_site` from the proc macro API,
996
1004
/// except that the location is taken from the span passed as an argument.
997
1005
pub fn with_def_site_ctxt ( & self , span : Span ) -> Span {
998
- span. with_def_site_ctxt ( self . current_expansion . id )
1006
+ span. with_def_site_ctxt ( self . current_expansion . id . to_expn_id ( ) )
999
1007
}
1000
1008
1001
1009
/// Equivalent of `Span::call_site` from the proc macro API,
1002
1010
/// except that the location is taken from the span passed as an argument.
1003
1011
pub fn with_call_site_ctxt ( & self , span : Span ) -> Span {
1004
- span. with_call_site_ctxt ( self . current_expansion . id )
1012
+ span. with_call_site_ctxt ( self . current_expansion . id . to_expn_id ( ) )
1005
1013
}
1006
1014
1007
1015
/// Equivalent of `Span::mixed_site` from the proc macro API,
1008
1016
/// except that the location is taken from the span passed as an argument.
1009
1017
pub fn with_mixed_site_ctxt ( & self , span : Span ) -> Span {
1010
- span. with_mixed_site_ctxt ( self . current_expansion . id )
1018
+ span. with_mixed_site_ctxt ( self . current_expansion . id . to_expn_id ( ) )
1011
1019
}
1012
1020
1013
1021
/// Returns span for the macro which originally caused the current expansion to happen.
0 commit comments