Auto merge of #10328 - compiler-errors:fix-re-erased-in-needless_pass_by_value, r=matthiaskrgr

Liberate late-bound regions rather than erasing them in `needless_pass_by_value`

changelog: [`needless_pass_by_value`]: fixes an ICE when there are late-bound regions in function arguments that are needlessly passed by value

Fixes rust-lang/rust#107147
r? `@matthiaskrgr`
This commit is contained in:
bors 2023-02-15 06:41:35 +00:00
commit e018a2c8bd
3 changed files with 25 additions and 1 deletions

View file

@ -149,7 +149,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
};
let fn_sig = cx.tcx.fn_sig(fn_def_id).subst_identity();
let fn_sig = cx.tcx.erase_late_bound_regions(fn_sig);
let fn_sig = cx.tcx.liberate_late_bound_regions(fn_def_id.to_def_id(), fn_sig);
for (idx, ((input, &ty), arg)) in decl.inputs.iter().zip(fn_sig.inputs()).zip(body.params).enumerate() {
// All spans generated from a proc-macro invocation are the same...