Skip to content

Commit 603e1af

Browse files
committed
address review comments and rebase
ci: always build with internal lints group up internal lints in lib.rs dogfood: we already pass --all-features, no need to enable internal-lints again
1 parent b25a6df commit 603e1af

File tree

3 files changed

+33
-52
lines changed

3 files changed

+33
-52
lines changed

.github/workflows/clippy_bors.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,6 @@ jobs:
128128
SYSROOT=$(rustc --print sysroot)
129129
echo "$SYSROOT/bin" >> $GITHUB_PATH
130130
131-
- name: Build
132-
run: cargo build --features deny-warnings
133-
134-
# compiletest would panic due to "Found multiple rlibs for crate `clippy_lints`"
135-
- name: clean rlibs
136-
run: rm -f ./target/debug/deps/libclippy_lints*
137-
138131
- name: Build with internal lints
139132
run: cargo build --features deny-warnings,internal-lints
140133

clippy_lints/src/lib.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -939,17 +939,23 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
939939
&zero_div_zero::ZERO_DIVIDED_BY_ZERO,
940940
]);
941941
// end register lints, do not remove this comment, it’s used in `update_lints`
942-
store.register_late_pass(|| box await_holding_invalid::AwaitHolding);
943-
store.register_late_pass(|| box serde_api::SerdeAPI);
942+
943+
// all the internal lints
944944
#[cfg(feature = "internal-lints")]
945945
{
946+
store.register_early_pass(|| box utils::internal_lints::ClippyLintsInternal);
947+
store.register_early_pass(|| box utils::internal_lints::ProduceIce);
948+
store.register_late_pass(|| box utils::inspector::DeepCodeInspector);
949+
store.register_late_pass(|| box utils::internal_lints::CollapsibleCalls);
946950
store.register_late_pass(|| box utils::internal_lints::CompilerLintFunctions::new());
951+
store.register_late_pass(|| box utils::internal_lints::InvalidPaths);
947952
store.register_late_pass(|| box utils::internal_lints::LintWithoutLintPass::default());
953+
store.register_late_pass(|| box utils::internal_lints::MatchTypeOnDiagItem);
948954
store.register_late_pass(|| box utils::internal_lints::OuterExpnDataPass);
949-
store.register_late_pass(|| box utils::internal_lints::InvalidPaths);
950-
store.register_late_pass(|| box utils::inspector::DeepCodeInspector);
951955
}
952956
store.register_late_pass(|| box utils::author::Author);
957+
store.register_late_pass(|| box await_holding_invalid::AwaitHolding);
958+
store.register_late_pass(|| box serde_api::SerdeAPI);
953959
let vec_box_size_threshold = conf.vec_box_size_threshold;
954960
store.register_late_pass(move || box types::Types::new(vec_box_size_threshold));
955961
store.register_late_pass(|| box booleans::NonminimalBool);
@@ -1134,8 +1140,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
11341140
store.register_early_pass(|| box literal_representation::LiteralDigitGrouping);
11351141
let literal_representation_threshold = conf.literal_representation_threshold;
11361142
store.register_early_pass(move || box literal_representation::DecimalLiteralRepresentation::new(literal_representation_threshold));
1137-
#[cfg(feature = "internal-lints")]
1138-
store.register_early_pass(|| box utils::internal_lints::ClippyLintsInternal);
1143+
11391144
let enum_variant_name_threshold = conf.enum_variant_name_threshold;
11401145
store.register_early_pass(move || box enum_variants::EnumVariantNames::new(enum_variant_name_threshold));
11411146
store.register_early_pass(|| box tabs_in_doc_comments::TabsInDocComments);
@@ -1149,8 +1154,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
11491154
store.register_late_pass(move || box large_const_arrays::LargeConstArrays::new(array_size_threshold));
11501155
store.register_late_pass(|| box floating_point_arithmetic::FloatingPointArithmetic);
11511156
store.register_early_pass(|| box as_conversions::AsConversions);
1152-
#[cfg(feature = "internal-lints")]
1153-
store.register_early_pass(|| box utils::internal_lints::ProduceIce);
1157+
11541158
store.register_late_pass(|| box let_underscore::LetUnderscore);
11551159
store.register_late_pass(|| box atomic_ordering::AtomicOrdering);
11561160
store.register_early_pass(|| box single_component_path_imports::SingleComponentPathImports);
@@ -1166,8 +1170,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
11661170
store.register_late_pass(|| box dereference::Dereferencing);
11671171
store.register_late_pass(|| box option_if_let_else::OptionIfLetElse);
11681172
store.register_late_pass(|| box future_not_send::FutureNotSend);
1169-
#[cfg(feature = "internal-lints")]
1170-
store.register_late_pass(|| box utils::internal_lints::CollapsibleCalls);
1173+
11711174
store.register_late_pass(|| box if_let_mutex::IfLetMutex);
11721175
store.register_late_pass(|| box mut_mutex_lock::MutMutexLock);
11731176
store.register_late_pass(|| box match_on_vec_items::MatchOnVecItems);
@@ -1192,8 +1195,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
11921195
store.register_late_pass(|| box manual_ok_or::ManualOkOr);
11931196
store.register_late_pass(|| box float_equality_without_abs::FloatEqualityWithoutAbs);
11941197
store.register_late_pass(|| box async_yields_async::AsyncYieldsAsync);
1195-
#[cfg(feature = "internal-lints")]
1196-
store.register_late_pass(|| box utils::internal_lints::MatchTypeOnDiagItem);
11971198
let disallowed_methods = conf.disallowed_methods.iter().cloned().collect::<FxHashSet<_>>();
11981199
store.register_late_pass(move || box disallowed_method::DisallowedMethod::new(&disallowed_methods));
11991200
store.register_early_pass(|| box asm_syntax::InlineAsmX86AttSyntax);

tests/dogfood.rs

Lines changed: 20 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -18,39 +18,26 @@ fn dogfood_clippy() {
1818
}
1919
let root_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
2020

21-
let output = if cfg!(feature = "internal-lints") {
22-
// with internal lints and internal warnings
23-
Command::new(&*CLIPPY_PATH)
24-
.current_dir(root_dir)
25-
.env("CLIPPY_DOGFOOD", "1")
26-
.env("CARGO_INCREMENTAL", "0")
27-
.arg("clippy-preview")
28-
.arg("--all-targets")
29-
.arg("--all-features")
30-
.args(&["--features", "internal-lints"])
31-
.arg("--")
32-
.args(&["-D", "clippy::all"])
33-
.args(&["-D", "clippy::pedantic"])
34-
.args(&["-D", "clippy::internal"])
35-
.arg("-Cdebuginfo=0") // disable debuginfo to generate less data in the target dir
36-
.output()
37-
.unwrap()
38-
} else {
39-
// without internal lints or warnings
40-
Command::new(&*CLIPPY_PATH)
41-
.current_dir(root_dir)
42-
.env("CLIPPY_DOGFOOD", "1")
43-
.env("CARGO_INCREMENTAL", "0")
44-
.arg("clippy-preview")
45-
.arg("--all-targets")
46-
.arg("--all-features")
47-
.arg("--")
48-
.args(&["-D", "clippy::all"])
49-
.args(&["-D", "clippy::pedantic"])
50-
.arg("-Cdebuginfo=0") // disable debuginfo to generate less data in the target dir
51-
.output()
52-
.unwrap()
53-
};
21+
let mut command = Command::new(&*CLIPPY_PATH);
22+
command
23+
.current_dir(root_dir)
24+
.env("CLIPPY_DOGFOOD", "1")
25+
.env("CARGO_INCREMENTAL", "0")
26+
.arg("clippy-preview")
27+
.arg("--all-targets")
28+
.arg("--all-features")
29+
.arg("--")
30+
.args(&["-D", "clippy::all"])
31+
.args(&["-D", "clippy::pedantic"])
32+
.arg("-Cdebuginfo=0"); // disable debuginfo to generate less data in the target dir
33+
34+
// internal lints only exist if we build with the internal-lints feature
35+
if cfg!(feature = "internal-lints") {
36+
command.args(&["-D", "clippy::internal"]);
37+
}
38+
39+
let output = command.output().unwrap();
40+
5441
println!("status: {}", output.status);
5542
println!("stdout: {}", String::from_utf8_lossy(&output.stdout));
5643
println!("stderr: {}", String::from_utf8_lossy(&output.stderr));

0 commit comments

Comments
 (0)