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 Add a new rustc_driver dylib to rexport rustc_driver_impl 2023-02-02 07:34:41 +01:00
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 Rollup merge of #107544 - nnethercote:improve-TokenCursor, r=petrochenkov 2023-02-03 23:04:51 +05:30
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 Rollup merge of #107646 - estebank:specific-span, r=compiler-errors 2023-02-04 20:29:06 +01:00
rustc_builtin_macros Don't generate unecessary &&self.field in deriving Debug 2023-02-02 22:06:23 +00:00
rustc_codegen_cranelift Auto merge of #106227 - bryangarza:ctfe-limit, r=oli-obk 2023-01-29 04:11:27 +00:00
rustc_codegen_gcc session: diagnostic migration lint on more fns 2023-01-30 17:11:35 +00:00
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 Disallow impl autotrait for trait object 2023-02-03 08:33:40 -08:00
rustc_driver Remove unneeded extern crate 2023-02-02 07:47:39 +01:00
rustc_driver_impl Add a new rustc_driver dylib to rexport rustc_driver_impl 2023-02-02 07:34:41 +01:00
rustc_error_codes make unaligned_reference a hard error 2023-01-31 20:28:11 +01:00
rustc_error_messages Auto merge of #107727 - Dylan-DPC:rollup-b1yexcl, r=Dylan-DPC 2023-02-06 16:28:18 +00:00
rustc_errors Make "use latest edition" subdiagnostic translatable 2023-02-01 21:56:28 +01:00
rustc_expand rustc_expand: remove huge error imports 2023-02-05 03:47:22 +01:00
rustc_feature Auto merge of #107297 - Mark-Simulacrum:bump-bootstrap, r=pietroalbini 2023-01-31 19:24:29 +00:00
rustc_fs_util
rustc_graphviz
rustc_hir Rollup merge of #107125 - WaffleLapkin:expect_an_item_in_your_hir_by_the_next_morning, r=Nilstrieb 2023-01-30 17:50:08 +01:00
rustc_hir_analysis remove unused imports 2023-02-06 17:40:18 +03:00
rustc_hir_pretty Use Mutability::{is_mut, is_not} 2023-01-30 12:26:26 +00:00
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 incremental: migrate diagnostics 2023-01-30 17:11:35 +00:00
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 make unaligned_reference a hard error 2023-01-31 20:28:11 +01:00
rustc_llvm llvm-wrapper: adapt for LLVM API changes 2023-02-02 10:09:48 +00:00
rustc_log Add log-backtrace option to show backtraces along with logging 2023-01-12 00:17:48 +09:00
rustc_macros Forbid #[suggestion_*(...)] on Vecs 2023-02-01 21:49:45 +01:00
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 Simplify ReplacementMap. 2023-02-05 13:41:24 +00:00
rustc_monomorphize Auto merge of #100754 - davidtwco:translation-incremental, r=compiler-errors 2023-01-31 10:20:58 +00:00
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 Rollup merge of #106805 - madsravn:master, r=compiler-errors 2023-02-03 06:30:23 +01:00
rustc_passes rustc_passes: remove huge error imports 2023-02-05 03:47:58 +01:00
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 Support parallel compiler. 2023-02-04 15:56:50 +00:00
rustc_resolve Rename rust_2015 => is_rust_2015 2023-02-02 08:17:13 +00:00
rustc_save_analysis Review changes 2023-01-31 07:54:01 +00:00
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 Introduce GeneratorWitnessMIR. 2023-01-27 18:58:44 +00:00
rustc_target Auto merge of #106925 - imWildCat:imWildCat/remove-hardcoded-ios-macbi-target-version, r=wesleywiser 2023-02-02 05:26:09 +00:00
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 Separate witness type computation from the generator transform. 2023-01-27 19:00:26 +00:00