Skip to content

Fixed lifetimes on syntax deriving structs, implemented Clone #15814

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/libsyntax/ext/deriving/generic/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ use parse::token::special_idents;
use std::gc::Gc;

/// The types of pointers
#[deriving(Clone)]
pub enum PtrTy<'a> {
/// &'lifetime mut
Borrowed(Option<&'a str>, ast::Mutability),
}

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

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

pub fn nil_ty() -> Ty<'static> {
pub fn nil_ty<'r>() -> Ty<'r> {
Tuple(Vec::new())
}

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

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

impl<'a> LifetimeBounds<'a> {
pub fn empty() -> LifetimeBounds<'static> {
pub fn empty() -> LifetimeBounds<'a> {
LifetimeBounds {
lifetimes: Vec::new(), bounds: Vec::new()
}
Expand Down