Skip to content

Commit f0db1d6

Browse files
committed
Remove local_def_id from captured_lifetimes
1 parent 2d826e2 commit f0db1d6

File tree

1 file changed

+17
-22
lines changed
  • compiler/rustc_ast_lowering/src

1 file changed

+17
-22
lines changed

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,10 @@ struct LoweringContext<'a, 'hir> {
137137
#[derive(Debug)]
138138
struct LifetimeCaptureContext {
139139
/// Set of lifetimes to rebind.
140-
captures: FxHashMap<
141-
LocalDefId, // original parameter id
142-
(
143-
Lifetime, // Lifetime parameter
144-
LifetimeRes, // original resolution
145-
),
146-
>,
140+
captures: Vec<(
141+
Lifetime, // Lifetime parameter
142+
LifetimeRes, // original resolution
143+
)>,
147144
}
148145

149146
trait ResolverAstLoweringExt {
@@ -1324,7 +1321,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
13241321

13251322
let opaque_ty_def_id = self.local_def_id(opaque_ty_node_id);
13261323

1327-
let mut collected_lifetimes = FxHashMap::default();
1324+
let mut collected_lifetimes = Vec::new();
13281325
let mut new_remapping = FxHashMap::default();
13291326

13301327
self.with_hir_id_owner(opaque_ty_node_id, |lctx| {
@@ -1360,8 +1357,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
13601357
};
13611358
debug!(?collected_lifetimes);
13621359

1363-
let lifetime_defs = lctx.arena.alloc_from_iter(collected_lifetimes.iter().map(
1364-
|(_, &(lifetime, _))| {
1360+
let lifetime_defs =
1361+
lctx.arena.alloc_from_iter(collected_lifetimes.iter().map(|&(lifetime, _)| {
13651362
let hir_id = lctx.lower_node_id(lifetime.id);
13661363
debug_assert_ne!(lctx.opt_local_def_id(lifetime.id), None);
13671364

@@ -1379,8 +1376,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
13791376
kind: hir::GenericParamKind::Lifetime { kind },
13801377
colon_span: None,
13811378
}
1382-
},
1383-
));
1379+
}));
13841380

13851381
debug!("lower_opaque_impl_trait: lifetime_defs={:#?}", lifetime_defs);
13861382

@@ -1400,8 +1396,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
14001396
lctx.generate_opaque_type(opaque_ty_def_id, opaque_ty_item, span, opaque_ty_span)
14011397
});
14021398

1403-
let lifetimes = self.arena.alloc_from_iter(collected_lifetimes.into_iter().map(
1404-
|(_, (lifetime, res))| {
1399+
let lifetimes =
1400+
self.arena.alloc_from_iter(collected_lifetimes.into_iter().map(|(lifetime, res)| {
14051401
let id = self.next_node_id();
14061402
let span = lifetime.ident.span;
14071403

@@ -1413,8 +1409,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
14131409

14141410
let l = self.new_named_lifetime_with_res(id, span, ident, res);
14151411
hir::GenericArg::Lifetime(l)
1416-
},
1417-
));
1412+
}));
14181413

14191414
debug!("lower_opaque_impl_trait: lifetimes={:#?}", lifetimes);
14201415

@@ -1468,7 +1463,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
14681463
remapping.insert(old_def_id, new_def_id);
14691464

14701465
let new_lifetime = Lifetime { id: node_id, ident: lifetime.ident };
1471-
captured_lifetimes.captures.insert(old_def_id, (new_lifetime, res));
1466+
captured_lifetimes.captures.push((new_lifetime, res));
14721467
}
14731468
}
14741469

@@ -1486,7 +1481,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
14861481
remapping.insert(old_def_id, new_def_id);
14871482

14881483
let new_lifetime = Lifetime { id: node_id, ident: lifetime.ident };
1489-
captured_lifetimes.captures.insert(old_def_id, (new_lifetime, res));
1484+
captured_lifetimes.captures.push((new_lifetime, res));
14901485
}
14911486
}
14921487

@@ -1694,7 +1689,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
16941689
// by the opaque type. This should include all in-scope
16951690
// lifetime parameters, including those defined in-band.
16961691

1697-
let mut captures = FxHashMap::default();
1692+
let mut captures = Vec::new();
16981693
let mut new_remapping = FxHashMap::default();
16991694

17001695
let extra_lifetime_params = self.resolver.take_extra_lifetime_params(opaque_ty_node_id);
@@ -1730,7 +1725,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
17301725
};
17311726

17321727
let new_lifetime = Lifetime { id: inner_node_id, ident };
1733-
captures.insert(outer_def_id, (new_lifetime, inner_res));
1728+
captures.push((new_lifetime, inner_res));
17341729
}
17351730

17361731
debug!(?captures);
@@ -1768,7 +1763,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
17681763
let future_bound = ret;
17691764

17701765
let generic_params =
1771-
this.arena.alloc_from_iter(captures.iter().map(|(_, &(lifetime, _))| {
1766+
this.arena.alloc_from_iter(captures.iter().map(|&(lifetime, _)| {
17721767
let hir_id = this.lower_node_id(lifetime.id);
17731768
debug_assert_ne!(this.opt_local_def_id(lifetime.id), None);
17741769

@@ -1821,7 +1816,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
18211816
// For the "output" lifetime parameters, we just want to
18221817
// generate `'_`.
18231818
let generic_args =
1824-
self.arena.alloc_from_iter(captures.into_iter().map(|(_, (lifetime, res))| {
1819+
self.arena.alloc_from_iter(captures.into_iter().map(|(lifetime, res)| {
18251820
let id = self.next_node_id();
18261821
let span = lifetime.ident.span;
18271822

0 commit comments

Comments
 (0)