Fix lint findings in librustc_typeck

This commit is contained in:
flip1995 2019-04-26 13:41:10 +02:00
parent 02f7de1be5
commit 1526f7a4ed
No known key found for this signature in database
GPG Key ID: 693086869D506637
4 changed files with 14 additions and 14 deletions

View File

@ -26,7 +26,7 @@ use super::{MethodError, NoMatchData, CandidateSource};
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`,

View File

@ -1026,10 +1026,10 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for GatherLocalsVisitor<'a, 'gcx, 'tcx> {
/// 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,

View File

@ -405,7 +405,7 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> {
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 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> {
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 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> {
}
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 @@ impl<'cx, 'gcx, 'tcx> Resolver<'cx, 'gcx, 'tcx> {
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();
}
}

View File

@ -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 @@ fn find_existential_constraints<'a, 'tcx>(
// 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<usize>)>,
found: Option<(Span, Ty<'tcx>, Vec<usize>)>,
}
impl<'a, 'tcx> ConstraintLocator<'a, 'tcx> {
@ -1519,7 +1519,7 @@ fn find_existential_constraints<'a, 'tcx>(
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,
};