rust/compiler
Stuart Cook 08e26fc678
Rollup merge of #144666 - compiler-errors:correct-late, r=lqd
Make sure to account for the right item universal regions in borrowck

Fixes https://github.com/rust-lang/rust/issues/144608.

The ICE comes from a mismatch between the liberated late bound regions (i.e. "`ReLateParam`"s) that come from promoting closure outlives, and the regions we have in our region vid mapping from `UniversalRegions`.

When building `UniversalRegions`, we end up using the liberated regions from the binder of the closure's signature:

c8bb4e8a12/compiler/rustc_borrowck/src/universal_regions.rs (L521)

Notably, this signature may be anonymized if the closure signature being deduced comes from an external constraints:

c8bb4e8a12/compiler/rustc_hir_typeck/src/closure.rs (L759-L762)

This is true in the test file I committed, where the signature is influenced by the `impl FnMut(&mut ())` RPIT.

However, when promoting a type outlives constraint we end up creating a late bound lifetime mapping that disagrees with those liberated late bound regions we constructed in `UniversalRegions`:

c8bb4e8a12/compiler/rustc_borrowck/src/universal_regions.rs (L299)

Specifically, in `for_each_late_bound_region_in_item` (which is called by `for_each_late_bound_region_in_recursive_scope`), we were using `tcx.late_bound_vars` which uses the late bound regions *from the HIR*. This query both undercounts the late bound regions (e.g. those that end up being deduced from bounds), and also doesn't account for the fact that we anonymize them in the signature as mentioned above.

c8bb4e8a12/compiler/rustc_borrowck/src/universal_regions.rs (L977)

This PR fixes that function to use the *correct signature*, which properly considers the bound vars that come from deducing the signature of the closure, and which comes from the closure's args from the `type_of` query.
2025-07-30 17:59:40 +10:00
..
rustc rename stable_mir to rustc_public, and rustc_smir to rustc_public_bridge 2025-07-14 09:25:54 +00:00
rustc_abi Reuse sign_extend helper 2025-07-29 14:17:48 +00:00
rustc_arena Introduce Arena::try_alloc_from_iter. 2025-04-19 01:13:18 +00:00
rustc_ast Don't lint against named labels in naked_asm! 2025-07-26 00:42:21 +01:00
rustc_ast_ir Use -Wunused_crate_dependencies for compiler crates. 2025-03-20 08:59:43 +11:00
rustc_ast_lowering Auto merge of #144557 - cjgillot:lower-more-span, r=compiler-errors 2025-07-29 17:39:48 +00:00
rustc_ast_passes use let chains in ast, borrowck, codegen, const_eval 2025-07-28 06:08:48 +05:00
rustc_ast_pretty use let chains in ast, borrowck, codegen, const_eval 2025-07-28 06:08:48 +05:00
rustc_attr_data_structures coverage: Rename CoverageStatus to CoverageAttrKind 2025-07-29 19:55:54 +10:00
rustc_attr_parsing coverage: Rename CoverageStatus to CoverageAttrKind 2025-07-29 19:55:54 +10:00
rustc_baked_icu_data Add unreachable_pub to RUSTC_LINT_FLAGS for compiler/ crates. 2025-03-11 13:14:21 +11:00
rustc_borrowck Rollup merge of #144666 - compiler-errors:correct-late, r=lqd 2025-07-30 17:59:40 +10:00
rustc_builtin_macros expand: Micro-optimize prelude injection 2025-07-28 17:35:09 +03:00
rustc_codegen_cranelift Remove [T]::array_chunks(_mut) 2025-07-27 23:03:07 -07:00
rustc_codegen_gcc Remove support for -Zcombine-cgu 2025-07-26 13:52:24 +00:00
rustc_codegen_llvm Rollup merge of #144407 - godzie44:godzie44/fix_dwarf_inconsistency, r=wesleywiser 2025-07-29 20:19:49 +10:00
rustc_codegen_ssa cc dependencies: clarify comment 2025-07-29 09:22:24 +02:00
rustc_const_eval Rename trait_of_item -> trait_of_assoc 2025-07-28 09:53:50 -05:00
rustc_data_structures Allow pretty printing paths with -Zself-profile-events=args 2025-07-25 22:24:21 +02:00
rustc_driver Remove recursion_limit increases. 2025-04-02 16:25:27 +11:00
rustc_driver_impl Rollup merge of #143719 - xizheyin:142812-1, r=jieyouxu 2025-07-18 04:27:51 +02:00
rustc_error_codes Update uitest stderrs 2025-07-23 13:33:23 +02:00
rustc_error_messages Remove unused feature gates 2025-06-28 23:36:46 +00:00
rustc_errors feat: Right align line numbers 2025-07-28 16:32:11 -06:00
rustc_expand Rollup merge of #143607 - JonathanBrouwer:proc_macro_attrs, r=jdonszelmann,traviscross 2025-07-28 01:16:38 +02:00
rustc_feature Mitigate #[align] name resolution ambiguity regression with a rename 2025-07-19 01:42:30 +08:00
rustc_fluent_macro Remove all unused feature gates from the compiler 2025-06-08 14:50:42 +00:00
rustc_fs_util Retry if creating temp fails with access denied 2025-04-25 11:28:36 +00:00
rustc_graphviz Remove #![warn(unreachable_pub)] from all compiler/ crates. 2025-03-11 13:14:21 +11:00
rustc_hashes Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00
rustc_hir Rollup merge of #144578 - FractalFir:m68k_fix, r=compiler-errors 2025-07-29 16:16:45 +10:00
rustc_hir_analysis Rename impl_of_method -> impl_of_assoc 2025-07-28 09:54:53 -05:00
rustc_hir_pretty parse const trait Trait 2025-07-17 18:06:26 +08:00
rustc_hir_typeck Create two methods to fix find_oldest_ancestor_in_same_ctxt 2025-07-29 14:54:47 +08:00
rustc_incremental Auto merge of #139758 - Zoxc:thread-local-graph, r=oli-obk 2025-05-07 12:39:54 +00:00
rustc_index use div_ceil instead of manual logic 2025-07-05 10:55:42 +02:00
rustc_index_macros In rustc_mir_tranform, iterate over index newtypes instead of ints 2025-04-12 11:53:07 +00:00
rustc_infer Add alias for ArgOutlivesPredicate 2025-07-15 16:02:26 +00:00
rustc_interface Stop compilation if macro expansion failed 2025-07-25 23:46:28 +02:00
rustc_lexer test(lexer): Add frontmatter unit test 2025-07-10 10:25:29 -05:00
rustc_lint Create two methods to fix find_oldest_ancestor_in_same_ctxt 2025-07-29 14:54:47 +08:00
rustc_lint_defs Rollup merge of #144014 - dianne:edition-guide-links, r=estebank 2025-07-24 15:08:21 +02:00
rustc_llvm cc dependencies: clarify comment 2025-07-29 09:22:24 +02:00
rustc_log Add documentation for init_logger_with_additional_layer 2025-06-12 12:11:15 +02:00
rustc_macros Implement AST visitors using a derive macro. 2025-07-22 01:52:34 +00:00
rustc_metadata Auto merge of #144469 - Kivooeo:chains-cleanup, r=SparrowLii 2025-07-28 05:25:23 +00:00
rustc_middle Auto merge of #144577 - oli-obk:wrapping-niche, r=scottmcm 2025-07-30 02:57:04 +00:00
rustc_mir_build fix: Reject upvar scrutinees for loop_match 2025-07-28 22:24:58 +09:00
rustc_mir_dataflow use let chains in hir, lint, mir 2025-07-28 06:10:14 +05:00
rustc_mir_transform Rollup merge of #144566 - scottmcm:align-of-slice, r=oli-obk 2025-07-29 23:50:35 +10:00
rustc_monomorphize Rename impl_of_method -> impl_of_assoc 2025-07-28 09:54:53 -05:00
rustc_next_trait_solver Auto merge of #143500 - compiler-errors:characterize-less, r=lcnr 2025-07-26 16:57:45 +00:00
rustc_parse Rollup merge of #144589 - compiler-errors:postfix-yield-after-cast, r=petrochenkov 2025-07-29 23:50:37 +10:00
rustc_parse_format update to literal-escaper-0.0.5 2025-07-08 10:16:44 +00:00
rustc_passes Rename impl_of_method -> impl_of_assoc 2025-07-28 09:54:53 -05:00
rustc_pattern_analysis Rollup merge of #144171 - Nadrieril:exhaustive-witnesses, r=davidtwco 2025-07-26 01:15:04 -05:00
rustc_privacy use let chains in mir, resolve, target 2025-07-28 06:10:36 +05:00
rustc_proc_macro update to literal-escaper-0.0.5 2025-07-08 10:16:44 +00:00
rustc_public remove movability from RigidTy::Coroutine and AggregateKind::Coroutine 2025-07-24 18:26:08 +08:00
rustc_public_bridge Remove useless lifetime parameter. 2025-07-23 23:54:37 +00:00
rustc_query_impl Remove unused allow attrs 2025-07-07 12:58:16 +00:00
rustc_query_system Auto merge of #144469 - Kivooeo:chains-cleanup, r=SparrowLii 2025-07-28 05:25:23 +00:00
rustc_resolve Rollup merge of #144605 - LorrensP-2158466:cache-extern-prelude, r=petrochenkov 2025-07-29 18:55:20 -04:00
rustc_sanitizers Rename impl_of_method -> impl_of_assoc 2025-07-28 09:54:53 -05:00
rustc_serialize use div_ceil instead of manual logic 2025-07-05 10:55:42 +02:00
rustc_session Auto merge of #144562 - matthiaskrgr:rollup-mlvn7qo, r=matthiaskrgr 2025-07-28 08:50:59 +00:00
rustc_span Create two methods to fix find_oldest_ancestor_in_same_ctxt 2025-07-29 14:54:47 +08:00
rustc_symbol_mangling use codegen_instance_attrs where an instance is (easily) available 2025-07-16 23:24:32 +02:00
rustc_target Rollup merge of #144640 - FractalFir:m68k_arch, r=Urgau 2025-07-29 18:55:22 -04:00
rustc_thread_pool Correct comments. 2025-06-28 17:58:21 +08:00
rustc_trait_selection Rename trait_of_item -> trait_of_assoc 2025-07-28 09:53:50 -05:00
rustc_traits Consider param-env for fast path 2025-07-20 17:45:01 +00:00
rustc_transmute compiler: Parse p- specs in datalayout string, allow definition of custom default data address space 2025-07-07 09:04:53 +02:00
rustc_ty_utils Rename trait_of_item -> trait_of_assoc 2025-07-28 09:53:50 -05:00
rustc_type_ir Avoid unnecessary new_adt/new_fn_def calls. 2025-07-24 10:24:45 +10:00
rustc_type_ir_macros Split TypeFolder and FallibleTypeFolder 2025-04-15 18:30:35 +00:00