Skip to content

Commit 63d096d

Browse files
committed
Use (😏) precise capture instead of Captures trait hack
precise capture
1 parent 627513a commit 63d096d

File tree

34 files changed

+96
-135
lines changed

34 files changed

+96
-135
lines changed

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343

4444
use rustc_ast::node_id::NodeMap;
4545
use rustc_ast::{self as ast, *};
46-
use rustc_data_structures::captures::Captures;
4746
use rustc_data_structures::fingerprint::Fingerprint;
4847
use rustc_data_structures::sorted_map::SortedMap;
4948
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
@@ -1803,7 +1802,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
18031802
&'s mut self,
18041803
params: &'s [GenericParam],
18051804
source: hir::GenericParamSource,
1806-
) -> impl Iterator<Item = hir::GenericParam<'hir>> + Captures<'a> + Captures<'s> {
1805+
) -> impl Iterator<Item = hir::GenericParam<'hir>> + use<'a, 'hir, 's> {
18071806
params.iter().map(move |param| self.lower_generic_param(param, source))
18081807
}
18091808

@@ -1968,7 +1967,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
19681967
&'s mut self,
19691968
bounds: &'s [GenericBound],
19701969
itctx: ImplTraitContext,
1971-
) -> impl Iterator<Item = hir::GenericBound<'hir>> + Captures<'s> + Captures<'a> {
1970+
) -> impl Iterator<Item = hir::GenericBound<'hir>> + use<'a, 'hir, 's> {
19721971
bounds.iter().map(move |bound| self.lower_param_bound(bound, itctx))
19731972
}
19741973

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use std::ops::ControlFlow;
88

99
use either::Either;
1010
use hir::{ClosureKind, Path};
11-
use rustc_data_structures::captures::Captures;
1211
use rustc_data_structures::fx::FxIndexSet;
1312
use rustc_errors::codes::*;
1413
use rustc_errors::{Applicability, Diag, MultiSpan, struct_span_code_err};
@@ -3524,7 +3523,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
35243523
fn predecessor_locations<'a, 'tcx>(
35253524
body: &'a mir::Body<'tcx>,
35263525
location: Location,
3527-
) -> impl Iterator<Item = Location> + Captures<'tcx> + 'a {
3526+
) -> impl Iterator<Item = Location> + use<'a, 'tcx> {
35283527
if location.statement_index == 0 {
35293528
let predecessors = body.basic_blocks.predecessors()[location.block].to_vec();
35303529
Either::Left(predecessors.into_iter().map(move |bb| body.terminator_loc(bb)))

compiler/rustc_borrowck/src/member_constraints.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use std::hash::Hash;
22
use std::ops::Index;
33

4-
use rustc_data_structures::captures::Captures;
54
use rustc_data_structures::fx::FxIndexMap;
65
use rustc_index::{IndexSlice, IndexVec};
76
use rustc_middle::ty::{self, Ty};
@@ -149,7 +148,7 @@ where
149148
{
150149
pub(crate) fn all_indices(
151150
&self,
152-
) -> impl Iterator<Item = NllMemberConstraintIndex> + Captures<'tcx> + '_ {
151+
) -> impl Iterator<Item = NllMemberConstraintIndex> + use<'tcx, '_, R> {
153152
self.constraints.indices()
154153
}
155154

@@ -159,7 +158,7 @@ where
159158
pub(crate) fn indices(
160159
&self,
161160
member_region_vid: R,
162-
) -> impl Iterator<Item = NllMemberConstraintIndex> + Captures<'tcx> + '_ {
161+
) -> impl Iterator<Item = NllMemberConstraintIndex> + use<'tcx, '_, R> {
163162
let mut next = self.first_constraints.get(&member_region_vid).cloned();
164163
std::iter::from_fn(move || -> Option<NllMemberConstraintIndex> {
165164
if let Some(current) = next {

compiler/rustc_data_structures/src/captures.rs

Lines changed: 0 additions & 8 deletions
This file was deleted.

compiler/rustc_data_structures/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ pub use rustc_index::static_assert_size;
4848
pub mod aligned;
4949
pub mod base_n;
5050
pub mod binary_search_util;
51-
pub mod captures;
5251
pub mod fingerprint;
5352
pub mod flat_map_in_place;
5453
pub mod flock;

compiler/rustc_hir_analysis/src/collect.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ use std::ops::Bound;
2020

2121
use rustc_abi::ExternAbi;
2222
use rustc_ast::Recovered;
23-
use rustc_data_structures::captures::Captures;
2423
use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
2524
use rustc_data_structures::unord::UnordMap;
2625
use rustc_errors::{
@@ -1705,7 +1704,7 @@ fn polarity_of_impl(
17051704
fn early_bound_lifetimes_from_generics<'a, 'tcx: 'a>(
17061705
tcx: TyCtxt<'tcx>,
17071706
generics: &'a hir::Generics<'a>,
1708-
) -> impl Iterator<Item = &'a hir::GenericParam<'a>> + Captures<'tcx> {
1707+
) -> impl Iterator<Item = &'a hir::GenericParam<'a>> + use<'a, 'tcx> {
17091708
generics.params.iter().filter(move |param| match param.kind {
17101709
GenericParamKind::Lifetime { .. } => !tcx.is_late_bound(param.hir_id),
17111710
_ => false,

compiler/rustc_infer/src/infer/canonical/query_response.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use std::fmt::Debug;
1111
use std::iter;
1212

13-
use rustc_data_structures::captures::Captures;
1413
use rustc_index::{Idx, IndexVec};
1514
use rustc_middle::arena::ArenaAllocatable;
1615
use rustc_middle::mir::ConstraintCategory;
@@ -547,7 +546,7 @@ impl<'tcx> InferCtxt<'tcx> {
547546
param_env: ty::ParamEnv<'tcx>,
548547
uninstantiated_region_constraints: &'a [QueryOutlivesConstraint<'tcx>],
549548
result_args: &'a CanonicalVarValues<'tcx>,
550-
) -> impl Iterator<Item = PredicateObligation<'tcx>> + 'a + Captures<'tcx> {
549+
) -> impl Iterator<Item = PredicateObligation<'tcx>> + 'a {
551550
uninstantiated_region_constraints.iter().map(move |&constraint| {
552551
let predicate = instantiate_value(self.tcx, result_args, constraint);
553552
self.query_outlives_constraint_to_obligation(predicate, cause.clone(), param_env)

compiler/rustc_infer/src/infer/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use region_constraints::{
1515
};
1616
pub use relate::StructurallyRelateAliases;
1717
pub use relate::combine::PredicateEmittingRelation;
18-
use rustc_data_structures::captures::Captures;
1918
use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
2019
use rustc_data_structures::undo_log::{Rollback, UndoLogs};
2120
use rustc_data_structures::unify as ut;
@@ -1297,7 +1296,7 @@ impl<'tcx> InferCtxt<'tcx> {
12971296
#[inline]
12981297
pub fn is_ty_infer_var_definitely_unchanged<'a>(
12991298
&'a self,
1300-
) -> (impl Fn(TyOrConstInferVar) -> bool + Captures<'tcx> + 'a) {
1299+
) -> (impl Fn(TyOrConstInferVar) -> bool + use<'tcx, 'a>) {
13011300
// This hoists the borrow/release out of the loop body.
13021301
let inner = self.inner.try_borrow();
13031302

compiler/rustc_metadata/src/rmeta/decoder.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use std::{io, iter, mem};
77
pub(super) use cstore_impl::provide;
88
use proc_macro::bridge::client::ProcMacro;
99
use rustc_ast as ast;
10-
use rustc_data_structures::captures::Captures;
1110
use rustc_data_structures::fingerprint::Fingerprint;
1211
use rustc_data_structures::fx::FxIndexMap;
1312
use rustc_data_structures::owned_slice::OwnedSlice;
@@ -958,7 +957,7 @@ impl CrateRoot {
958957
pub(crate) fn decode_crate_deps<'a>(
959958
&self,
960959
metadata: &'a MetadataBlob,
961-
) -> impl ExactSizeIterator<Item = CrateDep> + Captures<'a> {
960+
) -> impl ExactSizeIterator<Item = CrateDep> + 'a {
962961
self.crate_deps.decode(metadata)
963962
}
964963
}

compiler/rustc_middle/src/mir/mod.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use either::Either;
1212
use polonius_engine::Atom;
1313
use rustc_abi::{FieldIdx, VariantIdx};
1414
pub use rustc_ast::Mutability;
15-
use rustc_data_structures::captures::Captures;
1615
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
1716
use rustc_data_structures::graph::dominators::Dominators;
1817
use rustc_errors::{DiagArgName, DiagArgValue, DiagMessage, ErrorGuaranteed, IntoDiagArg};
@@ -481,7 +480,7 @@ impl<'tcx> Body<'tcx> {
481480

482481
/// Returns an iterator over all user-declared mutable locals.
483482
#[inline]
484-
pub fn mut_vars_iter<'a>(&'a self) -> impl Iterator<Item = Local> + Captures<'tcx> + 'a {
483+
pub fn mut_vars_iter<'a>(&'a self) -> impl Iterator<Item = Local> + use<'tcx, 'a> {
485484
(self.arg_count + 1..self.local_decls.len()).filter_map(move |index| {
486485
let local = Local::new(index);
487486
let decl = &self.local_decls[local];
@@ -491,9 +490,7 @@ impl<'tcx> Body<'tcx> {
491490

492491
/// Returns an iterator over all user-declared mutable arguments and locals.
493492
#[inline]
494-
pub fn mut_vars_and_args_iter<'a>(
495-
&'a self,
496-
) -> impl Iterator<Item = Local> + Captures<'tcx> + 'a {
493+
pub fn mut_vars_and_args_iter<'a>(&'a self) -> impl Iterator<Item = Local> + use<'tcx, 'a> {
497494
(1..self.local_decls.len()).filter_map(move |index| {
498495
let local = Local::new(index);
499496
let decl = &self.local_decls[local];

0 commit comments

Comments
 (0)