From ae4d278984291029274fd3046f112e864f102fa1 Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Mon, 8 Jun 2015 05:26:54 -0700 Subject: [PATCH] Update to rust HEAD (613e57b44), which adds const functions --- Cargo.toml | 4 ++-- src/item.rs | 8 ++++++++ src/method.rs | 8 ++++++++ tests/test_item.rs | 2 ++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 855d3c959..e2ad80560 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "aster" -version = "0.3.1" +version = "0.3.2" authors = ["Erick Tryzelaar "] license = "MIT/Apache-2.0" description = "A libsyntax ast builder" @@ -10,7 +10,7 @@ repository = "https://github.com/erickt/rust-aster" with-syntex = ["syntex_syntax"] [dependencies] -syntex_syntax = { version = ">= 0.6.0", optional = true } +syntex_syntax = { version = "^0.7.0", optional = true } [[test]] name = "test" diff --git a/src/item.rs b/src/item.rs index 98d7ae34b..3a87b7014 100644 --- a/src/item.rs +++ b/src/item.rs @@ -207,6 +207,7 @@ impl Invoke> for ItemFnDeclBuilder id: self.id, fn_decl: fn_decl, unsafety: ast::Unsafety::Normal, + constness: ast::Constness::NotConst, abi: Abi::Rust, generics: generics, } @@ -220,6 +221,7 @@ pub struct ItemFnBuilder { id: ast::Ident, fn_decl: P, unsafety: ast::Unsafety, + constness: ast::Constness, abi: Abi, generics: ast::Generics, } @@ -232,6 +234,11 @@ impl ItemFnBuilder self } + pub fn const_(mut self) -> Self { + self.constness = ast::Constness::Const; + self + } + pub fn abi(mut self, abi: Abi) -> Self { self.abi = abi; self @@ -245,6 +252,7 @@ impl ItemFnBuilder self.builder.build_item_(self.id, ast::Item_::ItemFn( self.fn_decl, self.unsafety, + self.constness, self.abi, self.generics, block, diff --git a/src/method.rs b/src/method.rs index d43f2049b..dd007e533 100644 --- a/src/method.rs +++ b/src/method.rs @@ -19,6 +19,7 @@ pub struct MethodBuilder { abi: Abi, generics: ast::Generics, unsafety: ast::Unsafety, + constness: ast::Constness, id: ast::Ident, vis: ast::Visibility, } @@ -42,6 +43,7 @@ impl MethodBuilder abi: Abi::Rust, generics: GenericsBuilder::new().build(), unsafety: ast::Unsafety::Normal, + constness: ast::Constness::NotConst, id: id.to_ident(), vis: ast::Visibility::Inherited, } @@ -66,6 +68,11 @@ impl MethodBuilder self } + pub fn const_(mut self) -> Self { + self.constness = ast::Constness::Const; + self + } + pub fn abi(mut self, abi: Abi) -> Self { self.abi = abi; self @@ -160,6 +167,7 @@ impl Invoke> for MethodSelfFnDeclBuilder fn invoke(self, block: P) -> F::Result { let method_sig = ast::MethodSig { unsafety: self.builder.unsafety, + constness: self.builder.constness, abi: self.builder.abi, decl: self.fn_decl, generics: self.builder.generics, diff --git a/tests/test_item.rs b/tests/test_item.rs index 1bbc571d7..8d7176236 100644 --- a/tests/test_item.rs +++ b/tests/test_item.rs @@ -31,6 +31,7 @@ fn test_fn() { node: ast::ItemFn( builder.fn_decl().return_().isize(), ast::Unsafety::Normal, + ast::Constness::NotConst, Abi::Rust, builder.generics().build(), block @@ -68,6 +69,7 @@ fn test_generic_fn() { node: ast::ItemFn( builder.fn_decl().return_().isize(), ast::Unsafety::Normal, + ast::Constness::NotConst, Abi::Rust, builder.generics() .lifetime("'a").build()