Skip to content

regression: cannot find type SourceFile in crate proc_macro #142428

Closed as not planned

Description

@BoxyUwU
[INFO] [stdout] error[E0412]: cannot find type `SourceFile` in crate `proc_macro`
[INFO] [stdout]    --> src/wrapper.rs:366:26
[INFO] [stdout]     |
[INFO] [stdout] 366 |     Compiler(proc_macro::SourceFile),
[INFO] [stdout]     |                          ^^^^^^^^^^ not found in `proc_macro`
[INFO] [stdout]     |
[INFO] [stdout] help: consider importing one of these structs
[INFO] [stdout]     |
[INFO] [stdout] 1   + use crate::SourceFile;
[INFO] [stdout]     |
[INFO] [stdout] 1   + use crate::fallback::SourceFile;
[INFO] [stdout]     |
[INFO] [stdout] help: if you import `SourceFile`, refer to it directly
[INFO] [stdout]     |
[INFO] [stdout] 366 -     Compiler(proc_macro::SourceFile),
[INFO] [stdout] 366 +     Compiler(SourceFile),
[INFO] [stdout]     |

Activity

  1. added
    T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.
    C-bugCategory: This is a bug.
    on Jun 12, 2025
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Jun 12, 2025
  3. added this to the 1.88.0 milestone on Jun 12, 2025
  4. bjorn3 commented on Jun 12, 2025

    @bjorn3
    Member

    This is probably just proc-macro2 detecting that the rustc supports unstable features at all and then assumes that all unstable features it thinks exist haven't changed since it was released (or maybe in this case do already exist in the rustc version it gets compiled with).

  5. Nemo157 commented on Jun 13, 2025

    @Nemo157
    Contributor

    proc-macro2 actually compiles a probe file to decide whether to enable nightly features. So it seems there's something a little weird going on to make that pass on beta.

  6. Nemo157 commented on Jun 13, 2025

    @Nemo157
    Contributor
    "-e" "RUSTC_BOOTSTRAP=1"
    

    It seems that nightly features are enabled in that run, so this is just the lack of dtolnay/proc-macro2#497 from 1.0.95 updating the nightly APIs that proc-macro2 uses.

  7. bjorn3 commented on Jun 13, 2025

    @bjorn3
    Member

    That probe file didn't reference SourceFile even before dtolnay/proc-macro2#497.

  8. Nemo157 commented on Jun 13, 2025

    @Nemo157
    Contributor

    Yes, the probe file was incorrect in what API it used which is why 1.0.94 is broken on nightly/RUSTC_BOOTSTRAP, but it at least should always fail to compile on any stable compiler since it uses #![feature].

  9. removed
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Jun 13, 2025
  10. 0xcoinymous commented on Jul 26, 2025

    @0xcoinymous

    The solution I found is to force Cargo to update to compatible versions of proc-macro2, syn, etc.
    so first run this:

    cargo clean
    cargo update
    

    and then try rebuilding:

    anchor build
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions