Skip to content

Commit 1893e1e

Browse files
authored
Unify manual_unwrap_or and manual_unwrap_or_default code (rust-lang#14332)
Both lints share a lot of characteristics but were implemented in unrelated ways. This unifies them, saving around 100 SLOC in the process, and making one more test trigger the lint. Also, this removes useless blocks in suggestions. Close rust-lang#12956 changelog: none
2 parents a001ae3 + 94233fb commit 1893e1e

13 files changed

+322
-349
lines changed

clippy_lints/src/declared_lints.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,6 @@ pub static LINTS: &[&crate::LintInfo] = &[
335335
crate::manual_slice_size_calculation::MANUAL_SLICE_SIZE_CALCULATION_INFO,
336336
crate::manual_string_new::MANUAL_STRING_NEW_INFO,
337337
crate::manual_strip::MANUAL_STRIP_INFO,
338-
crate::manual_unwrap_or_default::MANUAL_UNWRAP_OR_DEFAULT_INFO,
339338
crate::map_unit_fn::OPTION_MAP_UNIT_FN_INFO,
340339
crate::map_unit_fn::RESULT_MAP_UNIT_FN_INFO,
341340
crate::match_result_ok::MATCH_RESULT_OK_INFO,
@@ -345,6 +344,7 @@ pub static LINTS: &[&crate::LintInfo] = &[
345344
crate::matches::MANUAL_MAP_INFO,
346345
crate::matches::MANUAL_OK_ERR_INFO,
347346
crate::matches::MANUAL_UNWRAP_OR_INFO,
347+
crate::matches::MANUAL_UNWRAP_OR_DEFAULT_INFO,
348348
crate::matches::MATCH_AS_REF_INFO,
349349
crate::matches::MATCH_BOOL_INFO,
350350
crate::matches::MATCH_LIKE_MATCHES_MACRO_INFO,

clippy_lints/src/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ mod manual_rotate;
226226
mod manual_slice_size_calculation;
227227
mod manual_string_new;
228228
mod manual_strip;
229-
mod manual_unwrap_or_default;
230229
mod map_unit_fn;
231230
mod match_result_ok;
232231
mod matches;
@@ -960,7 +959,6 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
960959
store.register_early_pass(|| Box::new(multiple_bound_locations::MultipleBoundLocations));
961960
store.register_late_pass(move |_| Box::new(assigning_clones::AssigningClones::new(conf)));
962961
store.register_late_pass(|_| Box::new(zero_repeat_side_effects::ZeroRepeatSideEffects));
963-
store.register_late_pass(|_| Box::new(manual_unwrap_or_default::ManualUnwrapOrDefault));
964962
store.register_late_pass(|_| Box::new(integer_division_remainder_used::IntegerDivisionRemainderUsed));
965963
store.register_late_pass(move |_| Box::new(macro_metavars_in_unsafe::ExprMetavarsInUnsafe::new(conf)));
966964
store.register_late_pass(move |_| Box::new(string_patterns::StringPatterns::new(conf)));

clippy_lints/src/manual_unwrap_or_default.rs

-212
This file was deleted.

0 commit comments

Comments
 (0)