Skip to content

Commit 5975594

Browse files
committed
Unify manual_unwrap_or and manual_unwrap_or_default code
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.
1 parent 62f34f2 commit 5975594

File tree

9 files changed

+249
-346
lines changed

9 files changed

+249
-346
lines changed

clippy_lints/src/declared_lints.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,6 @@ pub static LINTS: &[&crate::LintInfo] = &[
333333
crate::manual_slice_size_calculation::MANUAL_SLICE_SIZE_CALCULATION_INFO,
334334
crate::manual_string_new::MANUAL_STRING_NEW_INFO,
335335
crate::manual_strip::MANUAL_STRIP_INFO,
336-
crate::manual_unwrap_or_default::MANUAL_UNWRAP_OR_DEFAULT_INFO,
337336
crate::map_unit_fn::OPTION_MAP_UNIT_FN_INFO,
338337
crate::map_unit_fn::RESULT_MAP_UNIT_FN_INFO,
339338
crate::match_result_ok::MATCH_RESULT_OK_INFO,
@@ -343,6 +342,7 @@ pub static LINTS: &[&crate::LintInfo] = &[
343342
crate::matches::MANUAL_MAP_INFO,
344343
crate::matches::MANUAL_OK_ERR_INFO,
345344
crate::matches::MANUAL_UNWRAP_OR_INFO,
345+
crate::matches::MANUAL_UNWRAP_OR_DEFAULT_INFO,
346346
crate::matches::MATCH_AS_REF_INFO,
347347
crate::matches::MATCH_BOOL_INFO,
348348
crate::matches::MATCH_LIKE_MATCHES_MACRO_INFO,

clippy_lints/src/lib.rs

Lines changed: 0 additions & 2 deletions
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

Lines changed: 0 additions & 212 deletions
This file was deleted.

0 commit comments

Comments
 (0)