1
Fork 0
rust/compiler
bors fec98b3bbc Auto merge of #125468 - BoxyUwU:remove_defid_from_regionparam, r=compiler-errors
Remove `DefId` from `EarlyParamRegion`

Currently we represent usages of `Region` parameters via the `ReEarlyParam` or `ReLateParam` variants. The `ReEarlyParam` is effectively equivalent to `TyKind::Param` and `ConstKind::Param` (i.e. it stores a `Symbol` and a `u32` index) however it also stores a `DefId` for the definition of the lifetime parameter.

This was used in roughly two places:
- Borrowck diagnostics instead of threading the appropriate `body_id` down to relevant locations. Interestingly there were already some places that had to pass down a `DefId` manually.
- Some opaque type checking logic was using the `DefId` field to track captured lifetimes

I've split this PR up into a commit for generate rote changes to diagnostics code to pass around a `DefId` manually everywhere, and another commit for the opaque type related changes which likely require more careful review as they might change the semantics of lints/errors.

Instead of manually passing the `DefId` around everywhere I previously tried to bundle it in with `TypeErrCtxt` but ran into issues with some call sites of `infcx.err_ctxt` being unable to provide a `DefId`, particularly places involved with trait solving and normalization. It might be worth investigating adding some new wrapper type to pass this around everywhere but I think this might be acceptable for now.

This pr also has the effect of reducing the size of `EarlyParamRegion` from 16 bytes -> 8 bytes. I wouldn't expect this to have any direct performance improvement however, other variants of `RegionKind` over `8` bytes are all because they contain a `BoundRegionKind` which is, as far as I know, mostly there for diagnostics. If we're ever able to remove this it would shrink the `RegionKind` type from `24` bytes to `12` (and with clever bit packing we might be able to get it to `8` bytes). I am curious what the performance impact would be of removing interning of `Region`'s if we ever manage to shrink `RegionKind` that much.

Sidenote: by removing the `DefId` the `Debug` output for `Region` has gotten significantly nicer. As an example see this opaque type debug print before vs after this PR:
`Opaque(DefId(0:13 ~ impl_trait_captures[aeb9]::foo::{opaque#0}), [DefId(0:9 ~ impl_trait_captures[aeb9]::foo::'a)_'a/#0, T, DefId(0:9 ~ impl_trait_captures[aeb9]::foo::'a)_'a/#0])`
`Opaque(DefId(0:13 ~ impl_trait_captures[aeb9]::foo::{opaque#0}), ['a/#0, T, 'a/#0])`

r? `@compiler-errors` (I would like someone who understands the opaque type setup to atleast review the type system commit, but the rest is likely reviewable by anyone)
2024-05-27 06:36:57 +00:00
..
rustc Change SIGPIPE ui from #[unix_sigpipe = "..."] to -Zon-broken-pipe=... 2024-05-02 19:48:29 +02:00
rustc_abi Temporarily revert to NonZeroUsize in rustc-abi to fix building on stable 2024-05-18 11:27:29 +03:00
rustc_arena
rustc_ast Rollup merge of #125316 - nnethercote:tweak-Spacing, r=petrochenkov 2024-05-23 07:41:18 +02:00
rustc_ast_ir Remove extern crate rustc_macros from numerous crates. 2024-04-29 10:21:54 +10:00
rustc_ast_lowering Rename Unsafe to Safety 2024-05-17 18:33:37 -03:00
rustc_ast_passes Rollup merge of #124048 - veera-sivarajan:bugfix-123773-c23-variadics, r=compiler-errors 2024-05-26 15:28:26 -07:00
rustc_ast_pretty Add some comments. 2024-05-23 06:03:17 +10:00
rustc_attr Rename buffer_lint_with_diagnostic to buffer_lint 2024-05-21 20:16:39 +00:00
rustc_baked_icu_data
rustc_borrowck Remove DefId from EarlyParamRegion (tedium/diagnostics) 2024-05-24 18:06:53 +01:00
rustc_builtin_macros Rollup merge of #125316 - nnethercote:tweak-Spacing, r=petrochenkov 2024-05-23 07:41:18 +02:00
rustc_codegen_cranelift Rollup merge of #125345 - durin42:thin-link-bitcode, r=bjorn3 2024-05-23 23:39:26 +02:00
rustc_codegen_gcc Rollup merge of #125345 - durin42:thin-link-bitcode, r=bjorn3 2024-05-23 23:39:26 +02:00
rustc_codegen_llvm Auto merge of #125463 - GuillaumeGomez:rollup-287wx4y, r=GuillaumeGomez 2024-05-24 03:04:06 +00:00
rustc_codegen_ssa Rollup merge of #125046 - bjorn3:no_mutable_static_linkage, r=cjgillot 2024-05-26 15:28:26 -07:00
rustc_const_eval Rollup merge of #125483 - workingjubilee:move-transform-validate-to-mir-transform, r=oli-obk 2024-05-24 23:01:09 +02:00
rustc_data_structures Rollup merge of #124818 - compiler-errors:ena, r=Mark-Simulacrum 2024-05-11 08:00:15 +02:00
rustc_driver
rustc_driver_impl Exit the process a short time after entering our ctrl-c handler 2024-05-24 17:43:02 -04:00
rustc_error_codes Remove a stray backtick in an error explanation. 2024-05-13 07:53:38 +10:00
rustc_error_messages Remove #[macro_use] extern crate tracing from rustc_error_messages. 2024-05-23 18:02:17 +10:00
rustc_errors Auto merge of #125335 - compiler-errors:binder, r=lcnr 2024-05-22 08:33:34 +00:00
rustc_expand Rollup merge of #125316 - nnethercote:tweak-Spacing, r=petrochenkov 2024-05-23 07:41:18 +02:00
rustc_feature Auto merge of #125326 - weiznich:move/do_not_recommend_to_diganostic_namespace, r=compiler-errors 2024-05-22 04:14:08 +00:00
rustc_fluent_macro
rustc_fs_util Stabilize std::path::absolute 2024-04-24 14:35:02 +00:00
rustc_graphviz
rustc_hir Rename Unsafe to Safety 2024-05-17 18:33:37 -03:00
rustc_hir_analysis Auto merge of #125468 - BoxyUwU:remove_defid_from_regionparam, r=compiler-errors 2024-05-27 06:36:57 +00:00
rustc_hir_pretty Rollup merge of #125158 - Nilstrieb:block-indent, r=compiler-errors 2024-05-21 00:47:02 +02:00
rustc_hir_typeck Rollup merge of #125469 - compiler-errors:dont-skip-inner-const-body, r=cjgillot 2024-05-26 15:28:27 -07:00
rustc_incremental Run rustfmt on files that need it. 2024-05-24 15:17:21 +10:00
rustc_index Simplify static_assert_sizes. 2024-04-18 15:36:25 +10:00
rustc_index_macros rustc_index: Add a ZERO constant to index types 2024-04-03 19:06:22 +03:00
rustc_infer Auto merge of #125468 - BoxyUwU:remove_defid_from_regionparam, r=compiler-errors 2024-05-27 06:36:57 +00:00
rustc_interface remove proof tree formatter, make em shallow 2024-05-24 18:41:31 +00:00
rustc_lexer Improved the compiler code with clippy 2024-04-24 09:41:44 +02:00
rustc_lint Auto merge of #125468 - BoxyUwU:remove_defid_from_regionparam, r=compiler-errors 2024-05-27 06:36:57 +00:00
rustc_lint_defs Auto merge of #124661 - RalfJung:only-structural-consts-in-patterns, r=pnkfelix 2024-05-26 07:55:47 +00:00
rustc_llvm thinlto: only build summary file if needed 2024-05-23 14:58:30 -04:00
rustc_log Use Backtrace::force_capture instead of Backtrace::capture in rustc_log 2024-05-21 10:54:36 +02:00
rustc_macros Rollup merge of #125391 - nnethercote:serialize-rs-tweaks, r=compiler-errors 2024-05-22 23:41:13 +02:00
rustc_metadata Auto merge of #125434 - nnethercote:rm-more-extern-tracing, r=jackh726 2024-05-23 21:36:54 +00:00
rustc_middle Auto merge of #125468 - BoxyUwU:remove_defid_from_regionparam, r=compiler-errors 2024-05-27 06:36:57 +00:00
rustc_mir_build Auto merge of #124661 - RalfJung:only-structural-consts-in-patterns, r=pnkfelix 2024-05-26 07:55:47 +00:00
rustc_mir_dataflow Remove #[macro_use] extern crate tracing from rustc_mir_dataflow. 2024-05-23 18:02:40 +10:00
rustc_mir_transform Avoid a FieldIdx::from_usize in InstSimplify 2024-05-26 13:31:28 -07:00
rustc_monomorphize Don't eagerly monomorphize drop for types that are impossible to instantiate 2024-05-24 21:53:39 -04:00
rustc_next_trait_solver Uplift binder 2024-05-21 17:00:45 -04:00
rustc_parse Remove #[macro_use] extern crate tracing from rustc_parse. 2024-05-23 18:02:40 +10:00
rustc_parse_format Simplify static_assert_sizes. 2024-04-18 15:36:25 +10:00
rustc_passes Auto merge of #125434 - nnethercote:rm-more-extern-tracing, r=jackh726 2024-05-23 21:36:54 +00:00
rustc_pattern_analysis Stabilize exclusive_range 2024-05-02 19:42:31 -04:00
rustc_privacy split out AliasTy -> AliasTerm 2024-05-13 11:59:42 -04:00
rustc_query_impl Remove extern crate rustc_middle from rustc_query_impl. 2024-05-13 08:20:18 +10:00
rustc_query_system Add a footer in FileEncoder and check for it in MemDecoder 2024-05-21 20:12:29 -04:00
rustc_resolve Rollup merge of #125156 - zachs18:for_loops_over_fallibles_behind_refs, r=Nilstrieb 2024-05-23 07:41:17 +02:00
rustc_sanitizers Fix typos (taking into account review comments) 2024-05-18 18:12:18 +02:00
rustc_serialize PR feedback 2024-05-21 20:12:30 -04:00
rustc_session remove proof tree formatter, make em shallow 2024-05-24 18:41:31 +00:00
rustc_smir Remove DefId from EarlyParamRegion (clippy/smir) 2024-05-24 18:06:57 +01:00
rustc_span Remove #[macro_use] extern crate tracing from rustc_span`. 2024-05-22 16:03:48 +10:00
rustc_symbol_mangling Rename Unsafe to Safety 2024-05-17 18:33:37 -03:00
rustc_target Stop using the avx512er and avx512pf x86 target features 2024-05-24 20:12:42 +02:00
rustc_trait_selection Auto merge of #125468 - BoxyUwU:remove_defid_from_regionparam, r=compiler-errors 2024-05-27 06:36:57 +00:00
rustc_traits split out AliasTy -> AliasTerm 2024-05-13 11:59:42 -04:00
rustc_transmute Align: add bytes_usize and bits_usize 2024-05-01 15:57:33 +02:00
rustc_ty_utils Remove DefId from EarlyParamRegion (tedium/diagnostics) 2024-05-24 18:06:53 +01:00
rustc_type_ir remove proof tree formatter, make em shallow 2024-05-24 18:41:31 +00:00
rustc_type_ir_macros Uplift TraitPredicate 2024-05-11 18:20:00 -04:00
stable_mir Remove DefId from EarlyParamRegion (clippy/smir) 2024-05-24 18:06:57 +01:00