Skip to content

Commit 85e4866

Browse files
committed
PathParameters -> GenericArgs fixes
1 parent 083a7ea commit 85e4866

File tree

4 files changed

+26
-38
lines changed

4 files changed

+26
-38
lines changed

src/librustc/hir/lowering.rs

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ pub trait Resolver {
168168
span: Span,
169169
crate_root: Option<&str>,
170170
components: &[&str],
171-
params: Option<P<hir::PathParameters>>
171+
params: Option<P<hir::GenericArgs>>,
172172
is_value: bool,
173173
) -> hir::Path;
174174
}
@@ -1176,7 +1176,8 @@ impl<'a> LoweringContext<'a> {
11761176
// Set the name to `impl Bound1 + Bound2`
11771177
let exist_ty_name = Symbol::intern(&pprust::ty_to_string(t));
11781178
self.lower_existential_impl_trait(
1179-
span, fn_def_id, exist_ty_name, |this| this.lower_bounds(bounds, itctx))
1179+
span, fn_def_id, exist_ty_name,
1180+
|this| this.lower_param_bounds(bounds, itctx))
11801181
}
11811182
ImplTraitContext::Universal(def_id) => {
11821183
let def_node_id = self.next_id().node_id;
@@ -1245,7 +1246,7 @@ impl<'a> LoweringContext<'a> {
12451246
span: Span,
12461247
fn_def_id: DefId,
12471248
exist_ty_name: Name,
1248-
lower_bounds: impl FnOnce(&mut LoweringContext) -> hir::TyParamBounds,
1249+
lower_bounds: impl FnOnce(&mut LoweringContext) -> hir::GenericBounds,
12491250
) -> hir::Ty_ {
12501251
// We need to manually repeat the code of `next_id` because the lowering
12511252
// needs to happen while the owner_id is pointing to the item itself,
@@ -1970,15 +1971,15 @@ impl<'a> LoweringContext<'a> {
19701971
hir::intravisit::NestedVisitorMap::None
19711972
}
19721973

1973-
fn visit_path_parameters(&mut self, span: Span, parameters: &'v hir::PathParameters) {
1974+
fn visit_generic_args(&mut self, span: Span, parameters: &'v hir::GenericArgs) {
19741975
// Don't collect elided lifetimes used inside of `Fn()` syntax.
19751976
if parameters.parenthesized {
19761977
let old_collect_elided_lifetimes = self.collect_elided_lifetimes;
19771978
self.collect_elided_lifetimes = false;
1978-
hir::intravisit::walk_path_parameters(self, span, parameters);
1979+
hir::intravisit::walk_generic_args(self, span, parameters);
19791980
self.collect_elided_lifetimes = old_collect_elided_lifetimes;
19801981
} else {
1981-
hir::intravisit::walk_path_parameters(self, span, parameters);
1982+
hir::intravisit::walk_generic_args(self, span, parameters);
19821983
}
19831984
}
19841985

@@ -2013,11 +2014,12 @@ impl<'a> LoweringContext<'a> {
20132014
}
20142015

20152016
fn visit_generic_param(&mut self, param: &'v hir::GenericParam) {
2016-
// Record the introduction of 'a in `for<'a> ...`
2017-
if let hir::GenericParam::Lifetime(ref lt_def) = *param {
2017+
// Record the introduction of 'a in `for<'a> ...`
2018+
if let hir::GenericParamKind::Lifetime { .. } = param.kind {
20182019
// Introduce lifetimes one at a time so that we can handle
20192020
// cases like `fn foo<'d>() -> impl for<'a, 'b: 'a, 'c: 'b + 'd>`
2020-
self.currently_bound_lifetimes.push(lt_def.lifetime.name);
2021+
let lt_name = hir::LifetimeName::Param(param.name);
2022+
self.currently_bound_lifetimes.push(lt_name);
20212023
}
20222024

20232025
hir::intravisit::walk_generic_param(self, param);
@@ -2034,8 +2036,7 @@ impl<'a> LoweringContext<'a> {
20342036
return;
20352037
}
20362038
}
2037-
name @ hir::LifetimeName::Fresh(_) => name,
2038-
name @ hir::LifetimeName::Name(_) => name,
2039+
hir::LifetimeName::Param(_) => lifetime.name,
20392040
hir::LifetimeName::Static => return,
20402041
};
20412042

@@ -2117,9 +2118,8 @@ impl<'a> LoweringContext<'a> {
21172118
};
21182119

21192120
// "<Output = T>"
2120-
let future_params = P(hir::PathParameters {
2121-
lifetimes: hir_vec![],
2122-
types: hir_vec![],
2121+
let future_params = P(hir::GenericArgs {
2122+
args: hir_vec![],
21232123
bindings: hir_vec![hir::TypeBinding {
21242124
name: Symbol::intern(FN_OUTPUT_NAME),
21252125
ty: output_ty,
@@ -2129,13 +2129,11 @@ impl<'a> LoweringContext<'a> {
21292129
parenthesized: false,
21302130
});
21312131

2132-
let let future_path =
2132+
let future_path =
21332133
this.std_path(span, &["future", "Future"], Some(future_params), false);
21342134

2135-
// FIXME(cramertj) collect input lifetimes to function and add them to
2136-
// the output `impl Trait` type here.
21372135
let mut bounds = vec![
2138-
hir::TyParamBound::TraitTyParamBound(
2136+
hir::GenericBound::Trait(
21392137
hir::PolyTraitRef {
21402138
trait_ref: hir::TraitRef {
21412139
path: future_path,
@@ -2149,7 +2147,7 @@ impl<'a> LoweringContext<'a> {
21492147
];
21502148

21512149
if let Some((name, span)) = bound_lifetime {
2152-
bounds.push(hir::RegionTyParamBound(
2150+
bounds.push(hir::GenericBound::Outlives(
21532151
hir::Lifetime { id: this.next_id().node_id, name, span }));
21542152
}
21552153

@@ -4366,7 +4364,7 @@ impl<'a> LoweringContext<'a> {
43664364
&mut self,
43674365
span: Span,
43684366
components: &[&str],
4369-
params: Option<P<hir::PathParameters>>,
4367+
params: Option<P<hir::GenericArgs>>,
43704368
attrs: ThinVec<Attribute>,
43714369
) -> hir::Expr {
43724370
let path = self.std_path(span, components, params, true);
@@ -4545,7 +4543,7 @@ impl<'a> LoweringContext<'a> {
45454543
&mut self,
45464544
span: Span,
45474545
components: &[&str],
4548-
params: Option<P<hir::PathParameters>>,
4546+
params: Option<P<hir::GenericArgs>>,
45494547
is_value: bool
45504548
) -> hir::Path {
45514549
self.resolver

src/librustc/hir/map/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ impl<'hir> MapEntry<'hir> {
174174
match self {
175175
EntryItem(_, _, ref item) => {
176176
match item.node {
177-
ItemFn(ref fn_decl, _, _, _, _, _) => Some(&fn_decl),
177+
ItemFn(ref fn_decl, _, _, _) => Some(&fn_decl),
178178
_ => None,
179179
}
180180
}

src/librustc/hir/mod.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -245,16 +245,6 @@ pub enum LifetimeName {
245245
}
246246

247247
impl LifetimeName {
248-
pub fn is_elided(self) -> bool {
249-
match self {
250-
LifetimeName::Implicit
251-
| LifetimeName::Underscore => true,
252-
LifetimeName::Fresh(_)
253-
| LifetimeName::Static
254-
| LifetimeName::Name(_) => false,
255-
}
256-
}
257-
258248
pub fn name(&self) -> Name {
259249
use self::LifetimeName::*;
260250
match *self {
@@ -265,7 +255,7 @@ impl LifetimeName {
265255
}
266256
}
267257

268-
fn is_elided(&self) -> bool {
258+
pub fn is_elided(&self) -> bool {
269259
use self::LifetimeName::*;
270260
match self {
271261
Implicit | Underscore => true,

src/librustc_resolve/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ use syntax::util::lev_distance::find_best_match_for_name;
5555

5656
use syntax::visit::{self, FnKind, Visitor};
5757
use syntax::attr;
58-
use syntax::ast::{Arm, IsAsync, BindingMode, Block, Crate, Expr, ExprKind, FnHeader};
58+
use syntax::ast::{Arm, IsAsync, BindingMode, Block, Crate, Expr, ExprKind};
5959
use syntax::ast::{FnDecl, ForeignItem, ForeignItemKind, GenericParamKind, Generics};
6060
use syntax::ast::{Item, ItemKind, ImplItem, ImplItemKind};
6161
use syntax::ast::{Label, Local, Mutability, Pat, PatKind, Path};
@@ -1494,7 +1494,7 @@ impl<'a> hir::lowering::Resolver for Resolver<'a> {
14941494
span: Span,
14951495
crate_root: Option<&str>,
14961496
components: &[&str],
1497-
params: Option<hir::PathParameters>,
1497+
args: Option<P<hir::GenericArgs>>,
14981498
is_value: bool
14991499
) -> hir::Path {
15001500
let mut segments = iter::once(keywords::CrateRoot.name())
@@ -1504,11 +1504,11 @@ impl<'a> hir::lowering::Resolver for Resolver<'a> {
15041504
.map(Symbol::intern)
15051505
).map(hir::PathSegment::from_name).collect::<Vec<_>>();
15061506

1507-
if let Some(parameters) = params {
1508-
let last_name = segments.last().unwrap().name;
1507+
if let Some(args) = args {
1508+
let name = segments.last().unwrap().name;
15091509
*segments.last_mut().unwrap() = hir::PathSegment {
15101510
name,
1511-
parameters,
1511+
args: Some(args),
15121512
infer_types: true,
15131513
};
15141514
}

0 commit comments

Comments
 (0)