Skip to content

Commit c6f70f8

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 c6f70f8

File tree

3 files changed

+31
-54
lines changed

3 files changed

+31
-54
lines changed

.github/workflows/clippy_bors.yml

-7
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

+11-14
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,6 @@ 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);
11391143
let enum_variant_name_threshold = conf.enum_variant_name_threshold;
11401144
store.register_early_pass(move || box enum_variants::EnumVariantNames::new(enum_variant_name_threshold));
11411145
store.register_early_pass(|| box tabs_in_doc_comments::TabsInDocComments);
@@ -1149,8 +1153,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
11491153
store.register_late_pass(move || box large_const_arrays::LargeConstArrays::new(array_size_threshold));
11501154
store.register_late_pass(|| box floating_point_arithmetic::FloatingPointArithmetic);
11511155
store.register_early_pass(|| box as_conversions::AsConversions);
1152-
#[cfg(feature = "internal-lints")]
1153-
store.register_early_pass(|| box utils::internal_lints::ProduceIce);
11541156
store.register_late_pass(|| box let_underscore::LetUnderscore);
11551157
store.register_late_pass(|| box atomic_ordering::AtomicOrdering);
11561158
store.register_early_pass(|| box single_component_path_imports::SingleComponentPathImports);
@@ -1166,16 +1168,13 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
11661168
store.register_late_pass(|| box dereference::Dereferencing);
11671169
store.register_late_pass(|| box option_if_let_else::OptionIfLetElse);
11681170
store.register_late_pass(|| box future_not_send::FutureNotSend);
1169-
#[cfg(feature = "internal-lints")]
1170-
store.register_late_pass(|| box utils::internal_lints::CollapsibleCalls);
11711171
store.register_late_pass(|| box if_let_mutex::IfLetMutex);
11721172
store.register_late_pass(|| box mut_mutex_lock::MutMutexLock);
11731173
store.register_late_pass(|| box match_on_vec_items::MatchOnVecItems);
11741174
store.register_late_pass(|| box manual_async_fn::ManualAsyncFn);
11751175
store.register_early_pass(|| box redundant_field_names::RedundantFieldNames);
11761176
store.register_late_pass(|| box vec_resize_to_zero::VecResizeToZero);
11771177
store.register_late_pass(|| box panic_in_result_fn::PanicInResultFn);
1178-
11791178
let single_char_binding_names_threshold = conf.single_char_binding_names_threshold;
11801179
store.register_early_pass(move || box non_expressive_names::NonExpressiveNames {
11811180
single_char_binding_names_threshold,
@@ -1192,8 +1191,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
11921191
store.register_late_pass(|| box manual_ok_or::ManualOkOr);
11931192
store.register_late_pass(|| box float_equality_without_abs::FloatEqualityWithoutAbs);
11941193
store.register_late_pass(|| box async_yields_async::AsyncYieldsAsync);
1195-
#[cfg(feature = "internal-lints")]
1196-
store.register_late_pass(|| box utils::internal_lints::MatchTypeOnDiagItem);
11971194
let disallowed_methods = conf.disallowed_methods.iter().cloned().collect::<FxHashSet<_>>();
11981195
store.register_late_pass(move || box disallowed_method::DisallowedMethod::new(&disallowed_methods));
11991196
store.register_early_pass(|| box asm_syntax::InlineAsmX86AttSyntax);
@@ -1202,7 +1199,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
12021199
store.register_late_pass(|| box strings::StrToString);
12031200
store.register_late_pass(|| box strings::StringToString);
12041201

1205-
12061202
store.register_group(true, "clippy::restriction", Some("clippy_restriction"), vec![
12071203
LintId::of(&arithmetic::FLOAT_ARITHMETIC),
12081204
LintId::of(&arithmetic::INTEGER_ARITHMETIC),
@@ -1333,6 +1329,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
13331329
LintId::of(&wildcard_imports::ENUM_GLOB_USE),
13341330
LintId::of(&wildcard_imports::WILDCARD_IMPORTS),
13351331
]);
1332+
13361333
#[cfg(feature = "internal-lints")]
13371334
store.register_group(true, "clippy::internal", Some("clippy_internal"), vec![
13381335
LintId::of(&utils::internal_lints::CLIPPY_LINTS_INTERNAL),

tests/dogfood.rs

+20-33
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)