Skip to content

Commit a152770

Browse files
committed
Generics Unification rebase fallout
1 parent 9859a52 commit a152770

File tree

2 files changed

+26
-27
lines changed

2 files changed

+26
-27
lines changed

src/librustc/hir/lowering.rs

+25-26
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ enum ImplTraitContext<'a> {
174174
/// We store a DefId here so we can look up necessary information later
175175
///
176176
/// Newly generated parameters should be inserted into the given `Vec`
177-
Universal(DefId, &'a mut Vec<hir::TyParam>),
177+
Universal(DefId, &'a mut Vec<hir::GenericParam>),
178178

179179
/// Treat `impl Trait` as shorthand for a new universal existential parameter.
180180
/// Example: `fn foo() -> impl Debug`, where `impl Debug` is conceptually
@@ -183,7 +183,7 @@ enum ImplTraitContext<'a> {
183183
/// We store a DefId here so we can look up necessary information later
184184
///
185185
/// All generics of the surrounding function must go into the generated existential type
186-
Existential(DefId, &'a [hir::TyParam], &'a hir::Generics),
186+
Existential(DefId, &'a [hir::GenericParam], &'a hir::Generics),
187187

188188
/// `impl Trait` is not accepted in this position.
189189
Disallowed,
@@ -656,7 +656,7 @@ impl<'a> LoweringContext<'a> {
656656
f: F,
657657
) -> (Vec<hir::GenericParam>, T)
658658
where
659-
F: FnOnce(&mut LoweringContext) -> (Vec<hir::TyParam>, T),
659+
F: FnOnce(&mut LoweringContext) -> (Vec<hir::GenericParam>, T),
660660
{
661661
assert!(!self.is_collecting_in_band_lifetimes);
662662
assert!(self.lifetimes_to_define.is_empty());
@@ -804,7 +804,7 @@ impl<'a> LoweringContext<'a> {
804804
f: F,
805805
) -> (hir::Generics, T)
806806
where
807-
F: FnOnce(&mut LoweringContext, &mut Vec<hir::TyParam>, &hir::Generics) -> T,
807+
F: FnOnce(&mut LoweringContext, &mut Vec<hir::GenericParam>, &hir::Generics) -> T,
808808
{
809809
let (in_band_defs, (mut lowered_generics, res)) = self.with_in_scope_lifetime_defs(
810810
&generics.params,
@@ -1045,7 +1045,7 @@ impl<'a> LoweringContext<'a> {
10451045
-> hir::GenericArg {
10461046
match arg {
10471047
ast::GenericArg::Lifetime(lt) => GenericArg::Lifetime(self.lower_lifetime(&lt)),
1048-
ast::GenericArg::Type(ty) => GenericArg::Type(self.lower_ty(&ty, itctx)),
1048+
ast::GenericArg::Type(ty) => GenericArg::Type(self.lower_ty_direct(&ty, itctx)),
10491049
}
10501050
}
10511051

@@ -1175,7 +1175,7 @@ impl<'a> LoweringContext<'a> {
11751175
lctx.lower_param_bounds(bounds, itctx)
11761176
});
11771177

1178-
let (path_params, params) = self.generics_from_impl_trait_bounds(
1178+
let (params, lifetimes) = self.generics_from_impl_trait_bounds(
11791179
def_node_id,
11801180
exist_ty_def_index,
11811181
&hir_bounds,
@@ -1222,7 +1222,7 @@ impl<'a> LoweringContext<'a> {
12221222
id: exist_ty_id.node_id
12231223
},
12241224
DefId::local(exist_ty_def_index),
1225-
path_params.lifetimes,
1225+
lifetimes,
12261226
)
12271227
})
12281228
}
@@ -1241,7 +1241,7 @@ impl<'a> LoweringContext<'a> {
12411241
);
12421242
// Set the name to `impl Bound1 + Bound2`
12431243
let name = Symbol::intern(&pprust::ty_to_string(t));
1244-
self.in_band_ty_params.push(hir::GenericParam {
1244+
in_band_ty_params.push(hir::GenericParam {
12451245
id: def_node_id,
12461246
name: ParamName::Plain(name),
12471247
span,
@@ -1292,7 +1292,7 @@ impl<'a> LoweringContext<'a> {
12921292
exist_ty_id: NodeId,
12931293
parent_index: DefIndex,
12941294
bounds: &hir::GenericBounds,
1295-
) -> (hir::PathParameters, HirVec<hir::GenericParam>) {
1295+
) -> (HirVec<hir::GenericParam>, HirVec<hir::Lifetime>) {
12961296
// This visitor walks over impl trait bounds and creates defs for all lifetimes which
12971297
// appear in the bounds, excluding lifetimes that are created within the bounds.
12981298
// e.g. 'a, 'b, but not 'c in `impl for<'c> SomeTrait<'a, 'b, 'c>`
@@ -1408,23 +1408,23 @@ impl<'a> LoweringContext<'a> {
14081408
lifetime.span,
14091409
);
14101410

1411-
let name = match name {
1411+
let (in_band, name) = match name {
14121412
hir::LifetimeName::Underscore => {
1413-
hir::ParamName::Plain(keywords::UnderscoreLifetime.name())
1413+
(true, hir::ParamName::Plain(keywords::UnderscoreLifetime.name()))
14141414
}
1415-
hir::LifetimeName::Param(param_name) => param_name,
1415+
hir::LifetimeName::Param(param_name) => (false, param_name),
14161416
_ => bug!("expected LifetimeName::Param or ParamName::Plain"),
14171417
};
14181418

1419-
self.output_lifetime_params.push(hir::GenericParam {
1419+
self.output_params.push(hir::GenericParam {
14201420
id: def_node_id,
14211421
name,
14221422
span: lifetime.span,
14231423
pure_wrt_drop: false,
14241424
attrs: hir_vec![],
14251425
bounds: hir_vec![],
14261426
kind: hir::GenericParamKind::Lifetime {
1427-
in_band: false,
1427+
in_band,
14281428
}
14291429
});
14301430
}
@@ -1447,13 +1447,8 @@ impl<'a> LoweringContext<'a> {
14471447
}
14481448

14491449
(
1450-
hir::PathParameters {
1451-
lifetimes: lifetime_collector.output_lifetimes.into(),
1452-
types: HirVec::new(),
1453-
bindings: HirVec::new(),
1454-
parenthesized: false,
1455-
},
14561450
lifetime_collector.output_params.into(),
1451+
lifetime_collector.output_lifetimes.into(),
14571452
)
14581453
}
14591454

@@ -1844,7 +1839,7 @@ impl<'a> LoweringContext<'a> {
18441839
fn lower_fn_decl(
18451840
&mut self,
18461841
decl: &FnDecl,
1847-
mut in_band_ty_params: Option<(DefId, &mut Vec<hir::TyParam>, &hir::Generics)>,
1842+
mut in_band_ty_params: Option<(DefId, &mut Vec<hir::GenericParam>, &hir::Generics)>,
18481843
impl_trait_return_allow: bool,
18491844
) -> P<hir::FnDecl> {
18501845
// NOTE: The two last parameters here have to do with impl Trait. If fn_def_id is Some,
@@ -1943,15 +1938,19 @@ impl<'a> LoweringContext<'a> {
19431938
add_bounds: &NodeMap<Vec<GenericBound>>,
19441939
mut itctx: ImplTraitContext,
19451940
) -> hir::HirVec<hir::GenericParam> {
1946-
params.iter().map(|param| self.lower_generic_param(param, add_bounds, itctx)).collect()
1941+
params.iter().map(|param| self.lower_generic_param(
1942+
param,
1943+
add_bounds,
1944+
itctx.reborrow(),
1945+
)).collect()
19471946
}
19481947

19491948
fn lower_generic_param(&mut self,
19501949
param: &GenericParam,
19511950
add_bounds: &NodeMap<Vec<GenericBound>>,
1952-
itctx: ImplTraitContext)
1951+
mut itctx: ImplTraitContext)
19531952
-> hir::GenericParam {
1954-
let mut bounds = self.lower_param_bounds(&param.bounds, itctx);
1953+
let mut bounds = self.lower_param_bounds(&param.bounds, itctx.reborrow());
19551954
match param.kind {
19561955
GenericParamKind::Lifetime => {
19571956
let was_collecting_in_band = self.is_collecting_in_band_lifetimes;
@@ -2809,8 +2808,8 @@ impl<'a> LoweringContext<'a> {
28092808
path_span: Span,
28102809
path_segment: &'v PathSegment,
28112810
) {
2812-
if let Some(ref p) = path_segment.parameters {
2813-
if let PathParameters::Parenthesized(..) = **p {
2811+
if let Some(ref p) = path_segment.args {
2812+
if let GenericArgs::Parenthesized(..) = **p {
28142813
return;
28152814
}
28162815
}

src/librustc/hir/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ impl PathSegment {
383383
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
384384
pub enum GenericArg {
385385
Lifetime(Lifetime),
386-
Type(P<Ty>),
386+
Type(Ty),
387387
}
388388

389389
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]

0 commit comments

Comments
 (0)