Skip to content

Commit

Permalink
Move invalidate_current_thread_spans to proc_macro2::extra
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Jan 21, 2024
1 parent 58861e6 commit 64778fc
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 4 additions & 0 deletions src/extra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ use crate::marker::{ProcMacroAutoTraits, MARKER};
use crate::Span;
use core::fmt::{self, Debug};

#[cfg(span_locations)]
#[cfg_attr(doc_cfg, doc(cfg(feature = "span-locations")))]
pub use crate::imp::invalidate_current_thread_spans;

/// An object that holds a [`Group`]'s `span_open()` and `span_close()` together
/// in a more compact representation than holding those 2 spans individually.
///
Expand Down
4 changes: 0 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,6 @@ use std::error::Error;
#[cfg(procmacro2_semver_exempt)]
use std::path::PathBuf;

#[cfg(span_locations)]
#[cfg_attr(doc_cfg, doc(cfg(feature = "span-locations")))]
pub use crate::imp::invalidate_current_thread_spans;

#[cfg(span_locations)]
#[cfg_attr(doc_cfg, doc(cfg(feature = "span-locations")))]
pub use crate::location::LineColumn;
Expand Down
2 changes: 1 addition & 1 deletion src/wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@ impl Debug for Literal {
pub fn invalidate_current_thread_spans() {
if inside_proc_macro() {
panic!(
"proc_macro2::invalidate_current_thread_spans is not available in procedural macros"
"proc_macro2::extra::invalidate_current_thread_spans is not available in procedural macros"
);
} else {
crate::fallback::invalidate_current_thread_spans();
Expand Down
4 changes: 2 additions & 2 deletions tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ fn test_invalidate_current_thread_spans() {
let actual = format!("{:#?}", create_span());
assert_eq!(actual, "bytes(3..4)");

proc_macro2::invalidate_current_thread_spans();
proc_macro2::extra::invalidate_current_thread_spans();

let actual = format!("{:#?}", create_span());
// Test that span offsets have been reset after the call
Expand All @@ -789,7 +789,7 @@ fn test_invalidate_current_thread_spans() {
fn test_use_span_after_invalidation() {
let span = create_span();

proc_macro2::invalidate_current_thread_spans();
proc_macro2::extra::invalidate_current_thread_spans();

span.source_text();
}

0 comments on commit 64778fc

Please sign in to comment.