Skip to content

Commit c222080

Browse files
committed
Ensure bb fn type params are sorted by locals
1 parent 3daf10d commit c222080

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

src/refine/template.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,9 +335,12 @@ where
335335
where
336336
I: IntoIterator<Item = (Local, mir_ty::TypeAndMut<'tcx>)>,
337337
{
338+
// this is necessary for local_def::Analyzer::elaborate_unused_args
339+
let mut live_locals: Vec<_> = live_locals.into_iter().collect();
340+
live_locals.sort_by_key(|(local, _)| *local);
341+
338342
let mut locals = IndexVec::<rty::FunctionParamIdx, _>::new();
339343
let mut tys = Vec::new();
340-
// TODO: avoid two iteration and assumption of FunctionParamIdx match between locals and ty
341344
for (local, ty) in live_locals {
342345
locals.push((local, ty.mutbl));
343346
tys.push(ty);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//@error-in-other-file: Unsat
2+
//@compile-flags: -C debug-assertions=off
3+
4+
fn main() {
5+
let incr = |x| {
6+
x + 1
7+
};
8+
assert!(incr(2) == 2);
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//@check-pass
2+
//@compile-flags: -C debug-assertions=off
3+
4+
fn main() {
5+
let incr = |x| {
6+
x + 1
7+
};
8+
assert!(incr(1) == 2);
9+
}

0 commit comments

Comments
 (0)