Skip to content

Commit e27977b

Browse files
committed
Rename unwrap_or_else_default to unwrap_or_default
1 parent 84c4112 commit e27977b

12 files changed

+75
-63
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -5366,6 +5366,7 @@ Released 2018-09-13
53665366
[`unused_unit`]: https://rust-lang.github.io/rust-clippy/master/index.html#unused_unit
53675367
[`unusual_byte_groupings`]: https://rust-lang.github.io/rust-clippy/master/index.html#unusual_byte_groupings
53685368
[`unwrap_in_result`]: https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_in_result
5369+
[`unwrap_or_default`]: https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_or_default
53695370
[`unwrap_or_else_default`]: https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_or_else_default
53705371
[`unwrap_used`]: https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_used
53715372
[`upper_case_acronyms`]: https://rust-lang.github.io/rust-clippy/master/index.html#upper_case_acronyms

clippy_lints/src/declared_lints.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
422422
crate::methods::UNNECESSARY_LITERAL_UNWRAP_INFO,
423423
crate::methods::UNNECESSARY_SORT_BY_INFO,
424424
crate::methods::UNNECESSARY_TO_OWNED_INFO,
425-
crate::methods::UNWRAP_OR_ELSE_DEFAULT_INFO,
425+
crate::methods::UNWRAP_OR_DEFAULT_INFO,
426426
crate::methods::UNWRAP_USED_INFO,
427427
crate::methods::USELESS_ASREF_INFO,
428428
crate::methods::VEC_RESIZE_TO_ZERO_INFO,

clippy_lints/src/methods/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ declare_clippy_lint! {
506506
/// map.entry(42).or_default();
507507
/// ```
508508
#[clippy::version = "1.56.0"]
509-
pub UNWRAP_OR_ELSE_DEFAULT,
509+
pub UNWRAP_OR_DEFAULT,
510510
style,
511511
"using `.unwrap_or`, etc. with an argument that constructs a default value"
512512
}
@@ -3505,7 +3505,7 @@ impl_lint_pass!(Methods => [
35053505
SHOULD_IMPLEMENT_TRAIT,
35063506
WRONG_SELF_CONVENTION,
35073507
OK_EXPECT,
3508-
UNWRAP_OR_ELSE_DEFAULT,
3508+
UNWRAP_OR_DEFAULT,
35093509
MAP_UNWRAP_OR,
35103510
RESULT_MAP_OR_INTO_OPTION,
35113511
OPTION_MAP_OR_NONE,

clippy_lints/src/methods/or_fun_call.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_span::source_map::Span;
1111
use rustc_span::symbol::{self, sym, Symbol};
1212
use {rustc_ast as ast, rustc_hir as hir};
1313

14-
use super::{OR_FUN_CALL, UNWRAP_OR_ELSE_DEFAULT};
14+
use super::{OR_FUN_CALL, UNWRAP_OR_DEFAULT};
1515

1616
/// Checks for the `OR_FUN_CALL` lint.
1717
#[allow(clippy::too_many_lines)]
@@ -80,7 +80,7 @@ pub(super) fn check<'tcx>(
8080
then {
8181
span_lint_and_sugg(
8282
cx,
83-
UNWRAP_OR_ELSE_DEFAULT,
83+
UNWRAP_OR_DEFAULT,
8484
method_span.with_hi(span.hi()),
8585
&format!("use of `{name}` to construct default value"),
8686
"try",

clippy_lints/src/renamed_lints.rs

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ pub static RENAMED_LINTS: &[(&str, &str)] = &[
3030
("clippy::single_char_push_str", "clippy::single_char_add_str"),
3131
("clippy::stutter", "clippy::module_name_repetitions"),
3232
("clippy::to_string_in_display", "clippy::recursive_format_impl"),
33+
("clippy::unwrap_or_else_default", "clippy::unwrap_or_default"),
3334
("clippy::zero_width_space", "clippy::invisible_characters"),
3435
("clippy::cast_ref_to_mut", "cast_ref_to_mut"),
3536
("clippy::clone_double_ref", "suspicious_double_ref_op"),

tests/ui/or_fun_call.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ error: use of `unwrap_or` to construct default value
1212
LL | with_new.unwrap_or(Vec::new());
1313
| ^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()`
1414
|
15-
= note: `-D clippy::unwrap-or-else-default` implied by `-D warnings`
15+
= note: `-D clippy::unwrap-or-default` implied by `-D warnings`
1616

1717
error: use of `unwrap_or` followed by a function call
1818
--> $DIR/or_fun_call.rs:59:21

tests/ui/rename.fixed

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#![allow(clippy::single_char_add_str)]
2828
#![allow(clippy::module_name_repetitions)]
2929
#![allow(clippy::recursive_format_impl)]
30+
#![allow(clippy::unwrap_or_default)]
3031
#![allow(clippy::invisible_characters)]
3132
#![allow(cast_ref_to_mut)]
3233
#![allow(suspicious_double_ref_op)]
@@ -78,6 +79,7 @@
7879
#![warn(clippy::single_char_add_str)]
7980
#![warn(clippy::module_name_repetitions)]
8081
#![warn(clippy::recursive_format_impl)]
82+
#![warn(clippy::unwrap_or_default)]
8183
#![warn(clippy::invisible_characters)]
8284
#![warn(cast_ref_to_mut)]
8385
#![warn(suspicious_double_ref_op)]

tests/ui/rename.rs

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#![allow(clippy::single_char_add_str)]
2828
#![allow(clippy::module_name_repetitions)]
2929
#![allow(clippy::recursive_format_impl)]
30+
#![allow(clippy::unwrap_or_default)]
3031
#![allow(clippy::invisible_characters)]
3132
#![allow(cast_ref_to_mut)]
3233
#![allow(suspicious_double_ref_op)]
@@ -78,6 +79,7 @@
7879
#![warn(clippy::single_char_push_str)]
7980
#![warn(clippy::stutter)]
8081
#![warn(clippy::to_string_in_display)]
82+
#![warn(clippy::unwrap_or_else_default)]
8183
#![warn(clippy::zero_width_space)]
8284
#![warn(clippy::cast_ref_to_mut)]
8385
#![warn(clippy::clone_double_ref)]

0 commit comments

Comments
 (0)