diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 0e28590bd6609..65813899bf5c5 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -43,7 +43,6 @@ use rustc_ast::node_id::NodeMap; use rustc_ast::{self as ast, *}; -use rustc_data_structures::captures::Captures; use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::sorted_map::SortedMap; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; @@ -1803,7 +1802,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { &'s mut self, params: &'s [GenericParam], source: hir::GenericParamSource, - ) -> impl Iterator> + Captures<'a> + Captures<'s> { + ) -> impl Iterator> + use<'a, 'hir, 's> { params.iter().map(move |param| self.lower_generic_param(param, source)) } @@ -1968,7 +1967,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { &'s mut self, bounds: &'s [GenericBound], itctx: ImplTraitContext, - ) -> impl Iterator> + Captures<'s> + Captures<'a> { + ) -> impl Iterator> + use<'a, 'hir, 's> { bounds.iter().map(move |bound| self.lower_param_bound(bound, itctx)) } diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs index 4d19d89b3ce24..a7d0ddcfaaae4 100644 --- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs @@ -8,7 +8,6 @@ use std::ops::ControlFlow; use either::Either; use hir::{ClosureKind, Path}; -use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::FxIndexSet; use rustc_errors::codes::*; use rustc_errors::{Applicability, Diag, MultiSpan, struct_span_code_err}; @@ -3524,7 +3523,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { fn predecessor_locations<'a, 'tcx>( body: &'a mir::Body<'tcx>, location: Location, - ) -> impl Iterator + Captures<'tcx> + 'a { + ) -> impl Iterator + use<'a, 'tcx> { if location.statement_index == 0 { let predecessors = body.basic_blocks.predecessors()[location.block].to_vec(); Either::Left(predecessors.into_iter().map(move |bb| body.terminator_loc(bb))) diff --git a/compiler/rustc_borrowck/src/member_constraints.rs b/compiler/rustc_borrowck/src/member_constraints.rs index a0adf471fd31f..2078a118b44de 100644 --- a/compiler/rustc_borrowck/src/member_constraints.rs +++ b/compiler/rustc_borrowck/src/member_constraints.rs @@ -1,7 +1,6 @@ use std::hash::Hash; use std::ops::Index; -use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::FxIndexMap; use rustc_index::{IndexSlice, IndexVec}; use rustc_middle::ty::{self, Ty}; @@ -149,7 +148,7 @@ where { pub(crate) fn all_indices( &self, - ) -> impl Iterator + Captures<'tcx> + '_ { + ) -> impl Iterator + use<'tcx, '_, R> { self.constraints.indices() } @@ -159,7 +158,7 @@ where pub(crate) fn indices( &self, member_region_vid: R, - ) -> impl Iterator + Captures<'tcx> + '_ { + ) -> impl Iterator + use<'tcx, '_, R> { let mut next = self.first_constraints.get(&member_region_vid).cloned(); std::iter::from_fn(move || -> Option { if let Some(current) = next { diff --git a/compiler/rustc_data_structures/src/captures.rs b/compiler/rustc_data_structures/src/captures.rs deleted file mode 100644 index 677ccb31454ea..0000000000000 --- a/compiler/rustc_data_structures/src/captures.rs +++ /dev/null @@ -1,8 +0,0 @@ -/// "Signaling" trait used in impl trait to tag lifetimes that you may -/// need to capture but don't really need for other reasons. -/// Basically a workaround; see [this comment] for details. -/// -/// [this comment]: https://github.com/rust-lang/rust/issues/34511#issuecomment-373423999 -pub trait Captures<'a> {} - -impl<'a, T: ?Sized> Captures<'a> for T {} diff --git a/compiler/rustc_data_structures/src/lib.rs b/compiler/rustc_data_structures/src/lib.rs index 65d586124b33a..597d7fd9e6c90 100644 --- a/compiler/rustc_data_structures/src/lib.rs +++ b/compiler/rustc_data_structures/src/lib.rs @@ -48,7 +48,6 @@ pub use rustc_index::static_assert_size; pub mod aligned; pub mod base_n; pub mod binary_search_util; -pub mod captures; pub mod fingerprint; pub mod flat_map_in_place; pub mod flock; diff --git a/compiler/rustc_hir_analysis/src/collect.rs b/compiler/rustc_hir_analysis/src/collect.rs index d41b03640b696..f0c917767008e 100644 --- a/compiler/rustc_hir_analysis/src/collect.rs +++ b/compiler/rustc_hir_analysis/src/collect.rs @@ -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::{ @@ -1705,7 +1704,7 @@ fn polarity_of_impl( fn early_bound_lifetimes_from_generics<'a, 'tcx: 'a>( tcx: TyCtxt<'tcx>, generics: &'a hir::Generics<'a>, -) -> impl Iterator> + Captures<'tcx> { +) -> impl Iterator> + use<'a, 'tcx> { generics.params.iter().filter(move |param| match param.kind { GenericParamKind::Lifetime { .. } => !tcx.is_late_bound(param.hir_id), _ => false, diff --git a/compiler/rustc_infer/src/infer/canonical/query_response.rs b/compiler/rustc_infer/src/infer/canonical/query_response.rs index d5aab4781de86..2f5277a3e23f6 100644 --- a/compiler/rustc_infer/src/infer/canonical/query_response.rs +++ b/compiler/rustc_infer/src/infer/canonical/query_response.rs @@ -10,7 +10,6 @@ use std::fmt::Debug; use std::iter; -use rustc_data_structures::captures::Captures; use rustc_index::{Idx, IndexVec}; use rustc_middle::arena::ArenaAllocatable; use rustc_middle::mir::ConstraintCategory; @@ -547,7 +546,7 @@ impl<'tcx> InferCtxt<'tcx> { param_env: ty::ParamEnv<'tcx>, uninstantiated_region_constraints: &'a [QueryOutlivesConstraint<'tcx>], result_args: &'a CanonicalVarValues<'tcx>, - ) -> impl Iterator> + 'a + Captures<'tcx> { + ) -> impl Iterator> + 'a { uninstantiated_region_constraints.iter().map(move |&constraint| { let predicate = instantiate_value(self.tcx, result_args, constraint); self.query_outlives_constraint_to_obligation(predicate, cause.clone(), param_env) diff --git a/compiler/rustc_infer/src/infer/mod.rs b/compiler/rustc_infer/src/infer/mod.rs index 1f7180fb80a0c..730e858c399a3 100644 --- a/compiler/rustc_infer/src/infer/mod.rs +++ b/compiler/rustc_infer/src/infer/mod.rs @@ -15,7 +15,6 @@ use region_constraints::{ }; pub use relate::StructurallyRelateAliases; pub use relate::combine::PredicateEmittingRelation; -use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::{FxHashSet, FxIndexMap}; use rustc_data_structures::undo_log::{Rollback, UndoLogs}; use rustc_data_structures::unify as ut; @@ -1297,7 +1296,7 @@ impl<'tcx> InferCtxt<'tcx> { #[inline] pub fn is_ty_infer_var_definitely_unchanged<'a>( &'a self, - ) -> (impl Fn(TyOrConstInferVar) -> bool + Captures<'tcx> + 'a) { + ) -> (impl Fn(TyOrConstInferVar) -> bool + use<'tcx, 'a>) { // This hoists the borrow/release out of the loop body. let inner = self.inner.try_borrow(); diff --git a/compiler/rustc_metadata/src/rmeta/decoder.rs b/compiler/rustc_metadata/src/rmeta/decoder.rs index e02c4871f35bd..bf710adcbf8f1 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder.rs @@ -7,7 +7,6 @@ use std::{io, iter, mem}; pub(super) use cstore_impl::provide; use proc_macro::bridge::client::ProcMacro; use rustc_ast as ast; -use rustc_data_structures::captures::Captures; use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::owned_slice::OwnedSlice; @@ -958,7 +957,7 @@ impl CrateRoot { pub(crate) fn decode_crate_deps<'a>( &self, metadata: &'a MetadataBlob, - ) -> impl ExactSizeIterator + Captures<'a> { + ) -> impl ExactSizeIterator + 'a { self.crate_deps.decode(metadata) } } diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs index bbb8bdce4a0ca..20f1ee481ebfa 100644 --- a/compiler/rustc_middle/src/mir/mod.rs +++ b/compiler/rustc_middle/src/mir/mod.rs @@ -12,7 +12,6 @@ use either::Either; use polonius_engine::Atom; use rustc_abi::{FieldIdx, VariantIdx}; pub use rustc_ast::Mutability; -use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::graph::dominators::Dominators; use rustc_errors::{DiagArgName, DiagArgValue, DiagMessage, ErrorGuaranteed, IntoDiagArg}; @@ -481,7 +480,7 @@ impl<'tcx> Body<'tcx> { /// Returns an iterator over all user-declared mutable locals. #[inline] - pub fn mut_vars_iter<'a>(&'a self) -> impl Iterator + Captures<'tcx> + 'a { + pub fn mut_vars_iter<'a>(&'a self) -> impl Iterator + use<'tcx, 'a> { (self.arg_count + 1..self.local_decls.len()).filter_map(move |index| { let local = Local::new(index); let decl = &self.local_decls[local]; @@ -491,9 +490,7 @@ impl<'tcx> Body<'tcx> { /// Returns an iterator over all user-declared mutable arguments and locals. #[inline] - pub fn mut_vars_and_args_iter<'a>( - &'a self, - ) -> impl Iterator + Captures<'tcx> + 'a { + pub fn mut_vars_and_args_iter<'a>(&'a self) -> impl Iterator + use<'tcx, 'a> { (1..self.local_decls.len()).filter_map(move |index| { let local = Local::new(index); let decl = &self.local_decls[local]; diff --git a/compiler/rustc_middle/src/ty/adt.rs b/compiler/rustc_middle/src/ty/adt.rs index e28fcc555dcd1..19ed9f812a3fc 100644 --- a/compiler/rustc_middle/src/ty/adt.rs +++ b/compiler/rustc_middle/src/ty/adt.rs @@ -4,7 +4,6 @@ use std::ops::Range; use std::str; use rustc_abi::{FIRST_VARIANT, ReprOptions, VariantIdx}; -use rustc_data_structures::captures::Captures; use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::intern::Interned; @@ -536,7 +535,7 @@ impl<'tcx> AdtDef<'tcx> { pub fn discriminants( self, tcx: TyCtxt<'tcx>, - ) -> impl Iterator)> + Captures<'tcx> { + ) -> impl Iterator)> + 'tcx { assert!(self.is_enum()); let repr_type = self.repr().discr_type(); let initial = repr_type.initial_discriminant(tcx); diff --git a/compiler/rustc_middle/src/ty/closure.rs b/compiler/rustc_middle/src/ty/closure.rs index 33d39b137b6d9..79f70b71c3633 100644 --- a/compiler/rustc_middle/src/ty/closure.rs +++ b/compiler/rustc_middle/src/ty/closure.rs @@ -1,6 +1,5 @@ use std::fmt::Write; -use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::FxIndexMap; use rustc_hir as hir; use rustc_hir::HirId; @@ -415,7 +414,7 @@ pub fn analyze_coroutine_closure_captures<'a, 'tcx: 'a, T>( parent_captures: impl IntoIterator>, child_captures: impl IntoIterator>, mut for_each: impl FnMut((usize, &'a CapturedPlace<'tcx>), (usize, &'a CapturedPlace<'tcx>)) -> T, -) -> impl Iterator + Captures<'a> + Captures<'tcx> { +) -> impl Iterator { std::iter::from_coroutine( #[coroutine] move || { diff --git a/compiler/rustc_middle/src/ty/predicate.rs b/compiler/rustc_middle/src/ty/predicate.rs index 32d6455e82557..ee6b6ebad71c4 100644 --- a/compiler/rustc_middle/src/ty/predicate.rs +++ b/compiler/rustc_middle/src/ty/predicate.rs @@ -1,6 +1,5 @@ use std::cmp::Ordering; -use rustc_data_structures::captures::Captures; use rustc_data_structures::intern::Interned; use rustc_hir::def_id::DefId; use rustc_macros::{HashStable, extension}; @@ -350,7 +349,7 @@ impl<'tcx> ty::List> { } #[inline] - pub fn auto_traits<'a>(&'a self) -> impl Iterator + Captures<'tcx> + 'a { + pub fn auto_traits<'a>(&'a self) -> impl Iterator + use<'tcx, 'a> { self.iter().filter_map(|predicate| match predicate.skip_binder() { ExistentialPredicate::AutoTrait(did) => Some(did), _ => None, diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index 2980964898c3a..e14bf31bf1bff 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -9,7 +9,6 @@ use std::ops::{ControlFlow, Range}; use hir::def::{CtorKind, DefKind}; use rustc_abi::{ExternAbi, FIRST_VARIANT, FieldIdx, VariantIdx}; -use rustc_data_structures::captures::Captures; use rustc_errors::{ErrorGuaranteed, MultiSpan}; use rustc_hir as hir; use rustc_hir::LangItem; @@ -105,7 +104,7 @@ impl<'tcx> ty::CoroutineArgs> { self, def_id: DefId, tcx: TyCtxt<'tcx>, - ) -> impl Iterator)> + Captures<'tcx> { + ) -> impl Iterator)> { self.variant_range(def_id, tcx).map(move |index| { (index, Discr { val: index.as_usize() as u128, ty: self.discr_ty(tcx) }) }) @@ -139,7 +138,7 @@ impl<'tcx> ty::CoroutineArgs> { self, def_id: DefId, tcx: TyCtxt<'tcx>, - ) -> impl Iterator> + Captures<'tcx>> { + ) -> impl Iterator>> { let layout = tcx.coroutine_layout(def_id, self.kind_ty()).unwrap(); layout.variant_fields.iter().map(move |variant| { variant.iter().map(move |field| { diff --git a/compiler/rustc_mir_dataflow/src/value_analysis.rs b/compiler/rustc_mir_dataflow/src/value_analysis.rs index a51af8c40fd43..8fc3dcf3c3bae 100644 --- a/compiler/rustc_mir_dataflow/src/value_analysis.rs +++ b/compiler/rustc_mir_dataflow/src/value_analysis.rs @@ -2,7 +2,6 @@ use std::fmt::{Debug, Formatter}; use std::ops::Range; use rustc_abi::{FieldIdx, VariantIdx}; -use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::{FxHashMap, FxIndexSet, StdEntry}; use rustc_data_structures::stack::ensure_sufficient_stack; use rustc_index::IndexVec; @@ -677,10 +676,7 @@ impl<'tcx> Map<'tcx> { } /// Iterate over all direct children. - fn children( - &self, - parent: PlaceIndex, - ) -> impl Iterator + Captures<'_> + Captures<'tcx> { + fn children(&self, parent: PlaceIndex) -> impl Iterator + use<'tcx, '_> { Children::new(self, parent) } diff --git a/compiler/rustc_mir_transform/src/coverage/counters.rs b/compiler/rustc_mir_transform/src/coverage/counters.rs index a9111a5ef9b4a..8c9ad090d596a 100644 --- a/compiler/rustc_mir_transform/src/coverage/counters.rs +++ b/compiler/rustc_mir_transform/src/coverage/counters.rs @@ -1,7 +1,6 @@ use std::cmp::Ordering; use std::fmt::{self, Debug}; -use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::graph::DirectedGraph; use rustc_index::IndexVec; @@ -144,9 +143,7 @@ impl CoverageCounters { /// Returns an iterator over all the nodes/edges in the coverage graph that /// should have a counter-increment statement injected into MIR, along with /// each site's corresponding counter ID. - pub(super) fn counter_increment_sites( - &self, - ) -> impl Iterator + Captures<'_> { + pub(super) fn counter_increment_sites(&self) -> impl Iterator + '_ { self.counter_increment_sites.iter_enumerated().map(|(id, &site)| (id, site)) } @@ -154,7 +151,7 @@ impl CoverageCounters { /// with a counter *expression*, along with the ID of that expression. pub(super) fn bcb_nodes_with_coverage_expressions( &self, - ) -> impl Iterator + Captures<'_> { + ) -> impl Iterator + '_ { self.node_counters.iter_enumerated().filter_map(|(bcb, &counter)| match counter { // Yield the BCB along with its associated expression ID. Some(BcbCounter::Expression { id }) => Some((bcb, id)), @@ -212,7 +209,7 @@ fn sibling_out_edge_targets( graph: &CoverageGraph, from_bcb: BasicCoverageBlock, to_bcb: BasicCoverageBlock, -) -> impl Iterator + Captures<'_> { +) -> impl Iterator + '_ { graph.successors[from_bcb].iter().copied().filter(move |&t| t != to_bcb) } diff --git a/compiler/rustc_mir_transform/src/coverage/graph.rs b/compiler/rustc_mir_transform/src/coverage/graph.rs index 3fa8b063fa75f..415d699179fa9 100644 --- a/compiler/rustc_mir_transform/src/coverage/graph.rs +++ b/compiler/rustc_mir_transform/src/coverage/graph.rs @@ -3,7 +3,6 @@ use std::collections::VecDeque; use std::ops::{Index, IndexMut}; use std::{iter, mem, slice}; -use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::graph::dominators::Dominators; use rustc_data_structures::graph::{self, DirectedGraph, StartNode}; @@ -246,7 +245,7 @@ impl CoverageGraph { pub(crate) fn loop_headers_containing( &self, bcb: BasicCoverageBlock, - ) -> impl Iterator + Captures<'_> { + ) -> impl Iterator + '_ { let self_if_loop_header = self.is_loop_header.contains(bcb).then_some(bcb).into_iter(); let mut curr = Some(bcb); @@ -266,7 +265,7 @@ impl CoverageGraph { pub(crate) fn reloop_predecessors( &self, to_bcb: BasicCoverageBlock, - ) -> impl Iterator + Captures<'_> { + ) -> impl Iterator + '_ { self.predecessors[to_bcb].iter().copied().filter(move |&pred| self.dominates(to_bcb, pred)) } } diff --git a/compiler/rustc_mir_transform/src/coverage/query.rs b/compiler/rustc_mir_transform/src/coverage/query.rs index 3e7cf8541c23a..a8948a1595555 100644 --- a/compiler/rustc_mir_transform/src/coverage/query.rs +++ b/compiler/rustc_mir_transform/src/coverage/query.rs @@ -1,4 +1,3 @@ -use rustc_data_structures::captures::Captures; use rustc_index::bit_set::DenseBitSet; use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; use rustc_middle::mir::coverage::{ @@ -134,7 +133,7 @@ fn coverage_ids_info<'tcx>( fn all_coverage_in_mir_body<'a, 'tcx>( body: &'a Body<'tcx>, -) -> impl Iterator + Captures<'tcx> { +) -> impl Iterator + use<'a, 'tcx> { body.basic_blocks.iter().flat_map(|bb_data| &bb_data.statements).filter_map(|statement| { match statement.kind { StatementKind::Coverage(ref kind) if !is_inlined(body, statement) => Some(kind), diff --git a/compiler/rustc_mir_transform/src/coverage/spans.rs b/compiler/rustc_mir_transform/src/coverage/spans.rs index 314a86ea52f0a..7c659a4de577d 100644 --- a/compiler/rustc_mir_transform/src/coverage/spans.rs +++ b/compiler/rustc_mir_transform/src/coverage/spans.rs @@ -1,6 +1,5 @@ use std::collections::VecDeque; -use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::FxHashSet; use rustc_middle::mir; use rustc_span::{DesugaringKind, ExpnKind, MacroKind, Span}; @@ -179,10 +178,10 @@ fn divide_spans_into_buckets(input_covspans: Vec, holes: &[Hole]) -> Ve /// Similar to `.drain(..)`, but stops just before it would remove an item not /// satisfying the predicate. -fn drain_front_while<'a, T>( +fn drain_front_while<'a, T, F: FnMut(&T) -> bool>( queue: &'a mut VecDeque, - mut pred_fn: impl FnMut(&T) -> bool, -) -> impl Iterator + Captures<'a> { + mut pred_fn: F, +) -> impl Iterator + use<'a, T, F> { std::iter::from_fn(move || if pred_fn(queue.front()?) { queue.pop_front() } else { None }) } diff --git a/compiler/rustc_pattern_analysis/src/pat_column.rs b/compiler/rustc_pattern_analysis/src/pat_column.rs index eb4e095c1c662..29bb0a348edad 100644 --- a/compiler/rustc_pattern_analysis/src/pat_column.rs +++ b/compiler/rustc_pattern_analysis/src/pat_column.rs @@ -1,6 +1,6 @@ use crate::constructor::{Constructor, SplitConstructorSet}; use crate::pat::{DeconstructedPat, PatOrWild}; -use crate::{Captures, MatchArm, PatCx}; +use crate::{MatchArm, PatCx}; /// A column of patterns in a match, where a column is the intuitive notion of "subpatterns that /// inspect the same subvalue/place". @@ -41,7 +41,7 @@ impl<'p, Cx: PatCx> PatternColumn<'p, Cx> { pub fn head_ty(&self) -> Option<&Cx::Ty> { self.patterns.first().map(|pat| pat.ty()) } - pub fn iter<'a>(&'a self) -> impl Iterator> + Captures<'a> { + pub fn iter<'a>(&'a self) -> impl Iterator> + use<'p, 'a, Cx> { self.patterns.iter().copied() } diff --git a/compiler/rustc_pattern_analysis/src/rustc.rs b/compiler/rustc_pattern_analysis/src/rustc.rs index ae991e3ce4030..a10238637f745 100644 --- a/compiler/rustc_pattern_analysis/src/rustc.rs +++ b/compiler/rustc_pattern_analysis/src/rustc.rs @@ -175,8 +175,7 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> { &self, ty: RevealedTy<'tcx>, variant: &'tcx VariantDef, - ) -> impl Iterator)> + Captures<'p> + Captures<'_> - { + ) -> impl Iterator)> + use<'p, 'tcx, '_> { let ty::Adt(_, args) = ty.kind() else { bug!() }; variant.fields.iter().map(move |field| { let ty = field.ty(self.tcx, args); @@ -209,7 +208,7 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> { ty: RevealedTy<'tcx>, ) -> impl Iterator, PrivateUninhabitedField)> + ExactSizeIterator - + Captures<'a> { + + use<'tcx, 'a> { fn reveal_and_alloc<'a, 'tcx>( cx: &'a RustcPatCtxt<'_, 'tcx>, iter: impl Iterator>, diff --git a/compiler/rustc_pattern_analysis/src/usefulness.rs b/compiler/rustc_pattern_analysis/src/usefulness.rs index cc09cd491af19..1a4df4a6ba57c 100644 --- a/compiler/rustc_pattern_analysis/src/usefulness.rs +++ b/compiler/rustc_pattern_analysis/src/usefulness.rs @@ -719,7 +719,7 @@ use tracing::{debug, instrument}; use self::PlaceValidity::*; use crate::constructor::{Constructor, ConstructorSet, IntRange}; use crate::pat::{DeconstructedPat, PatId, PatOrWild, WitnessPat}; -use crate::{Captures, MatchArm, PatCx, PrivateUninhabitedField}; +use crate::{MatchArm, PatCx, PrivateUninhabitedField}; #[cfg(not(feature = "rustc"))] pub fn ensure_sufficient_stack(f: impl FnOnce() -> R) -> R { f() @@ -905,7 +905,7 @@ impl PlaceInfo { &'a self, cx: &'a Cx, ctor: &'a Constructor, - ) -> impl Iterator + ExactSizeIterator + Captures<'a> { + ) -> impl Iterator + ExactSizeIterator + use<'a, Cx> { let ctor_sub_tys = cx.ctor_sub_tys(ctor, &self.ty); let ctor_sub_validity = self.validity.specialize(ctor); ctor_sub_tys.map(move |(ty, PrivateUninhabitedField(private_uninhabited))| PlaceInfo { @@ -1045,13 +1045,13 @@ impl<'p, Cx: PatCx> PatStack<'p, Cx> { self.pats[0] } - fn iter(&self) -> impl Iterator> + Captures<'_> { + fn iter(&self) -> impl Iterator> + use<'p, '_, Cx> { self.pats.iter().copied() } // Expand the first or-pattern into its subpatterns. Only useful if the pattern is an // or-pattern. Panics if `self` is empty. - fn expand_or_pat(&self) -> impl Iterator> + Captures<'_> { + fn expand_or_pat(&self) -> impl Iterator> + use<'p, '_, Cx> { self.head().expand_or_pat().into_iter().map(move |pat| { let mut new = self.clone(); new.pats[0] = pat; @@ -1156,7 +1156,7 @@ impl<'p, Cx: PatCx> MatrixRow<'p, Cx> { self.pats.head() } - fn iter(&self) -> impl Iterator> + Captures<'_> { + fn iter(&self) -> impl Iterator> + use<'p, '_, Cx> { self.pats.iter() } @@ -1164,7 +1164,7 @@ impl<'p, Cx: PatCx> MatrixRow<'p, Cx> { fn expand_or_pat( &self, parent_row: usize, - ) -> impl Iterator> + Captures<'_> { + ) -> impl Iterator> + use<'p, '_, Cx> { let is_or_pat = self.pats.head().is_or_pat(); self.pats.expand_or_pat().map(move |patstack| MatrixRow { pats: patstack, @@ -1274,7 +1274,7 @@ impl<'p, Cx: PatCx> Matrix<'p, Cx> { } /// Iterate over the first pattern of each row. - fn heads(&self) -> impl Iterator> + Clone + Captures<'_> { + fn heads(&self) -> impl Iterator> + Clone + use<'p, '_, Cx> { self.rows().map(|r| r.head()) } diff --git a/compiler/rustc_trait_selection/src/traits/fulfill.rs b/compiler/rustc_trait_selection/src/traits/fulfill.rs index 7529ee128f5e4..7fecbd7bffe7b 100644 --- a/compiler/rustc_trait_selection/src/traits/fulfill.rs +++ b/compiler/rustc_trait_selection/src/traits/fulfill.rs @@ -1,6 +1,5 @@ use std::marker::PhantomData; -use rustc_data_structures::captures::Captures; use rustc_data_structures::obligation_forest::{ Error, ForestObligation, ObligationForest, ObligationProcessor, Outcome, ProcessResult, }; @@ -903,7 +902,7 @@ impl<'a, 'tcx> FulfillProcessor<'a, 'tcx> { fn args_infer_vars<'a, 'tcx>( selcx: &SelectionContext<'a, 'tcx>, args: ty::Binder<'tcx, GenericArgsRef<'tcx>>, -) -> impl Iterator + Captures<'tcx> { +) -> impl Iterator + 'tcx { selcx .infcx .resolve_vars_if_possible(args) diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index 621abd535010f..8c937ea6d1c9b 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -16,7 +16,6 @@ use std::iter::{self, once}; use itertools::Itertools; use rustc_abi::ExternAbi; use rustc_attr_parsing::{ConstStability, StabilityLevel, StableSince}; -use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::FxHashSet; use rustc_hir as hir; use rustc_hir::def::DefKind; @@ -164,7 +163,7 @@ pub(crate) fn comma_sep( pub(crate) fn print_generic_bounds<'a, 'tcx: 'a>( bounds: &'a [clean::GenericBound], cx: &'a Context<'tcx>, -) -> impl Display + 'a + Captures<'tcx> { +) -> impl Display + use<'a, 'tcx> { display_fn(move |f| { let mut bounds_dup = FxHashSet::default(); @@ -182,7 +181,7 @@ impl clean::GenericParamDef { pub(crate) fn print<'a, 'tcx: 'a>( &'a self, cx: &'a Context<'tcx>, - ) -> impl Display + 'a + Captures<'tcx> { + ) -> impl Display + use<'a, 'tcx> { display_fn(move |f| match &self.kind { clean::GenericParamDefKind::Lifetime { outlives } => { write!(f, "{}", self.name)?; @@ -237,7 +236,7 @@ impl clean::Generics { pub(crate) fn print<'a, 'tcx: 'a>( &'a self, cx: &'a Context<'tcx>, - ) -> impl Display + 'a + Captures<'tcx> { + ) -> impl Display + use<'a, 'tcx> { display_fn(move |f| { let mut real_params = self.params.iter().filter(|p| !p.is_synthetic_param()).peekable(); if real_params.peek().is_none() { @@ -267,7 +266,7 @@ pub(crate) fn print_where_clause<'a, 'tcx: 'a>( cx: &'a Context<'tcx>, indent: usize, ending: Ending, -) -> impl Display + 'a + Captures<'tcx> { +) -> impl Display + use<'a, 'tcx> { display_fn(move |f| { let mut where_predicates = gens .where_predicates @@ -385,7 +384,7 @@ impl clean::ConstantKind { } impl clean::PolyTrait { - fn print<'a, 'tcx: 'a>(&'a self, cx: &'a Context<'tcx>) -> impl Display + 'a + Captures<'tcx> { + fn print<'a, 'tcx: 'a>(&'a self, cx: &'a Context<'tcx>) -> impl Display + use<'a, 'tcx> { display_fn(move |f| { print_higher_ranked_params_with_space(&self.generic_params, cx, "for").fmt(f)?; self.trait_.print(cx).fmt(f) @@ -397,7 +396,7 @@ impl clean::GenericBound { pub(crate) fn print<'a, 'tcx: 'a>( &'a self, cx: &'a Context<'tcx>, - ) -> impl Display + 'a + Captures<'tcx> { + ) -> impl Display + use<'a, 'tcx> { display_fn(move |f| match self { clean::GenericBound::Outlives(lt) => write!(f, "{}", lt.print()), clean::GenericBound::TraitBound(ty, modifiers) => { @@ -429,7 +428,7 @@ impl clean::GenericBound { } impl clean::GenericArgs { - fn print<'a, 'tcx: 'a>(&'a self, cx: &'a Context<'tcx>) -> impl Display + 'a + Captures<'tcx> { + fn print<'a, 'tcx: 'a>(&'a self, cx: &'a Context<'tcx>) -> impl Display + use<'a, 'tcx> { display_fn(move |f| { match self { clean::GenericArgs::AngleBracketed { args, constraints } => { @@ -949,7 +948,7 @@ fn tybounds<'a, 'tcx: 'a>( bounds: &'a [clean::PolyTrait], lt: &'a Option, cx: &'a Context<'tcx>, -) -> impl Display + 'a + Captures<'tcx> { +) -> impl Display + use<'a, 'tcx> { display_fn(move |f| { for (i, bound) in bounds.iter().enumerate() { if i > 0 { @@ -970,7 +969,7 @@ fn print_higher_ranked_params_with_space<'a, 'tcx: 'a>( params: &'a [clean::GenericParamDef], cx: &'a Context<'tcx>, keyword: &'static str, -) -> impl Display + 'a + Captures<'tcx> { +) -> impl Display + use<'a, 'tcx> { display_fn(move |f| { if !params.is_empty() { f.write_str(keyword)?; @@ -1266,19 +1265,19 @@ fn fmt_type( } impl clean::Type { - pub(crate) fn print<'b, 'a: 'b, 'tcx: 'a>( + pub(crate) fn print<'a, 'tcx: 'a>( &'a self, cx: &'a Context<'tcx>, - ) -> impl Display + 'b + Captures<'tcx> { + ) -> impl Display + use<'a, 'tcx> { display_fn(move |f| fmt_type(self, f, false, cx)) } } impl clean::Path { - pub(crate) fn print<'b, 'a: 'b, 'tcx: 'a>( + pub(crate) fn print<'a, 'tcx: 'a>( &'a self, cx: &'a Context<'tcx>, - ) -> impl Display + 'b + Captures<'tcx> { + ) -> impl Display + use<'a, 'tcx> { display_fn(move |f| resolved_path(f, self.def_id(), self, false, false, cx)) } } @@ -1288,7 +1287,7 @@ impl clean::Impl { &'a self, use_absolute: bool, cx: &'a Context<'tcx>, - ) -> impl Display + 'a + Captures<'tcx> { + ) -> impl Display + use<'a, 'tcx> { display_fn(move |f| { f.write_str("impl")?; self.generics.print(cx).fmt(f)?; @@ -1406,7 +1405,7 @@ impl clean::Arguments { pub(crate) fn print<'a, 'tcx: 'a>( &'a self, cx: &'a Context<'tcx>, - ) -> impl Display + 'a + Captures<'tcx> { + ) -> impl Display + use<'a, 'tcx> { display_fn(move |f| { for (i, input) in self.values.iter().enumerate() { write!(f, "{}: ", input.name)?; @@ -1443,10 +1442,10 @@ impl Display for Indent { } impl clean::FnDecl { - pub(crate) fn print<'b, 'a: 'b, 'tcx: 'a>( + pub(crate) fn print<'a, 'tcx: 'a>( &'a self, cx: &'a Context<'tcx>, - ) -> impl Display + 'b + Captures<'tcx> { + ) -> impl Display + use<'a, 'tcx> { display_fn(move |f| { let ellipsis = if self.c_variadic { ", ..." } else { "" }; if f.alternate() { @@ -1480,7 +1479,7 @@ impl clean::FnDecl { header_len: usize, indent: usize, cx: &'a Context<'tcx>, - ) -> impl Display + 'a + Captures<'tcx> { + ) -> impl Display + use<'a, 'tcx> { display_fn(move |f| { // First, generate the text form of the declaration, with no line wrapping, and count the bytes. let mut counter = WriteCounter(0); @@ -1562,10 +1561,7 @@ impl clean::FnDecl { self.print_output(cx).fmt(f) } - fn print_output<'a, 'tcx: 'a>( - &'a self, - cx: &'a Context<'tcx>, - ) -> impl Display + 'a + Captures<'tcx> { + fn print_output<'a, 'tcx: 'a>(&'a self, cx: &'a Context<'tcx>) -> impl Display + use<'a, 'tcx> { display_fn(move |f| match &self.output { clean::Tuple(tys) if tys.is_empty() => Ok(()), ty if f.alternate() => { @@ -1579,7 +1575,7 @@ impl clean::FnDecl { pub(crate) fn visibility_print_with_space<'a, 'tcx: 'a>( item: &clean::Item, cx: &'a Context<'tcx>, -) -> impl Display + 'a + Captures<'tcx> { +) -> impl Display + use<'a, 'tcx> { use std::fmt::Write as _; let vis: Cow<'static, str> = match item.visibility(cx.tcx()) { None => "".into(), @@ -1682,7 +1678,7 @@ impl clean::Import { pub(crate) fn print<'a, 'tcx: 'a>( &'a self, cx: &'a Context<'tcx>, - ) -> impl Display + 'a + Captures<'tcx> { + ) -> impl Display + use<'a, 'tcx> { display_fn(move |f| match self.kind { clean::ImportKind::Simple(name) => { if name == self.source.path.last() { @@ -1706,7 +1702,7 @@ impl clean::ImportSource { pub(crate) fn print<'a, 'tcx: 'a>( &'a self, cx: &'a Context<'tcx>, - ) -> impl Display + 'a + Captures<'tcx> { + ) -> impl Display + use<'a, 'tcx> { display_fn(move |f| match self.did { Some(did) => resolved_path(f, did, &self.path, true, false, cx), _ => { @@ -1734,7 +1730,7 @@ impl clean::AssocItemConstraint { pub(crate) fn print<'a, 'tcx: 'a>( &'a self, cx: &'a Context<'tcx>, - ) -> impl Display + 'a + Captures<'tcx> { + ) -> impl Display + use<'a, 'tcx> { display_fn(move |f| { f.write_str(self.assoc.name.as_str())?; self.assoc.args.print(cx).fmt(f)?; @@ -1773,7 +1769,7 @@ impl clean::GenericArg { pub(crate) fn print<'a, 'tcx: 'a>( &'a self, cx: &'a Context<'tcx>, - ) -> impl Display + 'a + Captures<'tcx> { + ) -> impl Display + use<'a, 'tcx> { display_fn(move |f| match self { clean::GenericArg::Lifetime(lt) => lt.print().fmt(f), clean::GenericArg::Type(ty) => ty.print(cx).fmt(f), @@ -1787,7 +1783,7 @@ impl clean::Term { pub(crate) fn print<'a, 'tcx: 'a>( &'a self, cx: &'a Context<'tcx>, - ) -> impl Display + 'a + Captures<'tcx> { + ) -> impl Display + use<'a, 'tcx> { display_fn(move |f| match self { clean::Term::Type(ty) => ty.print(cx).fmt(f), clean::Term::Constant(ct) => ct.print(cx.tcx()).fmt(f), diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 9a9ce31caaa4c..733cadd64c017 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -47,7 +47,6 @@ use rinja::Template; use rustc_attr_parsing::{ ConstStability, DeprecatedSince, Deprecation, RustcVersion, StabilityLevel, StableSince, }; -use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet}; use rustc_hir::Mutability; use rustc_hir::def_id::{DefId, DefIdSet}; @@ -508,7 +507,7 @@ fn document<'a, 'cx: 'a>( item: &'a clean::Item, parent: Option<&'a clean::Item>, heading_offset: HeadingOffset, -) -> impl fmt::Display + 'a + Captures<'cx> { +) -> impl fmt::Display + use<'a, 'cx> { if let Some(ref name) = item.name { info!("Documenting {name}"); } @@ -529,7 +528,7 @@ fn render_markdown<'a, 'cx: 'a>( md_text: &'a str, links: Vec, heading_offset: HeadingOffset, -) -> impl fmt::Display + 'a + Captures<'cx> { +) -> impl fmt::Display + use<'a, 'cx> { display_fn(move |f| { write!( f, @@ -556,7 +555,7 @@ fn document_short<'a, 'cx: 'a>( link: AssocItemLink<'a>, parent: &'a clean::Item, show_def_docs: bool, -) -> impl fmt::Display + 'a + Captures<'cx> { +) -> impl fmt::Display + use<'a, 'cx> { display_fn(move |f| { document_item_info(cx, item, Some(parent)).render_into(f).unwrap(); if !show_def_docs { @@ -587,7 +586,7 @@ fn document_full_collapsible<'a, 'cx: 'a>( item: &'a clean::Item, cx: &'a Context<'cx>, heading_offset: HeadingOffset, -) -> impl fmt::Display + 'a + Captures<'cx> { +) -> impl fmt::Display + use<'a, 'cx> { document_full_inner(item, cx, true, heading_offset) } @@ -595,7 +594,7 @@ fn document_full<'a, 'cx: 'a>( item: &'a clean::Item, cx: &'a Context<'cx>, heading_offset: HeadingOffset, -) -> impl fmt::Display + 'a + Captures<'cx> { +) -> impl fmt::Display + use<'a, 'cx> { document_full_inner(item, cx, false, heading_offset) } @@ -604,7 +603,7 @@ fn document_full_inner<'a, 'cx: 'a>( cx: &'a Context<'cx>, is_collapsible: bool, heading_offset: HeadingOffset, -) -> impl fmt::Display + 'a + Captures<'cx> { +) -> impl fmt::Display + use<'a, 'cx> { display_fn(move |f| { if let Some(s) = item.opt_doc_value() { debug!("Doc block: =====\n{s}\n====="); @@ -1158,7 +1157,7 @@ fn render_attributes_in_pre<'a, 'tcx: 'a>( it: &'a clean::Item, prefix: &'a str, cx: &'a Context<'tcx>, -) -> impl fmt::Display + Captures<'a> + Captures<'tcx> { +) -> impl fmt::Display + use<'a, 'tcx> { crate::html::format::display_fn(move |f| { for a in it.attributes(cx.tcx(), cx.cache(), false) { writeln!(f, "{prefix}{a}")?; @@ -1255,7 +1254,7 @@ fn render_assoc_items<'a, 'cx: 'a>( containing_item: &'a clean::Item, it: DefId, what: AssocItemRender<'a>, -) -> impl fmt::Display + 'a + Captures<'cx> { +) -> impl fmt::Display + use<'a, 'cx> { let mut derefs = DefIdSet::default(); derefs.insert(it); display_fn(move |f| { diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index e8230e63c0f60..0125e5daf6614 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -4,7 +4,6 @@ use std::fmt; use itertools::Itertools; use rinja::Template; use rustc_abi::VariantIdx; -use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::{FxHashMap, FxIndexSet}; use rustc_hir as hir; use rustc_hir::def::CtorKind; @@ -91,7 +90,7 @@ macro_rules! item_template { macro_rules! item_template_methods { () => {}; (document $($rest:tt)*) => { - fn document<'b>(&'b self) -> impl fmt::Display + Captures<'a> + 'b + Captures<'cx> { + fn document<'b>(&'b self) -> impl fmt::Display + use<'a, 'cx, 'b> { display_fn(move |f| { let (item, cx) = self.item_and_cx(); let v = document(cx, item, None, HeadingOffset::H2); @@ -101,7 +100,7 @@ macro_rules! item_template_methods { item_template_methods!($($rest)*); }; (document_type_layout $($rest:tt)*) => { - fn document_type_layout<'b>(&'b self) -> impl fmt::Display + Captures<'a> + 'b + Captures<'cx> { + fn document_type_layout<'b>(&'b self) -> impl fmt::Display + use<'a, 'cx, 'b> { display_fn(move |f| { let (item, cx) = self.item_and_cx(); let def_id = item.item_id.expect_def_id(); @@ -112,7 +111,7 @@ macro_rules! item_template_methods { item_template_methods!($($rest)*); }; (render_attributes_in_pre $($rest:tt)*) => { - fn render_attributes_in_pre<'b>(&'b self) -> impl fmt::Display + Captures<'a> + 'b + Captures<'cx> { + fn render_attributes_in_pre<'b>(&'b self) -> impl fmt::Display + use<'a, 'cx, 'b> { display_fn(move |f| { let (item, cx) = self.item_and_cx(); let v = render_attributes_in_pre(item, "", cx); @@ -122,7 +121,7 @@ macro_rules! item_template_methods { item_template_methods!($($rest)*); }; (render_assoc_items $($rest:tt)*) => { - fn render_assoc_items<'b>(&'b self) -> impl fmt::Display + Captures<'a> + 'b + Captures<'cx> { + fn render_assoc_items<'b>(&'b self) -> impl fmt::Display + use<'a, 'cx, 'b> { display_fn(move |f| { let (item, cx) = self.item_and_cx(); let def_id = item.item_id.expect_def_id(); @@ -538,7 +537,7 @@ fn extra_info_tags<'a, 'tcx: 'a>( item: &'a clean::Item, parent: &'a clean::Item, import_def_id: Option, -) -> impl fmt::Display + 'a + Captures<'tcx> { +) -> impl fmt::Display + use<'a, 'tcx> { display_fn(move |f| { fn tag_html<'a>( class: &'a str, @@ -1394,7 +1393,7 @@ fn item_union(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::Uni ); impl<'a, 'cx: 'a> ItemUnion<'a, 'cx> { - fn render_union<'b>(&'b self) -> impl fmt::Display + Captures<'a> + 'b + Captures<'cx> { + fn render_union<'b>(&'b self) -> impl fmt::Display + use<'a, 'cx, 'b> { display_fn(move |f| { let v = render_union(self.it, Some(&self.s.generics), &self.s.fields, self.cx); write!(f, "{v}") @@ -1404,7 +1403,7 @@ fn item_union(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::Uni fn document_field<'b>( &'b self, field: &'a clean::Item, - ) -> impl fmt::Display + Captures<'a> + 'b + Captures<'cx> { + ) -> impl fmt::Display + use<'a, 'cx, 'b> { display_fn(move |f| { let v = document(self.cx, field, Some(self.it), HeadingOffset::H3); write!(f, "{v}") @@ -1415,10 +1414,7 @@ fn item_union(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::Uni field.stability_class(self.cx.tcx()) } - fn print_ty<'b>( - &'b self, - ty: &'a clean::Type, - ) -> impl fmt::Display + Captures<'a> + 'b + Captures<'cx> { + fn print_ty<'b>(&'b self, ty: &'a clean::Type) -> impl fmt::Display + use<'a, 'cx, 'b> { display_fn(move |f| { let v = ty.print(self.cx); write!(f, "{v}") @@ -1445,7 +1441,7 @@ fn item_union(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::Uni fn print_tuple_struct_fields<'a, 'cx: 'a>( cx: &'a Context<'cx>, s: &'a [clean::Item], -) -> impl fmt::Display + 'a + Captures<'cx> { +) -> impl fmt::Display + use<'a, 'cx> { display_fn(|f| { if !s.is_empty() && s.iter().all(|field| { @@ -2170,7 +2166,7 @@ fn render_union<'a, 'cx: 'a>( g: Option<&'a clean::Generics>, fields: &'a [clean::Item], cx: &'a Context<'cx>, -) -> impl fmt::Display + 'a + Captures<'cx> { +) -> impl fmt::Display + use<'a, 'cx> { display_fn(move |mut f| { write!(f, "{}union {}", visibility_print_with_space(it, cx), it.name.unwrap(),)?; diff --git a/src/librustdoc/html/render/type_layout.rs b/src/librustdoc/html/render/type_layout.rs index 9317844956de8..723e085fd16a3 100644 --- a/src/librustdoc/html/render/type_layout.rs +++ b/src/librustdoc/html/render/type_layout.rs @@ -2,7 +2,6 @@ use std::fmt; use rinja::Template; use rustc_abi::{Primitive, TagEncoding, Variants}; -use rustc_data_structures::captures::Captures; use rustc_hir::def_id::DefId; use rustc_middle::span_bug; use rustc_middle::ty::layout::LayoutError; @@ -30,7 +29,7 @@ struct TypeLayoutSize { pub(crate) fn document_type_layout<'a, 'cx: 'a>( cx: &'a Context<'cx>, ty_def_id: DefId, -) -> impl fmt::Display + 'a + Captures<'cx> { +) -> impl fmt::Display + use<'a, 'cx> { display_fn(move |f| { if !cx.shared.show_type_layout { return Ok(());