@@ -127,7 +127,7 @@ impl ExpnHash {
127
127
128
128
/// Returns the crate-local part of the [ExpnHash].
129
129
///
130
- /// Used for tests .
130
+ /// Used for assertions .
131
131
#[ inline]
132
132
pub fn local_hash ( self ) -> Hash64 {
133
133
self . 0 . split ( ) . 1
@@ -170,7 +170,7 @@ impl LocalExpnId {
170
170
pub const ROOT : LocalExpnId = LocalExpnId :: from_u32 ( 0 ) ;
171
171
172
172
#[ inline]
173
- pub fn from_raw ( idx : ExpnIndex ) -> LocalExpnId {
173
+ fn from_raw ( idx : ExpnIndex ) -> LocalExpnId {
174
174
LocalExpnId :: from_u32 ( idx. as_u32 ( ) )
175
175
}
176
176
@@ -201,11 +201,6 @@ impl LocalExpnId {
201
201
} )
202
202
}
203
203
204
- #[ inline]
205
- pub fn expn_hash ( self ) -> ExpnHash {
206
- HygieneData :: with ( |data| data. local_expn_hash ( self ) )
207
- }
208
-
209
204
#[ inline]
210
205
pub fn expn_data ( self ) -> ExpnData {
211
206
HygieneData :: with ( |data| data. local_expn_data ( self ) . clone ( ) )
@@ -236,26 +231,13 @@ impl LocalExpnId {
236
231
self . to_expn_id ( ) . is_descendant_of ( ancestor. to_expn_id ( ) )
237
232
}
238
233
239
- /// `expn_id.outer_expn_is_descendant_of(ctxt)` is equivalent to but faster than
240
- /// `expn_id.is_descendant_of(ctxt.outer_expn())`.
241
- #[ inline]
242
- pub fn outer_expn_is_descendant_of ( self , ctxt : SyntaxContext ) -> bool {
243
- self . to_expn_id ( ) . outer_expn_is_descendant_of ( ctxt)
244
- }
245
-
246
234
/// Returns span for the macro which originally caused this expansion to happen.
247
235
///
248
236
/// Stops backtracing at include! boundary.
249
237
#[ inline]
250
238
pub fn expansion_cause ( self ) -> Option < Span > {
251
239
self . to_expn_id ( ) . expansion_cause ( )
252
240
}
253
-
254
- #[ inline]
255
- #[ track_caller]
256
- pub fn parent ( self ) -> LocalExpnId {
257
- self . expn_data ( ) . parent . as_local ( ) . unwrap ( )
258
- }
259
241
}
260
242
261
243
impl ExpnId {
@@ -330,7 +312,7 @@ impl ExpnId {
330
312
}
331
313
332
314
#[ derive( Debug ) ]
333
- pub struct HygieneData {
315
+ pub ( crate ) struct HygieneData {
334
316
/// Each expansion should have an associated expansion data, but sometimes there's a delay
335
317
/// between creation of an expansion ID and obtaining its data (e.g. macros are collected
336
318
/// first and then resolved later), so we use an `Option` here.
@@ -381,15 +363,10 @@ impl HygieneData {
381
363
}
382
364
}
383
365
384
- pub fn with < T , F : FnOnce ( & mut HygieneData ) -> T > ( f : F ) -> T {
366
+ fn with < T , F : FnOnce ( & mut HygieneData ) -> T > ( f : F ) -> T {
385
367
with_session_globals ( |session_globals| f ( & mut session_globals. hygiene_data . borrow_mut ( ) ) )
386
368
}
387
369
388
- #[ inline]
389
- fn local_expn_hash ( & self , expn_id : LocalExpnId ) -> ExpnHash {
390
- self . local_expn_hashes [ expn_id]
391
- }
392
-
393
370
#[ inline]
394
371
fn expn_hash ( & self , expn_id : ExpnId ) -> ExpnHash {
395
372
match expn_id. as_local ( ) {
@@ -743,7 +720,7 @@ impl SyntaxContext {
743
720
}
744
721
745
722
/// Like `SyntaxContext::adjust`, but also normalizes `self` to macros 2.0.
746
- pub fn normalize_to_macros_2_0_and_adjust ( & mut self , expn_id : ExpnId ) -> Option < ExpnId > {
723
+ pub ( crate ) fn normalize_to_macros_2_0_and_adjust ( & mut self , expn_id : ExpnId ) -> Option < ExpnId > {
747
724
HygieneData :: with ( |data| {
748
725
* self = data. normalize_to_macros_2_0 ( * self ) ;
749
726
data. adjust ( self , expn_id)
@@ -776,7 +753,11 @@ impl SyntaxContext {
776
753
/// ```
777
754
/// This returns `None` if the context cannot be glob-adjusted.
778
755
/// Otherwise, it returns the scope to use when privacy checking (see `adjust` for details).
779
- pub fn glob_adjust ( & mut self , expn_id : ExpnId , glob_span : Span ) -> Option < Option < ExpnId > > {
756
+ pub ( crate ) fn glob_adjust (
757
+ & mut self ,
758
+ expn_id : ExpnId ,
759
+ glob_span : Span ,
760
+ ) -> Option < Option < ExpnId > > {
780
761
HygieneData :: with ( |data| {
781
762
let mut scope = None ;
782
763
let mut glob_ctxt = data. normalize_to_macros_2_0 ( glob_span. ctxt ( ) ) ;
@@ -800,7 +781,7 @@ impl SyntaxContext {
800
781
/// assert!(self.glob_adjust(expansion, glob_ctxt) == Some(privacy_checking_scope));
801
782
/// }
802
783
/// ```
803
- pub fn reverse_glob_adjust (
784
+ pub ( crate ) fn reverse_glob_adjust (
804
785
& mut self ,
805
786
expn_id : ExpnId ,
806
787
glob_span : Span ,
@@ -855,11 +836,11 @@ impl SyntaxContext {
855
836
}
856
837
857
838
#[ inline]
858
- pub fn outer_mark ( self ) -> ( ExpnId , Transparency ) {
839
+ fn outer_mark ( self ) -> ( ExpnId , Transparency ) {
859
840
HygieneData :: with ( |data| data. outer_mark ( self ) )
860
841
}
861
842
862
- pub fn dollar_crate_name ( self ) -> Symbol {
843
+ pub ( crate ) fn dollar_crate_name ( self ) -> Symbol {
863
844
HygieneData :: with ( |data| data. syntax_context_data [ self . 0 as usize ] . dollar_crate_name )
864
845
}
865
846
@@ -958,12 +939,12 @@ pub struct ExpnData {
958
939
/// The normal module (`mod`) in which the expanded macro was defined.
959
940
pub parent_module : Option < DefId > ,
960
941
/// Suppresses the `unsafe_code` lint for code produced by this macro.
961
- pub allow_internal_unsafe : bool ,
942
+ pub ( crate ) allow_internal_unsafe : bool ,
962
943
/// Enables the macro helper hack (`ident!(...)` -> `$crate::ident!(...)`) for this macro.
963
944
pub local_inner_macros : bool ,
964
945
/// Should debuginfo for the macro be collapsed to the outermost expansion site (in other
965
946
/// words, was the macro definition annotated with `#[collapse_debuginfo]`)?
966
- pub collapse_debuginfo : bool ,
947
+ pub ( crate ) collapse_debuginfo : bool ,
967
948
}
968
949
969
950
impl !PartialEq for ExpnData { }
0 commit comments