Merge branch 'master' into rusty-hermit

This commit is contained in:
Stefan Lankes 2019-10-20 10:48:58 +02:00 committed by GitHub
commit b6801b7dcd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1077 changed files with 17752 additions and 10318 deletions

@ -1 +1 @@
Subproject commit 8b0561d68f12eeb1d72e07ceef464ebf6032a1bc
Subproject commit 3a9abe3f065554a7fbc59f440df2baba4a6e47ee

@ -1 +1 @@
Subproject commit 648e5b90b49af483d07caa8e413473a4517853d6
Subproject commit cbedd97b3a58023eff365a2fa74700d06115144a

View file

@ -15,7 +15,7 @@ fn main() {
println!("cargo:rerun-if-changed={}", entry.path().to_str().unwrap());
let file = fs::read_to_string(entry.path()).unwrap()
.replace("syntax::register_diagnostics!", "register_diagnostics!");
let contents = format!("(|| {{\n{}\n}})();", file);
let contents = format!("(|| {{\n{}\n}})()", file);
fs::write(&out_dir.join(&format!("error_{}.rs", idx)), &contents).unwrap();

@ -1 +1 @@
Subproject commit 07ac10277ea5ad42efbb914da5844e0ab08efbf4
Subproject commit 2adc39f27b7fd2d06b3d1d470827928766731a1d

View file

@ -143,7 +143,7 @@ def issue(
cc @{}, do you think you would have time to do the follow-up work?
If so, that would be great!
cc @{}, the PR reviewer, and @rust-lang/compiler -- nominating for prioritization.
cc @{}, the PR reviewer, and nominating for compiler team prioritization.
''').format(
relevant_pr_number, tool, status_description,

@ -1 +1 @@
Subproject commit 8dc9ba96d57c5705b99a18a380d41579e9d2d675
Subproject commit a18df16181947edd5eb593ea0f2321e0035448ee

@ -1 +1 @@
Subproject commit afb1ee1c14594aed5bb4a762b357b01f13c9de10
Subproject commit 33e3667085e4c73d4391c6168552458eb47664de

View file

@ -89,6 +89,7 @@ const WHITELIST: &[Crate<'_>] = &[
Crate("crc32fast"),
Crate("crossbeam-deque"),
Crate("crossbeam-epoch"),
Crate("crossbeam-queue"),
Crate("crossbeam-utils"),
Crate("datafrog"),
Crate("dlmalloc"),

View file

@ -0,0 +1,137 @@
//! Checks that all error codes have at least one test to prevent having error
//! codes that are silently not thrown by the compiler anymore.
use std::collections::HashMap;
use std::ffi::OsStr;
use std::path::Path;
// A few of those error codes can't be tested but all the others can and *should* be tested!
const WHITELIST: &[&str] = &[
"E0183",
"E0227",
"E0279",
"E0280",
"E0311",
"E0313",
"E0314",
"E0315",
"E0377",
"E0456",
"E0461",
"E0462",
"E0464",
"E0465",
"E0472",
"E0473",
"E0474",
"E0475",
"E0476",
"E0479",
"E0480",
"E0481",
"E0482",
"E0483",
"E0484",
"E0485",
"E0486",
"E0487",
"E0488",
"E0489",
"E0514",
"E0519",
"E0523",
"E0526",
"E0554",
"E0570",
"E0629",
"E0630",
"E0640",
"E0717",
"E0727",
"E0729",
];
fn extract_error_codes(f: &str, error_codes: &mut HashMap<String, bool>) {
let mut reached_no_explanation = false;
let mut last_error_code = None;
for line in f.lines() {
let s = line.trim();
if s.starts_with('E') && s.ends_with(": r##\"") {
if let Some(err_code) = s.splitn(2, ':').next() {
let err_code = err_code.to_owned();
last_error_code = Some(err_code.clone());
if !error_codes.contains_key(&err_code) {
error_codes.insert(err_code, false);
}
}
} else if s.starts_with("```") && s.contains("compile_fail") && s.contains('E') {
if let Some(err_code) = s.splitn(2, 'E').skip(1).next() {
if let Some(err_code) = err_code.splitn(2, ',').next() {
let nb = error_codes.entry(format!("E{}", err_code)).or_insert(false);
*nb = true;
}
}
} else if s == ";" {
reached_no_explanation = true;
} else if reached_no_explanation && s.starts_with('E') {
if let Some(err_code) = s.splitn(2, ',').next() {
let err_code = err_code.to_owned();
if !error_codes.contains_key(&err_code) { // this check should *never* fail!
error_codes.insert(err_code, false);
}
}
} else if s.starts_with("#### Note: this error code is no longer emitted by the compiler") {
if let Some(last) = last_error_code {
error_codes.get_mut(&last).map(|x| *x = true);
}
last_error_code = None;
}
}
}
fn extract_error_codes_from_tests(f: &str, error_codes: &mut HashMap<String, bool>) {
for line in f.lines() {
let s = line.trim();
if s.starts_with("error[E") || s.starts_with("warning[E") {
if let Some(err_code) = s.splitn(2, ']').next() {
if let Some(err_code) = err_code.splitn(2, '[').skip(1).next() {
let nb = error_codes.entry(err_code.to_owned()).or_insert(false);
*nb = true;
}
}
}
}
}
pub fn check(path: &Path, bad: &mut bool) {
println!("Checking which error codes lack tests...");
let mut error_codes: HashMap<String, bool> = HashMap::new();
super::walk(path,
&mut |path| super::filter_dirs(path),
&mut |entry, contents| {
let file_name = entry.file_name();
if file_name == "error_codes.rs" {
extract_error_codes(contents, &mut error_codes);
} else if entry.path().extension() == Some(OsStr::new("stderr")) {
extract_error_codes_from_tests(contents, &mut error_codes);
}
});
println!("Found {} error codes", error_codes.len());
let mut errors = Vec::new();
for (err_code, nb) in &error_codes {
if !*nb && !WHITELIST.contains(&err_code.as_str()) {
errors.push(format!("Error code {} needs to have at least one UI test!", err_code));
}
}
errors.sort();
for err in &errors {
eprintln!("{}", err);
}
println!("Found {} error codes with no tests", errors.len());
if !errors.is_empty() {
*bad = true;
}
println!("Done!");
}

View file

@ -41,6 +41,7 @@ pub mod extdeps;
pub mod ui_tests;
pub mod unit_tests;
pub mod unstable_book;
pub mod error_codes_check;
fn filter_dirs(path: &Path) -> bool {
let skip = [

View file

@ -35,6 +35,7 @@ fn main() {
deps::check_whitelist(&path, &cargo, &mut bad);
extdeps::check(&path, &mut bad);
ui_tests::check(&path, &mut bad);
error_codes_check::check(&path, &mut bad);
if bad {
eprintln!("some tidy checks failed");