File tree Expand file tree Collapse file tree 3 files changed +22
-20
lines changed Expand file tree Collapse file tree 3 files changed +22
-20
lines changed Original file line number Diff line number Diff line change @@ -7,9 +7,28 @@ use crate::marker::{ProcMacroAutoTraits, MARKER};
7
7
use crate :: Span ;
8
8
use core:: fmt:: { self , Debug } ;
9
9
10
+ /// Invalidate any `proc_macro2::Span` that exist on the current thread.
11
+ ///
12
+ /// The implementation of `Span` uses thread-local data structures and this
13
+ /// function clears them. Calling any method on a `Span` on the current thread
14
+ /// created prior to the invalidation will return incorrect values or crash.
15
+ ///
16
+ /// This function is useful for programs that process more than 2<sup>32</sup>
17
+ /// bytes of Rust source code on the same thread. Just like rustc, proc-macro2
18
+ /// uses 32-bit source locations, and these wrap around when the total source
19
+ /// code processed by the same thread exceeds 2<sup>32</sup> bytes (4
20
+ /// gigabytes). After a wraparound, `Span` methods such as `source_text()` can
21
+ /// return wrong data.
22
+ ///
23
+ /// # Panics
24
+ ///
25
+ /// This function is not applicable to and will panic if called from a
26
+ /// procedural macro.
10
27
#[ cfg( span_locations) ]
11
28
#[ cfg_attr( doc_cfg, doc( cfg( feature = "span-locations" ) ) ) ]
12
- pub use crate :: imp:: invalidate_current_thread_spans;
29
+ pub fn invalidate_current_thread_spans ( ) {
30
+ crate :: imp:: invalidate_current_thread_spans ( ) ;
31
+ }
13
32
14
33
/// An object that holds a [`Group`]'s `span_open()` and `span_close()` together
15
34
/// in a more compact representation than holding those 2 spans individually.
Original file line number Diff line number Diff line change @@ -335,7 +335,7 @@ thread_local! {
335
335
}
336
336
337
337
#[ cfg( span_locations) ]
338
- pub fn invalidate_current_thread_spans ( ) {
338
+ pub ( crate ) fn invalidate_current_thread_spans ( ) {
339
339
#[ cfg( not( fuzzing) ) ]
340
340
SOURCE_MAP . with ( |sm| sm. borrow_mut ( ) . files . truncate ( 1 ) ) ;
341
341
}
Original file line number Diff line number Diff line change @@ -929,25 +929,8 @@ impl Debug for Literal {
929
929
}
930
930
}
931
931
932
- /// Invalidate any `proc_macro2::Span` that exist on the current thread.
933
- ///
934
- /// The implementation of `Span` uses thread-local data structures and this
935
- /// function clears them. Calling any method on a `Span` on the current thread
936
- /// created prior to the invalidation will return incorrect values or crash.
937
- ///
938
- /// This function is useful for programs that process more than 2<sup>32</sup>
939
- /// bytes of Rust source code on the same thread. Just like rustc, proc-macro2
940
- /// uses 32-bit source locations, and these wrap around when the total source
941
- /// code processed by the same thread exceeds 2<sup>32</sup> bytes (4
942
- /// gigabytes). After a wraparound, `Span` methods such as `source_text()` can
943
- /// return wrong data.
944
- ///
945
- /// # Panics
946
- ///
947
- /// This function is not applicable to and will panic if called from a
948
- /// procedural macro.
949
932
#[ cfg( span_locations) ]
950
- pub fn invalidate_current_thread_spans ( ) {
933
+ pub ( crate ) fn invalidate_current_thread_spans ( ) {
951
934
if inside_proc_macro ( ) {
952
935
panic ! (
953
936
"proc_macro2::extra::invalidate_current_thread_spans is not available in procedural macros"
You can’t perform that action at this time.
0 commit comments