Skip to content

Commit df997e5

Browse files
committed
auto merge of #15814 : kvark/rust/ast, r=huonw
Makes working with syntax deriving a bit more pleasuring. For instance, once can use local (non-static) strings anywhere inside `TraitDef` now.
2 parents 8859df7 + a2467b9 commit df997e5

File tree

1 file changed

+6
-2
lines changed
  • src/libsyntax/ext/deriving/generic

1 file changed

+6
-2
lines changed

src/libsyntax/ext/deriving/generic/ty.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@ use parse::token::special_idents;
2424
use std::gc::Gc;
2525

2626
/// The types of pointers
27+
#[deriving(Clone)]
2728
pub enum PtrTy<'a> {
2829
/// &'lifetime mut
2930
Borrowed(Option<&'a str>, ast::Mutability),
3031
}
3132

3233
/// A path, e.g. `::std::option::Option::<int>` (global). Has support
3334
/// for type parameters and a lifetime.
35+
#[deriving(Clone)]
3436
pub struct Path<'a> {
3537
pub path: Vec<&'a str> ,
3638
pub lifetime: Option<&'a str>,
@@ -81,6 +83,7 @@ impl<'a> Path<'a> {
8183
}
8284

8385
/// A type. Supports pointers (except for *), Self, and literals
86+
#[deriving(Clone)]
8487
pub enum Ty<'a> {
8588
Self,
8689
/// &/Box/ Ty
@@ -107,7 +110,7 @@ pub fn borrowed_self<'r>() -> Ty<'r> {
107110
borrowed(box Self)
108111
}
109112

110-
pub fn nil_ty() -> Ty<'static> {
113+
pub fn nil_ty<'r>() -> Ty<'r> {
111114
Tuple(Vec::new())
112115
}
113116

@@ -205,13 +208,14 @@ fn mk_generics(lifetimes: Vec<ast::Lifetime>, ty_params: Vec<ast::TyParam> ) ->
205208
}
206209

207210
/// Lifetimes and bounds on type parameters
211+
#[deriving(Clone)]
208212
pub struct LifetimeBounds<'a> {
209213
pub lifetimes: Vec<&'a str>,
210214
pub bounds: Vec<(&'a str, Option<ast::TyParamBound>, Vec<Path<'a>>)>,
211215
}
212216

213217
impl<'a> LifetimeBounds<'a> {
214-
pub fn empty() -> LifetimeBounds<'static> {
218+
pub fn empty() -> LifetimeBounds<'a> {
215219
LifetimeBounds {
216220
lifetimes: Vec::new(), bounds: Vec::new()
217221
}

0 commit comments

Comments
 (0)