Skip to content

add ./miri clippy #2288

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 8 additions & 0 deletions miri
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ times and slower execution times.
./miri fmt <flags>:
Format all sources and tests. <flags> are passed to `rustfmt`.

./miri clippy <flags>:
Format all sources and tests. <flags> are passed to `cargo clippy`.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a copy-and-paste error.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good catch!


ENVIRONMENT VARIABLES

MIRI_SYSROOT:
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion rustup-toolchain
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion ui_test/src/comments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl Comments {
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
Expand Down
8 changes: 5 additions & 3 deletions ui_test/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions ui_test/src/rustc_stderr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,16 @@ impl Span {

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::<RustcMessage>(line) {
Ok(msg) => {
write!(
Expand Down
2 changes: 1 addition & 1 deletion ui_test/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fn main() {
}
";
let path = Path::new("$DIR/<dummy>");
let comments = Comments::parse(&path, s);
let comments = Comments::parse(path, s);
let mut errors = vec![];
let config = config();
let messages = vec![
Expand Down