diff options
| author | Simonas Kazlauskas <github@kazlauskas.me> | 2015-12-31 17:28:57 +0200 |
|---|---|---|
| committer | Simonas Kazlauskas <git@kazlauskas.me> | 2015-12-31 18:52:20 +0200 |
| commit | 7448f4861a8ee41b0a6d62b6bdaf623b3eeba453 (patch) | |
| tree | e897e9492882c3f2633b0bfd30a4c7433707b684 /src/libstd/sys | |
| parent | 1aa4abdb3bef48e706605650a60a43146bb3998f (diff) | |
| parent | f8b61340e33bbb24709a862fd834ec10c871413c (diff) | |
| download | rust-7448f4861a8ee41b0a6d62b6bdaf623b3eeba453.tar.gz rust-7448f4861a8ee41b0a6d62b6bdaf623b3eeba453.zip | |
Rollup merge of #30630 - tsion:mir-closure-args, r=nagisa
Previously, all references to closure arguments went to the argument before the one they should (e.g. to `arg1` when it was supposed to go to `arg2`). This was because the MIR builder did not account for the implicit arguments that come before the explicit arguments, and closures have one implicit argument - the struct containing the captures.
This is my test code and a diff of the MIR generated for the closure:
```rust
let a = 2i32;
let _f = |b: i32| -> i32 { a + b }:
```
```diff
--- old 2015-12-29 23:16:32.027926372 -0600
+++ new 2015-12-29 23:16:42.975400757 -0600
@@ -1,22 +1,22 @@
fn(arg0: &[closure@closure-args.rs:8:14: 8:39 a:&i32], arg1: i32) -> i32 {
let var0: i32; // b
let tmp0: ();
let tmp1: i32;
let tmp2: i32;
bb0: {
- var0 = arg0;
+ var0 = arg1;
tmp1 = (*(*arg0).0);
tmp2 = var0;
ReturnPointer = Add(tmp1, tmp2);
goto -> bb1;
}
bb1: {
return;
}
bb2: {
diverge;
}
}
```
(If you're wondering where this text MIR output comes from, it's from another branch of mine waiting on https://github.com/rust-lang/rust/pull/30602 to get merged.)
Diffstat (limited to 'src/libstd/sys')
0 files changed, 0 insertions, 0 deletions
