about summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-08-13 08:31:26 +0000
committerbors <bors@rust-lang.org>2021-08-13 08:31:26 +0000
commit2fc3c69e5419292e92663a5f1e39203478925661 (patch)
treeb6df21d26052fbfae4abeb42dc58f85530349574 /compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
parent04c9901a0838d20e6ac0bcda94ea1a8c239bb0d7 (diff)
parent26c590d1b38617602a84ccdd0878c3681d242669 (diff)
downloadrust-2fc3c69e5419292e92663a5f1e39203478925661.tar.gz
rust-2fc3c69e5419292e92663a5f1e39203478925661.zip
Auto merge of #87956 - m-ou-se:closure-migration-macro-body, r=Aaron1011
Fix closure migration suggestion when the body is a macro.

Fixes https://github.com/rust-lang/rust/issues/87955

Before:
```
warning: changes to closure capture in Rust 2021 will affect drop order
 --> src/main.rs:5:13
  |
5 |     let _ = || panic!(a.0);
  |             ^^^^^^^^^^---^
  |                       |
  |                       in Rust 2018, closure captures all of `a`, but in Rust 2021, it only captures `a.0`
6 | }
  | - in Rust 2018, `a` would be dropped here, but in Rust 2021, only `a.0` would be dropped here alongside the closure
  |

help: add a dummy let to cause `a` to be fully captured
  |
20~     ($msg:expr $(,)?) => ({ let _ = &a;
21+         $crate::rt::begin_panic($msg)
22~     }),
  |
```

After:
```
warning: changes to closure capture in Rust 2021 will affect drop order
 --> src/main.rs:5:13
  |
5 |     let _ = || panic!(a.0);
  |             ^^^^^^^^^^---^
  |                       |
  |                       in Rust 2018, closure captures all of `a`, but in Rust 2021, it only captures `a.0`
6 | }
  | - in Rust 2018, `a` would be dropped here, but in Rust 2021, only `a.0` would be dropped here alongside the closure
  |
help: add a dummy let to cause `a` to be fully captured
  |
5 |     let _ = || { let _ = &a; panic!(a.0) };
  |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp')
0 files changed, 0 insertions, 0 deletions