rust/compiler
bors 7f4b270aa4 Auto merge of #129313 - RalfJung:coroutine-niches, r=compiler-errors
Supress niches in coroutines to avoid aliasing violations

As mentioned [here](https://github.com/rust-lang/rust/issues/63818#issuecomment-2264915918), using niches in fields of coroutines that are referenced by other fields is unsound: the discriminant accesses violate the aliasing requirements of the reference pointing to the relevant field. This issue causes [Miri errors in practice](https://github.com/rust-lang/miri/issues/3780).

The "obvious" fix for this is to suppress niches in coroutines. That's what this PR does. However, we have several tests explicitly ensuring that we *do* use niches in coroutines. So I see two options:
- We guard this behavior behind a `-Z` flag (that Miri will set by default). There is no known case of these aliasing violations causing miscompilations. But absence of evidence is not evidence of absence...
- (What this PR does right now.) We temporarily adjust the coroutine layout logic and the associated tests until the proper fix lands. The "proper fix" here is to wrap fields that other fields can point to in [`UnsafePinned`](https://github.com/rust-lang/rust/issues/125735) and make `UnsafePinned` suppress niches; that would then still permit using niches of *other* fields (those that never get borrowed). However, I know that coroutine sizes are already a problem, so I am not sure if this temporary size regression is acceptable.

`@compiler-errors` any opinion? Also who else should be Cc'd here?
2024-09-08 03:11:12 +00:00
..
rustc disable size asserts in the compiler when randomizing layouts 2024-08-31 23:56:45 +02:00
rustc_abi inhibit layout randomization for Box 2024-08-31 23:56:45 +02:00
rustc_arena compiler: Remove feature(new_uninit) 2024-08-27 10:17:05 -07:00
rustc_ast Add initial support for raw lifetimes 2024-09-06 10:32:48 -04:00
rustc_ast_ir Add warn(unreachable_pub) to several crates. 2024-08-16 08:46:13 +10:00
rustc_ast_lowering chore: Fix typos in 'compiler' (batch 1) 2024-09-02 07:42:38 +02:00
rustc_ast_passes Create opaque definitions in resolver. 2024-08-31 20:14:43 +00:00
rustc_ast_pretty Add initial support for raw lifetimes 2024-09-06 10:32:48 -04:00
rustc_attr Rollup merge of #126013 - nnethercote:unreachable_pub, r=Urgau 2024-08-27 00:41:57 +02:00
rustc_baked_icu_data Don't add warn(unreachable_pub) to rustc_baked_icu. 2024-08-16 08:46:52 +10:00
rustc_borrowck Rollup merge of #129969 - GrigorenkoPV:boxed-ty, r=compiler-errors 2024-09-06 07:33:58 +02:00
rustc_builtin_macros Rollup merge of #123940 - kornelski:remove-derived-debug, r=Urgau 2024-08-29 16:21:46 +02:00
rustc_codegen_cranelift introduce PrettyPrintMirOptions for cosmetic MIR dump options 2024-08-30 07:07:28 +00:00
rustc_codegen_gcc Rollup merge of #128731 - RalfJung:simd-shuffle-vector, r=workingjubilee 2024-08-27 01:46:50 -05:00
rustc_codegen_llvm Auto merge of #129941 - BoxyUwU:bump-boostrap, r=albertlarsan68 2024-09-07 20:37:30 +00:00
rustc_codegen_ssa Auto merge of #129341 - madsmtm:refactor-deployment-target, r=petrochenkov 2024-09-07 01:37:52 +00:00
rustc_const_eval Make Ty::boxed_ty return an Option 2024-09-06 00:30:36 +03:00
rustc_data_structures Add an internal lint that warns when accessing untracked data 2024-09-03 19:14:19 +02:00
rustc_driver
rustc_driver_impl Auto merge of #129941 - BoxyUwU:bump-boostrap, r=albertlarsan68 2024-09-07 20:37:30 +00:00
rustc_error_codes chore: Fix typos in 'compiler' (batch 1) 2024-09-02 07:42:38 +02:00
rustc_error_messages Add warn(unreachable_pub) to rustc_error_messages. 2024-08-27 11:52:08 +10:00
rustc_errors Rollup merge of #129875 - Sajjon:sajjon_fix_typos_batch_1, r=compiler-errors,jieyouxu 2024-09-02 22:35:20 +02:00
rustc_expand Add initial support for raw lifetimes 2024-09-06 10:32:48 -04:00
rustc_feature Auto merge of #129941 - BoxyUwU:bump-boostrap, r=albertlarsan68 2024-09-07 20:37:30 +00:00
rustc_fluent_macro Add warn(unreachable_pub) to rustc_fluent_macro. 2024-08-27 12:56:54 +10:00
rustc_fs_util Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_graphviz Add warn(unreachable_pub) to rustc_graphviz. 2024-08-27 12:58:29 +10:00
rustc_hir Revert "Auto merge of #127537 - veluca93:struct_tf, r=BoxyUwU" 2024-09-01 16:35:53 +02:00
rustc_hir_analysis Auto merge of #126161 - Bryanskiy:delegation-generics-4, r=petrochenkov 2024-09-07 18:12:05 +00:00
rustc_hir_pretty Add warn(unreachable_pub) to rustc_hir_pretty. 2024-08-27 13:25:40 +10:00
rustc_hir_typeck Rollup merge of #129987 - compiler-errors:capture-place-region, r=davidtwco 2024-09-07 14:21:23 +03:00
rustc_incremental Add warn(unreachable_pub) to rustc_incremental. 2024-08-27 14:30:20 +10:00
rustc_index disable size asserts in the compiler when randomizing layouts 2024-08-31 23:56:45 +02:00
rustc_index_macros Remove usage of specialization from newtype_index! 2024-06-30 16:42:53 +00:00
rustc_infer chore: Fix typos in 'compiler' (batch 1) 2024-09-02 07:42:38 +02:00
rustc_interface stabilize -Znext-solver=coherence 2024-09-05 07:57:16 +00:00
rustc_lexer Add initial support for raw lifetimes 2024-09-06 10:32:48 -04:00
rustc_lint Rollup merge of #126452 - compiler-errors:raw-lifetimes, r=spastorino 2024-09-07 23:30:10 +02:00
rustc_lint_defs Rollup merge of #126452 - compiler-errors:raw-lifetimes, r=spastorino 2024-09-07 23:30:10 +02:00
rustc_llvm update cfgs 2024-09-05 17:24:01 +01:00
rustc_log Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_macros Add warn(unreachable_pub) to rustc_metadata. 2024-08-29 20:13:06 +10:00
rustc_metadata Auto merge of #128776 - Bryanskiy:deep-reject-ctxt, r=lcnr 2024-09-06 19:50:48 +00:00
rustc_middle Auto merge of #129941 - BoxyUwU:bump-boostrap, r=albertlarsan68 2024-09-07 20:37:30 +00:00
rustc_mir_build Revert "Auto merge of #127537 - veluca93:struct_tf, r=BoxyUwU" 2024-09-01 16:35:53 +02:00
rustc_mir_dataflow Adjust SanityCheck. 2024-09-03 15:18:30 +10:00
rustc_mir_transform Rollup merge of #129847 - compiler-errors:async-cycle, r=davidtwco 2024-09-07 23:30:13 +02:00
rustc_monomorphize Make Ty::boxed_ty return an Option 2024-09-06 00:30:36 +03:00
rustc_next_trait_solver Auto merge of #128776 - Bryanskiy:deep-reject-ctxt, r=lcnr 2024-09-06 19:50:48 +00:00
rustc_parse Rollup merge of #126452 - compiler-errors:raw-lifetimes, r=spastorino 2024-09-07 23:30:10 +02:00
rustc_parse_format Add warn(unreachable_pub) to rustc_parse_format. 2024-08-29 20:13:06 +10:00
rustc_passes Rollup merge of #128919 - Nadrieril:lint-query-leaks, r=cjgillot 2024-09-05 19:43:46 +02:00
rustc_pattern_analysis Rollup merge of #128934 - Nadrieril:fix-empty-non-exhaustive, r=compiler-errors 2024-09-03 19:13:24 +02:00
rustc_privacy Add warn(unreachable_pub) to rustc_privacy. 2024-08-29 20:18:44 +10:00
rustc_query_impl Add warn(unreachable_pub) to rustc_query_impl. 2024-08-29 20:18:44 +10:00
rustc_query_system chore: Fix typos in 'compiler' (batch 2) 2024-09-02 07:50:22 +02:00
rustc_resolve elided_named_lifetimes: unify lint def & pass MissingLifetimeKind 2024-09-06 15:47:52 +03:00
rustc_sanitizers Auto merge of #129777 - nnethercote:unreachable_pub-4, r=Urgau 2024-09-03 01:27:20 +00:00
rustc_serialize Auto merge of #129777 - nnethercote:unreachable_pub-4, r=Urgau 2024-09-03 01:27:20 +00:00
rustc_session stabilize -Znext-solver=coherence 2024-09-05 07:57:16 +00:00
rustc_smir Auto merge of #129777 - nnethercote:unreachable_pub-4, r=Urgau 2024-09-03 01:27:20 +00:00
rustc_span Rollup merge of #129899 - veera-sivarajan:fix-97793-pr-final, r=chenyukang 2024-09-07 14:21:22 +03:00
rustc_symbol_mangling Auto merge of #129777 - nnethercote:unreachable_pub-4, r=Urgau 2024-09-03 01:27:20 +00:00
rustc_target Auto merge of #129941 - BoxyUwU:bump-boostrap, r=albertlarsan68 2024-09-07 20:37:30 +00:00
rustc_trait_selection Auto merge of #126161 - Bryanskiy:delegation-generics-4, r=petrochenkov 2024-09-07 18:12:05 +00:00
rustc_traits Add warn(unreachable_pub) to rustc_traits. 2024-09-03 08:49:54 +10:00
rustc_transmute update cfgs 2024-09-05 17:24:01 +01:00
rustc_ty_utils Auto merge of #129313 - RalfJung:coroutine-niches, r=compiler-errors 2024-09-08 03:11:12 +00:00
rustc_type_ir Auto merge of #129941 - BoxyUwU:bump-boostrap, r=albertlarsan68 2024-09-07 20:37:30 +00:00
rustc_type_ir_macros Reformat use declarations. 2024-07-29 08:26:52 +10:00
stable_mir chore: Fix typos in 'compiler' (batch 3) 2024-09-02 07:33:41 +02:00