File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
3939detection you must build and run projects using genco with a ` nightly `
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ keywords = ["code-generation", "template"]
1616categories = [" 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 ]
2222syn = { version = " 2.0.38" , features = [" full" ] }
Original file line number Diff line number Diff 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
1822struct 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}
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ pub(crate) struct LineColumn {
1818}
1919
2020impl 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 }
Original file line number Diff line number Diff line change 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`
You can’t perform that action at this time.
0 commit comments