use rustc_version::{version_meta, Channel};
use build_info::{CompilerChannel, CompilerVersion, Version};
pub fn get_info() -> CompilerVersion {
let rustc_version = version_meta().unwrap();
let version = Version::parse(&rustc_version.semver.to_string()).unwrap();
let channel = match rustc_version.channel {
Channel::Stable => CompilerChannel::Stable,
Channel::Beta => CompilerChannel::Beta,
Channel::Nightly => CompilerChannel::Nightly,
Channel::Dev => CompilerChannel::Dev,
};
CompilerVersion {
version,
commit_hash: rustc_version.commit_hash,
commit_date: rustc_version.commit_date,
channel,
host_triple: rustc_version.host,
target_triple: std::env::var("TARGET").unwrap_or_else(|_| "UNKNOWN".to_string()),
}
}