about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc/hir/intravisit.rs4
-rw-r--r--src/librustc/hir/lowering.rs23
-rw-r--r--src/librustc/hir/mod.rs2
-rw-r--r--src/librustc/ich/impls_hir.rs3
-rw-r--r--src/libsyntax/ast.rs4
-rw-r--r--src/libsyntax/ext/build.rs4
-rw-r--r--src/libsyntax/parse/parser.rs4
-rw-r--r--src/libsyntax/print/pprust.rs37
-rw-r--r--src/libsyntax_ext/deriving/generic/mod.rs4
-rw-r--r--src/libsyntax_ext/deriving/generic/ty.rs4
10 files changed, 30 insertions, 59 deletions
diff --git a/src/librustc/hir/intravisit.rs b/src/librustc/hir/intravisit.rs
index a550f60fb4b..5a41d71b93d 100644
--- a/src/librustc/hir/intravisit.rs
+++ b/src/librustc/hir/intravisit.rs
@@ -736,9 +736,7 @@ pub fn walk_param_bound<'v, V: Visitor<'v>>(visitor: &mut V, bound: &'v ParamBou
         TraitTyParamBound(ref typ, modifier) => {
             visitor.visit_poly_trait_ref(typ, modifier);
         }
-        Outlives(ref lifetime) => {
-            visitor.visit_lifetime(lifetime);
-        }
+        Outlives(ref lifetime) => visitor.visit_lifetime(lifetime),
     }
 }
 
diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs
index d0a3f0d097f..ec162adf52b 100644
--- a/src/librustc/hir/lowering.rs
+++ b/src/librustc/hir/lowering.rs
@@ -706,13 +706,8 @@ impl<'a> LoweringContext<'a> {
                     kind: hir::GenericParamKind::Lifetime {
                         lt_name: hir_name,
                         in_band: true,
-                        lifetime: hir::Lifetime {
-                            id: def_node_id,
-                            span,
-                            name: hir_name,
                         }
                     }
-                }
             })
             .chain(in_band_ty_params.into_iter())
             .collect();
@@ -1423,12 +1418,7 @@ impl<'a> LoweringContext<'a> {
                         kind: hir::GenericParamKind::Lifetime {
                             lt_name: name,
                             in_band: false,
-                            lifetime: hir::Lifetime {
-                                id: def_node_id,
-                                span: lifetime.span,
-                                name,
                             }
-                        }
                     });
                 }
             }
@@ -1947,21 +1937,20 @@ impl<'a> LoweringContext<'a> {
                            -> hir::GenericParam {
         let mut bounds = self.lower_param_bounds(&param.bounds, itctx);
         match param.kind {
-            GenericParamKind::Lifetime { ref lifetime } => {
+            GenericParamKind::Lifetime => {
                 let was_collecting_in_band = self.is_collecting_in_band_lifetimes;
                 self.is_collecting_in_band_lifetimes = false;
 
-                let lifetime = self.lower_lifetime(lifetime);
+                let lt = self.lower_lifetime(&Lifetime { id: param.id, ident: param.ident });
                 let param = hir::GenericParam {
-                    id: lifetime.id,
-                    name: lifetime.name.name(),
-                    span: lifetime.span,
+                    id: lt.id,
+                    name: lt.name.name(),
+                    span: lt.span,
                     pure_wrt_drop: attr::contains_name(&param.attrs, "may_dangle"),
                     bounds,
                     kind: hir::GenericParamKind::Lifetime {
-                        lt_name: lifetime.name,
+                        lt_name: lt.name,
                         in_band: false,
-                        lifetime,
                     }
                 };
 
diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs
index b4470ed7c1e..cf0ae5aa94d 100644
--- a/src/librustc/hir/mod.rs
+++ b/src/librustc/hir/mod.rs
@@ -454,8 +454,6 @@ pub enum GenericParamKind {
         // as a result of an in-band lifetime usage like:
         // `fn foo(x: &'a u8) -> &'a u8 { x }`
         in_band: bool,
-        // We keep a `Lifetime` around for now just so we can `visit_lifetime`.
-        lifetime: Lifetime,
     },
     Type {
         default: Option<P<Ty>>,
diff --git a/src/librustc/ich/impls_hir.rs b/src/librustc/ich/impls_hir.rs
index 0c31134ae9c..ae2bf1e4c74 100644
--- a/src/librustc/ich/impls_hir.rs
+++ b/src/librustc/ich/impls_hir.rs
@@ -209,10 +209,9 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::GenericParamKind {
                                           hasher: &mut StableHasher<W>) {
         mem::discriminant(self).hash_stable(hcx, hasher);
         match self {
-            hir::GenericParamKind::Lifetime { lt_name, in_band, ref lifetime } => {
+            hir::GenericParamKind::Lifetime { lt_name, in_band } => {
                 lt_name.hash_stable(hcx, hasher);
                 in_band.hash_stable(hcx, hasher);
-                lifetime.hash_stable(hcx, hasher);
             }
             hir::GenericParamKind::Type { ref default, synthetic, attrs } => {
                 default.hash_stable(hcx, hasher);
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs
index 67679468fe4..98f786628f9 100644
--- a/src/libsyntax/ast.rs
+++ b/src/libsyntax/ast.rs
@@ -301,9 +301,7 @@ pub type ParamBounds = Vec<ParamBound>;
 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
 pub enum GenericParamKind {
     /// A lifetime definition, e.g. `'a: 'b+'c+'d`.
-    Lifetime {
-        lifetime: Lifetime,
-    },
+    Lifetime,
     Type {
         default: Option<P<Ty>>,
     }
diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs
index ea151ca68a8..cc0bc7f0c74 100644
--- a/src/libsyntax/ext/build.rs
+++ b/src/libsyntax/ext/build.rs
@@ -484,9 +484,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
             id: lifetime.id,
             attrs: attrs.into(),
             bounds,
-            kind: ast::GenericParamKind::Lifetime {
-                lifetime,
-            }
+            kind: ast::GenericParamKind::Lifetime,
         }
     }
 
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 66e48512065..b2cfb459c35 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -4877,9 +4877,7 @@ impl<'a> Parser<'a> {
                     id: lifetime.id,
                     attrs: attrs.into(),
                     bounds,
-                    kind: ast::GenericParamKind::Lifetime {
-                        lifetime,
-                    }
+                    kind: ast::GenericParamKind::Lifetime,
                 });
                 if seen_ty_param {
                     self.span_err(self.prev_span,
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index c672b01fb27..5d39367f4b0 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -308,8 +308,8 @@ pub fn expr_to_string(e: &ast::Expr) -> String {
     to_string(|s| s.print_expr(e))
 }
 
-pub fn lifetime_to_string(e: &ast::Lifetime) -> String {
-    to_string(|s| s.print_lifetime(e))
+pub fn lifetime_to_string(lt: &ast::Lifetime) -> String {
+    to_string(|s| s.print_lifetime(*lt))
 }
 
 pub fn tt_to_string(tt: tokenstream::TokenTree) -> String {
@@ -1008,10 +1008,9 @@ impl<'a> State<'a> {
         Ok(())
     }
 
-    pub fn print_opt_lifetime(&mut self,
-                              lifetime: &Option<ast::Lifetime>) -> io::Result<()> {
-        if let Some(l) = *lifetime {
-            self.print_lifetime(&l)?;
+    pub fn print_opt_lifetime(&mut self, lifetime: &Option<ast::Lifetime>) -> io::Result<()> {
+        if let Some(lt) = *lifetime {
+            self.print_lifetime(lt)?;
             self.nbsp()?;
         }
         Ok(())
@@ -1019,7 +1018,7 @@ impl<'a> State<'a> {
 
     pub fn print_generic_arg(&mut self, generic_arg: &GenericArg) -> io::Result<()> {
         match generic_arg {
-            GenericArg::Lifetime(lt) => self.print_lifetime(lt),
+            GenericArg::Lifetime(lt) => self.print_lifetime(*lt),
             GenericArg::Type(ty) => self.print_type(ty),
         }
     }
@@ -2833,26 +2832,19 @@ impl<'a> State<'a> {
                         }
                         self.print_poly_trait_ref(tref)?;
                     }
-                    Outlives(lt) => {
-                        self.print_lifetime(lt)?;
-                    }
+                    Outlives(lt) => self.print_lifetime(*lt)?,
                 }
             }
         }
         Ok(())
     }
 
-    pub fn print_lifetime(&mut self,
-                          lifetime: &ast::Lifetime)
-                          -> io::Result<()>
-    {
+    pub fn print_lifetime(&mut self, lifetime: ast::Lifetime) -> io::Result<()> {
         self.print_name(lifetime.ident.name)
     }
 
-    pub fn print_lifetime_bounds(&mut self,
-                                 lifetime: &ast::Lifetime,
-                                 bounds: &ast::ParamBounds)
-                                 -> io::Result<()>
+    pub fn print_lifetime_bounds(&mut self, lifetime: ast::Lifetime, bounds: &ast::ParamBounds)
+        -> io::Result<()>
     {
         self.print_lifetime(lifetime)?;
         if !bounds.is_empty() {
@@ -2862,7 +2854,7 @@ impl<'a> State<'a> {
                     self.s.word(" + ")?;
                 }
                 match bound {
-                    ast::ParamBound::Outlives(lt) => self.print_lifetime(lt)?,
+                    ast::ParamBound::Outlives(lt) => self.print_lifetime(*lt)?,
                     _ => panic!(),
                 }
             }
@@ -2882,9 +2874,10 @@ impl<'a> State<'a> {
 
         self.commasep(Inconsistent, &generic_params, |s, param| {
             match param.kind {
-                ast::GenericParamKind::Lifetime { ref lifetime } => {
+                ast::GenericParamKind::Lifetime => {
                     s.print_outer_attributes_inline(&param.attrs)?;
-                    s.print_lifetime_bounds(lifetime, &param.bounds)
+                    let lt = ast::Lifetime { id: param.id, ident: param.ident };
+                    s.print_lifetime_bounds(lt, &param.bounds)
                 },
                 ast::GenericParamKind::Type { ref default } => {
                     s.print_outer_attributes_inline(&param.attrs)?;
@@ -2934,7 +2927,7 @@ impl<'a> State<'a> {
                 ast::WherePredicate::RegionPredicate(ast::WhereRegionPredicate{ref lifetime,
                                                                                ref bounds,
                                                                                ..}) => {
-                    self.print_lifetime_bounds(lifetime, bounds)?;
+                    self.print_lifetime_bounds(*lifetime, bounds)?;
                 }
                 ast::WherePredicate::EqPredicate(ast::WhereEqPredicate{ref lhs_ty,
                                                                        ref rhs_ty,
diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs
index a7d8156f4a0..89b50044129 100644
--- a/src/libsyntax_ext/deriving/generic/mod.rs
+++ b/src/libsyntax_ext/deriving/generic/mod.rs
@@ -665,8 +665,8 @@ impl<'a> TraitDef<'a> {
         let trait_ref = cx.trait_ref(trait_path);
 
         let self_params: Vec<_> = generics.params.iter().map(|param| match param.kind {
-            GenericParamKind::Lifetime { ref lifetime, .. } => {
-                GenericArg::Lifetime(*lifetime)
+            GenericParamKind::Lifetime { .. } => {
+                GenericArg::Lifetime(ast::Lifetime { id: param.id, ident: param.ident })
             }
             GenericParamKind::Type { .. } => {
                 GenericArg::Type(cx.ty_ident(self.span, param.ident))
diff --git a/src/libsyntax_ext/deriving/generic/ty.rs b/src/libsyntax_ext/deriving/generic/ty.rs
index 327a35d39b3..99b6398160e 100644
--- a/src/libsyntax_ext/deriving/generic/ty.rs
+++ b/src/libsyntax_ext/deriving/generic/ty.rs
@@ -190,8 +190,8 @@ impl<'a> Ty<'a> {
         match *self {
             Self_ => {
                 let params: Vec<_> = generics.params.iter().map(|param| match param.kind {
-                    GenericParamKind::Lifetime { ref lifetime, .. } => {
-                        GenericArg::Lifetime(*lifetime)
+                    GenericParamKind::Lifetime { .. } => {
+                        GenericArg::Lifetime(ast::Lifetime { id: param.id, ident: param.ident })
                     }
                     GenericParamKind::Type { .. } => {
                         GenericArg::Type(cx.ty_ident(span, param.ident))