Skip to content

Commit 05e05ea

Browse files
committed
refactor: rename lint to or_then_unwrap
1 parent 44c62c9 commit 05e05ea

File tree

8 files changed

+14
-14
lines changed

8 files changed

+14
-14
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3538,7 +3538,7 @@ Released 2018-09-13
35383538
[`upper_case_acronyms`]: https://rust-lang.github.io/rust-clippy/master/index.html#upper_case_acronyms
35393539
[`use_debug`]: https://rust-lang.github.io/rust-clippy/master/index.html#use_debug
35403540
[`use_self`]: https://rust-lang.github.io/rust-clippy/master/index.html#use_self
3541-
[`use_unwrap_or`]: https://rust-lang.github.io/rust-clippy/master/index.html#use_unwrap_or
3541+
[`or_then_unwrap`]: https://rust-lang.github.io/rust-clippy/master/index.html#or_then_unwrap
35423542
[`used_underscore_binding`]: https://rust-lang.github.io/rust-clippy/master/index.html#used_underscore_binding
35433543
[`useless_asref`]: https://rust-lang.github.io/rust-clippy/master/index.html#useless_asref
35443544
[`useless_attribute`]: https://rust-lang.github.io/rust-clippy/master/index.html#useless_attribute

clippy_lints/src/lib.register_all.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ store.register_group(true, "clippy::all", Some("clippy_all"), vec![
310310
LintId::of(unwrap::PANICKING_UNWRAP),
311311
LintId::of(unwrap::UNNECESSARY_UNWRAP),
312312
LintId::of(upper_case_acronyms::UPPER_CASE_ACRONYMS),
313-
LintId::of(use_unwrap_or::USE_UNWRAP_OR),
313+
LintId::of(or_then_unwrap::OR_THEN_UNWRAP),
314314
LintId::of(useless_conversion::USELESS_CONVERSION),
315315
LintId::of(vec::USELESS_VEC),
316316
LintId::of(vec_init_then_push::VEC_INIT_THEN_PUSH),

clippy_lints/src/lib.register_complexity.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ store.register_group(true, "clippy::complexity", Some("clippy_complexity"), vec!
9494
LintId::of(unit_types::UNIT_ARG),
9595
LintId::of(unnecessary_sort_by::UNNECESSARY_SORT_BY),
9696
LintId::of(unwrap::UNNECESSARY_UNWRAP),
97-
LintId::of(use_unwrap_or::USE_UNWRAP_OR),
97+
LintId::of(or_then_unwrap::OR_THEN_UNWRAP),
9898
LintId::of(useless_conversion::USELESS_CONVERSION),
9999
LintId::of(zero_div_zero::ZERO_DIVIDED_BY_ZERO),
100100
])

clippy_lints/src/lib.register_lints.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ store.register_lints(&[
528528
unwrap_in_result::UNWRAP_IN_RESULT,
529529
upper_case_acronyms::UPPER_CASE_ACRONYMS,
530530
use_self::USE_SELF,
531-
use_unwrap_or::USE_UNWRAP_OR,
531+
or_then_unwrap::OR_THEN_UNWRAP,
532532
useless_conversion::USELESS_CONVERSION,
533533
vec::USELESS_VEC,
534534
vec_init_then_push::VEC_INIT_THEN_PUSH,

clippy_lints/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ mod only_used_in_recursion;
322322
mod open_options;
323323
mod option_env_unwrap;
324324
mod option_if_let_else;
325+
mod or_then_unwrap;
325326
mod overflow_check_conditional;
326327
mod panic_in_result_fn;
327328
mod panic_unimplemented;
@@ -394,7 +395,6 @@ mod unwrap;
394395
mod unwrap_in_result;
395396
mod upper_case_acronyms;
396397
mod use_self;
397-
mod use_unwrap_or;
398398
mod useless_conversion;
399399
mod vec;
400400
mod vec_init_then_push;
@@ -867,7 +867,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
867867
ignore_publish: cargo_ignore_publish,
868868
})
869869
});
870-
store.register_late_pass(|| Box::new(use_unwrap_or::UseUnwrapOr));
870+
store.register_late_pass(|| Box::new(or_then_unwrap::OrThenUnwrap));
871871
// add lints here, do not remove this comment, it's used in `new_lint`
872872
}
873873

clippy_lints/src/use_unwrap_or.rs renamed to clippy_lints/src/or_then_unwrap.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ declare_clippy_lint! {
3737
/// let value = option.unwrap_or(fallback);
3838
/// ```
3939
#[clippy::version = "1.61.0"]
40-
pub USE_UNWRAP_OR,
40+
pub OR_THEN_UNWRAP,
4141
complexity,
4242
"checks for `.or(…).unwrap()` calls to Options and Results."
4343
}
44-
declare_lint_pass!(UseUnwrapOr => [USE_UNWRAP_OR]);
44+
declare_lint_pass!(OrThenUnwrap => [OR_THEN_UNWRAP]);
4545

46-
impl<'tcx> LateLintPass<'tcx> for UseUnwrapOr {
46+
impl<'tcx> LateLintPass<'tcx> for OrThenUnwrap {
4747
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
4848
// look for x.or().unwrap()
4949
if_chain! {
@@ -73,7 +73,7 @@ impl<'tcx> LateLintPass<'tcx> for UseUnwrapOr {
7373

7474
span_lint_and_help(
7575
cx,
76-
USE_UNWRAP_OR,
76+
OR_THEN_UNWRAP,
7777
or_span.to(*unwrap_span),
7878
title,
7979
None,

tests/ui/use_unwrap_or.rs renamed to tests/ui/or_then_unwrap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![warn(clippy::use_unwrap_or)]
1+
#![warn(clippy::or_then_unwrap)]
22
#![allow(clippy::map_identity)]
33

44
struct SomeStruct {}

tests/ui/use_unwrap_or.stderr renamed to tests/ui/or_then_unwrap.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
error: .or(Some(…)).unwrap() found
2-
--> $DIR/use_unwrap_or.rs:22:20
2+
--> $DIR/or_then_unwrap.rs:22:20
33
|
44
LL | let _ = option.or(Some("fallback")).unwrap(); // should trigger lint
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
7-
= note: `-D clippy::use-unwrap-or` implied by `-D warnings`
7+
= note: `-D clippy::or-then-unwrap` implied by `-D warnings`
88
= help: use `unwrap_or()` instead
99

1010
error: .or(Ok(…)).unwrap() found
11-
--> $DIR/use_unwrap_or.rs:25:20
11+
--> $DIR/or_then_unwrap.rs:25:20
1212
|
1313
LL | let _ = result.or::<&str>(Ok("fallback")).unwrap(); // should trigger lint
1414
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)