Move handling of internal lints to `build.rs`

This commit is contained in:
Alex Crichton 2019-09-09 09:31:42 -07:00
parent f8b19f2b78
commit 22699d3139
3 changed files with 9 additions and 15 deletions

View File

@ -101,13 +101,6 @@ fn main() {
cmd.arg(format!("-Cdebuginfo={}", debuginfo_level));
}
if env::var_os("RUSTC_EXTERNAL_TOOL").is_none() {
if use_internal_lints(crate_name) {
cmd.arg("-Zunstable-options");
cmd.arg("-Wrustc::internal");
}
}
if let Some(target) = target {
// The stage0 compiler has a special sysroot distinct from what we
// actually downloaded, so we just always pass the `--sysroot` option,
@ -261,14 +254,6 @@ fn main() {
std::process::exit(code);
}
// Rustc crates for which internal lints are in effect.
fn use_internal_lints(crate_name: Option<&str>) -> bool {
crate_name.map_or(false, |crate_name| {
crate_name.starts_with("rustc") || crate_name.starts_with("syntax") ||
["arena", "fmt_macros"].contains(&crate_name)
})
}
#[cfg(unix)]
fn exec_cmd(cmd: &mut Command) -> io::Result<i32> {
use std::os::unix::process::CommandExt;

View File

@ -1067,6 +1067,14 @@ impl<'a> Builder<'a> {
}
}
match mode {
Mode::Rustc | Mode::Codegen => {
rustflags.arg("-Zunstable-options");
rustflags.arg("-Wrustc::internal");
}
_ => {}
}
// Throughout the build Cargo can execute a number of build scripts
// compiling C/C++ code and we need to pass compilers, archivers, flags, etc
// obtained previously to those build scripts.

View File

@ -15,6 +15,7 @@ Core encoding and decoding interfaces.
#![feature(nll)]
#![feature(associated_type_bounds)]
#![cfg_attr(test, feature(test))]
#![allow(rustc::internal)]
pub use self::serialize::{Decoder, Encoder, Decodable, Encodable};