Skip to content

Conversation

@VictorArcium
Copy link

@VictorArcium VictorArcium commented Jul 27, 2025

A lot of proc_macro2::Span methods have been stabilized in Rust 1.88: https://doc.rust-lang.org/stable/proc_macro/struct.Span.html#method.line.

This PR makes .start() and .end() work using these new methods.

@VictorArcium VictorArcium reopened this Jul 27, 2025
@esolskjaer
Copy link

Hi @dtolnay, I wanna use this too, so would be awesome to get this merged! Do you have an ETA on when/if this will land?

println!("cargo:rustc-cfg=proc_macro_span");
}

if proc_macro_span_location {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if proc_macro_span_location {
if proc_macro_span || rustc >= 88 {

Copy link
Owner

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This implementation is going to cause build failures for projects that use allow-features=.

$ RUSTFLAGS=-Zallow-features= cargo +nightly-2025-04-26 check --features=span-locations

error[E0658]: use of unstable library feature `proc_macro_span`
   --> src/wrapper.rs:436:25
    |
436 |                 line: s.line(),
    |                         ^^^^
    |
    = note: see issue #54725 <https://github.com/rust-lang/rust/issues/54725> for more information
    = help: add `#![feature(proc_macro_span)]` to the crate attributes to enable
    = note: this compiler was built on 2025-04-25; consider upgrading it if it is out of date

I put up a safer alternative in #517. Thanks anyway for the PR!

@dtolnay dtolnay closed this Aug 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants