mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-10 15:14:29 +00:00
Fix compilation on rustc 1.20.0-nightly (69c65d296 2017-06-28)
This commit is contained in:
parent
6a2525ccb8
commit
8ac0388307
10 changed files with 33 additions and 29 deletions
|
@ -136,9 +136,12 @@ impl<'a, 'tcx> Visitor<'tcx> for CCHelper<'a, 'tcx> {
|
|||
walk_expr(self, e);
|
||||
let ty = self.cx.tables.node_id_to_type(callee.id);
|
||||
match ty.sty {
|
||||
ty::TyFnDef(_, _, ty) |
|
||||
ty::TyFnPtr(ty) if ty.skip_binder().output().sty == ty::TyNever => {
|
||||
self.divergence += 1;
|
||||
ty::TyFnDef(..) |
|
||||
ty::TyFnPtr(_) => {
|
||||
let sig = ty.fn_sig(self.cx.tcx);
|
||||
if sig.skip_binder().output().sty == ty::TyNever {
|
||||
self.divergence += 1;
|
||||
}
|
||||
},
|
||||
_ => (),
|
||||
}
|
||||
|
|
|
@ -64,10 +64,11 @@ fn check_closure(cx: &LateContext, expr: &Expr) {
|
|||
let fn_ty = cx.tables.expr_ty(caller);
|
||||
match fn_ty.sty {
|
||||
// Is it an unsafe function? They don't implement the closure traits
|
||||
ty::TyFnDef(_, _, fn_ty) |
|
||||
ty::TyFnPtr(fn_ty) => {
|
||||
if fn_ty.skip_binder().unsafety == Unsafety::Unsafe ||
|
||||
fn_ty.skip_binder().output().sty == ty::TyNever {
|
||||
ty::TyFnDef(..) |
|
||||
ty::TyFnPtr(_) => {
|
||||
let sig = fn_ty.fn_sig(cx.tcx);
|
||||
if sig.skip_binder().unsafety == Unsafety::Unsafe ||
|
||||
sig.skip_binder().output().sty == ty::TyNever {
|
||||
return;
|
||||
}
|
||||
},
|
||||
|
|
|
@ -126,10 +126,12 @@ impl<'a, 'tcx> Visitor<'tcx> for DivergenceVisitor<'a, 'tcx> {
|
|||
match e.node {
|
||||
ExprAgain(_) | ExprBreak(_, _) | ExprRet(_) => self.report_diverging_sub_expr(e),
|
||||
ExprCall(ref func, _) => {
|
||||
match self.cx.tables.expr_ty(func).sty {
|
||||
ty::TyFnDef(_, _, fn_ty) |
|
||||
ty::TyFnPtr(fn_ty) => {
|
||||
if let ty::TyNever = self.cx.tcx.erase_late_bound_regions(&fn_ty).output().sty {
|
||||
let typ = self.cx.tables.expr_ty(func);
|
||||
match typ.sty {
|
||||
ty::TyFnDef(..) |
|
||||
ty::TyFnPtr(_) => {
|
||||
let sig = typ.fn_sig(self.cx.tcx);
|
||||
if let ty::TyNever = self.cx.tcx.erase_late_bound_regions(&sig).output().sty {
|
||||
self.report_diverging_sub_expr(e);
|
||||
}
|
||||
},
|
||||
|
|
|
@ -176,7 +176,7 @@ impl<'a, 'tcx> hir::intravisit::Visitor<'tcx> for DerefVisitor<'a, 'tcx> {
|
|||
hir::ExprCall(ref f, ref args) => {
|
||||
let ty = self.cx.tables.expr_ty(f);
|
||||
|
||||
if type_is_unsafe_function(ty) {
|
||||
if type_is_unsafe_function(self.cx, ty) {
|
||||
for arg in args {
|
||||
self.check_arg(arg);
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ impl<'a, 'tcx> hir::intravisit::Visitor<'tcx> for DerefVisitor<'a, 'tcx> {
|
|||
let def_id = self.cx.tables.type_dependent_defs[&expr.id].def_id();
|
||||
let base_type = self.cx.tcx.type_of(def_id);
|
||||
|
||||
if type_is_unsafe_function(base_type) {
|
||||
if type_is_unsafe_function(self.cx, base_type) {
|
||||
for arg in args {
|
||||
self.check_arg(arg);
|
||||
}
|
||||
|
|
|
@ -94,8 +94,7 @@ fn check_trait_items(cx: &LateContext, item: &Item, trait_items: &[TraitItemRef]
|
|||
has_self &&
|
||||
{
|
||||
let did = cx.tcx.hir.local_def_id(item.id.node_id);
|
||||
let impl_ty = cx.tcx.type_of(did);
|
||||
impl_ty.fn_sig().inputs().skip_binder().len() == 1
|
||||
cx.tcx.fn_sig(did).inputs().skip_binder().len() == 1
|
||||
}
|
||||
} else {
|
||||
false
|
||||
|
@ -121,8 +120,7 @@ fn check_impl_items(cx: &LateContext, item: &Item, impl_items: &[ImplItemRef]) {
|
|||
has_self &&
|
||||
{
|
||||
let did = cx.tcx.hir.local_def_id(item.id.node_id);
|
||||
let impl_ty = cx.tcx.type_of(did);
|
||||
impl_ty.fn_sig().inputs().skip_binder().len() == 1
|
||||
cx.tcx.fn_sig(did).inputs().skip_binder().len() == 1
|
||||
}
|
||||
} else {
|
||||
false
|
||||
|
@ -184,7 +182,7 @@ fn has_is_empty(cx: &LateContext, expr: &Expr) -> bool {
|
|||
fn is_is_empty(cx: &LateContext, item: &ty::AssociatedItem) -> bool {
|
||||
if let ty::AssociatedKind::Method = item.kind {
|
||||
if item.name == "is_empty" {
|
||||
let sig = cx.tcx.type_of(item.def_id).fn_sig();
|
||||
let sig = cx.tcx.fn_sig(item.def_id);
|
||||
let ty = sig.skip_binder();
|
||||
ty.inputs().len() == 1
|
||||
} else {
|
||||
|
|
|
@ -741,7 +741,7 @@ fn check_for_loop_arg(cx: &LateContext, pat: &Pat, arg: &Expr, expr: &Expr) {
|
|||
let substs = cx.tables.node_substs(arg.id);
|
||||
let method_type = cx.tcx.type_of(def_id).subst(cx.tcx, substs);
|
||||
|
||||
let fn_arg_tys = method_type.fn_sig().inputs();
|
||||
let fn_arg_tys = method_type.fn_sig(cx.tcx).inputs();
|
||||
assert_eq!(fn_arg_tys.skip_binder().len(), 1);
|
||||
if fn_arg_tys.skip_binder()[0].is_region_ptr() {
|
||||
lint_iter_method(cx, args, arg, &method_name);
|
||||
|
|
|
@ -55,11 +55,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnnecessaryMutPassed {
|
|||
}
|
||||
}
|
||||
|
||||
fn check_arguments(cx: &LateContext, arguments: &[Expr], type_definition: Ty, name: &str) {
|
||||
fn check_arguments<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, arguments: &[Expr], type_definition: Ty<'tcx>, name: &str) {
|
||||
match type_definition.sty {
|
||||
ty::TyFnDef(_, _, fn_type) |
|
||||
ty::TyFnPtr(fn_type) => {
|
||||
let parameters = fn_type.skip_binder().inputs();
|
||||
ty::TyFnDef(..) |
|
||||
ty::TyFnPtr(_) => {
|
||||
let parameters = type_definition.fn_sig(cx.tcx).skip_binder().inputs();
|
||||
for (argument, parameter) in arguments.iter().zip(parameters.iter()) {
|
||||
match parameter.sty {
|
||||
ty::TyRef(_, ty::TypeAndMut { mutbl: MutImmutable, .. }) |
|
||||
|
|
|
@ -95,7 +95,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue {
|
|||
ctx
|
||||
};
|
||||
|
||||
let fn_sig = cx.tcx.type_of(fn_def_id).fn_sig();
|
||||
let fn_sig = cx.tcx.fn_sig(fn_def_id);
|
||||
let fn_sig = cx.tcx.erase_late_bound_regions(&fn_sig);
|
||||
|
||||
for ((input, &ty), arg) in decl.inputs.iter().zip(fn_sig.inputs()).zip(&body.arguments) {
|
||||
|
|
|
@ -113,7 +113,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PointerPass {
|
|||
|
||||
fn check_fn(cx: &LateContext, decl: &FnDecl, fn_id: NodeId) {
|
||||
let fn_def_id = cx.tcx.hir.local_def_id(fn_id);
|
||||
let sig = cx.tcx.type_of(fn_def_id).fn_sig();
|
||||
let sig = cx.tcx.fn_sig(fn_def_id);
|
||||
let fn_ty = sig.skip_binder();
|
||||
|
||||
for (arg, ty) in decl.inputs.iter().zip(fn_ty.inputs()) {
|
||||
|
|
|
@ -764,7 +764,7 @@ pub fn camel_case_from(s: &str) -> usize {
|
|||
/// Convenience function to get the return type of a function
|
||||
pub fn return_ty<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, fn_item: NodeId) -> Ty<'tcx> {
|
||||
let fn_def_id = cx.tcx.hir.local_def_id(fn_item);
|
||||
let ret_ty = cx.tcx.type_of(fn_def_id).fn_sig().output();
|
||||
let ret_ty = cx.tcx.fn_sig(fn_def_id).output();
|
||||
cx.tcx.erase_late_bound_regions(&ret_ty)
|
||||
}
|
||||
|
||||
|
@ -776,10 +776,10 @@ pub fn same_tys<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, a: Ty<'tcx>, b: Ty<'tcx>)
|
|||
}
|
||||
|
||||
/// Return whether the given type is an `unsafe` function.
|
||||
pub fn type_is_unsafe_function(ty: Ty) -> bool {
|
||||
pub fn type_is_unsafe_function<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: Ty<'tcx>) -> bool {
|
||||
match ty.sty {
|
||||
ty::TyFnDef(_, _, f) |
|
||||
ty::TyFnPtr(f) => f.unsafety() == Unsafety::Unsafe,
|
||||
ty::TyFnDef(..) |
|
||||
ty::TyFnPtr(_) => ty.fn_sig(cx.tcx).unsafety() == Unsafety::Unsafe,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue