Skip to content

Commit d27f401

Browse files
committed
changes from review: add FIXME to clippy and change subst_identity to skip_binder in mir subst methods
1 parent e4f6b8b commit d27f401

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

compiler/rustc_middle/src/ty/instance.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ impl<'tcx> Instance<'tcx> {
586586
if let Some(substs) = self.substs_for_mir_body() {
587587
v.subst(tcx, substs)
588588
} else {
589-
v.subst_identity()
589+
v.skip_binder()
590590
}
591591
}
592592

@@ -603,7 +603,7 @@ impl<'tcx> Instance<'tcx> {
603603
if let Some(substs) = self.substs_for_mir_body() {
604604
tcx.subst_and_normalize_erasing_regions(substs, param_env, v)
605605
} else {
606-
tcx.normalize_erasing_regions(param_env, v.subst_identity())
606+
tcx.normalize_erasing_regions(param_env, v.skip_binder())
607607
}
608608
}
609609

@@ -620,7 +620,7 @@ impl<'tcx> Instance<'tcx> {
620620
if let Some(substs) = self.substs_for_mir_body() {
621621
tcx.try_subst_and_normalize_erasing_regions(substs, param_env, v)
622622
} else {
623-
tcx.try_normalize_erasing_regions(param_env, v.subst_identity())
623+
tcx.try_normalize_erasing_regions(param_env, v.skip_binder())
624624
}
625625
}
626626

src/tools/clippy/clippy_lints/src/methods/unnecessary_to_owned.rs

+3
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,9 @@ fn can_change_type<'a>(cx: &LateContext<'a>, mut expr: &'a Expr<'a>, mut ty: Ty<
385385
Node::Expr(parent_expr) => {
386386
if let Some((callee_def_id, call_substs, recv, call_args)) = get_callee_substs_and_args(cx, parent_expr)
387387
{
388+
// FIXME: the `subst_identity()` below seems incorrect, since we eventually
389+
// call `tcx.try_subst_and_normalize_erasing_regions` further down
390+
// (i.e., we are explicitly not in the identity context).
388391
let fn_sig = cx.tcx.fn_sig(callee_def_id).subst_identity().skip_binder();
389392
if let Some(arg_index) = recv.into_iter().chain(call_args).position(|arg| arg.hir_id == expr.hir_id)
390393
&& let Some(param_ty) = fn_sig.inputs().get(arg_index)

0 commit comments

Comments
 (0)