Fix lint findings in librustc_typeck
This commit is contained in:
parent
02f7de1be5
commit
1526f7a4ed
@ -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`,
|
||||
|
@ -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,
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user