Skip to content

Stabilize #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ This project solves the following language-specific concerns:

<br>

To support line changes during [whitespace detection], we depend on the
nightly [`proc_macro_span` feature]. On stable we can only detect column
changes.
To support line changes during [whitespace detection], we depend on span
information which was made available in Rust `1.88`. Before that, we relied
on a nightly [`proc_macro_span` feature] to work.

*Until this is stabilized* and you want fully functional whitespace
detection you must build and run projects using genco with a `nightly`
Expand Down
2 changes: 1 addition & 1 deletion genco-macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ keywords = ["code-generation", "template"]
categories = ["template-engine"]

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(proc_macro_span)'] }
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(proc_macro_span, has_proc_macro_span)'] }

[dependencies]
syn = { version = "2.0.38", features = ["full"] }
Expand Down
11 changes: 8 additions & 3 deletions genco-macros/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ fn main() {
nightly: false,
});

if version.nightly {
if version.nightly && version.minor < 88 {
println!("cargo:rustc-cfg=proc_macro_span");
println!("cargo:rustc-cfg=has_proc_macro_span");
} else if version.minor >= 88 {
// The relevant parts are stable since 1.88
println!("cargo:rustc-cfg=has_proc_macro_span");
}
}

struct RustcVersion {
#[allow(unused)]
minor: u32,
nightly: bool,
}
Expand All @@ -27,9 +30,11 @@ fn rustc_version() -> Option<RustcVersion> {
let version = str::from_utf8(&output.stdout).ok()?;
let nightly = version.contains("nightly") || version.contains("dev");
let mut pieces = version.split('.');
if pieces.next() != Some("rustc 1") {

if pieces.next()? != "rustc 1" {
return None;
}

let minor = pieces.next()?.parse().ok()?;
Some(RustcVersion { minor, nightly })
}
8 changes: 4 additions & 4 deletions genco-macros/src/fake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub(crate) struct LineColumn {
}

impl LineColumn {
#[cfg(proc_macro_span)]
#[cfg(has_proc_macro_span)]
pub(crate) fn start(span: Span) -> Option<Self> {
let span = span.unwrap().start();

Expand All @@ -28,7 +28,7 @@ impl LineColumn {
})
}

#[cfg(proc_macro_span)]
#[cfg(has_proc_macro_span)]
pub(crate) fn end(span: Span) -> Option<Self> {
let span = span.unwrap().end();

Expand All @@ -38,12 +38,12 @@ impl LineColumn {
})
}

#[cfg(not(proc_macro_span))]
#[cfg(not(has_proc_macro_span))]
pub(crate) fn start(_: Span) -> Option<Self> {
None
}

#[cfg(not(proc_macro_span))]
#[cfg(not(has_proc_macro_span))]
pub(crate) fn end(_: Span) -> Option<Self> {
None
}
Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
//!
//! <br>
//!
//! To support line changes during [whitespace detection], we depend on the
//! nightly [`proc_macro_span` feature]. On stable we can only detect column
//! changes.
//! To support line changes during [whitespace detection], we depend on span
//! information which was made available in Rust `1.88`. Before that, we relied
//! on a nightly [`proc_macro_span` feature] to work.
//!
//! *Until this is stabilized* and you want fully functional whitespace
//! detection you must build and run projects using genco with a `nightly`
Expand Down