diff options
| author | varkor <github@varkor.com> | 2018-05-30 16:49:39 +0100 |
|---|---|---|
| committer | varkor <github@varkor.com> | 2018-06-20 12:23:08 +0100 |
| commit | 6015edf9af375385ca9eb2ebbb8794c782fa7244 (patch) | |
| tree | e07b5a2233e2c32b950b84d3dd1547e62b983f5e /src/libsyntax | |
| parent | c4e8e718807d1925769bdcdd055c6d8de05f20ce (diff) | |
| download | rust-6015edf9af375385ca9eb2ebbb8794c782fa7244.tar.gz rust-6015edf9af375385ca9eb2ebbb8794c782fa7244.zip | |
Remove name from GenericParamKind::Lifetime
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/build.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 37 |
4 files changed, 18 insertions, 31 deletions
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(¶m.attrs)?; - s.print_lifetime_bounds(lifetime, ¶m.bounds) + let lt = ast::Lifetime { id: param.id, ident: param.ident }; + s.print_lifetime_bounds(lt, ¶m.bounds) }, ast::GenericParamKind::Type { ref default } => { s.print_outer_attributes_inline(¶m.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, |
