Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/rustc_ast_lowering/src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1928,11 +1928,11 @@ impl<'hir> LoweringContext<'_, 'hir> {

// Introduce extra lifetimes if late resolution tells us to.
let extra_lifetimes = self.resolver.extra_lifetime_params(parent_node_id);
params.extend(extra_lifetimes.into_iter().filter_map(|&(ident, node_id, res)| {
params.extend(extra_lifetimes.into_iter().map(|&(ident, node_id, kind)| {
self.lifetime_res_to_generic_param(
ident,
node_id,
res,
kind,
hir::GenericParamSource::Generics,
)
}));
Expand Down
47 changes: 17 additions & 30 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ use rustc_hir::definitions::PerParentDisambiguatorState;
use rustc_hir::lints::DelayedLint;
use rustc_hir::{
self as hir, AngleBrackets, ConstArg, GenericArg, HirId, ItemLocalMap, LifetimeSource,
LifetimeSyntax, ParamName, Target, TraitCandidate, find_attr,
LifetimeSyntax, MissingLifetimeKind, ParamName, Target, TraitCandidate, find_attr,
};
use rustc_index::{Idx, IndexSlice, IndexVec};
use rustc_macros::extension;
Expand Down Expand Up @@ -310,7 +310,7 @@ impl<'tcx> ResolverAstLowering<'tcx> {
///
/// The extra lifetimes that appear from the parenthesized `Fn`-trait desugaring
/// should appear at the enclosing `PolyTraitRef`.
fn extra_lifetime_params(&self, id: NodeId) -> &[(Ident, NodeId, LifetimeRes)] {
fn extra_lifetime_params(&self, id: NodeId) -> &[(Ident, NodeId, MissingLifetimeKind)] {
self.extra_lifetime_params_map.get(&id).map_or(&[], |v| &v[..])
}

Expand Down Expand Up @@ -948,43 +948,30 @@ impl<'hir> LoweringContext<'_, 'hir> {
&mut self,
ident: Ident,
node_id: NodeId,
res: LifetimeRes,
kind: MissingLifetimeKind,
source: hir::GenericParamSource,
) -> Option<hir::GenericParam<'hir>> {
let (name, kind) = match res {
LifetimeRes::Param { .. } => {
(hir::ParamName::Plain(ident), hir::LifetimeParamKind::Explicit)
}
LifetimeRes::Fresh { param, kind, .. } => {
// Late resolution delegates to us the creation of the `LocalDefId`.
let _def_id = self.create_def(
param,
Some(kw::UnderscoreLifetime),
DefKind::LifetimeParam,
ident.span,
);
debug!(?_def_id);
) -> hir::GenericParam<'hir> {
// Late resolution delegates to us the creation of the `LocalDefId`.
let _def_id = self.create_def(
node_id,
Some(kw::UnderscoreLifetime),
DefKind::LifetimeParam,
ident.span,
);
debug!(?_def_id);

(hir::ParamName::Fresh, hir::LifetimeParamKind::Elided(kind))
}
LifetimeRes::Static { .. } | LifetimeRes::Error(..) => return None,
res => panic!(
"Unexpected lifetime resolution {:?} for {:?} at {:?}",
res, ident, ident.span
),
};
let hir_id = self.lower_node_id(node_id);
let def_id = self.local_def_id(node_id);
Some(hir::GenericParam {
hir::GenericParam {
hir_id,
def_id,
name,
name: hir::ParamName::Fresh,
span: self.lower_span(ident.span),
pure_wrt_drop: false,
kind: hir::GenericParamKind::Lifetime { kind },
kind: hir::GenericParamKind::Lifetime { kind: hir::LifetimeParamKind::Elided(kind) },
colon_span: None,
source,
})
}
}

/// Lowers a lifetime binder that defines `generic_params`, returning the corresponding HIR
Expand All @@ -1005,7 +992,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
debug!(?extra_lifetimes);
let extra_lifetimes: Vec<_> = extra_lifetimes
.iter()
.filter_map(|&(ident, node_id, res)| {
.map(|&(ident, node_id, res)| {
self.lifetime_res_to_generic_param(
ident,
node_id,
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_hir/src/def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -991,8 +991,6 @@ pub enum LifetimeRes {
///
/// Creating the associated `LocalDefId` is the responsibility of lowering.
param: NodeId,
/// Id of the introducing place. See `Param`.
binder: NodeId,
/// Kind of elided lifetime
kind: hir::MissingLifetimeKind,
},
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_middle/src/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,11 @@ use rustc_data_structures::stable_hash::{StableHash, StableHashCtxt, StableHashe
use rustc_data_structures::steal::Steal;
use rustc_data_structures::unord::{UnordMap, UnordSet};
use rustc_errors::{Diag, ErrorGuaranteed, LintBuffer};
use rustc_hir as hir;
use rustc_hir::attrs::StrippedCfgItem;
use rustc_hir::def::{CtorKind, CtorOf, DefKind, DocLinkResMap, LifetimeRes, Res};
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, LocalDefIdMap};
use rustc_hir::definitions::PerParentDisambiguatorState;
use rustc_hir::{LangItem, attrs as attr, find_attr};
use rustc_hir::{self as hir, LangItem, MissingLifetimeKind, attrs as attr, find_attr};
use rustc_index::IndexVec;
use rustc_index::bit_set::BitMatrix;
use rustc_macros::{
Expand Down Expand Up @@ -232,7 +231,7 @@ pub struct ResolverAstLowering<'tcx> {
/// Resolutions for lifetimes.
pub lifetimes_res_map: NodeMap<LifetimeRes>,
/// Lifetime parameters that lowering will have to introduce.
pub extra_lifetime_params_map: NodeMap<Vec<(Ident, ast::NodeId, LifetimeRes)>>,
pub extra_lifetime_params_map: NodeMap<Vec<(Ident, ast::NodeId, MissingLifetimeKind)>>,

pub next_node_id: ast::NodeId,

Expand Down
Loading
Loading