From d110d309b64828142a2a9f4649e3e4647b54cb0f Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Tue, 11 Jun 2019 12:47:30 +0300 Subject: [PATCH] rustc_mir: deny(unused_lifetimes). --- .../borrow_check/nll/invalidation.rs | 2 +- src/librustc_mir/borrow_check/path_utils.rs | 2 +- src/librustc_mir/build/matches/mod.rs | 2 +- src/librustc_mir/build/matches/test.rs | 2 +- src/librustc_mir/interpret/snapshot.rs | 4 +-- src/librustc_mir/interpret/validity.rs | 2 +- src/librustc_mir/lib.rs | 1 + src/librustc_mir/monomorphize/collector.rs | 2 +- src/librustc_mir/transform/check_unsafety.rs | 2 +- src/librustc_mir/transform/generator.rs | 4 +-- src/librustc_mir/transform/simplify.rs | 2 +- src/librustc_mir/util/elaborate_drops.rs | 26 +++++++++---------- src/librustc_mir/util/liveness.rs | 2 +- 13 files changed, 27 insertions(+), 26 deletions(-) diff --git a/src/librustc_mir/borrow_check/nll/invalidation.rs b/src/librustc_mir/borrow_check/nll/invalidation.rs index 8fa3bb184721..516eb6d2941e 100644 --- a/src/librustc_mir/borrow_check/nll/invalidation.rs +++ b/src/librustc_mir/borrow_check/nll/invalidation.rs @@ -258,7 +258,7 @@ fn visit_terminator_kind( } } -impl<'cg, 'cx, 'tcx, 'gcx> InvalidationGenerator<'cx, 'tcx, 'gcx> { +impl<'cx, 'tcx, 'gcx> InvalidationGenerator<'cx, 'tcx, 'gcx> { /// Simulates mutation of a place. fn mutate_place( &mut self, diff --git a/src/librustc_mir/borrow_check/path_utils.rs b/src/librustc_mir/borrow_check/path_utils.rs index dc4235ea6d09..a11e5d9a5568 100644 --- a/src/librustc_mir/borrow_check/path_utils.rs +++ b/src/librustc_mir/borrow_check/path_utils.rs @@ -10,7 +10,7 @@ /// Returns `true` if the borrow represented by `kind` is /// allowed to be split into separate Reservation and /// Activation phases. -pub(super) fn allow_two_phase_borrow<'a, 'tcx, 'gcx: 'tcx>(kind: BorrowKind) -> bool { +pub(super) fn allow_two_phase_borrow(kind: BorrowKind) -> bool { kind.allows_two_phase_borrow() } diff --git a/src/librustc_mir/build/matches/mod.rs b/src/librustc_mir/build/matches/mod.rs index 20d1423f8a8b..fbb6161e8fe5 100644 --- a/src/librustc_mir/build/matches/mod.rs +++ b/src/librustc_mir/build/matches/mod.rs @@ -1575,7 +1575,7 @@ fn bind_and_guard_matched_candidate<'pat>( /// Append `AscribeUserType` statements onto the end of `block` /// for each ascription - fn ascribe_types<'pat>( + fn ascribe_types( &mut self, block: BasicBlock, ascriptions: &[Ascription<'tcx>], diff --git a/src/librustc_mir/build/matches/test.rs b/src/librustc_mir/build/matches/test.rs index 0995a2f7fdf4..c767fff92532 100644 --- a/src/librustc_mir/build/matches/test.rs +++ b/src/librustc_mir/build/matches/test.rs @@ -463,7 +463,7 @@ fn compare(&mut self, /// that it *doesn't* apply. For now, we return false, indicate that the /// test does not apply to this candidate, but it might be we can get /// tighter match code if we do something a bit different. - pub fn sort_candidate<'pat, 'cand>( + pub fn sort_candidate<'pat>( &mut self, test_place: &Place<'tcx>, test: &Test<'tcx>, diff --git a/src/librustc_mir/interpret/snapshot.rs b/src/librustc_mir/interpret/snapshot.rs index d806caf44151..4e13291c787d 100644 --- a/src/librustc_mir/interpret/snapshot.rs +++ b/src/librustc_mir/interpret/snapshot.rs @@ -315,7 +315,7 @@ struct FrameSnapshot<'a, 'tcx: 'a> { stmt: usize, } -impl_stable_hash_for!(impl<'mir, 'tcx: 'mir> for struct Frame<'mir, 'tcx> { +impl_stable_hash_for!(impl<> for struct Frame<'mir, 'tcx> { body, instance, span, @@ -422,7 +422,7 @@ fn hash(&self, state: &mut H) { } } -impl_stable_hash_for!(impl<'tcx, 'b, 'mir> for struct InterpSnapshot<'b, 'mir, 'tcx> { +impl_stable_hash_for!(impl<> for struct InterpSnapshot<'_, 'mir, 'tcx> { // Not hashing memory: Avoid hashing memory all the time during execution memory -> _, stack, diff --git a/src/librustc_mir/interpret/validity.rs b/src/librustc_mir/interpret/validity.rs index 21704bf66e8d..6768d9ec6bc1 100644 --- a/src/librustc_mir/interpret/validity.rs +++ b/src/librustc_mir/interpret/validity.rs @@ -81,7 +81,7 @@ pub struct RefTracking { pub todo: Vec<(T, Vec)>, } -impl<'tcx, T: Copy + Eq + Hash> RefTracking { +impl RefTracking { pub fn new(op: T) -> Self { let mut ref_tracking = RefTracking { seen: FxHashSet::default(), diff --git a/src/librustc_mir/lib.rs b/src/librustc_mir/lib.rs index 53302810b405..a7cbe84330d8 100644 --- a/src/librustc_mir/lib.rs +++ b/src/librustc_mir/lib.rs @@ -29,6 +29,7 @@ #![deny(rust_2018_idioms)] #![deny(internal)] +#![deny(unused_lifetimes)] #![allow(explicit_outlives_requirements)] #[macro_use] extern crate log; diff --git a/src/librustc_mir/monomorphize/collector.rs b/src/librustc_mir/monomorphize/collector.rs index f084919ac057..706ace0c1f1b 100644 --- a/src/librustc_mir/monomorphize/collector.rs +++ b/src/librustc_mir/monomorphize/collector.rs @@ -907,7 +907,7 @@ fn find_vtable_types_for_unsizing<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, } } -fn create_fn_mono_item<'a, 'tcx>(instance: Instance<'tcx>) -> MonoItem<'tcx> { +fn create_fn_mono_item<'tcx>(instance: Instance<'tcx>) -> MonoItem<'tcx> { debug!("create_fn_mono_item(instance={})", instance); MonoItem::Fn(instance) } diff --git a/src/librustc_mir/transform/check_unsafety.rs b/src/librustc_mir/transform/check_unsafety.rs index 87581c530b9d..b8077d224e4e 100644 --- a/src/librustc_mir/transform/check_unsafety.rs +++ b/src/librustc_mir/transform/check_unsafety.rs @@ -32,7 +32,7 @@ pub struct UnsafetyChecker<'a, 'tcx: 'a> { inherited_blocks: Vec<(hir::HirId, bool)>, } -impl<'a, 'gcx, 'tcx> UnsafetyChecker<'a, 'tcx> { +impl<'a, 'tcx> UnsafetyChecker<'a, 'tcx> { fn new( const_context: bool, min_const_fn: bool, diff --git a/src/librustc_mir/transform/generator.rs b/src/librustc_mir/transform/generator.rs index d2c75ebe8d6a..5ac8a41ffeea 100644 --- a/src/librustc_mir/transform/generator.rs +++ b/src/librustc_mir/transform/generator.rs @@ -829,14 +829,14 @@ fn create_generator_resume_function<'a, 'tcx>( dump_mir(tcx, None, "generator_resume", &0, source, body, |_, _| Ok(()) ); } -fn source_info<'a, 'tcx>(body: &Body<'tcx>) -> SourceInfo { +fn source_info<'tcx>(body: &Body<'tcx>) -> SourceInfo { SourceInfo { span: body.span, scope: OUTERMOST_SOURCE_SCOPE, } } -fn insert_clean_drop<'a, 'tcx>(body: &mut Body<'tcx>) -> BasicBlock { +fn insert_clean_drop<'tcx>(body: &mut Body<'tcx>) -> BasicBlock { let return_block = insert_term_block(body, TerminatorKind::Return); // Create a block to destroy an unresumed generators. This can only destroy upvars. diff --git a/src/librustc_mir/transform/simplify.rs b/src/librustc_mir/transform/simplify.rs index f1ca93ec13ff..4d1c90bc56d9 100644 --- a/src/librustc_mir/transform/simplify.rs +++ b/src/librustc_mir/transform/simplify.rs @@ -323,7 +323,7 @@ fn run_pass<'a, 'tcx>(&self, } /// Construct the mapping while swapping out unused stuff out from the `vec`. -fn make_local_map<'tcx, V>( +fn make_local_map( vec: &mut IndexVec, mask: BitSet, ) -> IndexVec> { diff --git a/src/librustc_mir/util/elaborate_drops.rs b/src/librustc_mir/util/elaborate_drops.rs index 6d761525639b..0fbf8bb3e273 100644 --- a/src/librustc_mir/util/elaborate_drops.rs +++ b/src/librustc_mir/util/elaborate_drops.rs @@ -147,7 +147,7 @@ fn tcx(&self) -> TyCtxt<'b, 'tcx, 'tcx> { // // FIXME: I think we should just control the flags externally, // and then we do not need this machinery. - pub fn elaborate_drop<'a>(&mut self, bb: BasicBlock) { + pub fn elaborate_drop(&mut self, bb: BasicBlock) { debug!("elaborate_drop({:?})", self); let style = self.elaborator.drop_style(self.path, DropFlagMode::Deep); debug!("elaborate_drop({:?}): live - {:?}", self, style); @@ -285,7 +285,7 @@ fn drop_ladder_bottom(&mut self) -> (BasicBlock, Unwind) { /// /// NOTE: this does not clear the master drop flag, so you need /// to point succ/unwind on a `drop_ladder_bottom`. - fn drop_ladder<'a>(&mut self, + fn drop_ladder(&mut self, fields: Vec<(Place<'tcx>, Option)>, succ: BasicBlock, unwind: Unwind) @@ -314,7 +314,7 @@ fn drop_ladder<'a>(&mut self, (*normal_ladder.last().unwrap(), *unwind_ladder.last().unwrap()) } - fn open_drop_for_tuple<'a>(&mut self, tys: &[Ty<'tcx>]) + fn open_drop_for_tuple(&mut self, tys: &[Ty<'tcx>]) -> BasicBlock { debug!("open_drop_for_tuple({:?}, {:?})", self, tys); @@ -328,7 +328,7 @@ fn open_drop_for_tuple<'a>(&mut self, tys: &[Ty<'tcx>]) self.drop_ladder(fields, succ, unwind).0 } - fn open_drop_for_box<'a>(&mut self, adt: &'tcx ty::AdtDef, substs: SubstsRef<'tcx>) + fn open_drop_for_box(&mut self, adt: &'tcx ty::AdtDef, substs: SubstsRef<'tcx>) -> BasicBlock { debug!("open_drop_for_box({:?}, {:?}, {:?})", self, adt, substs); @@ -346,7 +346,7 @@ fn open_drop_for_box<'a>(&mut self, adt: &'tcx ty::AdtDef, substs: SubstsRef<'tc self.drop_subpath(&interior, interior_path, succ, unwind_succ) } - fn open_drop_for_adt<'a>(&mut self, adt: &'tcx ty::AdtDef, substs: SubstsRef<'tcx>) + fn open_drop_for_adt(&mut self, adt: &'tcx ty::AdtDef, substs: SubstsRef<'tcx>) -> BasicBlock { debug!("open_drop_for_adt({:?}, {:?}, {:?})", self, adt, substs); if adt.variants.len() == 0 { @@ -505,7 +505,7 @@ fn adt_switch_block(&mut self, self.drop_flag_test_block(switch_block, succ, unwind) } - fn destructor_call_block<'a>(&mut self, (succ, unwind): (BasicBlock, Unwind)) + fn destructor_call_block(&mut self, (succ, unwind): (BasicBlock, Unwind)) -> BasicBlock { debug!("destructor_call_block({:?}, {:?})", self, succ); @@ -787,7 +787,7 @@ fn drop_loop_pair( /// /// This creates a "drop ladder" that drops the needed fields of the /// ADT, both in the success case or if one of the destructors fail. - fn open_drop<'a>(&mut self) -> BasicBlock { + fn open_drop(&mut self) -> BasicBlock { let ty = self.place_ty(self.place); match ty.sty { ty::Closure(def_id, substs) => { @@ -837,7 +837,7 @@ fn open_drop<'a>(&mut self) -> BasicBlock { /// if FLAG(self.path) /// if let Some(mode) = mode: FLAG(self.path)[mode] = false /// drop(self.place) - fn complete_drop<'a>(&mut self, + fn complete_drop(&mut self, drop_mode: Option, succ: BasicBlock, unwind: Unwind) -> BasicBlock @@ -867,7 +867,7 @@ fn drop_flag_reset_block(&mut self, block } - fn elaborated_drop_block<'a>(&mut self) -> BasicBlock { + fn elaborated_drop_block(&mut self) -> BasicBlock { debug!("elaborated_drop_block({:?})", self); let unwind = self.unwind; // FIXME(#43234) let succ = self.succ; @@ -876,7 +876,7 @@ fn elaborated_drop_block<'a>(&mut self) -> BasicBlock { blk } - fn box_free_block<'a>( + fn box_free_block( &mut self, adt: &'tcx ty::AdtDef, substs: SubstsRef<'tcx>, @@ -887,7 +887,7 @@ fn box_free_block<'a>( self.drop_flag_test_block(block, target, unwind) } - fn unelaborated_free_block<'a>( + fn unelaborated_free_block( &mut self, adt: &'tcx ty::AdtDef, substs: SubstsRef<'tcx>, @@ -917,7 +917,7 @@ fn unelaborated_free_block<'a>( free_block } - fn drop_block<'a>(&mut self, target: BasicBlock, unwind: Unwind) -> BasicBlock { + fn drop_block(&mut self, target: BasicBlock, unwind: Unwind) -> BasicBlock { let block = TerminatorKind::Drop { location: self.place.clone(), target, @@ -947,7 +947,7 @@ fn drop_flag_test_block(&mut self, } } - fn new_block<'a>(&mut self, + fn new_block(&mut self, unwind: Unwind, k: TerminatorKind<'tcx>) -> BasicBlock diff --git a/src/librustc_mir/util/liveness.rs b/src/librustc_mir/util/liveness.rs index 8bc43b610746..82ec5ab5f8a6 100644 --- a/src/librustc_mir/util/liveness.rs +++ b/src/librustc_mir/util/liveness.rs @@ -109,7 +109,7 @@ pub enum DefUse { Drop, } -pub fn categorize<'tcx>(context: PlaceContext) -> Option { +pub fn categorize(context: PlaceContext) -> Option { match context { /////////////////////////////////////////////////////////////////////////// // DEFS