Skip to content

Commit f61ba63

Browse files
committed
Last few tweaks
1 parent 66e1f49 commit f61ba63

File tree

6 files changed

+11
-9
lines changed

6 files changed

+11
-9
lines changed

CHANGELOG.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1491,7 +1491,6 @@ Released 2018-09-13
14911491
[`large_stack_arrays`]: https://rust-lang.github.io/rust-clippy/master/index.html#large_stack_arrays
14921492
[`len_without_is_empty`]: https://rust-lang.github.io/rust-clippy/master/index.html#len_without_is_empty
14931493
[`len_zero`]: https://rust-lang.github.io/rust-clippy/master/index.html#len_zero
1494-
[`let_and_return`]: https://rust-lang.github.io/rust-clippy/master/index.html#let_and_return
14951494
[`let_underscore_lock`]: https://rust-lang.github.io/rust-clippy/master/index.html#let_underscore_lock
14961495
[`let_underscore_must_use`]: https://rust-lang.github.io/rust-clippy/master/index.html#let_underscore_must_use
14971496
[`let_unit_value`]: https://rust-lang.github.io/rust-clippy/master/index.html#let_unit_value

clippy_lints/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,6 +1156,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
11561156
LintId::of(&needless_continue::NEEDLESS_CONTINUE),
11571157
LintId::of(&needless_pass_by_value::NEEDLESS_PASS_BY_VALUE),
11581158
LintId::of(&non_expressive_names::SIMILAR_NAMES),
1159+
LintId::of(&option_if_let_else::OPTION_IF_LET_ELSE),
11591160
LintId::of(&ranges::RANGE_PLUS_ONE),
11601161
LintId::of(&shadow::SHADOW_UNRELATED),
11611162
LintId::of(&strings::STRING_ADD_ASSIGN),
@@ -1367,7 +1368,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
13671368
LintId::of(&non_expressive_names::MANY_SINGLE_CHAR_NAMES),
13681369
LintId::of(&open_options::NONSENSICAL_OPEN_OPTIONS),
13691370
LintId::of(&option_env_unwrap::OPTION_ENV_UNWRAP),
1370-
LintId::of(&option_if_let_else::OPTION_IF_LET_ELSE),
13711371
LintId::of(&overflow_check_conditional::OVERFLOW_CHECK_CONDITIONAL),
13721372
LintId::of(&panic_unimplemented::PANIC_PARAMS),
13731373
LintId::of(&partialeq_ne_impl::PARTIALEQ_NE_IMPL),
@@ -1516,7 +1516,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
15161516
LintId::of(&new_without_default::NEW_WITHOUT_DEFAULT),
15171517
LintId::of(&non_expressive_names::JUST_UNDERSCORES_AND_DIGITS),
15181518
LintId::of(&non_expressive_names::MANY_SINGLE_CHAR_NAMES),
1519-
LintId::of(&option_if_let_else::OPTION_IF_LET_ELSE),
15201519
LintId::of(&panic_unimplemented::PANIC_PARAMS),
15211520
LintId::of(&ptr::CMP_NULL),
15221521
LintId::of(&ptr::PTR_ARG),

clippy_lints/src/minmax.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,5 @@ fn fetch_const<'a>(
103103
} else {
104104
None
105105
}
106-
}
107-
).map(|(c, arg)| (m, c, arg))
106+
})
108107
}

clippy_lints/src/option_if_let_else.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ declare_clippy_lint! {
6363
/// }, |foo| foo);
6464
/// ```
6565
pub OPTION_IF_LET_ELSE,
66-
style,
66+
pedantic,
6767
"reimplementation of Option::map_or"
6868
}
6969

clippy_lints/src/returns.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,15 @@ fn is_unit_expr(expr: &ast::Expr) -> bool {
259259

260260
fn lint_unneeded_unit_return(cx: &EarlyContext<'_>, ty: &ast::Ty, span: Span) {
261261
let (ret_span, appl) = if let Ok(fn_source) = cx.sess().source_map().span_to_snippet(span.with_hi(ty.span.hi())) {
262-
fn_source.rfind("->").map_or((ty.span, Applicability::MaybeIncorrect), |rpos| (
262+
if let Some(rpos) = fn_source.rfind("->") {
263+
#[allow(clippy::cast_possible_truncation)]
264+
(
263265
ty.span.with_lo(BytePos(span.lo().0 + rpos as u32)),
264266
Applicability::MachineApplicable,
265-
))
267+
)
268+
} else {
269+
(ty.span, Applicability::MaybeIncorrect)
270+
}
266271
} else {
267272
(ty.span, Applicability::MaybeIncorrect)
268273
};

src/lintlist/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1622,7 +1622,7 @@ pub static ref ALL_LINTS: Vec<Lint> = vec![
16221622
},
16231623
Lint {
16241624
name: "option_if_let_else",
1625-
group: "style",
1625+
group: "pedantic",
16261626
desc: "reimplementation of Option::map_or",
16271627
deprecation: None,
16281628
module: "option_if_let_else",

0 commit comments

Comments
 (0)