Skip to content

Commit 7e7bb0f

Browse files
committed
Improve documentation of invalidate_current_thread_spans
1 parent 64778fc commit 7e7bb0f

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@
101101
clippy::let_underscore_untyped,
102102
clippy::manual_assert,
103103
clippy::manual_range_contains,
104-
clippy::missing_panics_doc,
105104
clippy::missing_safety_doc,
106105
clippy::must_use_candidate,
107106
clippy::needless_doctest_main,

src/wrapper.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -929,23 +929,23 @@ impl Debug for Literal {
929929
}
930930
}
931931

932-
/// Invalidates any `proc_macro2::Span` on the current thread
932+
/// Invalidate any `proc_macro2::Span` that exist on the current thread.
933933
///
934-
/// The implementation of the `proc_macro2::Span` type relies on thread-local
935-
/// memory and this function clears it. Calling any method on a
936-
/// `proc_macro2::Span` on the current thread and that was created before this
937-
/// function was called will either lead to incorrect results or abort your
938-
/// program.
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.
939937
///
940-
/// This function is useful for programs that process more than 2^32 bytes of
941-
/// text on a single thread. The internal representation of `proc_macro2::Span`
942-
/// uses 32-bit integers to represent offsets and those will overflow when
943-
/// processing more than 2^32 bytes. This function resets all offsets and
944-
/// thereby also invalidates any previously created `proc_macro2::Span`.
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.
945944
///
946-
/// This function requires the `span-locations` feature to be enabled. This
947-
/// function is not applicable to and will panic if called from a procedural
948-
/// macro.
945+
/// # Panics
946+
///
947+
/// This function is not applicable to and will panic if called from a
948+
/// procedural macro.
949949
#[cfg(span_locations)]
950950
pub fn invalidate_current_thread_spans() {
951951
if inside_proc_macro() {

0 commit comments

Comments
 (0)