File tree Expand file tree Collapse file tree 3 files changed +31
-5
lines changed
Expand file tree Collapse file tree 3 files changed +31
-5
lines changed Original file line number Diff line number Diff line change @@ -32,9 +32,13 @@ trybuild = { version = "1.0.99", features = ["diff"] }
3232default = [" syn-error" ]
3333syn-error = [" dep:syn" ]
3434nightly = []
35+ detect-nightly = []
3536
3637[lints .rust ]
37- unexpected_cfgs = { level = " warn" , check-cfg = [' cfg(run_ui_tests)' ] }
38+ unexpected_cfgs = { level = " warn" , check-cfg = [
39+ ' cfg(run_ui_tests)' ,
40+ ' cfg(detected_nightly)' ,
41+ ] }
3842
3943[lints .clippy ]
4044pedantic = { level = " warn" , priority = -1 }
Original file line number Diff line number Diff line change 1+ #[ cfg( all( feature = "detect-nightly" , not( feature = "nightly" ) ) ) ]
2+ pub fn main ( ) {
3+ let rustc = std:: env:: var ( "RUSTC" ) . unwrap_or_else ( |_| "rustc" . to_string ( ) ) ;
4+
5+ let rustc_version = std:: process:: Command :: new ( rustc)
6+ . arg ( "--version" )
7+ . output ( )
8+ . expect ( "Failed to get rustc version" )
9+ . stdout ;
10+
11+ let rustc_version = String :: from_utf8 ( rustc_version) . expect ( "Failed to parse rustc version" ) ;
12+ if rustc_version. contains ( "nightly" ) {
13+ println ! ( "cargo:rustc-cfg=detected_nightly" ) ;
14+ }
15+ }
16+
17+ #[ cfg( not( feature = "detect-nightly" ) ) ]
18+ pub fn main ( ) {
19+ // do nothing if the 'detect-nightly' feature is not enabled
20+ }
Original file line number Diff line number Diff line change 270270//! [`proc-macro2::Span`]: https://docs.rs/proc-macro2/1.0.10/proc_macro2/struct.Span.html
271271//! [`ToTokens`]: https://docs.rs/quote/1.0.3/quote/trait.ToTokens.html
272272//!
273-
274- #![ cfg_attr( feature = "nightly" , feature( proc_macro_diagnostic) ) ]
273+ #![ cfg_attr(
274+ any( feature = "nightly" , detected_nightly) ,
275+ feature( proc_macro_diagnostic)
276+ ) ]
275277#![ forbid( unsafe_code) ]
276278
277279extern crate proc_macro;
@@ -294,11 +296,11 @@ mod diagnostic;
294296mod macros;
295297mod sealed;
296298
297- #[ cfg( not( feature = "nightly" ) ) ]
299+ #[ cfg( not( any ( feature = "nightly" , detected_nightly ) ) ) ]
298300#[ path = "imp/fallback.rs" ]
299301mod imp;
300302
301- #[ cfg( feature = "nightly" ) ]
303+ #[ cfg( any ( feature = "nightly" , detected_nightly ) ) ]
302304#[ path = "imp/delegate.rs" ]
303305mod imp;
304306
You can’t perform that action at this time.
0 commit comments