Auto merge of #116952 - compiler-errors:lifetime_capture_rules_2024, r=TaKO8Ki

Implement 2024-edition lifetime capture rules RFC

Implements rust-lang/rfcs#3498.
This commit is contained in:
bors
2023-12-10 15:51:39 +00:00
11 changed files with 125 additions and 8 deletions

View File

@@ -1574,8 +1574,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
Vec::new()
}
hir::OpaqueTyOrigin::FnReturn(..) => {
if let FnDeclKind::Impl | FnDeclKind::Trait =
fn_kind.expect("expected RPITs to be lowered with a FnKind")
if matches!(
fn_kind.expect("expected RPITs to be lowered with a FnKind"),
FnDeclKind::Impl | FnDeclKind::Trait
) || self.tcx.features().lifetime_capture_rules_2024
|| span.at_least_rust_2024()
{
// return-position impl trait in trait was decided to capture all
// in-scope lifetimes, which we collect for all opaques during resolution.