diff options
| author | bors <bors@rust-lang.org> | 2014-08-31 12:50:55 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-08-31 12:50:55 +0000 |
| commit | 27e8d5bca79c09258c757e9be6e13aaa24086d84 (patch) | |
| tree | 76b2a3bd57c4927f4caca9db20f4f0a8c21f6bb5 /src/libsyntax | |
| parent | db47aa5bdf308213b4198b81e9d2e406ec716189 (diff) | |
| parent | 2b312eca89c4da41403f594d9a8887dfed55d54c (diff) | |
| download | rust-27e8d5bca79c09258c757e9be6e13aaa24086d84.tar.gz rust-27e8d5bca79c09258c757e9be6e13aaa24086d84.zip | |
auto merge of #16788 : Manishearth/rust/raw-ptr-syntax-ty, r=huonw
@huonw , r? :) #16781
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ext/build.rs | 11 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/generic/ty.rs | 6 |
2 files changed, 16 insertions, 1 deletions
diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 909f8f1e78c..64ab0e5cb19 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -52,6 +52,9 @@ pub trait AstBuilder { ty: P<ast::Ty>, lifetime: Option<ast::Lifetime>, mutbl: ast::Mutability) -> P<ast::Ty>; + fn ty_ptr(&self, span: Span, + ty: P<ast::Ty>, + mutbl: ast::Mutability) -> P<ast::Ty>; fn ty_uniq(&self, span: Span, ty: P<ast::Ty>) -> P<ast::Ty>; fn ty_option(&self, ty: P<ast::Ty>) -> P<ast::Ty>; @@ -369,6 +372,14 @@ impl<'a> AstBuilder for ExtCtxt<'a> { ast::TyRptr(lifetime, self.ty_mt(ty, mutbl))) } + fn ty_ptr(&self, + span: Span, + ty: P<ast::Ty>, + mutbl: ast::Mutability) + -> P<ast::Ty> { + self.ty(span, + ast::TyPtr(self.ty_mt(ty, mutbl))) + } fn ty_uniq(&self, span: Span, ty: P<ast::Ty>) -> P<ast::Ty> { self.ty(span, ast::TyUniq(ty)) } diff --git a/src/libsyntax/ext/deriving/generic/ty.rs b/src/libsyntax/ext/deriving/generic/ty.rs index f4a9b85f75d..8b4a9c51cf0 100644 --- a/src/libsyntax/ext/deriving/generic/ty.rs +++ b/src/libsyntax/ext/deriving/generic/ty.rs @@ -28,6 +28,8 @@ use std::gc::Gc; pub enum PtrTy<'a> { /// &'lifetime mut Borrowed(Option<&'a str>, ast::Mutability), + /// *mut + Raw(ast::Mutability), } /// A path, e.g. `::std::option::Option::<int>` (global). Has support @@ -82,7 +84,7 @@ impl<'a> Path<'a> { } } -/// A type. Supports pointers (except for *), Self, and literals +/// A type. Supports pointers, Self, and literals #[deriving(Clone)] pub enum Ty<'a> { Self, @@ -143,6 +145,7 @@ impl<'a> Ty<'a> { let lt = mk_lifetime(cx, span, lt); cx.ty_rptr(span, raw_ty, lt, mutbl) } + Raw(mutbl) => cx.ty_ptr(span, raw_ty, mutbl) } } Literal(ref p) => { p.to_ty(cx, span, self_ty, self_generics) } @@ -273,6 +276,7 @@ pub fn get_explicit_self(cx: &ExtCtxt, span: Span, self_ptr: &Option<PtrTy>) let lt = lt.map(|s| cx.lifetime(span, cx.ident_of(s).name)); ast::SelfRegion(lt, mutbl, special_idents::self_) } + Raw(_) => cx.span_bug(span, "attempted to use *self in deriving definition") }); let self_expr = cx.expr_deref(span, self_path); (self_expr, self_ty) |
