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};
77use crate :: Span ;
88use core:: fmt:: { self , Debug } ;
99
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.
1027#[ cfg( span_locations) ]
1128#[ 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+ }
1332
1433/// An object that holds a [`Group`]'s `span_open()` and `span_close()` together
1534/// 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! {
335335}
336336
337337#[ cfg( span_locations) ]
338- pub fn invalidate_current_thread_spans ( ) {
338+ pub ( crate ) fn invalidate_current_thread_spans ( ) {
339339 #[ cfg( not( fuzzing) ) ]
340340 SOURCE_MAP . with ( |sm| sm. borrow_mut ( ) . files . truncate ( 1 ) ) ;
341341}
Original file line number Diff line number Diff line change @@ -929,25 +929,8 @@ impl Debug for Literal {
929929 }
930930}
931931
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.
949932#[ cfg( span_locations) ]
950- pub fn invalidate_current_thread_spans ( ) {
933+ pub ( crate ) fn invalidate_current_thread_spans ( ) {
951934 if inside_proc_macro ( ) {
952935 panic ! (
953936 "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