Skip to content

Commit 570b963

Browse files
committed
Replace potentially ICEgen ast_ty_to_ty_cache
1 parent d755b1e commit 570b963

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

src/methods.rs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ impl LateLintPass for MethodsPass {
366366
return;
367367
}
368368

369-
if let ItemImpl(_, _, _, None, ref ty, ref items) = item.node {
369+
if let ItemImpl(_, _, _, None, _, ref items) = item.node {
370370
for implitem in items {
371371
let name = implitem.name;
372372
if let ImplItemKind::Method(ref sig, _) = implitem.node {
@@ -387,6 +387,7 @@ impl LateLintPass for MethodsPass {
387387
}
388388

389389
// 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;
390391
let is_copy = is_copy(cx, &ty, &item);
391392
for &(ref conv, self_kinds) in &CONVENTIONS {
392393
if conv.check(&name.as_str()) &&
@@ -412,12 +413,13 @@ impl LateLintPass for MethodsPass {
412413
if &name.as_str() == &"new" {
413414
let returns_self = if let FunctionRetTy::Return(ref ret_ty) = sig.decl.output {
414415
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);
416416
let ret_ty = ast_ty_to_ty_cache.get(&ret_ty.id);
417417

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
421423
}
422424
}
423425
else {
@@ -983,12 +985,7 @@ fn is_bool(ty: &Ty) -> bool {
983985
false
984986
}
985987

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)
994991
}

0 commit comments

Comments
 (0)