diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c603d1f5d25..7d6e39dc31b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -98,12 +98,8 @@ jobs: ./rustup-toolchain "" -c clippy - name: rustfmt run: ./miri fmt --check - - name: clippy (miri) - run: cargo clippy --all-targets -- -D warnings - #- name: Clippy (ui_test) - # run: cargo clippy --manifest-path ui_test/Cargo.toml --all-targets -- -D warnings - - name: clippy (cargo-miri) - run: cargo clippy --manifest-path cargo-miri/Cargo.toml --all-targets -- -D warnings + - name: clippy + run: ./miri clippy -- -D warnings - name: rustdoc run: RUSTDOCFLAGS="-Dwarnings" cargo doc --document-private-items diff --git a/miri b/miri index e89a9e380ff..6b7e9dbf03f 100755 --- a/miri +++ b/miri @@ -28,6 +28,9 @@ times and slower execution times. ./miri fmt : Format all sources and tests. are passed to `rustfmt`. +./miri clippy : +Format all sources and tests. are passed to `cargo clippy`. + ENVIRONMENT VARIABLES MIRI_SYSROOT: @@ -163,6 +166,11 @@ fmt) find "$MIRIDIR" -not \( -name target -prune \) -name '*.rs' \ | xargs rustfmt --edition=2021 --config-path "$MIRIDIR/rustfmt.toml" "$@" ;; +clippy) + cargo clippy $CARGO_BUILD_FLAGS --manifest-path "$MIRIDIR"/Cargo.toml --all-targets "$@" + cargo clippy $CARGO_BUILD_FLAGS --manifest-path "$MIRIDIR"/ui_test/Cargo.toml --all-targets "$@" + cargo clippy $CARGO_BUILD_FLAGS --manifest-path "$MIRIDIR"/cargo-miri/Cargo.toml "$@" + ;; *) if [ -n "$COMMAND" ]; then echo "Unknown command: $COMMAND" diff --git a/rustup-toolchain b/rustup-toolchain index 34472c727f6..7b9a17145d0 100755 --- a/rustup-toolchain +++ b/rustup-toolchain @@ -42,7 +42,7 @@ fi # Install and setup new toolchain. rustup toolchain uninstall miri -rustup-toolchain-install-master -n miri -c cargo -c rust-src -c rustc-dev -c llvm-tools -c rustfmt "$@" -- "$NEW_COMMIT" +rustup-toolchain-install-master -n miri -c cargo -c rust-src -c rustc-dev -c llvm-tools -c rustfmt -c clippy "$@" -- "$NEW_COMMIT" rustup override set miri # Cleanup. diff --git a/ui_test/src/comments.rs b/ui_test/src/comments.rs index 43c687e9c9a..e7b4968a9ca 100644 --- a/ui_test/src/comments.rs +++ b/ui_test/src/comments.rs @@ -90,7 +90,7 @@ pub(crate) fn parse(path: &Path, content: &str) -> Self { path.display() ); this.revisions = - Some(revisions.trim().split_whitespace().map(|s| s.to_string()).collect()); + Some(revisions.split_whitespace().map(|s| s.to_string()).collect()); } if let Some(s) = line.strip_prefix("// ignore-") { let s = s diff --git a/ui_test/src/lib.rs b/ui_test/src/lib.rs index 30e1296f7b3..ff0c4e1c899 100644 --- a/ui_test/src/lib.rs +++ b/ui_test/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(clippy::enum_variant_names, clippy::useless_format, clippy::too_many_arguments)] + use std::collections::VecDeque; use std::fmt::Write; use std::path::{Path, PathBuf}; @@ -338,17 +340,17 @@ fn check_test_result( revised("stderr"), target, &config.stderr_filters, - &config, + config, comments, ); check_output( - &stdout, + stdout, path, errors, revised("stdout"), target, &config.stdout_filters, - &config, + config, comments, ); // Check error annotations in the source against output diff --git a/ui_test/src/rustc_stderr.rs b/ui_test/src/rustc_stderr.rs index 2d3845752e9..ea32ce4bd29 100644 --- a/ui_test/src/rustc_stderr.rs +++ b/ui_test/src/rustc_stderr.rs @@ -117,16 +117,16 @@ fn line(&self, file: &Path) -> Option { pub(crate) fn filter_annotations_from_rendered(rendered: &str) -> std::borrow::Cow<'_, str> { let annotations = Regex::new(r"\s*//(\[[^\]]\])?~.*").unwrap(); - annotations.replace_all(&rendered, "") + annotations.replace_all(rendered, "") } pub(crate) fn process(file: &Path, stderr: &[u8]) -> Diagnostics { - let stderr = std::str::from_utf8(&stderr).unwrap(); + let stderr = std::str::from_utf8(stderr).unwrap(); let mut rendered = String::new(); let mut messages = vec![]; let mut messages_from_unknown_file_or_line = vec![]; for line in stderr.lines() { - if line.starts_with("{") { + if line.starts_with('{') { match serde_json::from_str::(line) { Ok(msg) => { write!( diff --git a/ui_test/src/tests.rs b/ui_test/src/tests.rs index 7e08a68be7b..a45f8f8933c 100644 --- a/ui_test/src/tests.rs +++ b/ui_test/src/tests.rs @@ -29,7 +29,7 @@ fn main() { } "; let path = Path::new("$DIR/"); - let comments = Comments::parse(&path, s); + let comments = Comments::parse(path, s); let mut errors = vec![]; let config = config(); let messages = vec![