rust/compiler
bors c78ebb7bdc Auto merge of #87123 - RalfJung:miri-provenance-overhaul, r=oli-obk
CTFE/Miri engine Pointer type overhaul

This fixes the long-standing problem that we are using `Scalar` as a type to represent pointers that might be integer values (since they point to a ZST). The main problem is that with int-to-ptr casts, there are multiple ways to represent the same pointer as a `Scalar` and it is unclear if "normalization" (i.e., the cast) already happened or not. This leads to ugly methods like `force_mplace_ptr` and `force_op_ptr`.
Another problem this solves is that in Miri, it would make a lot more sense to have the `Pointer::offset` field represent the full absolute address (instead of being relative to the `AllocId`). This means we can do ptr-to-int casts without access to any machine state, and it means that the overflow checks on pointer arithmetic are (finally!) accurate.

To solve this, the `Pointer` type is made entirely parametric over the provenance, so that we can use `Pointer<AllocId>` inside `Scalar` but use `Pointer<Option<AllocId>>` when accessing memory (where `None` represents the case that we could not figure out an `AllocId`; in that case the `offset` is an absolute address). Moreover, the `Provenance` trait determines if a pointer with a given provenance can be cast to an integer by simply dropping the provenance.

I hope this can be read commit-by-commit, but the first commit does the bulk of the work. It introduces some FIXMEs that are resolved later.
Fixes https://github.com/rust-lang/miri/issues/841
Miri PR: https://github.com/rust-lang/miri/pull/1851
r? `@oli-obk`
2021-07-17 15:26:27 +00:00
..
rustc use jemallocator in rustc/rustdoc 2021-04-04 14:10:26 -07:00
rustc_apfloat Use HTTPS links where possible 2021-06-23 16:26:46 -04:00
rustc_arena Remove (lots of) dead code 2021-03-27 22:16:33 -04:00
rustc_ast Auto merge of #83918 - workingjubilee:stable-rangefrom-pat, r=joshtriplett 2021-07-11 06:31:42 +00:00
rustc_ast_lowering Remove refs from pat slices 2021-07-15 16:09:57 -05:00
rustc_ast_passes Auto merge of #83918 - workingjubilee:stable-rangefrom-pat, r=joshtriplett 2021-07-11 06:31:42 +00:00
rustc_ast_pretty Rework SESSION_GLOBALS API to prevent overwriting it 2021-07-08 16:16:28 +02:00
rustc_attr Enhance well-formedness checks for #[repr(...)] attributes 2021-07-09 22:03:48 +02:00
rustc_builtin_macros expand: Support helper attributes for built-in derive macros 2021-07-13 21:59:22 +03:00
rustc_codegen_cranelift fix cranelift 2021-07-14 18:17:49 +02:00
rustc_codegen_llvm Auto merge of #87123 - RalfJung:miri-provenance-overhaul, r=oli-obk 2021-07-17 15:26:27 +00:00
rustc_codegen_ssa Auto merge of #87123 - RalfJung:miri-provenance-overhaul, r=oli-obk 2021-07-17 15:26:27 +00:00
rustc_data_structures Fix VecMap Extend impl 2021-07-13 15:05:29 +00:00
rustc_driver Auto merge of #80182 - in42:stack_trace, r=tmandry 2021-07-02 05:40:51 +00:00
rustc_error_codes Rollup merge of #86838 - lambinoo:I-69630-rust_const_unstable_check_const, r=oli-obk 2021-07-08 18:30:34 +02:00
rustc_errors Simplify future incompatible reporting. 2021-07-11 13:08:58 -07:00
rustc_expand Rollup merge of #87027 - petrochenkov:builderhelp, r=oli-obk 2021-07-14 19:53:35 +02:00
rustc_feature Auto merge of #87201 - GuillaumeGomez:rollup-4loi2q9, r=GuillaumeGomez 2021-07-16 19:04:16 +00:00
rustc_fs_util
rustc_graphviz Use HTTPS links where possible 2021-06-23 16:26:46 -04:00
rustc_hir Remove refs from pat slices 2021-07-15 16:09:57 -05:00
rustc_hir_pretty Rollup merge of #86358 - klensy:pp-loop, r=Mark-Simulacrum 2021-06-29 00:26:55 +09:00
rustc_incremental Revert "Revert "Merge CrateDisambiguator into StableCrateId"" 2021-07-06 11:28:04 +02:00
rustc_index Remove unused feature gates 2021-05-31 13:55:43 +02:00
rustc_infer Add initial implementation of HIR-based WF checking for diagnostics 2021-07-16 16:29:02 -05:00
rustc_interface Rollup merge of #87145 - jsgf:fix-lint-opt-hash, r=michaelwoerister 2021-07-16 10:08:07 +02:00
rustc_lexer Rename 'bad prefix' to 'unknown prefix'. 2021-06-26 23:11:14 +08:00
rustc_lint Make GATs no longer incomplete 2021-07-16 00:22:01 -04:00
rustc_lint_defs Simplify future incompatible reporting. 2021-07-11 13:08:58 -07:00
rustc_llvm Upgrade cc crate to 1.0.69 2021-07-13 17:58:50 +09:00
rustc_macros Fix default_hash_types to use resolved path 2021-07-09 09:10:45 -05:00
rustc_metadata Auto merge of #86876 - jyn514:56935-target-crate-num, r=petrochenkov 2021-07-15 02:39:38 +00:00
rustc_middle Auto merge of #87123 - RalfJung:miri-provenance-overhaul, r=oli-obk 2021-07-17 15:26:27 +00:00
rustc_mir Auto merge of #87123 - RalfJung:miri-provenance-overhaul, r=oli-obk 2021-07-17 15:26:27 +00:00
rustc_mir_build Auto merge of #87123 - RalfJung:miri-provenance-overhaul, r=oli-obk 2021-07-17 15:26:27 +00:00
rustc_parse Suggest a path separator if a stray colon is found in a match arm 2021-07-14 01:15:59 +02:00
rustc_parse_format Rework SESSION_GLOBALS API to prevent overwriting it 2021-07-08 16:16:28 +02:00
rustc_passes Auto merge of #86857 - fee1-dead:add-attr, r=oli-obk 2021-07-13 06:59:34 +00:00
rustc_plugin_impl Use () for plugin_registrar_fn. 2021-05-12 13:58:43 +02:00
rustc_privacy Make resolutions a query. 2021-07-06 19:22:27 +02:00
rustc_query_impl Add initial implementation of HIR-based WF checking for diagnostics 2021-07-16 16:29:02 -05:00
rustc_query_system Auto merge of #85154 - cjgillot:lessfn, r=bjorn3 2021-06-15 14:52:58 +00:00
rustc_resolve Rollup merge of #87134 - BoxyUwU:cgd-self-ty-error, r=lcnr 2021-07-15 21:19:20 +09:00
rustc_save_analysis rustc_span: Revert addition of proc_macro field to ExpnKind::Macro 2021-07-10 23:03:35 +03:00
rustc_serialize Emit warnings for unused fields in custom targets. 2021-06-17 21:48:02 +02:00
rustc_session Rollup merge of #87145 - jsgf:fix-lint-opt-hash, r=michaelwoerister 2021-07-16 10:08:07 +02:00
rustc_span Auto merge of #87106 - Mark-Simulacrum:edition-no-clone, r=petrochenkov 2021-07-14 01:41:12 +00:00
rustc_symbol_mangling Revert "Revert "Merge CrateDisambiguator into StableCrateId"" 2021-07-06 11:28:04 +02:00
rustc_target Auto merge of #87124 - Andy-Python-Programmer:code_model_uefi_patch, r=petrochenkov 2021-07-17 10:15:33 +00:00
rustc_trait_selection Auto merge of #83898 - Aaron1011:feature/hir-wf, r=estebank 2021-07-16 21:54:42 +00:00
rustc_traits Add initial implementation of HIR-based WF checking for diagnostics 2021-07-16 16:29:02 -05:00
rustc_ty_utils Add impl_constness query 2021-07-10 20:54:49 +08:00
rustc_type_ir Remove unused feature gates 2021-05-31 13:55:43 +02:00
rustc_typeck Auto merge of #83898 - Aaron1011:feature/hir-wf, r=estebank 2021-07-16 21:54:42 +00:00