From b510ea1487286123c00f425b368a8328637ac947 Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Wed, 17 Jun 2015 01:39:20 +0300 Subject: [PATCH] Clean up unused argument/variable warnings. --- src/librustc/middle/free_region.rs | 1 - src/librustc/middle/infer/combine.rs | 1 - src/librustc/middle/infer/higher_ranked/mod.rs | 2 -- src/librustc/middle/mem_categorization.rs | 1 - src/librustc/middle/traits/coherence.rs | 3 +-- src/librustc/middle/traits/fulfill.rs | 9 +++------ src/librustc/middle/traits/mod.rs | 7 ++----- src/librustc/middle/traits/project.rs | 4 ---- src/librustc/middle/traits/select.rs | 3 +-- src/librustc/middle/traits/util.rs | 3 +-- src/librustc/middle/ty_relate/mod.rs | 1 - src/librustc_borrowck/borrowck/fragments.rs | 10 ++++------ src/librustc_trans/trans/base.rs | 1 - src/librustc_trans/trans/foreign.rs | 2 -- src/librustc_trans/trans/glue.rs | 8 +++++--- src/librustc_typeck/check/assoc.rs | 2 +- src/librustc_typeck/check/method/probe.rs | 3 +-- src/librustc_typeck/check/mod.rs | 6 ++---- src/librustc_typeck/check/regionck.rs | 5 +---- src/librustc_typeck/check/upvar.rs | 4 ---- 20 files changed, 22 insertions(+), 54 deletions(-) diff --git a/src/librustc/middle/free_region.rs b/src/librustc/middle/free_region.rs index a245de3deae..ed1ce3458a2 100644 --- a/src/librustc/middle/free_region.rs +++ b/src/librustc/middle/free_region.rs @@ -29,7 +29,6 @@ impl FreeRegionMap { } pub fn relate_free_regions_from_implications<'tcx>(&mut self, - tcx: &ty::ctxt<'tcx>, implications: &[Implication<'tcx>]) { for implication in implications { diff --git a/src/librustc/middle/infer/combine.rs b/src/librustc/middle/infer/combine.rs index decd07b87c0..30242dac695 100644 --- a/src/librustc/middle/infer/combine.rs +++ b/src/librustc/middle/infer/combine.rs @@ -187,7 +187,6 @@ impl<'a, 'tcx> CombineFields<'a, 'tcx> { b_vid: ty::TyVid) -> RelateResult<'tcx, ()> { - let tcx = self.infcx.tcx; let mut stack = Vec::new(); stack.push((a_ty, dir, b_vid)); loop { diff --git a/src/librustc/middle/infer/higher_ranked/mod.rs b/src/librustc/middle/infer/higher_ranked/mod.rs index d38de0f5a3f..d6001270d1c 100644 --- a/src/librustc/middle/infer/higher_ranked/mod.rs +++ b/src/librustc/middle/infer/higher_ranked/mod.rs @@ -46,8 +46,6 @@ impl<'a,'tcx> HigherRankedRelations<'a,'tcx> for CombineFields<'a,'tcx> { -> RelateResult<'tcx, Binder> where T: Relate<'a,'tcx> { - let tcx = self.infcx.tcx; - debug!("higher_ranked_sub(a={}, b={})", a.repr(), b.repr()); diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index a3e12db6644..3dbb3dfae2f 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -418,7 +418,6 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { } fn pat_ty(&self, pat: &ast::Pat) -> McResult> { - let tcx = self.typer.tcx(); let base_ty = try!(self.typer.node_ty(pat.id)); // FIXME (Issue #18207): This code detects whether we are // looking at a `ref x`, and if so, figures out what the type diff --git a/src/librustc/middle/traits/coherence.rs b/src/librustc/middle/traits/coherence.rs index b7568b565ce..622ed134a60 100644 --- a/src/librustc/middle/traits/coherence.rs +++ b/src/librustc/middle/traits/coherence.rs @@ -81,7 +81,6 @@ fn overlap(selcx: &mut SelectionContext, debug!("overlap: subtraitref check succeeded"); // Are any of the obligations unsatisfiable? If so, no overlap. - let tcx = selcx.tcx(); let infcx = selcx.infcx(); let opt_failing_obligation = a_obligations.iter() @@ -155,7 +154,7 @@ fn impl_trait_ref_and_oblig<'a,'tcx>(selcx: &mut SelectionContext<'a,'tcx>, let Normalized { value: predicates, obligations: normalization_obligations2 } = project::normalize(selcx, ObligationCause::dummy(), &predicates); let impl_obligations = - util::predicates_for_generics(selcx.tcx(), ObligationCause::dummy(), 0, &predicates); + util::predicates_for_generics(ObligationCause::dummy(), 0, &predicates); let impl_obligations: Vec<_> = impl_obligations.into_iter() diff --git a/src/librustc/middle/traits/fulfill.rs b/src/librustc/middle/traits/fulfill.rs index 8615a7822be..418c4522cd9 100644 --- a/src/librustc/middle/traits/fulfill.rs +++ b/src/librustc/middle/traits/fulfill.rs @@ -171,12 +171,11 @@ impl<'tcx> FulfillmentContext<'tcx> { } pub fn register_region_obligation<'a>(&mut self, - infcx: &InferCtxt<'a,'tcx>, t_a: Ty<'tcx>, r_b: ty::Region, cause: ObligationCause<'tcx>) { - register_region_obligation(infcx.tcx, t_a, r_b, cause, &mut self.region_obligations); + register_region_obligation(t_a, r_b, cause, &mut self.region_obligations); } pub fn register_predicate_obligation<'a>(&mut self, @@ -366,7 +365,6 @@ fn process_predicate<'a,'tcx>(selcx: &mut SelectionContext<'a,'tcx>, * type inference. */ - let tcx = selcx.tcx(); match obligation.predicate { ty::Predicate::Trait(ref data) => { let trait_obligation = obligation.with(data.clone()); @@ -430,7 +428,7 @@ fn process_predicate<'a,'tcx>(selcx: &mut SelectionContext<'a,'tcx>, CodeSelectionError(Unimplemented))); } else { let ty::OutlivesPredicate(t_a, r_b) = binder.0; - register_region_obligation(tcx, t_a, r_b, + register_region_obligation(t_a, r_b, obligation.cause.clone(), region_obligations); } @@ -471,8 +469,7 @@ impl<'tcx> Repr for RegionObligation<'tcx> { } } -fn register_region_obligation<'tcx>(tcx: &ty::ctxt<'tcx>, - t_a: Ty<'tcx>, +fn register_region_obligation<'tcx>(t_a: Ty<'tcx>, r_b: ty::Region, cause: ObligationCause<'tcx>, region_obligations: &mut NodeMap>>) diff --git a/src/librustc/middle/traits/mod.rs b/src/librustc/middle/traits/mod.rs index 036aaedb446..551bafc5716 100644 --- a/src/librustc/middle/traits/mod.rs +++ b/src/librustc/middle/traits/mod.rs @@ -300,12 +300,11 @@ pub struct VtableObjectData<'tcx> { } /// Creates predicate obligations from the generic bounds. -pub fn predicates_for_generics<'tcx>(tcx: &ty::ctxt<'tcx>, - cause: ObligationCause<'tcx>, +pub fn predicates_for_generics<'tcx>(cause: ObligationCause<'tcx>, generic_bounds: &ty::InstantiatedPredicates<'tcx>) -> PredicateObligations<'tcx> { - util::predicates_for_generics(tcx, cause, 0, generic_bounds) + util::predicates_for_generics(cause, 0, generic_bounds) } /// Determines whether the type `ty` is known to meet `bound` and @@ -436,8 +435,6 @@ pub fn fully_normalize<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>, -> Result>> where T : TypeFoldable<'tcx> + HasProjectionTypes + Clone + Repr { - let tcx = closure_typer.tcx(); - debug!("normalize_param_env(value={})", value.repr()); let mut selcx = &mut SelectionContext::new(infcx, closure_typer); diff --git a/src/librustc/middle/traits/project.rs b/src/librustc/middle/traits/project.rs index ef89dc384bb..1b5f79452c0 100644 --- a/src/librustc/middle/traits/project.rs +++ b/src/librustc/middle/traits/project.rs @@ -373,7 +373,6 @@ fn opt_normalize_projection_type<'a,'b,'tcx>( obligations.repr()); if ty::type_has_projection(projected_ty) { - let tcx = selcx.tcx(); let mut normalizer = AssociatedTypeNormalizer::new(selcx, cause, depth); let normalized_ty = normalizer.fold(&projected_ty); @@ -633,7 +632,6 @@ fn assemble_candidates_from_object_type<'cx,'tcx>( candidate_set: &mut ProjectionTyCandidateSet<'tcx>, object_ty: Ty<'tcx>) { - let infcx = selcx.infcx(); debug!("assemble_candidates_from_object_type(object_ty={})", object_ty.repr()); let data = match object_ty.sty { @@ -745,8 +743,6 @@ fn confirm_candidate<'cx,'tcx>( candidate: ProjectionTyCandidate<'tcx>) -> (Ty<'tcx>, Vec>) { - let infcx = selcx.infcx(); - debug!("confirm_candidate(candidate={}, obligation={})", candidate.repr(), obligation.repr()); diff --git a/src/librustc/middle/traits/select.rs b/src/librustc/middle/traits/select.rs index ea5d789683f..5519ad97d22 100644 --- a/src/librustc/middle/traits/select.rs +++ b/src/librustc/middle/traits/select.rs @@ -2896,8 +2896,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { let predicates = normalize_with_depth(self, cause.clone(), recursion_depth, &predicates); let mut predicates = self.infcx().plug_leaks(skol_map, snapshot, &predicates); let mut obligations = - util::predicates_for_generics(self.tcx(), - cause, + util::predicates_for_generics(cause, recursion_depth, &predicates.value); obligations.append(&mut predicates.obligations); diff --git a/src/librustc/middle/traits/util.rs b/src/librustc/middle/traits/util.rs index a3ce5a90c2b..475e2f69a4c 100644 --- a/src/librustc/middle/traits/util.rs +++ b/src/librustc/middle/traits/util.rs @@ -321,8 +321,7 @@ impl<'tcx> fmt::Debug for super::VtableObjectData<'tcx> { } /// See `super::obligations_for_generics` -pub fn predicates_for_generics<'tcx>(tcx: &ty::ctxt<'tcx>, - cause: ObligationCause<'tcx>, +pub fn predicates_for_generics<'tcx>(cause: ObligationCause<'tcx>, recursion_depth: usize, generic_bounds: &ty::InstantiatedPredicates<'tcx>) -> Vec> diff --git a/src/librustc/middle/ty_relate/mod.rs b/src/librustc/middle/ty_relate/mod.rs index a97f9d0b9f8..e9c84f4c9ce 100644 --- a/src/librustc/middle/ty_relate/mod.rs +++ b/src/librustc/middle/ty_relate/mod.rs @@ -191,7 +191,6 @@ fn relate_region_params<'a,'tcx:'a,R>(relation: &mut R, -> RelateResult<'tcx, Vec> where R: TypeRelation<'a,'tcx> { - let tcx = relation.tcx(); let num_region_params = a_rs.len(); debug!("relate_region_params(a_rs={}, \ diff --git a/src/librustc_borrowck/borrowck/fragments.rs b/src/librustc_borrowck/borrowck/fragments.rs index 75e9c09fb3d..6f896fffd3d 100644 --- a/src/librustc_borrowck/borrowck/fragments.rs +++ b/src/librustc_borrowck/borrowck/fragments.rs @@ -42,7 +42,7 @@ enum Fragment { } impl Fragment { - fn loan_path_repr<'tcx>(&self, move_data: &MoveData<'tcx>, tcx: &ty::ctxt<'tcx>) -> String { + fn loan_path_repr(&self, move_data: &MoveData) -> String { let repr = |mpi| move_data.path_loan_path(mpi).repr(); match *self { Just(mpi) => repr(mpi), @@ -50,9 +50,7 @@ impl Fragment { } } - fn loan_path_user_string<'tcx>(&self, - move_data: &MoveData<'tcx>, - tcx: &ty::ctxt<'tcx>) -> String { + fn loan_path_user_string(&self, move_data: &MoveData) -> String { let user_string = |mpi| move_data.path_loan_path(mpi).user_string(); match *self { Just(mpi) => user_string(mpi), @@ -138,7 +136,7 @@ pub fn instrument_move_fragments<'tcx>(this: &MoveData<'tcx>, let instrument_all_fragments = |kind, vec_rc: &Vec| { for (i, f) in vec_rc.iter().enumerate() { - let render = || f.loan_path_user_string(this, tcx); + let render = || f.loan_path_user_string(this); if span_err { tcx.sess.span_err(sp, &format!("{}: `{}`", kind, render())); } @@ -176,7 +174,7 @@ pub fn fixup_fragment_sets<'tcx>(this: &MoveData<'tcx>, tcx: &ty::ctxt<'tcx>) { }; let frag_lps = |fs: &[Fragment]| -> Vec { - fs.iter().map(|f| f.loan_path_repr(this, tcx)).collect() + fs.iter().map(|f| f.loan_path_repr(this)).collect() }; // First, filter out duplicates diff --git a/src/librustc_trans/trans/base.rs b/src/librustc_trans/trans/base.rs index 291541aa98f..81657c95370 100644 --- a/src/librustc_trans/trans/base.rs +++ b/src/librustc_trans/trans/base.rs @@ -1671,7 +1671,6 @@ pub fn trans_named_tuple_constructor<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, -> Result<'blk, 'tcx> { let ccx = bcx.fcx.ccx; - let tcx = ccx.tcx(); let result_ty = match ctor_ty.sty { ty::TyBareFn(_, ref bft) => { diff --git a/src/librustc_trans/trans/foreign.rs b/src/librustc_trans/trans/foreign.rs index bfbcbd92734..66f7a89d7ab 100644 --- a/src/librustc_trans/trans/foreign.rs +++ b/src/librustc_trans/trans/foreign.rs @@ -233,7 +233,6 @@ pub fn trans_native_call<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, -> Block<'blk, 'tcx> { let ccx = bcx.ccx(); - let tcx = bcx.tcx(); debug!("trans_native_call(callee_ty={}, \ llfn={}, \ @@ -636,7 +635,6 @@ pub fn trans_rust_fn_with_foreign_abi<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) { let _icx = push_ctxt( "foreign::trans_rust_fn_with_foreign_abi::build_wrap_fn"); - let tcx = ccx.tcx(); debug!("build_wrap_fn(llrustfn={}, llwrapfn={}, t={})", ccx.tn().val_to_string(llrustfn), diff --git a/src/librustc_trans/trans/glue.rs b/src/librustc_trans/trans/glue.rs index 05cc16c9b88..e885f56ef8e 100644 --- a/src/librustc_trans/trans/glue.rs +++ b/src/librustc_trans/trans/glue.rs @@ -203,8 +203,10 @@ impl<'tcx> DropGlueKind<'tcx> { DropGlueKind::TyContents(t) => DropGlueKind::TyContents(f(t)), } } +} - fn to_string<'a>(&self, ccx: &CrateContext<'a, 'tcx>) -> String { +impl<'tcx> Repr for DropGlueKind<'tcx> { + fn repr(&self) -> String { match *self { DropGlueKind::Ty(ty) => { format!("DropGlueKind::Ty({})", ty.repr()) @@ -218,9 +220,9 @@ impl<'tcx> DropGlueKind<'tcx> { fn get_drop_glue_core<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, g: DropGlueKind<'tcx>) -> ValueRef { - debug!("make drop glue for {}", g.to_string(ccx)); + debug!("make drop glue for {}", g.repr()); let g = g.map_ty(|t| get_drop_glue_type(ccx, t)); - debug!("drop glue type {}", g.to_string(ccx)); + debug!("drop glue type {}", g.repr()); match ccx.drop_glues().borrow().get(&g) { Some(&glue) => return glue, _ => { } diff --git a/src/librustc_typeck/check/assoc.rs b/src/librustc_typeck/check/assoc.rs index 334fe2f54c0..5e25404bf73 100644 --- a/src/librustc_typeck/check/assoc.rs +++ b/src/librustc_typeck/check/assoc.rs @@ -12,7 +12,7 @@ use middle::infer::InferCtxt; use middle::traits::{self, FulfillmentContext, Normalized, MiscObligation, SelectionContext, ObligationCause}; use middle::ty::{self, HasProjectionTypes}; -use middle::ty_fold::{TypeFoldable, TypeFolder}; +use middle::ty_fold::TypeFoldable; use syntax::ast; use syntax::codemap::Span; use util::ppaux::Repr; diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs index daa2b95e07e..eeccb576749 100644 --- a/src/librustc_typeck/check/method/probe.rs +++ b/src/librustc_typeck/check/method/probe.rs @@ -1062,8 +1062,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> { // Convert the bounds into obligations. let obligations = - traits::predicates_for_generics(self.tcx(), - cause.clone(), + traits::predicates_for_generics(cause.clone(), &impl_bounds); debug!("impl_obligations={}", obligations.repr()); diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 34403b53fc6..b728c012919 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -1745,7 +1745,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { cause: traits::ObligationCause<'tcx>) { let mut fulfillment_cx = self.inh.fulfillment_cx.borrow_mut(); - fulfillment_cx.register_region_obligation(self.infcx(), ty, region, cause); + fulfillment_cx.register_region_obligation(ty, region, cause); } pub fn add_default_region_param_bounds(&self, @@ -1787,9 +1787,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { debug!("add_obligations_for_parameters(predicates={})", predicates.repr()); - for obligation in traits::predicates_for_generics(self.tcx(), - cause, - predicates) { + for obligation in traits::predicates_for_generics(cause, predicates) { self.register_predicate(obligation); } } diff --git a/src/librustc_typeck/check/regionck.rs b/src/librustc_typeck/check/regionck.rs index 057b4de3f0d..949cf118afc 100644 --- a/src/librustc_typeck/check/regionck.rs +++ b/src/librustc_typeck/check/regionck.rs @@ -348,7 +348,6 @@ impl<'a, 'tcx> Rcx<'a, 'tcx> { body_id: ast::NodeId, span: Span) { debug!("relate_free_regions >>"); - let tcx = self.tcx(); for &ty in fn_sig_tys { let ty = self.resolve_type(ty); @@ -359,7 +358,7 @@ impl<'a, 'tcx> Rcx<'a, 'tcx> { ty, body_scope, span); // Record any relations between free regions that we observe into the free-region-map. - self.free_region_map.relate_free_regions_from_implications(tcx, &implications); + self.free_region_map.relate_free_regions_from_implications(&implications); // But also record other relationships, such as `T:'x`, // that don't go into the free-region-map but which we use @@ -823,7 +822,6 @@ fn constrain_call<'a, I: Iterator>(rcx: &mut Rcx, //! in the type of the function. Also constrains the regions that //! appear in the arguments appropriately. - let tcx = rcx.fcx.tcx(); debug!("constrain_call(call_expr={}, \ receiver={}, \ implicitly_ref_args={})", @@ -1156,7 +1154,6 @@ fn link_autoref(rcx: &Rcx, fn link_by_ref(rcx: &Rcx, expr: &ast::Expr, callee_scope: CodeExtent) { - let tcx = rcx.tcx(); debug!("link_by_ref(expr={}, callee_scope={:?})", expr.repr(), callee_scope); let mc = mc::MemCategorizationContext::new(rcx.fcx); diff --git a/src/librustc_typeck/check/upvar.rs b/src/librustc_typeck/check/upvar.rs index f27985d741a..a5668d8e860 100644 --- a/src/librustc_typeck/check/upvar.rs +++ b/src/librustc_typeck/check/upvar.rs @@ -178,10 +178,6 @@ impl<'a,'tcx> AdjustBorrowKind<'a,'tcx> { AdjustBorrowKind { fcx: fcx, closures_with_inferred_kinds: closures_with_inferred_kinds } } - fn tcx(&self) -> &'a ty::ctxt<'tcx> { - self.fcx.tcx() - } - fn analyze_closure(&mut self, id: ast::NodeId, decl: &ast::FnDecl, body: &ast::Block) { /*! * Analysis starting point.