os-rust/compiler
Matthias Krüger bc22740882
Rollup merge of #131789 - compiler-errors:capture-more, r=fmease
Make sure that outer opaques capture inner opaques's lifetimes even with precise capturing syntax

When lowering an opaque, we must capture and duplicate all of the lifetimes in the opaque's bounds to correctly lower the opaque's bounds. We do this *even if* the lifetime is not captured according to the `+ use<>` precise capturing bound; in that case, we will later reject that captured lifetime. For example, Given an opaque like `impl Sized + 'a + use<>`, we will still duplicate `'a` but later error that it is not mentioned in the `use<>` bound.

The current heuristic was not properly handling cases like:

```
//@ edition: 2024
fn foo<'a>() -> impl Trait<Assoc = impl Trait2> + use<> {}
```

Which forces the outer `impl Trait` to capture `'a` since `impl Trait2` *implicitly* captures `'a` due to the new lifetime capture rules for edition 2024. We were only capturing lifetimes syntactically mentioned in the bounds. (Note that this still is an error; we just need to capture `'a` so it is handled later in the compiler correctly -- hence the ICE in #131769 where a late-bound lifetime was being referenced outside of its binder).

This PR reworks the way we collect lifetimes to capture and duplicate in AST lowering to fix this.

Fixes #131769
2024-10-19 22:00:57 +02:00
..
rustc disable size asserts in the compiler when randomizing layouts 2024-08-31 23:56:45 +02:00
rustc_abi compiler: Wire {TyAnd,}Layout into rustc_abi 2024-10-11 17:41:52 -07:00
rustc_arena Remove unnecessary lifetimes from Arena. 2024-09-13 15:33:19 +10:00
rustc_ast Auto merge of #131723 - matthiaskrgr:rollup-krcslig, r=matthiaskrgr 2024-10-15 11:50:31 +00:00
rustc_ast_ir Add sugar for &pin (const|mut) types 2024-10-07 11:15:04 -07:00
rustc_ast_lowering Make sure that outer opaques capture inner opaques's lifetimes even with precise capturing syntax 2024-10-19 18:02:26 +00:00
rustc_ast_passes Auto merge of #130654 - lcnr:stabilize-coherence-again, r=compiler-errors 2024-10-15 14:21:34 +00:00
rustc_ast_pretty Auto merge of #131723 - matthiaskrgr:rollup-krcslig, r=matthiaskrgr 2024-10-15 11:50:31 +00:00
rustc_attr Handle gracefully true/false in cfg(target(..)) compact 2024-10-16 09:41:49 +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 #127675 - chenyukang:yukang-fix-127562-addr, r=petrochenkov 2024-10-19 22:00:55 +02:00
rustc_builtin_macros Auto merge of #131723 - matthiaskrgr:rollup-krcslig, r=matthiaskrgr 2024-10-15 11:50:31 +00:00
rustc_codegen_cranelift Allow dropping dyn principal 2024-10-17 20:43:31 +02:00
rustc_codegen_gcc intrinsics.fmuladdf{16,32,64,128}: expose llvm.fmuladd.* semantics 2024-10-11 15:32:56 -06:00
rustc_codegen_llvm llvm: Match aarch64 data layout to new LLVM layout 2024-10-16 01:16:44 +00:00
rustc_codegen_ssa Allow dropping dyn principal 2024-10-17 20:43:31 +02:00
rustc_const_eval interpret errors: add map_err_kind, rename InterpError -> InterpErrorKind 2024-10-19 09:22:38 +02:00
rustc_data_structures Auto merge of #131767 - cuviper:bump-stage0, r=Mark-Simulacrum 2024-10-16 14:40:08 +00:00
rustc_driver Use tidy to sort crate attributes for all compiler crates. 2024-06-12 15:49:10 +10:00
rustc_driver_impl Rollup merge of #130899 - bjorn3:wasi_bootstrap_fixes, r=davidtwco 2024-10-07 11:10:53 -07:00
rustc_error_codes Fix typo in E0793 2024-10-09 10:28:16 -07:00
rustc_error_messages Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
rustc_errors Rollup merge of #131344 - nnethercote:ref-Lrc, r=compiler-errors 2024-10-07 12:23:54 +02:00
rustc_expand Auto merge of #131723 - matthiaskrgr:rollup-krcslig, r=matthiaskrgr 2024-10-15 11:50:31 +00:00
rustc_feature replace placeholder version 2024-10-15 20:13:55 -07:00
rustc_fluent_macro Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
rustc_fs_util Couple of changes to make it easier to compile rustc for wasm 2024-09-26 19:51:14 +00:00
rustc_graphviz Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
rustc_hir Auto merge of #131723 - matthiaskrgr:rollup-krcslig, r=matthiaskrgr 2024-10-15 11:50:31 +00:00
rustc_hir_analysis Rollup merge of #128391 - cafce25:issue-128390, r=lcnr 2024-10-17 12:07:19 +02:00
rustc_hir_pretty Move trait bound modifiers into hir::PolyTraitRef 2024-10-14 09:20:38 -04:00
rustc_hir_typeck Mark unexpected variant res suggestion as having placeholders 2024-10-18 12:30:27 -04:00
rustc_incremental Rename NestedMetaItem to MetaItemInner 2024-10-06 23:28:30 +09:00
rustc_index Rollup merge of #130625 - heiseish:issue-124028-fix, r=jieyouxu 2024-10-10 12:49:18 +02:00
rustc_index_macros Remove 'apostrophes' from rustc_parse_format 2024-10-14 23:22:51 +02:00
rustc_infer move defining_opaque_types out of Canonical 2024-10-17 10:22:52 +02:00
rustc_interface stabilize -Znext-solver=coherence 2024-10-15 13:11:00 +02:00
rustc_lexer Reserve guarded string literals (RFC 3593) 2024-10-08 18:21:16 -06:00
rustc_lint Rollup merge of #116863 - workingjubilee:non-exhaustive-is-not-ffi-unsafe, r=jieyouxu 2024-10-19 22:00:54 +02:00
rustc_lint_defs Auto merge of #131792 - matthiaskrgr:rollup-480nwg4, r=matthiaskrgr 2024-10-16 17:58:25 +00:00
rustc_llvm clang-format 2024-10-16 21:46:52 +00:00
rustc_log Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
rustc_macros Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
rustc_metadata rustc_metadata: reduce repetition 2024-10-17 11:13:28 -04:00
rustc_middle interpret errors: add map_err_kind, rename InterpError -> InterpErrorKind 2024-10-19 09:22:38 +02:00
rustc_mir_build Rollup merge of #131381 - Nadrieril:min-match-ergonomics, r=pnkfelix 2024-10-16 19:18:30 +02:00
rustc_mir_dataflow Add defaults for Analysis::apply_{call_return_effect,terminator_effect}. 2024-10-14 16:35:47 +11:00
rustc_mir_transform interpret errors: add map_err_kind, rename InterpError -> InterpErrorKind 2024-10-19 09:22:38 +02:00
rustc_monomorphize Add fast-path when computing the default visibility 2024-10-14 16:37:54 +02:00
rustc_next_trait_solver Rollup merge of #131857 - WaffleLapkin:dyn-drop-principal-3, r=compiler-errors 2024-10-18 06:59:07 +02:00
rustc_parse Auto merge of #131723 - matthiaskrgr:rollup-krcslig, r=matthiaskrgr 2024-10-15 11:50:31 +00:00
rustc_parse_format Remove 'apostrophes' from rustc_parse_format 2024-10-14 23:22:51 +02:00
rustc_passes Unify secondary_span and swap_secondary_and_primary 2024-10-15 14:39:49 -04:00
rustc_pattern_analysis cleanup: don't clone types that are Copy 2024-09-29 13:31:30 +02:00
rustc_privacy Visit opaques for visibilities. 2024-10-04 23:31:55 +00:00
rustc_query_impl Handle rustc_query_impl cases of rustc::potential_query_instability lint 2024-10-03 12:47:08 +03:00
rustc_query_system add unstable support for outputting file checksums for use in cargo 2024-10-01 21:23:20 -06:00
rustc_resolve Fix #131471, range misleading field access 2024-10-18 17:27:28 +02:00
rustc_sanitizers Fix some pub(crate) that were undetected bc of instrument 2024-10-04 14:02:09 -04:00
rustc_serialize Fix explicit_iter_loop in rustc_serialize 2024-10-16 15:44:16 +02:00
rustc_session stabilize -Znext-solver=coherence 2024-10-15 13:11:00 +02:00
rustc_smir various fixes for naked_asm! implementation 2024-10-06 19:00:09 +02:00
rustc_span Auto merge of #129458 - EnzymeAD:enzyme-frontend, r=jieyouxu 2024-10-15 01:30:01 +00:00
rustc_symbol_mangling Rollup merge of #130344 - Jaic1:fix-116306, r=BoxyUwU 2024-09-23 06:45:33 +02:00
rustc_target Default to the medium code model on OpenHarmony LoongArch target 2024-10-18 14:16:51 +08:00
rustc_trait_selection Rollup merge of #131864 - lrh2000:upcast_reorder, r=WaffleLapkin 2024-10-18 14:52:25 +01:00
rustc_traits move defining_opaque_types out of Canonical 2024-10-17 10:22:52 +02:00
rustc_transmute Fix some pub(crate) that were undetected bc of instrument 2024-10-04 14:02:09 -04:00
rustc_ty_utils Auto merge of #131211 - bjorn3:rust_abi_follow_c_rules, r=nikic,jieyouxu 2024-10-19 14:21:46 +00:00
rustc_type_ir Rollup merge of #131815 - workingjubilee:did-you-mean-is-none-or, r=jieyouxu 2024-10-17 12:07:22 +02:00
rustc_type_ir_macros Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
stable_mir Rollup merge of #131778 - practicalrs:fix_needless_lifetimes, r=jieyouxu 2024-10-16 20:15:56 +02:00