mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-14 17:07:17 +00:00
Directly construct Inherited.
This commit is contained in:
parent
27910cbcbd
commit
5c85cd9fee
2 changed files with 32 additions and 33 deletions
|
@ -369,10 +369,10 @@ fn can_change_type<'a>(cx: &LateContext<'a>, mut expr: &'a Expr<'a>, mut ty: Ty<
|
|||
Node::Item(item) => {
|
||||
if let ItemKind::Fn(_, _, body_id) = &item.kind
|
||||
&& let output_ty = return_ty(cx, item.owner_id)
|
||||
&& Inherited::build(cx.tcx, item.owner_id.def_id).enter(|inherited| {
|
||||
let fn_ctxt = FnCtxt::new(inherited, cx.param_env, item.owner_id.def_id);
|
||||
fn_ctxt.can_coerce(ty, output_ty)
|
||||
}) {
|
||||
&& let inherited = Inherited::new(cx.tcx, item.owner_id.def_id)
|
||||
&& let fn_ctxt = FnCtxt::new(&inherited, cx.param_env, item.owner_id.def_id)
|
||||
&& fn_ctxt.can_coerce(ty, output_ty)
|
||||
{
|
||||
if has_lifetime(output_ty) && has_lifetime(ty) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -33,8 +33,8 @@ pub(super) fn check_cast<'tcx>(
|
|||
let hir_id = e.hir_id;
|
||||
let local_def_id = hir_id.owner.def_id;
|
||||
|
||||
Inherited::build(cx.tcx, local_def_id).enter(|inherited| {
|
||||
let fn_ctxt = FnCtxt::new(inherited, cx.param_env, local_def_id);
|
||||
let inherited = Inherited::new(cx.tcx, local_def_id);
|
||||
let fn_ctxt = FnCtxt::new(&inherited, cx.param_env, local_def_id);
|
||||
|
||||
// If we already have errors, we can't be sure we can pointer cast.
|
||||
assert!(
|
||||
|
@ -66,5 +66,4 @@ pub(super) fn check_cast<'tcx>(
|
|||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue