forked from CreepySkeleton/proc-macro-error
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a cargo feature to automatically detect usage of a nightly compiler
- Loading branch information
1 parent
b02d79c
commit bec8429
Showing
3 changed files
with
31 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#[cfg(all(feature = "detect-nightly", not(feature = "nightly")))] | ||
pub fn main() { | ||
let rustc_version = std::process::Command::new("rustc") | ||
.arg("--version") | ||
.output() | ||
.expect("Failed to get rustc version") | ||
.stdout; | ||
|
||
let rustc_version = String::from_utf8(rustc_version).expect("Failed to parse rustc version"); | ||
if rustc_version.contains("nightly") { | ||
println!("cargo:rustc-cfg=detected_nightly"); | ||
} | ||
} | ||
|
||
#[cfg(not(feature = "detect-nightly"))] | ||
pub fn main() { | ||
// do nothing if the 'detect-nightly' feature is not enabled | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters