@@ -366,7 +366,7 @@ impl LateLintPass for MethodsPass {
366
366
return ;
367
367
}
368
368
369
- if let ItemImpl ( _, _, _, None , ref ty , ref items) = item. node {
369
+ if let ItemImpl ( _, _, _, None , _ , ref items) = item. node {
370
370
for implitem in items {
371
371
let name = implitem. name ;
372
372
if let ImplItemKind :: Method ( ref sig, _) = implitem. node {
@@ -387,6 +387,7 @@ impl LateLintPass for MethodsPass {
387
387
}
388
388
389
389
// check conventions w.r.t. conversion method names and predicates
390
+ let ty = cx. tcx . lookup_item_type ( cx. tcx . map . local_def_id ( item. id ) ) . ty ;
390
391
let is_copy = is_copy ( cx, & ty, & item) ;
391
392
for & ( ref conv, self_kinds) in & CONVENTIONS {
392
393
if conv. check ( & name. as_str ( ) ) &&
@@ -412,12 +413,13 @@ impl LateLintPass for MethodsPass {
412
413
if & name. as_str ( ) == & "new" {
413
414
let returns_self = if let FunctionRetTy :: Return ( ref ret_ty) = sig. decl . output {
414
415
let ast_ty_to_ty_cache = cx. tcx . ast_ty_to_ty_cache . borrow ( ) ;
415
- let ty = ast_ty_to_ty_cache. get ( & ty. id ) ;
416
416
let ret_ty = ast_ty_to_ty_cache. get ( & ret_ty. id ) ;
417
417
418
- match ( ty, ret_ty) {
419
- ( Some ( & ty) , Some ( & ret_ty) ) => ret_ty. walk ( ) . any ( |t| t == ty) ,
420
- _ => false ,
418
+ if let Some ( & ret_ty) = ret_ty {
419
+ ret_ty. walk ( ) . any ( |t| t == ty)
420
+ }
421
+ else {
422
+ false
421
423
}
422
424
}
423
425
else {
@@ -983,12 +985,7 @@ fn is_bool(ty: &Ty) -> bool {
983
985
false
984
986
}
985
987
986
- fn is_copy ( cx : & LateContext , ast_ty : & Ty , item : & Item ) -> bool {
987
- match cx. tcx . ast_ty_to_ty_cache . borrow ( ) . get ( & ast_ty. id ) {
988
- None => false ,
989
- Some ( ty) => {
990
- let env = ty:: ParameterEnvironment :: for_item ( cx. tcx , item. id ) ;
991
- !ty. subst ( cx. tcx , & env. free_substs ) . moves_by_default ( & env, ast_ty. span )
992
- }
993
- }
988
+ fn is_copy < ' a , ' ctx > ( cx : & LateContext < ' a , ' ctx > , ty : ty:: Ty < ' ctx > , item : & Item ) -> bool {
989
+ let env = ty:: ParameterEnvironment :: for_item ( cx. tcx , item. id ) ;
990
+ !ty. subst ( cx. tcx , & env. free_substs ) . moves_by_default ( & env, item. span )
994
991
}
0 commit comments