Skip to content

Commit 93f0f5d

Browse files
committed
Last few tweaks
1 parent 5150277 commit 93f0f5d

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
@@ -1161,6 +1161,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
11611161
LintId::of(&needless_continue::NEEDLESS_CONTINUE),
11621162
LintId::of(&needless_pass_by_value::NEEDLESS_PASS_BY_VALUE),
11631163
LintId::of(&non_expressive_names::SIMILAR_NAMES),
1164+
LintId::of(&option_if_let_else::OPTION_IF_LET_ELSE),
11641165
LintId::of(&ranges::RANGE_PLUS_ONE),
11651166
LintId::of(&shadow::SHADOW_UNRELATED),
11661167
LintId::of(&strings::STRING_ADD_ASSIGN),
@@ -1372,7 +1373,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
13721373
LintId::of(&non_expressive_names::MANY_SINGLE_CHAR_NAMES),
13731374
LintId::of(&open_options::NONSENSICAL_OPEN_OPTIONS),
13741375
LintId::of(&option_env_unwrap::OPTION_ENV_UNWRAP),
1375-
LintId::of(&option_if_let_else::OPTION_IF_LET_ELSE),
13761376
LintId::of(&overflow_check_conditional::OVERFLOW_CHECK_CONDITIONAL),
13771377
LintId::of(&panic_unimplemented::PANIC_PARAMS),
13781378
LintId::of(&partialeq_ne_impl::PARTIALEQ_NE_IMPL),
@@ -1521,7 +1521,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
15211521
LintId::of(&new_without_default::NEW_WITHOUT_DEFAULT),
15221522
LintId::of(&non_expressive_names::JUST_UNDERSCORES_AND_DIGITS),
15231523
LintId::of(&non_expressive_names::MANY_SINGLE_CHAR_NAMES),
1524-
LintId::of(&option_if_let_else::OPTION_IF_LET_ELSE),
15251524
LintId::of(&panic_unimplemented::PANIC_PARAMS),
15261525
LintId::of(&ptr::CMP_NULL),
15271526
LintId::of(&ptr::PTR_ARG),

clippy_lints/src/minmax.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,5 @@ fn fetch_const<'a>(cx: &LateContext<'_>, args: &'a [Expr<'a>], m: MinMax) -> Opt
9999
} else {
100100
None
101101
}
102-
}
103-
).map(|(c, arg)| (m, c, arg))
102+
})
104103
}

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)