Skip to content

Commit b83030a

Browse files
committed
needless_deref
1 parent be1a73b commit b83030a

29 files changed

+197
-61
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3031,6 +3031,7 @@ Released 2018-09-13
30313031
[`needless_borrowed_reference`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrowed_reference
30323032
[`needless_collect`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_collect
30333033
[`needless_continue`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_continue
3034+
[`needless_deref`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_deref
30343035
[`needless_doctest_main`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_doctest_main
30353036
[`needless_for_each`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_for_each
30363037
[`needless_late_init`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_late_init

clippy_lints/src/enum_variants.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ fn check_variant(
154154
}
155155
}
156156
let first = &def.variants[0].ident.name.as_str();
157-
let mut pre = &first[..str_utils::camel_case_until(&*first).byte_index];
158-
let mut post = &first[str_utils::camel_case_start(&*first).byte_index..];
157+
let mut pre = &first[..str_utils::camel_case_until(first).byte_index];
158+
let mut post = &first[str_utils::camel_case_start(first).byte_index..];
159159
for var in def.variants {
160160
let name = var.ident.name.as_str();
161161

clippy_lints/src/eval_order_dependence.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ impl<'a, 'tcx> DivergenceVisitor<'a, 'tcx> {
121121
self.visit_expr(if_expr);
122122
}
123123
// make sure top level arm expressions aren't linted
124-
self.maybe_walk_expr(&*arm.body);
124+
self.maybe_walk_expr(arm.body);
125125
}
126126
},
127127
_ => walk_expr(self, e),

clippy_lints/src/let_if_seq.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl<'tcx> LateLintPass<'tcx> for LetIfSeq {
6868
if let hir::ExprKind::If(hir::Expr { kind: hir::ExprKind::DropTemps(cond), ..}, then, else_) = if_.kind;
6969
if !is_local_used(cx, *cond, canonical_id);
7070
if let hir::ExprKind::Block(then, _) = then.kind;
71-
if let Some(value) = check_assign(cx, canonical_id, &*then);
71+
if let Some(value) = check_assign(cx, canonical_id, then);
7272
if !is_local_used(cx, value, canonical_id);
7373
then {
7474
let span = stmt.span.to(if_.span);

clippy_lints/src/lib.register_all.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ store.register_group(true, "clippy::all", Some("clippy_all"), vec![
207207
LintId::of(needless_bool::NEEDLESS_BOOL),
208208
LintId::of(needless_borrowed_ref::NEEDLESS_BORROWED_REFERENCE),
209209
LintId::of(needless_late_init::NEEDLESS_LATE_INIT),
210+
LintId::of(needless_deref::NEEDLESS_DEREF),
210211
LintId::of(needless_option_as_deref::NEEDLESS_OPTION_AS_DEREF),
211212
LintId::of(needless_question_mark::NEEDLESS_QUESTION_MARK),
212213
LintId::of(needless_update::NEEDLESS_UPDATE),

clippy_lints/src/lib.register_complexity.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ store.register_group(true, "clippy::complexity", Some("clippy_complexity"), vec!
5656
LintId::of(needless_bool::BOOL_COMPARISON),
5757
LintId::of(needless_bool::NEEDLESS_BOOL),
5858
LintId::of(needless_borrowed_ref::NEEDLESS_BORROWED_REFERENCE),
59+
LintId::of(needless_deref::NEEDLESS_DEREF),
5960
LintId::of(needless_option_as_deref::NEEDLESS_OPTION_AS_DEREF),
6061
LintId::of(needless_question_mark::NEEDLESS_QUESTION_MARK),
6162
LintId::of(needless_update::NEEDLESS_UPDATE),

clippy_lints/src/lib.register_lints.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ store.register_lints(&[
361361
needless_bool::NEEDLESS_BOOL,
362362
needless_borrowed_ref::NEEDLESS_BORROWED_REFERENCE,
363363
needless_continue::NEEDLESS_CONTINUE,
364+
needless_deref::NEEDLESS_DEREF,
364365
needless_for_each::NEEDLESS_FOR_EACH,
365366
needless_late_init::NEEDLESS_LATE_INIT,
366367
needless_option_as_deref::NEEDLESS_OPTION_AS_DEREF,

clippy_lints/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ mod needless_bitwise_bool;
298298
mod needless_bool;
299299
mod needless_borrowed_ref;
300300
mod needless_continue;
301+
mod needless_deref;
301302
mod needless_for_each;
302303
mod needless_late_init;
303304
mod needless_option_as_deref;
@@ -603,6 +604,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
603604
store.register_late_pass(|| Box::new(mutex_atomic::Mutex));
604605
store.register_late_pass(|| Box::new(needless_update::NeedlessUpdate));
605606
store.register_late_pass(|| Box::new(needless_borrowed_ref::NeedlessBorrowedRef));
607+
store.register_late_pass(|| Box::new(needless_deref::NeedlessDeref));
606608
store.register_late_pass(|| Box::new(no_effect::NoEffect));
607609
store.register_late_pass(|| Box::new(temporary_assignment::TemporaryAssignment));
608610
store.register_late_pass(|| Box::new(transmute::Transmute));

clippy_lints/src/loops/never_loop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ fn never_loop_expr(expr: &Expr<'_>, main_loop_id: HirId) -> NeverLoopResult {
148148
if arms.is_empty() {
149149
e
150150
} else {
151-
let arms = never_loop_expr_branch(&mut arms.iter().map(|a| &*a.body), main_loop_id);
151+
let arms = never_loop_expr_branch(&mut arms.iter().map(|a| a.body), main_loop_id);
152152
combine_seq(e, arms)
153153
}
154154
},

clippy_lints/src/matches.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -885,8 +885,8 @@ fn check_match_bool(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>], expr:
885885
let exprs = if let PatKind::Lit(arm_bool) = arms[0].pat.kind {
886886
if let ExprKind::Lit(ref lit) = arm_bool.kind {
887887
match lit.node {
888-
LitKind::Bool(true) => Some((&*arms[0].body, &*arms[1].body)),
889-
LitKind::Bool(false) => Some((&*arms[1].body, &*arms[0].body)),
888+
LitKind::Bool(true) => Some((arms[0].body, arms[1].body)),
889+
LitKind::Bool(false) => Some((arms[1].body, arms[0].body)),
890890
_ => None,
891891
}
892892
} else {

0 commit comments

Comments
 (0)