about summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-03-13 09:47:07 +0000
committerbors <bors@rust-lang.org>2021-03-13 09:47:07 +0000
commit178bd9130e9e5f4f26be325bbf593f69dfa894b0 (patch)
treea91396b3b6d891ac8628b015876d0cd71c5233f5 /compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
parentec487bf3cfc9ce386da25169509fae8f2b4d4eec (diff)
parent612a9b2f95fc44dd140a3545dc303058d98100a9 (diff)
downloadrust-178bd9130e9e5f4f26be325bbf593f69dfa894b0.tar.gz
rust-178bd9130e9e5f4f26be325bbf593f69dfa894b0.zip
Auto merge of #82878 - sexxi-goose:repr_packed, r=nikomatsakis
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 where we decided to restrict precision:
```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

r? `@nikomatsakis`
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions