Skip to content

Commit d39c6b5

Browse files
committed
Stabilize
1 parent 51b492d commit d39c6b5

5 files changed

Lines changed: 19 additions & 14 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ This project solves the following language-specific concerns:
3131

3232
<br>
3333

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

3838
*Until this is stabilized* and you want fully functional whitespace
3939
detection you must build and run projects using genco with a `nightly`

genco-macros/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ keywords = ["code-generation", "template"]
1616
categories = ["template-engine"]
1717

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

2121
[dependencies]
2222
syn = { version = "2.0.38", features = ["full"] }

genco-macros/build.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@ fn main() {
1010
nightly: false,
1111
});
1212

13-
if version.nightly {
13+
if version.nightly && version.minor < 88 {
1414
println!("cargo:rustc-cfg=proc_macro_span");
15+
println!("cargo:rustc-cfg=has_proc_macro_span");
16+
} else if version.minor >= 88 {
17+
// The relevant parts are stable since 1.88
18+
println!("cargo:rustc-cfg=has_proc_macro_span");
1519
}
1620
}
1721

1822
struct RustcVersion {
19-
#[allow(unused)]
2023
minor: u32,
2124
nightly: bool,
2225
}
@@ -27,9 +30,11 @@ fn rustc_version() -> Option<RustcVersion> {
2730
let version = str::from_utf8(&output.stdout).ok()?;
2831
let nightly = version.contains("nightly") || version.contains("dev");
2932
let mut pieces = version.split('.');
30-
if pieces.next() != Some("rustc 1") {
33+
34+
if pieces.next()? != "rustc 1" {
3135
return None;
3236
}
37+
3338
let minor = pieces.next()?.parse().ok()?;
3439
Some(RustcVersion { minor, nightly })
3540
}

genco-macros/src/fake.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub(crate) struct LineColumn {
1818
}
1919

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

@@ -28,7 +28,7 @@ impl LineColumn {
2828
})
2929
}
3030

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

@@ -38,12 +38,12 @@ impl LineColumn {
3838
})
3939
}
4040

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

46-
#[cfg(not(proc_macro_span))]
46+
#[cfg(not(has_proc_macro_span))]
4747
pub(crate) fn end(_: Span) -> Option<Self> {
4848
None
4949
}

src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
//!
2929
//! <br>
3030
//!
31-
//! To support line changes during [whitespace detection], we depend on the
32-
//! nightly [`proc_macro_span` feature]. On stable we can only detect column
33-
//! changes.
31+
//! To support line changes during [whitespace detection], we depend on span
32+
//! information which was made available in Rust `1.88`. Before that, we relied
33+
//! on a nightly [`proc_macro_span` feature] to work.
3434
//!
3535
//! *Until this is stabilized* and you want fully functional whitespace
3636
//! detection you must build and run projects using genco with a `nightly`

0 commit comments

Comments
 (0)