summaryrefslogtreecommitdiffstats
path: root/src/tools/tidy
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:44 +0000
commitc23a457e72abe608715ac76f076f47dc42af07a5 (patch)
tree2772049aaf84b5c9d0ed12ec8d86812f7a7904b6 /src/tools/tidy
parentReleasing progress-linux version 1.73.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-c23a457e72abe608715ac76f076f47dc42af07a5.tar.xz
rustc-c23a457e72abe608715ac76f076f47dc42af07a5.zip
Merging upstream version 1.74.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools/tidy')
-rw-r--r--src/tools/tidy/src/deps.rs10
-rw-r--r--src/tools/tidy/src/error_codes.rs7
-rw-r--r--src/tools/tidy/src/lib.rs2
-rw-r--r--src/tools/tidy/src/main.rs2
-rw-r--r--src/tools/tidy/src/pal.rs1
-rw-r--r--src/tools/tidy/src/primitive_docs.rs17
-rw-r--r--src/tools/tidy/src/rustdoc_css_themes.rs99
-rw-r--r--src/tools/tidy/src/ui_tests.rs4
8 files changed, 116 insertions, 26 deletions
diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs
index 410852b6a..7d3ef4197 100644
--- a/src/tools/tidy/src/deps.rs
+++ b/src/tools/tidy/src/deps.rs
@@ -18,6 +18,7 @@ const LICENSES: &[&str] = &[
"Apache-2.0/MIT",
"ISC",
"MIT / Apache-2.0",
+ "MIT OR Apache-2.0 OR LGPL-2.1-or-later", // r-efi, r-efi-alloc
"MIT OR Apache-2.0 OR Zlib", // tinyvec_macros
"MIT OR Apache-2.0",
"MIT OR Zlib OR Apache-2.0", // miniz_oxide
@@ -57,14 +58,14 @@ const EXCEPTIONS_CARGO: &[(&str, &str)] = &[
// tidy-alphabetical-start
("bitmaps", "MPL-2.0+"),
("bytesize", "Apache-2.0"),
+ ("byteyarn", "Apache-2.0"),
("ciborium", "Apache-2.0"),
("ciborium-io", "Apache-2.0"),
("ciborium-ll", "Apache-2.0"),
("dunce", "CC0-1.0 OR MIT-0 OR Apache-2.0"),
+ ("encoding_rs", "(Apache-2.0 OR MIT) AND BSD-3-Clause"),
("fiat-crypto", "MIT OR Apache-2.0 OR BSD-1-Clause"),
("im-rc", "MPL-2.0+"),
- ("imara-diff", "Apache-2.0"),
- ("instant", "BSD-3-Clause"),
("normalize-line-endings", "Apache-2.0"),
("openssl", "Apache-2.0"),
("ryu", "Apache-2.0 OR BSL-1.0"),
@@ -120,7 +121,6 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[
"annotate-snippets",
"ar_archive_writer",
"arrayvec",
- "atty",
"autocfg",
"bitflags",
"block-buffer",
@@ -180,7 +180,7 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[
"instant",
"intl-memoizer",
"intl_pluralrules",
- "io-lifetimes",
+ "is-terminal",
"itertools",
"itoa",
"jobserver",
@@ -217,6 +217,8 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[
"pulldown-cmark",
"punycode",
"quote",
+ "r-efi",
+ "r-efi-alloc",
"rand",
"rand_chacha",
"rand_core",
diff --git a/src/tools/tidy/src/error_codes.rs b/src/tools/tidy/src/error_codes.rs
index 417ace58c..3e67bac49 100644
--- a/src/tools/tidy/src/error_codes.rs
+++ b/src/tools/tidy/src/error_codes.rs
@@ -354,7 +354,12 @@ fn check_error_codes_used(
for code in error_codes {
if !found_codes.contains(code) && !no_longer_emitted.contains(code) {
- errors.push(format!("Error code `{code}` exists, but is not emitted by the compiler!"))
+ errors.push(format!(
+ "Error code `{code}` exists, but is not emitted by the compiler!\n\
+ Please mark the code as no longer emitted by adding the following note to the top of the `EXXXX.md` file:\n\
+ `#### Note: this error code is no longer emitted by the compiler`\n\
+ Also, do not forget to mark doctests that no longer apply as `ignore (error is no longer emitted)`."
+ ));
}
if found_codes.contains(code) && no_longer_emitted.contains(code) {
diff --git a/src/tools/tidy/src/lib.rs b/src/tools/tidy/src/lib.rs
index 9b19b8eec..fc69c1432 100644
--- a/src/tools/tidy/src/lib.rs
+++ b/src/tools/tidy/src/lib.rs
@@ -63,7 +63,7 @@ pub mod features;
pub mod fluent_alphabetical;
pub mod mir_opt_tests;
pub mod pal;
-pub mod primitive_docs;
+pub mod rustdoc_css_themes;
pub mod rustdoc_gui_tests;
pub mod style;
pub mod target_specific_tests;
diff --git a/src/tools/tidy/src/main.rs b/src/tools/tidy/src/main.rs
index 5fa91715a..80e58ba00 100644
--- a/src/tools/tidy/src/main.rs
+++ b/src/tools/tidy/src/main.rs
@@ -104,6 +104,7 @@ fn main() {
check!(ui_tests, &tests_path);
check!(mir_opt_tests, &tests_path, bless);
check!(rustdoc_gui_tests, &tests_path);
+ check!(rustdoc_css_themes, &librustdoc_path);
// Checks that only make sense for the compiler.
check!(error_codes, &root_path, &[&compiler_path, &librustdoc_path], verbose);
@@ -111,7 +112,6 @@ fn main() {
// Checks that only make sense for the std libs.
check!(pal, &library_path);
- check!(primitive_docs, &library_path);
// Checks that need to be done for both the compiler and std libraries.
check!(unit_tests, &src_path);
diff --git a/src/tools/tidy/src/pal.rs b/src/tools/tidy/src/pal.rs
index 3a4d9c53d..5f6b63a67 100644
--- a/src/tools/tidy/src/pal.rs
+++ b/src/tools/tidy/src/pal.rs
@@ -56,6 +56,7 @@ const EXCEPTION_PATHS: &[&str] = &[
"library/std/src/path.rs",
"library/std/src/sys_common", // Should only contain abstractions over platforms
"library/std/src/net/test.rs", // Utility helpers for tests
+ "library/std/src/io/error.rs", // Repr unpacked needed for UEFI
];
pub fn check(path: &Path, bad: &mut bool) {
diff --git a/src/tools/tidy/src/primitive_docs.rs b/src/tools/tidy/src/primitive_docs.rs
deleted file mode 100644
index f3200e0af..000000000
--- a/src/tools/tidy/src/primitive_docs.rs
+++ /dev/null
@@ -1,17 +0,0 @@
-//! Tidy check to make sure `library/{std,core}/src/primitive_docs.rs` are the same file. These are
-//! different files so that relative links work properly without having to have `CARGO_PKG_NAME`
-//! set, but conceptually they should always be the same.
-
-use std::path::Path;
-
-pub fn check(library_path: &Path, bad: &mut bool) {
- let std_name = "std/src/primitive_docs.rs";
- let core_name = "core/src/primitive_docs.rs";
- let std_contents = std::fs::read_to_string(library_path.join(std_name))
- .unwrap_or_else(|e| panic!("failed to read library/{std_name}: {e}"));
- let core_contents = std::fs::read_to_string(library_path.join(core_name))
- .unwrap_or_else(|e| panic!("failed to read library/{core_name}: {e}"));
- if std_contents != core_contents {
- tidy_error!(bad, "library/{core_name} and library/{std_name} have different contents");
- }
-}
diff --git a/src/tools/tidy/src/rustdoc_css_themes.rs b/src/tools/tidy/src/rustdoc_css_themes.rs
new file mode 100644
index 000000000..852d6e14e
--- /dev/null
+++ b/src/tools/tidy/src/rustdoc_css_themes.rs
@@ -0,0 +1,99 @@
+//! Tidy check to make sure light and dark themes are synchronized between
+//! JS-controlled rustdoc.css and noscript.css
+
+use std::path::Path;
+
+pub fn check(librustdoc_path: &Path, bad: &mut bool) {
+ let rustdoc_css = "html/static/css/rustdoc.css";
+ let noscript_css = "html/static/css/noscript.css";
+ let rustdoc_css_contents = std::fs::read_to_string(librustdoc_path.join(rustdoc_css))
+ .unwrap_or_else(|e| panic!("failed to read librustdoc/{rustdoc_css}: {e}"));
+ let noscript_css_contents = std::fs::read_to_string(librustdoc_path.join(noscript_css))
+ .unwrap_or_else(|e| panic!("failed to read librustdoc/{noscript_css}: {e}"));
+ compare_themes_from_files(
+ "light",
+ rustdoc_css_contents.lines().enumerate().map(|(i, l)| (i + 1, l.trim())),
+ noscript_css_contents.lines().enumerate().map(|(i, l)| (i + 1, l.trim())),
+ bad,
+ );
+ compare_themes_from_files(
+ "dark",
+ rustdoc_css_contents.lines().enumerate(),
+ noscript_css_contents.lines().enumerate(),
+ bad,
+ );
+}
+
+fn compare_themes_from_files<'a>(
+ name: &str,
+ mut rustdoc_css_lines: impl Iterator<Item = (usize, &'a str)>,
+ mut noscript_css_lines: impl Iterator<Item = (usize, &'a str)>,
+ bad: &mut bool,
+) {
+ let begin_theme_pat = format!("/* Begin theme: {name}");
+ let mut found_theme = None;
+ let mut found_theme_noscript = None;
+ while let Some((rustdoc_css_line_number, rustdoc_css_line)) = rustdoc_css_lines.next() {
+ if !rustdoc_css_line.starts_with(&begin_theme_pat) {
+ continue;
+ }
+ if let Some(found_theme) = found_theme {
+ tidy_error!(
+ bad,
+ "rustdoc.css contains two {name} themes on lines {rustdoc_css_line_number} and {found_theme}",
+ );
+ return;
+ }
+ found_theme = Some(rustdoc_css_line_number);
+ while let Some((noscript_css_line_number, noscript_css_line)) = noscript_css_lines.next() {
+ if !noscript_css_line.starts_with(&begin_theme_pat) {
+ continue;
+ }
+ if let Some(found_theme_noscript) = found_theme_noscript {
+ tidy_error!(
+ bad,
+ "noscript.css contains two {name} themes on lines {noscript_css_line_number} and {found_theme_noscript}",
+ );
+ return;
+ }
+ found_theme_noscript = Some(noscript_css_line_number);
+ compare_themes(name, &mut rustdoc_css_lines, &mut noscript_css_lines, bad);
+ }
+ }
+}
+
+fn compare_themes<'a>(
+ name: &str,
+ rustdoc_css_lines: impl Iterator<Item = (usize, &'a str)>,
+ noscript_css_lines: impl Iterator<Item = (usize, &'a str)>,
+ bad: &mut bool,
+) {
+ let end_theme_pat = format!("/* End theme: {name}");
+ for (
+ (rustdoc_css_line_number, rustdoc_css_line),
+ (noscript_css_line_number, noscript_css_line),
+ ) in rustdoc_css_lines.zip(noscript_css_lines)
+ {
+ if noscript_css_line.starts_with(":root {")
+ && rustdoc_css_line.starts_with(&format!(r#":root[data-theme="{name}"] {{"#))
+ {
+ // selectors are different between rustdoc.css and noscript.css
+ // that's why they both exist: one uses JS, the other uses media queries
+ continue;
+ }
+ if noscript_css_line.starts_with(&end_theme_pat)
+ && rustdoc_css_line.starts_with(&end_theme_pat)
+ {
+ break;
+ }
+ if rustdoc_css_line != noscript_css_line {
+ tidy_error!(
+ bad,
+ "noscript.css:{noscript_css_line_number} and rustdoc.css:{rustdoc_css_line_number} contain copies of {name} theme that are not the same",
+ );
+ eprintln!("- {noscript_css_line}");
+ eprintln!("+ {rustdoc_css_line}");
+ return;
+ }
+ }
+}
diff --git a/src/tools/tidy/src/ui_tests.rs b/src/tools/tidy/src/ui_tests.rs
index 341492400..2b828e58d 100644
--- a/src/tools/tidy/src/ui_tests.rs
+++ b/src/tools/tidy/src/ui_tests.rs
@@ -10,8 +10,8 @@ use std::path::{Path, PathBuf};
const ENTRY_LIMIT: usize = 900;
// FIXME: The following limits should be reduced eventually.
-const ISSUES_ENTRY_LIMIT: usize = 1891;
-const ROOT_ENTRY_LIMIT: usize = 866;
+const ISSUES_ENTRY_LIMIT: usize = 1854;
+const ROOT_ENTRY_LIMIT: usize = 865;
const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[
"rs", // test source files