From 1526f7a4eddcdbb3d8fab0a6ae3ca1caf327df55 Mon Sep 17 00:00:00 2001 From: flip1995 Date: Fri, 26 Apr 2019 13:41:10 +0200 Subject: [PATCH] Fix lint findings in librustc_typeck --- src/librustc_typeck/check/method/suggest.rs | 2 +- src/librustc_typeck/check/mod.rs | 4 ++-- src/librustc_typeck/check/writeback.rs | 14 +++++++------- src/librustc_typeck/collect.rs | 8 ++++---- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index 7121b06e27a..35d4568bd9c 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -26,7 +26,7 @@ use super::probe::Mode; impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { - fn is_fn_ty(&self, ty: &Ty<'tcx>, span: Span) -> bool { + fn is_fn_ty(&self, ty: Ty<'tcx>, span: Span) -> bool { let tcx = self.tcx; match ty.sty { // Not all of these (e.g., unsafe fns) implement `FnOnce`, diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 250dd90c789..f1163847892 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -1026,10 +1026,10 @@ fn visit_argument_source(&mut self, s: &'gcx hir::ArgSource) { /// points. struct GeneratorTypes<'tcx> { /// Type of value that is yielded. - yield_ty: ty::Ty<'tcx>, + yield_ty: Ty<'tcx>, /// Types that are captured (see `GeneratorInterior` for more). - interior: ty::Ty<'tcx>, + interior: Ty<'tcx>, /// Indicates if the generator is movable or static (immovable). movability: hir::GeneratorMovability, diff --git a/src/librustc_typeck/check/writeback.rs b/src/librustc_typeck/check/writeback.rs index 193b17af55e..e4f690c6ec0 100644 --- a/src/librustc_typeck/check/writeback.rs +++ b/src/librustc_typeck/check/writeback.rs @@ -405,7 +405,7 @@ fn visit_user_provided_tys(&mut self) { c_ty } else { span_bug!( - hir_id.to_span(&self.fcx.tcx), + hir_id.to_span(self.fcx.tcx), "writeback: `{:?}` missing from the global type context", c_ty ); @@ -730,7 +730,7 @@ fn resolve(&self, x: &T, span: &dyn Locatable) -> T::Lifted lifted } else { span_bug!( - span.to_span(&self.fcx.tcx), + span.to_span(self.fcx.tcx), "writeback: `{:?}` missing from the global type context", x ); @@ -739,24 +739,24 @@ fn resolve(&self, x: &T, span: &dyn Locatable) -> T::Lifted } trait Locatable { - fn to_span(&self, tcx: &TyCtxt<'_, '_, '_>) -> Span; + fn to_span(&self, tcx: TyCtxt<'_, '_, '_>) -> Span; } impl Locatable for Span { - fn to_span(&self, _: &TyCtxt<'_, '_, '_>) -> Span { + fn to_span(&self, _: TyCtxt<'_, '_, '_>) -> Span { *self } } impl Locatable for DefIndex { - fn to_span(&self, tcx: &TyCtxt<'_, '_, '_>) -> Span { + fn to_span(&self, tcx: TyCtxt<'_, '_, '_>) -> Span { let hir_id = tcx.hir().def_index_to_hir_id(*self); tcx.hir().span_by_hir_id(hir_id) } } impl Locatable for hir::HirId { - fn to_span(&self, tcx: &TyCtxt<'_, '_, '_>) -> Span { + fn to_span(&self, tcx: TyCtxt<'_, '_, '_>) -> Span { tcx.hir().span_by_hir_id(*self) } } @@ -789,7 +789,7 @@ fn new( fn report_error(&self, t: Ty<'tcx>) { if !self.tcx.sess.has_errors() { self.infcx - .need_type_info_err(Some(self.body.id()), self.span.to_span(&self.tcx), t) + .need_type_info_err(Some(self.body.id()), self.span.to_span(self.tcx), t) .emit(); } } diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index afb30af054f..b4f6ae9baae 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -1451,8 +1451,8 @@ pub fn checked_type_of<'a, 'tcx>( fn find_existential_constraints<'a, 'tcx>( tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId, -) -> ty::Ty<'tcx> { - use rustc::hir::*; +) -> Ty<'tcx> { + use rustc::hir::{ImplItem, Item, TraitItem}; struct ConstraintLocator<'a, 'tcx: 'a> { tcx: TyCtxt<'a, 'tcx, 'tcx>, @@ -1463,7 +1463,7 @@ struct ConstraintLocator<'a, 'tcx: 'a> { // The mapping is an index for each use site of a generic parameter in the concrete type // // The indices index into the generic parameters on the existential type. - found: Option<(Span, ty::Ty<'tcx>, Vec)>, + found: Option<(Span, Ty<'tcx>, Vec)>, } impl<'a, 'tcx> ConstraintLocator<'a, 'tcx> { @@ -1519,7 +1519,7 @@ fn check(&mut self, def_id: DefId) { ty::Param(p) => Some(*index_map.get(p).unwrap()), _ => None, }).collect(); - let is_param = |ty: ty::Ty<'_>| match ty.sty { + let is_param = |ty: Ty<'_>| match ty.sty { ty::Param(_) => true, _ => false, };