diff options
| author | Aman Arora <me@aman-arora.com> | 2021-03-06 21:47:53 -0500 |
|---|---|---|
| committer | Aman Arora <me@aman-arora.com> | 2021-03-09 20:23:02 -0500 |
| commit | 612a9b2f95fc44dd140a3545dc303058d98100a9 (patch) | |
| tree | dbdbd6234fcd225f8d6aeae5f1fdfe97bd4695e0 /compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp | |
| parent | dfe519b344b60e54a2028d3366ca366a228537e3 (diff) | |
| download | rust-612a9b2f95fc44dd140a3545dc303058d98100a9.tar.gz rust-612a9b2f95fc44dd140a3545dc303058d98100a9.zip | |
2229: Handle capturing a reference into a repr packed struct
RFC 1240 states that it is unsafe to capture references into a
packed-struct. This PR ensures that when a closure captures a precise
path, we aren't violating this safety constraint.
To acheive so we restrict the capture precision to the struct itself.
An interesting edge case:
```rust
struct Foo(String);
let foo: Foo;
let c = || {
println!("{}", foo.0);
let x = foo.0;
}
```
Given how closures get desugared today, foo.0 will be moved into the
closure, making the `println!`, safe. However this can be very subtle
and also will be unsafe if the closure gets inline.
Closes: https://github.com/rust-lang/project-rfc-2229/issues/33
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions
