From b9cd8646cbc5d2170240dd214d4ab932d70e3b2c Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Mon, 11 Mar 2024 19:59:40 -0700 Subject: [PATCH] Fix dead_code warning on fallback SourceFile warning: struct `SourceFile` is never constructed --> src/fallback.rs:301:19 | 301 | pub(crate) struct SourceFile { | ^^^^^^^^^^ | = note: `#[warn(dead_code)]` on by default warning: methods `path` and `is_real` are never used --> src/fallback.rs:307:12 | 305 | impl SourceFile { | --------------- methods in this implementation 306 | /// Get the path to this source file as a string. 307 | pub fn path(&self) -> PathBuf { | ^^^^ ... 311 | pub fn is_real(&self) -> bool { | ^^^^^^^ --- src/fallback.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/fallback.rs b/src/fallback.rs index 16bf645..7839d4e 100644 --- a/src/fallback.rs +++ b/src/fallback.rs @@ -16,6 +16,7 @@ use core::ops::Range; use core::ops::RangeBounds; use core::ptr; use core::str::FromStr; +#[cfg(procmacro2_semver_exempt)] use std::path::PathBuf; /// Force use of proc-macro2's fallback implementation of the API for now, even @@ -297,11 +298,13 @@ impl IntoIterator for TokenStream { } } +#[cfg(procmacro2_semver_exempt)] #[derive(Clone, PartialEq, Eq)] pub(crate) struct SourceFile { path: PathBuf, } +#[cfg(procmacro2_semver_exempt)] impl SourceFile { /// Get the path to this source file as a string. pub fn path(&self) -> PathBuf { @@ -313,6 +316,7 @@ impl SourceFile { } } +#[cfg(procmacro2_semver_exempt)] impl Debug for SourceFile { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("SourceFile")