diff options
| author | Nick Cameron <ncameron@mozilla.com> | 2014-07-08 14:26:02 +1200 |
|---|---|---|
| committer | Nick Cameron <ncameron@mozilla.com> | 2014-07-08 22:44:31 +1200 |
| commit | a0cfda53c4b7367f6494e3d746b35cea644ee50d (patch) | |
| tree | a9a65cb86769ae39e01562cda9eda0dfdb860245 /src/libsyntax/ext/deriving/generic | |
| parent | 6959931498820b2b784168164b53a79dceafc4da (diff) | |
| download | rust-a0cfda53c4b7367f6494e3d746b35cea644ee50d.tar.gz rust-a0cfda53c4b7367f6494e3d746b35cea644ee50d.zip | |
Change DST syntax: type -> Sized?
closes #13367
[breaking-change] Use `Sized?` to indicate a dynamically sized type parameter or trait (used to be `type`). E.g.,
```
trait Tr for Sized? {}
fn foo<Sized? X: Share>(x: X) {}
```
Diffstat (limited to 'src/libsyntax/ext/deriving/generic')
| -rw-r--r-- | src/libsyntax/ext/deriving/generic/mod.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/generic/ty.rs | 13 |
2 files changed, 8 insertions, 7 deletions
diff --git a/src/libsyntax/ext/deriving/generic/mod.rs b/src/libsyntax/ext/deriving/generic/mod.rs index 157b64fb47c..7ad11b186f5 100644 --- a/src/libsyntax/ext/deriving/generic/mod.rs +++ b/src/libsyntax/ext/deriving/generic/mod.rs @@ -406,8 +406,8 @@ impl<'a> TraitDef<'a> { cx.typaram(self.span, ty_param.ident, - ty_param.sized, OwnedSlice::from_vec(bounds), + ty_param.unbound.clone(), None) })); let trait_generics = Generics { diff --git a/src/libsyntax/ext/deriving/generic/ty.rs b/src/libsyntax/ext/deriving/generic/ty.rs index 7501b950770..28f39a4cb8c 100644 --- a/src/libsyntax/ext/deriving/generic/ty.rs +++ b/src/libsyntax/ext/deriving/generic/ty.rs @@ -188,17 +188,18 @@ impl<'a> Ty<'a> { } -fn mk_ty_param(cx: &ExtCtxt, span: Span, name: &str, sized: ast::Sized, bounds: &[Path], +fn mk_ty_param(cx: &ExtCtxt, span: Span, name: &str, + bounds: &[Path], unbound: Option<ast::TyParamBound>, self_ident: Ident, self_generics: &Generics) -> ast::TyParam { let bounds = bounds.iter().map(|b| { let path = b.to_path(cx, span, self_ident, self_generics); cx.typarambound(path) }).collect(); - cx.typaram(span, cx.ident_of(name), sized, bounds, None) + cx.typaram(span, cx.ident_of(name), bounds, unbound, None) } -fn mk_generics(lifetimes: Vec<ast::Lifetime> , ty_params: Vec<ast::TyParam> ) -> Generics { +fn mk_generics(lifetimes: Vec<ast::Lifetime>, ty_params: Vec<ast::TyParam> ) -> Generics { Generics { lifetimes: lifetimes, ty_params: OwnedSlice::from_vec(ty_params) @@ -208,7 +209,7 @@ fn mk_generics(lifetimes: Vec<ast::Lifetime> , ty_params: Vec<ast::TyParam> ) - /// Lifetimes and bounds on type parameters pub struct LifetimeBounds<'a> { pub lifetimes: Vec<&'a str>, - pub bounds: Vec<(&'a str, ast::Sized, Vec<Path<'a>>)>, + pub bounds: Vec<(&'a str, Option<ast::TyParamBound>, Vec<Path<'a>>)>, } impl<'a> LifetimeBounds<'a> { @@ -228,12 +229,12 @@ impl<'a> LifetimeBounds<'a> { }).collect(); let ty_params = self.bounds.iter().map(|t| { match t { - &(ref name, sized, ref bounds) => { + &(ref name, ref unbound, ref bounds) => { mk_ty_param(cx, span, *name, - sized, bounds.as_slice(), + unbound.clone(), self_ty, self_generics) } |
