From b46f5b4a98125c6c3a36d5014d6ca98d58c0352c Mon Sep 17 00:00:00 2001 From: flip1995 Date: Fri, 4 Oct 2019 14:24:47 +0200 Subject: [PATCH] Rustup to rust-lang/rust#64874 Episode 1 - The simple cases --- clippy_lints/src/escape.rs | 16 ++++++---------- clippy_lints/src/loops.rs | 21 +++++++-------------- clippy_lints/src/needless_pass_by_value.rs | 15 ++++----------- clippy_lints/src/utils/usage.rs | 14 +++----------- 4 files changed, 20 insertions(+), 46 deletions(-) diff --git a/clippy_lints/src/escape.rs b/clippy_lints/src/escape.rs index 5b890f6abe0..3055e081c62 100644 --- a/clippy_lints/src/escape.rs +++ b/clippy_lints/src/escape.rs @@ -85,7 +85,6 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxedLocal { cx.param_env, region_scope_tree, cx.tables, - None, ) .consume_body(body); @@ -114,15 +113,14 @@ fn is_argument(map: &hir::map::Map<'_>, id: HirId) -> bool { } impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> { - fn consume(&mut self, _: HirId, _: Span, cmt: &cmt_<'tcx>, mode: ConsumeMode) { + fn consume(&mut self, cmt: &cmt_<'tcx>, mode: ConsumeMode) { if let Categorization::Local(lid) = cmt.cat { - if let Move(DirectRefMove) | Move(CaptureMove) = mode { + if let ConsumeMode::Move = mode { // moved out or in. clearly can't be localized self.set.remove(&lid); } } } - fn matched_pat(&mut self, _: &Pat, _: &cmt_<'tcx>, _: MatchMode) {} fn consume_pat(&mut self, consume_pat: &Pat, cmt: &cmt_<'tcx>, _: ConsumeMode) { let map = &self.cx.tcx.hir(); if is_argument(map, consume_pat.hir_id) { @@ -137,7 +135,7 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> { } return; } - if let Categorization::Rvalue(..) = cmt.cat { + if let Categorization::Rvalue = cmt.cat { if let Some(Node::Stmt(st)) = map.find(map.get_parent_node(cmt.hir_id)) { if let StmtKind::Local(ref loc) = st.kind { if let Some(ref ex) = loc.init { @@ -163,12 +161,10 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> { } } } + fn borrow( &mut self, - _: HirId, - _: Span, cmt: &cmt_<'tcx>, - _: ty::Region<'_>, _: ty::BorrowKind, loan_cause: LoanCause, ) { @@ -192,8 +188,8 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> { } } } - fn decl_without_init(&mut self, _: HirId, _: Span) {} - fn mutate(&mut self, _: HirId, _: Span, _: &cmt_<'tcx>, _: MutateMode) {} + + fn mutate(&mut self, _: &cmt_<'tcx>) {} } impl<'a, 'tcx> EscapeDelegate<'a, 'tcx> { diff --git a/clippy_lints/src/loops.rs b/clippy_lints/src/loops.rs index 52477f68cd3..ea496a0294a 100644 --- a/clippy_lints/src/loops.rs +++ b/clippy_lints/src/loops.rs @@ -1547,37 +1547,31 @@ struct MutatePairDelegate { } impl<'tcx> Delegate<'tcx> for MutatePairDelegate { - fn consume(&mut self, _: HirId, _: Span, _: &cmt_<'tcx>, _: ConsumeMode) {} + fn consume(&mut self, _: &cmt_<'tcx>, _: ConsumeMode) {} - fn matched_pat(&mut self, _: &Pat, _: &cmt_<'tcx>, _: MatchMode) {} - - fn consume_pat(&mut self, _: &Pat, _: &cmt_<'tcx>, _: ConsumeMode) {} - - fn borrow(&mut self, _: HirId, sp: Span, cmt: &cmt_<'tcx>, _: ty::Region<'_>, bk: ty::BorrowKind, _: LoanCause) { + fn borrow(&mut self, cmt: &cmt_<'tcx>, bk: ty::BorrowKind) { if let ty::BorrowKind::MutBorrow = bk { if let Categorization::Local(id) = cmt.cat { if Some(id) == self.hir_id_low { - self.span_low = Some(sp) + self.span_low = Some(cmt.span) } if Some(id) == self.hir_id_high { - self.span_high = Some(sp) + self.span_high = Some(cmt.span) } } } } - fn mutate(&mut self, _: HirId, sp: Span, cmt: &cmt_<'tcx>, _: MutateMode) { + fn mutate(&mut self, cmt: &cmt_<'tcx>) { if let Categorization::Local(id) = cmt.cat { if Some(id) == self.hir_id_low { - self.span_low = Some(sp) + self.span_low = Some(cmt.span) } if Some(id) == self.hir_id_high { - self.span_high = Some(sp) + self.span_high = Some(cmt.span) } } } - - fn decl_without_init(&mut self, _: HirId, _: Span) {} } impl<'tcx> MutatePairDelegate { @@ -1655,7 +1649,6 @@ fn check_for_mutation( cx.param_env, region_scope_tree, cx.tables, - None, ) .walk_expr(body); delegate.mutation_span() diff --git a/clippy_lints/src/needless_pass_by_value.rs b/clippy_lints/src/needless_pass_by_value.rs index e2ac39f8262..932660da19c 100644 --- a/clippy_lints/src/needless_pass_by_value.rs +++ b/clippy_lints/src/needless_pass_by_value.rs @@ -143,7 +143,6 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue { cx.param_env, region_scope_tree, cx.tables, - None, ) .consume_body(body); ctx @@ -400,9 +399,9 @@ impl<'a, 'tcx> MovedVariablesCtxt<'a, 'tcx> { } impl<'a, 'tcx> euv::Delegate<'tcx> for MovedVariablesCtxt<'a, 'tcx> { - fn consume(&mut self, consume_id: HirId, consume_span: Span, cmt: &mc::cmt_<'tcx>, mode: euv::ConsumeMode) { - if let euv::ConsumeMode::Move(_) = mode { - self.move_common(consume_id, consume_span, cmt); + fn consume(&mut self, cmt: &mc::cmt_<'tcx>, mode: euv::ConsumeMode) { + if let euv::ConsumeMode::Move = mode { + self.move_common(cmt.hir_id, cmt.span, cmt); } } @@ -422,18 +421,12 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for MovedVariablesCtxt<'a, 'tcx> { fn borrow( &mut self, - _: HirId, - _: Span, _: &mc::cmt_<'tcx>, - _: ty::Region<'_>, _: ty::BorrowKind, - _: euv::LoanCause, ) { } - fn mutate(&mut self, _: HirId, _: Span, _: &mc::cmt_<'tcx>, _: euv::MutateMode) {} - - fn decl_without_init(&mut self, _: HirId, _: Span) {} + fn mutate(&mut self, _: &mc::cmt_<'tcx>) {} } fn unwrap_downcast_or_interior<'a, 'tcx>(mut cmt: &'a mc::cmt_<'tcx>) -> mc::cmt_<'tcx> { diff --git a/clippy_lints/src/utils/usage.rs b/clippy_lints/src/utils/usage.rs index 3427d88ff03..41662099fd3 100644 --- a/clippy_lints/src/utils/usage.rs +++ b/clippy_lints/src/utils/usage.rs @@ -6,7 +6,6 @@ use rustc::middle::mem_categorization::cmt_; use rustc::middle::mem_categorization::Categorization; use rustc::ty; use rustc_data_structures::fx::FxHashSet; -use syntax::source_map::Span; /// Returns a set of mutated local variable IDs, or `None` if mutations could not be determined. pub fn mutated_variables<'a, 'tcx>(expr: &'tcx Expr, cx: &'a LateContext<'a, 'tcx>) -> Option> { @@ -23,7 +22,6 @@ pub fn mutated_variables<'a, 'tcx>(expr: &'tcx Expr, cx: &'a LateContext<'a, 'tc cx.param_env, region_scope_tree, cx.tables, - None, ) .walk_expr(expr); @@ -66,21 +64,15 @@ impl<'tcx> MutVarsDelegate { } impl<'tcx> Delegate<'tcx> for MutVarsDelegate { - fn consume(&mut self, _: HirId, _: Span, _: &cmt_<'tcx>, _: ConsumeMode) {} + fn consume(&mut self, _: &cmt_<'tcx>, _: ConsumeMode) {} - fn matched_pat(&mut self, _: &Pat, _: &cmt_<'tcx>, _: MatchMode) {} - - fn consume_pat(&mut self, _: &Pat, _: &cmt_<'tcx>, _: ConsumeMode) {} - - fn borrow(&mut self, _: HirId, _: Span, cmt: &cmt_<'tcx>, _: ty::Region<'_>, bk: ty::BorrowKind, _: LoanCause) { + fn borrow(&mut self, cmt: &cmt_<'tcx>, bk: ty::BorrowKind) { if let ty::BorrowKind::MutBorrow = bk { self.update(&cmt.cat) } } - fn mutate(&mut self, _: HirId, _: Span, cmt: &cmt_<'tcx>, _: MutateMode) { + fn mutate(&mut self, cmt: &cmt_<'tcx>) { self.update(&cmt.cat) } - - fn decl_without_init(&mut self, _: HirId, _: Span) {} }