1
Fork 0

Greatly simplify lifetime captures in edition 2024

This commit is contained in:
Michael Goulet 2025-02-20 18:58:46 +00:00
parent 46420c9607
commit 12e3911d81
84 changed files with 223 additions and 294 deletions

View file

@ -20,7 +20,6 @@ use std::ops::Bound;
use rustc_abi::ExternAbi;
use rustc_ast::Recovered;
use rustc_data_structures::captures::Captures;
use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
use rustc_data_structures::unord::UnordMap;
use rustc_errors::{
@ -1690,10 +1689,10 @@ fn polarity_of_impl(
/// the lifetimes that are declared. For fns or methods, we have to
/// screen out those that do not appear in any where-clauses etc using
/// `resolve_lifetime::early_bound_lifetimes`.
fn early_bound_lifetimes_from_generics<'a, 'tcx: 'a>(
fn early_bound_lifetimes_from_generics<'a, 'tcx>(
tcx: TyCtxt<'tcx>,
generics: &'a hir::Generics<'a>,
) -> impl Iterator<Item = &'a hir::GenericParam<'a>> + Captures<'tcx> {
) -> impl Iterator<Item = &'a hir::GenericParam<'a>> {
generics.params.iter().filter(move |param| match param.kind {
GenericParamKind::Lifetime { .. } => !tcx.is_late_bound(param.hir_id),
_ => false,

View file

@ -160,7 +160,7 @@ enum Scope<'a> {
impl<'a> Scope<'a> {
// A helper for debugging scopes without printing parent scopes
fn debug_truncated(&'a self) -> impl fmt::Debug + 'a {
fn debug_truncated(&self) -> impl fmt::Debug {
fmt::from_fn(move |f| match self {
Self::Binder { bound_vars, scope_type, hir_id, where_bound_origin, s: _ } => f
.debug_struct("Binder")
@ -2159,10 +2159,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
/// Walk the generics of the item for a trait bound whose self type
/// corresponds to the expected res, and return the trait def id.
fn for_each_trait_bound_on_res(
&self,
expected_res: Res,
) -> impl Iterator<Item = DefId> + use<'tcx, '_> {
fn for_each_trait_bound_on_res(&self, expected_res: Res) -> impl Iterator<Item = DefId> {
std::iter::from_coroutine(
#[coroutine]
move || {