rust/compiler
bors 178bd9130e 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`
2021-03-13 09:47:07 +00:00
..
rustc Rollup merge of #82642 - sfackler:jemalloc-zone, r=pnkfelix 2021-03-08 13:13:22 +01:00
rustc_apfloat
rustc_arena
rustc_ast Rollup merge of #82841 - hvdijk:x32, r=joshtriplett 2021-03-09 09:05:24 +00:00
rustc_ast_lowering Rollup merge of #82984 - camsteffen:lower-block, r=cjgillot 2021-03-13 09:44:42 +09:00
rustc_ast_passes rustc_target: add "unwind" payloads to Abi 2021-03-09 14:38:29 -05:00
rustc_ast_pretty
rustc_attr
rustc_builtin_macros Rollup merge of #82217 - m-ou-se:edition-prelude, r=nikomatsakis 2021-03-10 17:55:38 +01:00
rustc_codegen_cranelift Auto merge of #76570 - cratelyn:implement-rfc-2945-c-unwind-abi, r=Amanieu 2021-03-10 16:44:04 +00:00
rustc_codegen_llvm Remove the -Zinsert-sideeffect 2021-03-10 12:21:43 +02:00
rustc_codegen_ssa Rollup merge of #83020 - hi-rustin:rustin-patch-enum, r=lcnr 2021-03-13 09:44:44 +09:00
rustc_data_structures Auto merge of #82641 - camelid:lang-item-docs, r=jyn514 2021-03-11 06:38:22 +00:00
rustc_driver Add -Z unpretty flag for the THIR 2021-03-11 19:42:40 +01:00
rustc_error_codes
rustc_errors
rustc_expand Auto merge of #82422 - petrochenkov:allunst, r=oli-obk 2021-03-12 11:46:50 +00:00
rustc_feature Auto merge of #76570 - cratelyn:implement-rfc-2945-c-unwind-abi, r=Amanieu 2021-03-10 16:44:04 +00:00
rustc_fs_util
rustc_graphviz
rustc_hir Auto merge of #82641 - camelid:lang-item-docs, r=jyn514 2021-03-11 06:38:22 +00:00
rustc_hir_pretty Use BTreeMap to store attributes. 2021-03-09 19:28:01 +01:00
rustc_incremental Deduplicate unchecked_attrs errors. 2021-03-09 19:28:00 +01:00
rustc_index Remove useless Clone bound in IndexVec. 2021-03-09 18:51:36 +01:00
rustc_infer
rustc_interface Auto merge of #82884 - nagisa:nagisa/remove-most-of-sideeffect-inserts, r=nikic 2021-03-10 14:03:00 +00:00
rustc_lexer
rustc_lint Track HirId when visiting attributes. 2021-03-09 19:27:59 +01:00
rustc_lint_defs Rollup merge of #79208 - LeSeulArtichaut:stable-unsafe_op_in_unsafe_fn, r=nikomatsakis 2021-03-10 08:01:25 +09:00
rustc_llvm Support merge_functions option in NewPM since LLVM >= 12 2021-03-12 08:16:10 +09:00
rustc_macros
rustc_metadata Remove hir::Item::attrs. 2021-03-09 19:27:50 +01:00
rustc_middle Auto merge of #82964 - Nicholas-Baron:shorten_middle_ty, r=jackh726 2021-03-11 04:09:44 +00:00
rustc_mir Auto merge of #82935 - henryboisdequin:diagnostic-cleanups, r=estebank 2021-03-12 09:05:38 +00:00
rustc_mir_build Rollup merge of #83018 - oli-obk:float_check, r=davidtwco 2021-03-12 08:55:22 +09:00
rustc_parse Rollup merge of #82048 - mark-i-m:or-pat-type-ascription, r=petrochenkov 2021-03-09 09:05:20 +00:00
rustc_parse_format
rustc_passes Track HirId when visiting attributes. 2021-03-09 19:27:59 +01:00
rustc_plugin_impl Remove hir::Item::attrs. 2021-03-09 19:27:50 +01:00
rustc_privacy Remove hir::MacroDef::attrs. 2021-03-09 19:09:36 +01:00
rustc_query_impl
rustc_query_system
rustc_resolve Auto merge of #79519 - cjgillot:noattr, r=wesleywiser 2021-03-10 08:40:51 +00:00
rustc_save_analysis Remove hir::Item::attrs. 2021-03-09 19:27:50 +01:00
rustc_serialize
rustc_session Add -Z unpretty flag for the THIR 2021-03-11 19:42:40 +01:00
rustc_span Auto merge of #82982 - Dylan-DPC:rollup-mt497z7, r=Dylan-DPC 2021-03-10 19:12:53 +00:00
rustc_symbol_mangling rustc_target: add "unwind" payloads to Abi 2021-03-09 14:38:29 -05:00
rustc_target Auto merge of #82982 - Dylan-DPC:rollup-mt497z7, r=Dylan-DPC 2021-03-10 19:12:53 +00:00
rustc_trait_selection Auto merge of #82935 - henryboisdequin:diagnostic-cleanups, r=estebank 2021-03-12 09:05:38 +00:00
rustc_traits
rustc_ty_utils
rustc_type_ir
rustc_typeck Auto merge of #82878 - sexxi-goose:repr_packed, r=nikomatsakis 2021-03-13 09:47:07 +00:00