Skip to content

Commit

Permalink
Fix dead_code warning on fallback SourceFile
Browse files Browse the repository at this point in the history
    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 {
        |            ^^^^^^^
  • Loading branch information
dtolnay committed Mar 12, 2024
1 parent e94f432 commit b9cd864
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/fallback.rs
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -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")
Expand Down

0 comments on commit b9cd864

Please sign in to comment.