Skip to content

Commit f07c56d

Browse files
committed
extra_lifetime_params_map can only ever contain LifetimeRes::Fresh, so just encode the fields we need
1 parent 43dd8a4 commit f07c56d

5 files changed

Lines changed: 20 additions & 29 deletions

File tree

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1928,11 +1928,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
19281928

19291929
// Introduce extra lifetimes if late resolution tells us to.
19301930
let extra_lifetimes = self.resolver.extra_lifetime_params(parent_node_id);
1931-
params.extend(extra_lifetimes.into_iter().map(|&(ident, node_id, res)| {
1931+
params.extend(extra_lifetimes.into_iter().map(|&(ident, node_id, kind)| {
19321932
self.lifetime_res_to_generic_param(
19331933
ident,
19341934
node_id,
1935-
res,
1935+
kind,
19361936
hir::GenericParamSource::Generics,
19371937
)
19381938
}));

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ use rustc_hir::definitions::PerParentDisambiguatorState;
5555
use rustc_hir::lints::DelayedLint;
5656
use rustc_hir::{
5757
self as hir, AngleBrackets, ConstArg, GenericArg, HirId, ItemLocalMap, LifetimeSource,
58-
LifetimeSyntax, ParamName, Target, TraitCandidate, find_attr,
58+
LifetimeSyntax, MissingLifetimeKind, ParamName, Target, TraitCandidate, find_attr,
5959
};
6060
use rustc_index::{Idx, IndexSlice, IndexVec};
6161
use rustc_macros::extension;
@@ -310,7 +310,7 @@ impl<'tcx> ResolverAstLowering<'tcx> {
310310
///
311311
/// The extra lifetimes that appear from the parenthesized `Fn`-trait desugaring
312312
/// should appear at the enclosing `PolyTraitRef`.
313-
fn extra_lifetime_params(&self, id: NodeId) -> &[(Ident, NodeId, LifetimeRes)] {
313+
fn extra_lifetime_params(&self, id: NodeId) -> &[(Ident, NodeId, MissingLifetimeKind)] {
314314
self.extra_lifetime_params_map.get(&id).map_or(&[], |v| &v[..])
315315
}
316316

@@ -948,36 +948,27 @@ impl<'hir> LoweringContext<'_, 'hir> {
948948
&mut self,
949949
ident: Ident,
950950
node_id: NodeId,
951-
res: LifetimeRes,
951+
kind: MissingLifetimeKind,
952952
source: hir::GenericParamSource,
953953
) -> hir::GenericParam<'hir> {
954-
let (name, kind) = match res {
955-
LifetimeRes::Fresh { param, kind, .. } => {
956-
// Late resolution delegates to us the creation of the `LocalDefId`.
957-
let _def_id = self.create_def(
958-
param,
959-
Some(kw::UnderscoreLifetime),
960-
DefKind::LifetimeParam,
961-
ident.span,
962-
);
963-
debug!(?_def_id);
954+
// Late resolution delegates to us the creation of the `LocalDefId`.
955+
let _def_id = self.create_def(
956+
node_id,
957+
Some(kw::UnderscoreLifetime),
958+
DefKind::LifetimeParam,
959+
ident.span,
960+
);
961+
debug!(?_def_id);
964962

965-
(hir::ParamName::Fresh, hir::LifetimeParamKind::Elided(kind))
966-
}
967-
res => panic!(
968-
"Unexpected lifetime resolution {:?} for {:?} at {:?}",
969-
res, ident, ident.span
970-
),
971-
};
972963
let hir_id = self.lower_node_id(node_id);
973964
let def_id = self.local_def_id(node_id);
974965
hir::GenericParam {
975966
hir_id,
976967
def_id,
977-
name,
968+
name: hir::ParamName::Fresh,
978969
span: self.lower_span(ident.span),
979970
pure_wrt_drop: false,
980-
kind: hir::GenericParamKind::Lifetime { kind },
971+
kind: hir::GenericParamKind::Lifetime { kind: hir::LifetimeParamKind::Elided(kind) },
981972
colon_span: None,
982973
source,
983974
}

compiler/rustc_middle/src/ty/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ use rustc_data_structures::stable_hash::{StableHash, StableHashCtxt, StableHashe
3737
use rustc_data_structures::steal::Steal;
3838
use rustc_data_structures::unord::{UnordMap, UnordSet};
3939
use rustc_errors::{Diag, ErrorGuaranteed, LintBuffer};
40-
use rustc_hir as hir;
40+
use rustc_hir::{self as hir, MissingLifetimeKind};
4141
use rustc_hir::attrs::StrippedCfgItem;
4242
use rustc_hir::def::{CtorKind, CtorOf, DefKind, DocLinkResMap, LifetimeRes, Res};
4343
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, LocalDefIdMap};
@@ -232,7 +232,7 @@ pub struct ResolverAstLowering<'tcx> {
232232
/// Resolutions for lifetimes.
233233
pub lifetimes_res_map: NodeMap<LifetimeRes>,
234234
/// Lifetime parameters that lowering will have to introduce.
235-
pub extra_lifetime_params_map: NodeMap<Vec<(Ident, ast::NodeId, LifetimeRes)>>,
235+
pub extra_lifetime_params_map: NodeMap<Vec<(Ident, ast::NodeId, MissingLifetimeKind)>>,
236236

237237
pub next_node_id: ast::NodeId,
238238

compiler/rustc_resolve/src/late.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2151,7 +2151,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
21512151
.extra_lifetime_params_map
21522152
.entry(binder)
21532153
.or_insert_with(Vec::new)
2154-
.push((ident, param, res));
2154+
.push((ident, param, kind));
21552155
res
21562156
}
21572157

compiler/rustc_resolve/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ use rustc_hir::def::{
5858
};
5959
use rustc_hir::def_id::{CRATE_DEF_ID, CrateNum, DefId, LOCAL_CRATE, LocalDefId, LocalDefIdMap};
6060
use rustc_hir::definitions::{PerParentDisambiguatorState, PerParentDisambiguatorsMap};
61-
use rustc_hir::{PrimTy, TraitCandidate, find_attr};
61+
use rustc_hir::{MissingLifetimeKind, PrimTy, TraitCandidate, find_attr};
6262
use rustc_index::bit_set::DenseBitSet;
6363
use rustc_metadata::creader::CStore;
6464
use rustc_middle::metadata::{AmbigModChild, ModChild, Reexport};
@@ -1385,7 +1385,7 @@ pub struct Resolver<'ra, 'tcx> {
13851385
/// Resolutions for lifetimes.
13861386
lifetimes_res_map: NodeMap<LifetimeRes> = Default::default(),
13871387
/// Lifetime parameters that lowering will have to introduce.
1388-
extra_lifetime_params_map: NodeMap<Vec<(Ident, NodeId, LifetimeRes)>> = Default::default(),
1388+
extra_lifetime_params_map: NodeMap<Vec<(Ident, NodeId, MissingLifetimeKind)>> = Default::default(),
13891389

13901390
/// `CrateNum` resolutions of `extern crate` items.
13911391
extern_crate_map: UnordMap<LocalDefId, CrateNum> = Default::default(),

0 commit comments

Comments
 (0)