Skip to content

Commit ccfb869

Browse files
committed
Auto merge of rust-lang#2288 - RalfJung:clippy, r=RalfJung
add ./miri clippy also make ui_test comply with clippy
2 parents 328a8c7 + e33efc7 commit ccfb869

File tree

7 files changed

+21
-15
lines changed

7 files changed

+21
-15
lines changed

.github/workflows/ci.yml

+2-6
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,8 @@ jobs:
9898
./rustup-toolchain "" -c clippy
9999
- name: rustfmt
100100
run: ./miri fmt --check
101-
- name: clippy (miri)
102-
run: cargo clippy --all-targets -- -D warnings
103-
#- name: Clippy (ui_test)
104-
# run: cargo clippy --manifest-path ui_test/Cargo.toml --all-targets -- -D warnings
105-
- name: clippy (cargo-miri)
106-
run: cargo clippy --manifest-path cargo-miri/Cargo.toml --all-targets -- -D warnings
101+
- name: clippy
102+
run: ./miri clippy -- -D warnings
107103
- name: rustdoc
108104
run: RUSTDOCFLAGS="-Dwarnings" cargo doc --document-private-items
109105

miri

+8
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ times and slower execution times.
2828
./miri fmt <flags>:
2929
Format all sources and tests. <flags> are passed to `rustfmt`.
3030
31+
./miri clippy <flags>:
32+
Format all sources and tests. <flags> are passed to `cargo clippy`.
33+
3134
ENVIRONMENT VARIABLES
3235
3336
MIRI_SYSROOT:
@@ -163,6 +166,11 @@ fmt)
163166
find "$MIRIDIR" -not \( -name target -prune \) -name '*.rs' \
164167
| xargs rustfmt --edition=2021 --config-path "$MIRIDIR/rustfmt.toml" "$@"
165168
;;
169+
clippy)
170+
cargo clippy $CARGO_BUILD_FLAGS --manifest-path "$MIRIDIR"/Cargo.toml --all-targets "$@"
171+
cargo clippy $CARGO_BUILD_FLAGS --manifest-path "$MIRIDIR"/ui_test/Cargo.toml --all-targets "$@"
172+
cargo clippy $CARGO_BUILD_FLAGS --manifest-path "$MIRIDIR"/cargo-miri/Cargo.toml "$@"
173+
;;
166174
*)
167175
if [ -n "$COMMAND" ]; then
168176
echo "Unknown command: $COMMAND"

rustup-toolchain

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ fi
4242

4343
# Install and setup new toolchain.
4444
rustup toolchain uninstall miri
45-
rustup-toolchain-install-master -n miri -c cargo -c rust-src -c rustc-dev -c llvm-tools -c rustfmt "$@" -- "$NEW_COMMIT"
45+
rustup-toolchain-install-master -n miri -c cargo -c rust-src -c rustc-dev -c llvm-tools -c rustfmt -c clippy "$@" -- "$NEW_COMMIT"
4646
rustup override set miri
4747

4848
# Cleanup.

ui_test/src/comments.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl Comments {
9090
path.display()
9191
);
9292
this.revisions =
93-
Some(revisions.trim().split_whitespace().map(|s| s.to_string()).collect());
93+
Some(revisions.split_whitespace().map(|s| s.to_string()).collect());
9494
}
9595
if let Some(s) = line.strip_prefix("// ignore-") {
9696
let s = s

ui_test/src/lib.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(clippy::enum_variant_names, clippy::useless_format, clippy::too_many_arguments)]
2+
13
use std::collections::VecDeque;
24
use std::fmt::Write;
35
use std::path::{Path, PathBuf};
@@ -338,17 +340,17 @@ fn check_test_result(
338340
revised("stderr"),
339341
target,
340342
&config.stderr_filters,
341-
&config,
343+
config,
342344
comments,
343345
);
344346
check_output(
345-
&stdout,
347+
stdout,
346348
path,
347349
errors,
348350
revised("stdout"),
349351
target,
350352
&config.stdout_filters,
351-
&config,
353+
config,
352354
comments,
353355
);
354356
// Check error annotations in the source against output

ui_test/src/rustc_stderr.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,16 @@ impl Span {
117117

118118
pub(crate) fn filter_annotations_from_rendered(rendered: &str) -> std::borrow::Cow<'_, str> {
119119
let annotations = Regex::new(r"\s*//(\[[^\]]\])?~.*").unwrap();
120-
annotations.replace_all(&rendered, "")
120+
annotations.replace_all(rendered, "")
121121
}
122122

123123
pub(crate) fn process(file: &Path, stderr: &[u8]) -> Diagnostics {
124-
let stderr = std::str::from_utf8(&stderr).unwrap();
124+
let stderr = std::str::from_utf8(stderr).unwrap();
125125
let mut rendered = String::new();
126126
let mut messages = vec![];
127127
let mut messages_from_unknown_file_or_line = vec![];
128128
for line in stderr.lines() {
129-
if line.starts_with("{") {
129+
if line.starts_with('{') {
130130
match serde_json::from_str::<RustcMessage>(line) {
131131
Ok(msg) => {
132132
write!(

ui_test/src/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ fn main() {
2929
}
3030
";
3131
let path = Path::new("$DIR/<dummy>");
32-
let comments = Comments::parse(&path, s);
32+
let comments = Comments::parse(path, s);
3333
let mut errors = vec![];
3434
let config = config();
3535
let messages = vec![

0 commit comments

Comments
 (0)