Merge from rustc

This commit is contained in:
Ralf Jung 2023-05-16 10:34:36 +02:00
commit ed0573fb2a
275 changed files with 7688 additions and 2669 deletions

View file

@ -30,19 +30,11 @@ error: sub-expression diverges
LL | 3 => true || diverge(),
| ^^^^^^^^^
error: sub-expression diverges
--> $DIR/diverging_sub_expression.rs:36:30
|
LL | _ => true || panic!("boo"),
| ^^^^^^^^^^^^^
|
= note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
error: sub-expression diverges
--> $DIR/diverging_sub_expression.rs:38:26
|
LL | _ => true || break,
| ^^^^^
error: aborting due to 7 previous errors
error: aborting due to 6 previous errors

View file

@ -139,18 +139,18 @@ enum FileEntry {
type Cache = HashMap<String, FileEntry>;
fn small_url_encode(s: &str) -> String {
s.replace("<", "%3C")
.replace(">", "%3E")
.replace(" ", "%20")
.replace("?", "%3F")
.replace("'", "%27")
.replace("&", "%26")
.replace(",", "%2C")
.replace(":", "%3A")
.replace(";", "%3B")
.replace("[", "%5B")
.replace("]", "%5D")
.replace("\"", "%22")
s.replace('<', "%3C")
.replace('>', "%3E")
.replace(' ', "%20")
.replace('?', "%3F")
.replace('\'', "%27")
.replace('&', "%26")
.replace(',', "%2C")
.replace(':', "%3A")
.replace(';', "%3B")
.replace('[', "%5B")
.replace(']', "%5D")
.replace('\"', "%22")
}
impl Checker {
@ -267,7 +267,6 @@ impl Checker {
FileEntry::OtherFile => return,
FileEntry::Redirect { target } => {
let t = target.clone();
drop(target);
let (target, redir_entry) = self.load_file(&t, report);
match redir_entry {
FileEntry::Missing => {
@ -391,7 +390,7 @@ impl Checker {
const ERROR_INVALID_NAME: i32 = 123;
let pretty_path =
file.strip_prefix(&self.root).unwrap_or(&file).to_str().unwrap().to_string();
file.strip_prefix(&self.root).unwrap_or(file).to_str().unwrap().to_string();
let entry =
self.cache.entry(pretty_path.clone()).or_insert_with(|| match fs::metadata(file) {
@ -470,10 +469,8 @@ fn is_exception(file: &Path, link: &str) -> bool {
// NOTE: This cannot be added to `LINKCHECK_EXCEPTIONS` because the resolved path
// calculated in `check` function is outside `build/<triple>/doc` dir.
// So the `strip_prefix` method just returns the old absolute broken path.
if file.ends_with("std/primitive.slice.html") {
if link.ends_with("primitive.slice.html") {
return true;
}
if file.ends_with("std/primitive.slice.html") && link.ends_with("primitive.slice.html") {
return true;
}
false
}
@ -545,7 +542,7 @@ fn with_attrs_in_source<F: FnMut(&str, usize, &str)>(source: &str, attr: &str, m
fn parse_ids(ids: &mut HashSet<String>, file: &str, source: &str, report: &mut Report) {
if ids.is_empty() {
with_attrs_in_source(source, " id", |fragment, i, _| {
let frag = fragment.trim_start_matches("#").to_owned();
let frag = fragment.trim_start_matches('#').to_owned();
let encoded = small_url_encode(&frag);
if !ids.insert(frag) {
report.errors += 1;

View file

@ -28,8 +28,8 @@ use rustc_middle::{
middle::exported_symbols::{
ExportedSymbol, SymbolExportInfo, SymbolExportKind, SymbolExportLevel,
},
query::LocalCrate,
ty::{query::ExternProviders, TyCtxt},
query::{ExternProviders, LocalCrate},
ty::TyCtxt,
};
use rustc_session::config::OptLevel;

View file

@ -145,6 +145,7 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[
"expect-test",
"fallible-iterator", // dependency of `thorin`
"fastrand",
"field-offset",
"fixedbitset",
"flate2",
"fluent-bundle",

View file

@ -296,6 +296,12 @@ pub fn check(path: &Path, bad: &mut bool) {
if filename.contains("ignore-tidy") {
return;
}
// Shell completions are automatically generated
if let Some(p) = file.parent() {
if p.ends_with(Path::new("src/etc/completions")) {
return;
}
}
// apfloat shouldn't be changed because of license problems
if is_in(file, "compiler", "rustc_apfloat") {
return;

View file

@ -4,13 +4,38 @@
use ignore::Walk;
use std::collections::HashMap;
use std::ffi::OsStr;
use std::fs;
use std::path::{Path, PathBuf};
const ENTRY_LIMIT: usize = 900;
// FIXME: The following limits should be reduced eventually.
const ISSUES_ENTRY_LIMIT: usize = 1920;
const ROOT_ENTRY_LIMIT: usize = 895;
const ROOT_ENTRY_LIMIT: usize = 896;
const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[
"rs", // test source files
"stderr", // expected stderr file, corresponds to a rs file
"stdout", // expected stdout file, corresponds to a rs file
"fixed", // expected source file after applying fixes
"md", // test directory descriptions
"ftl", // translation tests
];
const EXTENSION_EXCEPTION_PATHS: &[&str] = &[
"tests/ui/asm/named-asm-labels.s", // loading an external asm file to test named labels lint
"tests/ui/check-cfg/my-awesome-platform.json", // testing custom targets with cfgs
"tests/ui/commandline-argfile-badutf8.args", // passing args via a file
"tests/ui/commandline-argfile.args", // passing args via a file
"tests/ui/crate-loading/auxiliary/libfoo.rlib", // testing loading a manually created rlib
"tests/ui/include-macros/data.bin", // testing including data with the include macros
"tests/ui/include-macros/file.txt", // testing including data with the include macros
"tests/ui/macros/macro-expanded-include/file.txt", // testing including data with the include macros
"tests/ui/macros/not-utf8.bin", // testing including data with the include macros
"tests/ui/macros/syntax-extension-source-utils-files/includeme.fragment", // more include
"tests/ui/unused-crate-deps/test.mk", // why would you use make
"tests/ui/proc-macro/auxiliary/included-file.txt", // more include
];
fn check_entries(tests_path: &Path, bad: &mut bool) {
let mut directories: HashMap<PathBuf, usize> = HashMap::new();
@ -66,7 +91,14 @@ pub fn check(path: &Path, bad: &mut bool) {
let paths = [ui.as_path(), ui_fulldeps.as_path()];
crate::walk::walk_no_read(&paths, |_, _| false, &mut |entry| {
let file_path = entry.path();
if let Some(ext) = file_path.extension() {
if let Some(ext) = file_path.extension().and_then(OsStr::to_str) {
// files that are neither an expected extension or an exception should not exist
// they're probably typos or not meant to exist
if !(EXPECTED_TEST_FILE_EXTENSIONS.contains(&ext)
|| EXTENSION_EXCEPTION_PATHS.iter().any(|path| file_path.ends_with(path)))
{
tidy_error!(bad, "file {} has unexpected extension {}", file_path.display(), ext);
}
if ext == "stderr" || ext == "stdout" {
// Test output filenames have one of the formats:
// ```