rust/compiler
Aman Arora 612a9b2f95 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
2021-03-09 20:23:02 -05:00
..
2021-02-20 17:19:30 -05:00
2021-02-20 10:51:26 +01:00
2021-02-21 12:22:22 +01:00
2021-02-21 12:22:22 +01:00
2021-03-03 11:22:44 +01:00
2021-03-03 11:22:44 +01:00