Merge pull request #3018 from rust-lang-nursery/beta

We are riding the trains to stable, there's no point in trying to check the rustc version
This commit is contained in:
Oliver Schneider 2018-08-27 11:08:58 +02:00 committed by GitHub
commit 89012722ba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 0 additions and 98 deletions

View file

@ -59,9 +59,5 @@ derive-new = "0.5"
# for more information. # for more information.
rustc-workspace-hack = "1.0.0" rustc-workspace-hack = "1.0.0"
[build-dependencies]
rustc_version = "0.2.2"
ansi_term = "0.11"
[features] [features]
debugging = [] debugging = []

View file

@ -13,98 +13,11 @@
//! This build script was originally taken from the Rocket web framework: //! This build script was originally taken from the Rocket web framework:
//! https://github.com/SergioBenitez/Rocket //! https://github.com/SergioBenitez/Rocket
use ansi_term::Colour::Red;
use rustc_version::{version_meta, version_meta_for, Channel, Version, VersionMeta};
use std::env; use std::env;
fn main() { fn main() {
check_rustc_version();
// Forward the profile to the main compilation // Forward the profile to the main compilation
println!("cargo:rustc-env=PROFILE={}", env::var("PROFILE").unwrap()); println!("cargo:rustc-env=PROFILE={}", env::var("PROFILE").unwrap());
// Don't rebuild even if nothing changed // Don't rebuild even if nothing changed
println!("cargo:rerun-if-changed=build.rs"); println!("cargo:rerun-if-changed=build.rs");
} }
fn check_rustc_version() {
let string = include_str!("min_version.txt");
let min_version_meta = version_meta_for(string).expect("Could not parse version string in min_version.txt");
let current_version_meta = version_meta().expect("Could not retrieve current rustc version information from ENV");
let min_version = min_version_meta.clone().semver;
let min_date_str = min_version_meta
.clone()
.commit_date
.expect("min_version.txt does not contain a rustc commit date");
// Dev channel (rustc built from git) does not have any date or commit information in rustc -vV
// `current_version_meta.commit_date` would crash, so we return early here.
if current_version_meta.channel == Channel::Dev {
return;
}
let current_version = current_version_meta.clone().semver;
let current_date_str = current_version_meta
.clone()
.commit_date
.expect("current rustc version information does not contain a rustc commit date");
let print_version_err = |version: &Version, date: &str| {
eprintln!(
"> {} {}. {} {}.\n",
"Installed rustc version is:",
format!("{} ({})", version, date),
"Minimum required rustc version:",
format!("{} ({})", min_version, min_date_str)
);
};
if !correct_channel(&current_version_meta) {
eprintln!(
"\n{} {}",
Red.bold().paint("error:"),
"Clippy requires a nightly version of Rust."
);
print_version_err(&current_version, &*current_date_str);
eprintln!(
"{}{}{}",
"See the README (", "https://github.com/rust-lang-nursery/rust-clippy#usage", ") for more information."
);
panic!("Aborting compilation due to incompatible compiler.")
}
let current_date = str_to_ymd(&current_date_str).unwrap();
let min_date = str_to_ymd(&min_date_str).unwrap();
if current_date < min_date {
eprintln!(
"\n{} {}",
Red.bold().paint("error:"),
"Clippy does not support this version of rustc nightly."
);
eprintln!(
"> {}{}{}",
"Use `", "rustup update", "` or your preferred method to update Rust."
);
print_version_err(&current_version, &*current_date_str);
panic!("Aborting compilation due to incompatible compiler.")
}
}
fn correct_channel(version_meta: &VersionMeta) -> bool {
match version_meta.channel {
Channel::Stable | Channel::Beta => false,
Channel::Nightly | Channel::Dev => true,
}
}
/// Convert a string of %Y-%m-%d to a single u32 maintaining ordering.
fn str_to_ymd(ymd: &str) -> Option<u32> {
let ymd: Vec<u32> = ymd.split("-").filter_map(|s| s.parse::<u32>().ok()).collect();
if ymd.len() != 3 {
return None;
}
let (y, m, d) = (ymd[0], ymd[1], ymd[2]);
Some((y << 9) | (m << 5) | d)
}

View file

@ -1,7 +0,0 @@
rustc 1.28.0-nightly (e3bf634e0 2018-06-28)
binary: rustc
commit-hash: e3bf634e060bc2f8665878288bcea02008ca346e
commit-date: 2018-06-28
host: x86_64-unknown-linux-gnu
release: 1.28.0-nightly
LLVM version: 6.0