Skip to content

Commit 6015edf

Browse files
committed
Remove name from GenericParamKind::Lifetime
1 parent c4e8e71 commit 6015edf

File tree

10 files changed

+30
-59
lines changed

10 files changed

+30
-59
lines changed

src/librustc/hir/intravisit.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -736,9 +736,7 @@ pub fn walk_param_bound<'v, V: Visitor<'v>>(visitor: &mut V, bound: &'v ParamBou
736736
TraitTyParamBound(ref typ, modifier) => {
737737
visitor.visit_poly_trait_ref(typ, modifier);
738738
}
739-
Outlives(ref lifetime) => {
740-
visitor.visit_lifetime(lifetime);
741-
}
739+
Outlives(ref lifetime) => visitor.visit_lifetime(lifetime),
742740
}
743741
}
744742

src/librustc/hir/lowering.rs

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -706,13 +706,8 @@ impl<'a> LoweringContext<'a> {
706706
kind: hir::GenericParamKind::Lifetime {
707707
lt_name: hir_name,
708708
in_band: true,
709-
lifetime: hir::Lifetime {
710-
id: def_node_id,
711-
span,
712-
name: hir_name,
713709
}
714710
}
715-
}
716711
})
717712
.chain(in_band_ty_params.into_iter())
718713
.collect();
@@ -1423,12 +1418,7 @@ impl<'a> LoweringContext<'a> {
14231418
kind: hir::GenericParamKind::Lifetime {
14241419
lt_name: name,
14251420
in_band: false,
1426-
lifetime: hir::Lifetime {
1427-
id: def_node_id,
1428-
span: lifetime.span,
1429-
name,
14301421
}
1431-
}
14321422
});
14331423
}
14341424
}
@@ -1947,21 +1937,20 @@ impl<'a> LoweringContext<'a> {
19471937
-> hir::GenericParam {
19481938
let mut bounds = self.lower_param_bounds(&param.bounds, itctx);
19491939
match param.kind {
1950-
GenericParamKind::Lifetime { ref lifetime } => {
1940+
GenericParamKind::Lifetime => {
19511941
let was_collecting_in_band = self.is_collecting_in_band_lifetimes;
19521942
self.is_collecting_in_band_lifetimes = false;
19531943

1954-
let lifetime = self.lower_lifetime(lifetime);
1944+
let lt = self.lower_lifetime(&Lifetime { id: param.id, ident: param.ident });
19551945
let param = hir::GenericParam {
1956-
id: lifetime.id,
1957-
name: lifetime.name.name(),
1958-
span: lifetime.span,
1946+
id: lt.id,
1947+
name: lt.name.name(),
1948+
span: lt.span,
19591949
pure_wrt_drop: attr::contains_name(&param.attrs, "may_dangle"),
19601950
bounds,
19611951
kind: hir::GenericParamKind::Lifetime {
1962-
lt_name: lifetime.name,
1952+
lt_name: lt.name,
19631953
in_band: false,
1964-
lifetime,
19651954
}
19661955
};
19671956

src/librustc/hir/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,8 +454,6 @@ pub enum GenericParamKind {
454454
// as a result of an in-band lifetime usage like:
455455
// `fn foo(x: &'a u8) -> &'a u8 { x }`
456456
in_band: bool,
457-
// We keep a `Lifetime` around for now just so we can `visit_lifetime`.
458-
lifetime: Lifetime,
459457
},
460458
Type {
461459
default: Option<P<Ty>>,

src/librustc/ich/impls_hir.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,9 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::GenericParamKind {
209209
hasher: &mut StableHasher<W>) {
210210
mem::discriminant(self).hash_stable(hcx, hasher);
211211
match self {
212-
hir::GenericParamKind::Lifetime { lt_name, in_band, ref lifetime } => {
212+
hir::GenericParamKind::Lifetime { lt_name, in_band } => {
213213
lt_name.hash_stable(hcx, hasher);
214214
in_band.hash_stable(hcx, hasher);
215-
lifetime.hash_stable(hcx, hasher);
216215
}
217216
hir::GenericParamKind::Type { ref default, synthetic, attrs } => {
218217
default.hash_stable(hcx, hasher);

src/libsyntax/ast.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,7 @@ pub type ParamBounds = Vec<ParamBound>;
301301
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
302302
pub enum GenericParamKind {
303303
/// A lifetime definition, e.g. `'a: 'b+'c+'d`.
304-
Lifetime {
305-
lifetime: Lifetime,
306-
},
304+
Lifetime,
307305
Type {
308306
default: Option<P<Ty>>,
309307
}

src/libsyntax/ext/build.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -484,9 +484,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
484484
id: lifetime.id,
485485
attrs: attrs.into(),
486486
bounds,
487-
kind: ast::GenericParamKind::Lifetime {
488-
lifetime,
489-
}
487+
kind: ast::GenericParamKind::Lifetime,
490488
}
491489
}
492490

src/libsyntax/parse/parser.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4877,9 +4877,7 @@ impl<'a> Parser<'a> {
48774877
id: lifetime.id,
48784878
attrs: attrs.into(),
48794879
bounds,
4880-
kind: ast::GenericParamKind::Lifetime {
4881-
lifetime,
4882-
}
4880+
kind: ast::GenericParamKind::Lifetime,
48834881
});
48844882
if seen_ty_param {
48854883
self.span_err(self.prev_span,

src/libsyntax/print/pprust.rs

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,8 @@ pub fn expr_to_string(e: &ast::Expr) -> String {
308308
to_string(|s| s.print_expr(e))
309309
}
310310

311-
pub fn lifetime_to_string(e: &ast::Lifetime) -> String {
312-
to_string(|s| s.print_lifetime(e))
311+
pub fn lifetime_to_string(lt: &ast::Lifetime) -> String {
312+
to_string(|s| s.print_lifetime(*lt))
313313
}
314314

315315
pub fn tt_to_string(tt: tokenstream::TokenTree) -> String {
@@ -1008,18 +1008,17 @@ impl<'a> State<'a> {
10081008
Ok(())
10091009
}
10101010

1011-
pub fn print_opt_lifetime(&mut self,
1012-
lifetime: &Option<ast::Lifetime>) -> io::Result<()> {
1013-
if let Some(l) = *lifetime {
1014-
self.print_lifetime(&l)?;
1011+
pub fn print_opt_lifetime(&mut self, lifetime: &Option<ast::Lifetime>) -> io::Result<()> {
1012+
if let Some(lt) = *lifetime {
1013+
self.print_lifetime(lt)?;
10151014
self.nbsp()?;
10161015
}
10171016
Ok(())
10181017
}
10191018

10201019
pub fn print_generic_arg(&mut self, generic_arg: &GenericArg) -> io::Result<()> {
10211020
match generic_arg {
1022-
GenericArg::Lifetime(lt) => self.print_lifetime(lt),
1021+
GenericArg::Lifetime(lt) => self.print_lifetime(*lt),
10231022
GenericArg::Type(ty) => self.print_type(ty),
10241023
}
10251024
}
@@ -2833,26 +2832,19 @@ impl<'a> State<'a> {
28332832
}
28342833
self.print_poly_trait_ref(tref)?;
28352834
}
2836-
Outlives(lt) => {
2837-
self.print_lifetime(lt)?;
2838-
}
2835+
Outlives(lt) => self.print_lifetime(*lt)?,
28392836
}
28402837
}
28412838
}
28422839
Ok(())
28432840
}
28442841

2845-
pub fn print_lifetime(&mut self,
2846-
lifetime: &ast::Lifetime)
2847-
-> io::Result<()>
2848-
{
2842+
pub fn print_lifetime(&mut self, lifetime: ast::Lifetime) -> io::Result<()> {
28492843
self.print_name(lifetime.ident.name)
28502844
}
28512845

2852-
pub fn print_lifetime_bounds(&mut self,
2853-
lifetime: &ast::Lifetime,
2854-
bounds: &ast::ParamBounds)
2855-
-> io::Result<()>
2846+
pub fn print_lifetime_bounds(&mut self, lifetime: ast::Lifetime, bounds: &ast::ParamBounds)
2847+
-> io::Result<()>
28562848
{
28572849
self.print_lifetime(lifetime)?;
28582850
if !bounds.is_empty() {
@@ -2862,7 +2854,7 @@ impl<'a> State<'a> {
28622854
self.s.word(" + ")?;
28632855
}
28642856
match bound {
2865-
ast::ParamBound::Outlives(lt) => self.print_lifetime(lt)?,
2857+
ast::ParamBound::Outlives(lt) => self.print_lifetime(*lt)?,
28662858
_ => panic!(),
28672859
}
28682860
}
@@ -2882,9 +2874,10 @@ impl<'a> State<'a> {
28822874

28832875
self.commasep(Inconsistent, &generic_params, |s, param| {
28842876
match param.kind {
2885-
ast::GenericParamKind::Lifetime { ref lifetime } => {
2877+
ast::GenericParamKind::Lifetime => {
28862878
s.print_outer_attributes_inline(&param.attrs)?;
2887-
s.print_lifetime_bounds(lifetime, &param.bounds)
2879+
let lt = ast::Lifetime { id: param.id, ident: param.ident };
2880+
s.print_lifetime_bounds(lt, &param.bounds)
28882881
},
28892882
ast::GenericParamKind::Type { ref default } => {
28902883
s.print_outer_attributes_inline(&param.attrs)?;
@@ -2934,7 +2927,7 @@ impl<'a> State<'a> {
29342927
ast::WherePredicate::RegionPredicate(ast::WhereRegionPredicate{ref lifetime,
29352928
ref bounds,
29362929
..}) => {
2937-
self.print_lifetime_bounds(lifetime, bounds)?;
2930+
self.print_lifetime_bounds(*lifetime, bounds)?;
29382931
}
29392932
ast::WherePredicate::EqPredicate(ast::WhereEqPredicate{ref lhs_ty,
29402933
ref rhs_ty,

src/libsyntax_ext/deriving/generic/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -665,8 +665,8 @@ impl<'a> TraitDef<'a> {
665665
let trait_ref = cx.trait_ref(trait_path);
666666

667667
let self_params: Vec<_> = generics.params.iter().map(|param| match param.kind {
668-
GenericParamKind::Lifetime { ref lifetime, .. } => {
669-
GenericArg::Lifetime(*lifetime)
668+
GenericParamKind::Lifetime { .. } => {
669+
GenericArg::Lifetime(ast::Lifetime { id: param.id, ident: param.ident })
670670
}
671671
GenericParamKind::Type { .. } => {
672672
GenericArg::Type(cx.ty_ident(self.span, param.ident))

src/libsyntax_ext/deriving/generic/ty.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,8 @@ impl<'a> Ty<'a> {
190190
match *self {
191191
Self_ => {
192192
let params: Vec<_> = generics.params.iter().map(|param| match param.kind {
193-
GenericParamKind::Lifetime { ref lifetime, .. } => {
194-
GenericArg::Lifetime(*lifetime)
193+
GenericParamKind::Lifetime { .. } => {
194+
GenericArg::Lifetime(ast::Lifetime { id: param.id, ident: param.ident })
195195
}
196196
GenericParamKind::Type { .. } => {
197197
GenericArg::Type(cx.ty_ident(span, param.ident))

0 commit comments

Comments
 (0)