rust/compiler
bors dffea43fc1 Auto merge of #106180 - RalfJung:dereferenceable-generators, r=nbdd0121
make &mut !Unpin not dereferenceable, and Box<!Unpin> not noalias

See https://github.com/rust-lang/unsafe-code-guidelines/issues/381 and [this LLVM discussion](https://discourse.llvm.org/t/interaction-of-noalias-and-dereferenceable/66979). The exact semantics of how `noalias` and `dereferenceable` interact are unclear, and `@comex` found a case of LLVM actually exploiting that ambiguity for optimizations. I think for now we should treat LLVM `dereferenceable` as implying a "fake read" to happen immediately at the top of the function (standing in for the spurious reads that LLVM might introduce), and that fake read is subject to all the usual `noalias` restrictions. This means we cannot put `dereferenceable` on `&mut !Unpin` references as those references can alias with other references that are being read and written inside the function (e.g. for self-referential generators), meaning the fake read introduces aliasing conflicts with those other accesses.

For `&` this is already not a problem due to https://github.com/rust-lang/rust/pull/98017 which removed the `dereferenceable` attribute for other reasons.

Regular `&mut Unpin` references are unaffected, so I hope the impact of this is going to be tiny.

The first commit does some refactoring of the `PointerKind` enum since I found the old code very confusing each time I had to touch it. It doesn't change behavior.

Fixes https://github.com/rust-lang/miri/issues/2714

EDIT: Turns out our `Box<!Unpin>` treatment was incorrect, too, so the PR also fixes that now (in codegen and Miri): we do not put `noalias` on these boxes any more.
2023-02-07 03:35:10 +00:00
..
rustc
rustc_abi also do not add noalias on not-Unpin Box 2023-02-06 12:17:41 +01:00
rustc_apfloat
rustc_arena
rustc_ast
rustc_ast_lowering remove unused imports 2023-02-06 17:40:18 +03:00
rustc_ast_passes
rustc_ast_pretty remove unused imports 2023-02-06 17:40:18 +03:00
rustc_attr
rustc_baked_icu_data
rustc_borrowck
rustc_builtin_macros
rustc_codegen_cranelift
rustc_codegen_gcc
rustc_codegen_llvm remove unused imports 2023-02-06 17:40:18 +03:00
rustc_codegen_ssa remove unused imports 2023-02-06 17:40:18 +03:00
rustc_const_eval Rollup merge of #107731 - RalfJung:interpret-discriminant, r=cjgillot 2023-02-06 21:16:43 +01:00
rustc_data_structures
rustc_driver
rustc_driver_impl
rustc_error_codes
rustc_error_messages Auto merge of #107727 - Dylan-DPC:rollup-b1yexcl, r=Dylan-DPC 2023-02-06 16:28:18 +00:00
rustc_errors
rustc_expand
rustc_feature
rustc_fs_util
rustc_graphviz
rustc_hir
rustc_hir_analysis remove unused imports 2023-02-06 17:40:18 +03:00
rustc_hir_pretty
rustc_hir_typeck Rollup merge of #106477 - Nathan-Fenner:nathanf/refined-error-span-trait-impl, r=compiler-errors 2023-02-06 21:16:39 +01:00
rustc_incremental
rustc_index
rustc_infer Rollup merge of #107724 - klensy:imports, r=Mark-Simulacrum 2023-02-06 21:16:42 +01:00
rustc_interface remove unused imports 2023-02-06 17:40:18 +03:00
rustc_lexer
rustc_lint Auto merge of #103761 - chenyukang:yukang/fix-103320-must-use, r=compiler-errors 2023-02-06 12:57:37 +00:00
rustc_lint_defs
rustc_llvm
rustc_log
rustc_macros
rustc_metadata rustc_metadata: Encode/decode DefPathHashes without an Option 2023-02-05 18:53:47 +04:00
rustc_middle Auto merge of #106180 - RalfJung:dereferenceable-generators, r=nbdd0121 2023-02-07 03:35:10 +00:00
rustc_mir_build remove unused imports 2023-02-06 17:40:18 +03:00
rustc_mir_dataflow Rollup merge of #107724 - klensy:imports, r=Mark-Simulacrum 2023-02-06 21:16:42 +01:00
rustc_mir_transform
rustc_monomorphize
rustc_parse Rollup merge of #107580 - lenko-d:default_value_for_a_lifetime_generic_parameter_produces_confusing_diagnostic, r=compiler-errors 2023-02-06 19:54:14 +05:30
rustc_parse_format
rustc_passes
rustc_plugin_impl
rustc_privacy remove unused imports 2023-02-06 17:40:18 +03:00
rustc_query_impl remove unused imports 2023-02-06 17:40:18 +03:00
rustc_query_system
rustc_resolve
rustc_save_analysis
rustc_serialize
rustc_session Sort Generator print-type-sizes according to their yield points 2023-02-05 17:34:33 +01:00
rustc_smir
rustc_span rustc_metadata: Encode/decode DefPathHashes without an Option 2023-02-05 18:53:47 +04:00
rustc_symbol_mangling
rustc_target
rustc_trait_selection Rollup merge of #107724 - klensy:imports, r=Mark-Simulacrum 2023-02-06 21:16:42 +01:00
rustc_traits remove unused imports 2023-02-06 17:40:18 +03:00
rustc_transmute
rustc_ty_utils Auto merge of #106180 - RalfJung:dereferenceable-generators, r=nbdd0121 2023-02-07 03:35:10 +00:00
rustc_type_ir