Skip to content
This repository has been archived by the owner on May 6, 2020. It is now read-only.

Commit

Permalink
Update to rust HEAD (613e57b44), which adds const functions
Browse files Browse the repository at this point in the history
  • Loading branch information
erickt committed Jun 8, 2015
1 parent 51a3046 commit ae4d278
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "aster"
version = "0.3.1"
version = "0.3.2"
authors = ["Erick Tryzelaar <[email protected]>"]
license = "MIT/Apache-2.0"
description = "A libsyntax ast builder"
Expand All @@ -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"
Expand Down
8 changes: 8 additions & 0 deletions src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ impl<F> Invoke<P<ast::FnDecl>> for ItemFnDeclBuilder<F>
id: self.id,
fn_decl: fn_decl,
unsafety: ast::Unsafety::Normal,
constness: ast::Constness::NotConst,
abi: Abi::Rust,
generics: generics,
}
Expand All @@ -220,6 +221,7 @@ pub struct ItemFnBuilder<F> {
id: ast::Ident,
fn_decl: P<ast::FnDecl>,
unsafety: ast::Unsafety,
constness: ast::Constness,
abi: Abi,
generics: ast::Generics,
}
Expand All @@ -232,6 +234,11 @@ impl<F> ItemFnBuilder<F>
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
Expand All @@ -245,6 +252,7 @@ impl<F> ItemFnBuilder<F>
self.builder.build_item_(self.id, ast::Item_::ItemFn(
self.fn_decl,
self.unsafety,
self.constness,
self.abi,
self.generics,
block,
Expand Down
8 changes: 8 additions & 0 deletions src/method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub struct MethodBuilder<F=Identity> {
abi: Abi,
generics: ast::Generics,
unsafety: ast::Unsafety,
constness: ast::Constness,
id: ast::Ident,
vis: ast::Visibility,
}
Expand All @@ -42,6 +43,7 @@ impl<F> MethodBuilder<F>
abi: Abi::Rust,
generics: GenericsBuilder::new().build(),
unsafety: ast::Unsafety::Normal,
constness: ast::Constness::NotConst,
id: id.to_ident(),
vis: ast::Visibility::Inherited,
}
Expand All @@ -66,6 +68,11 @@ impl<F> MethodBuilder<F>
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
Expand Down Expand Up @@ -160,6 +167,7 @@ impl<F> Invoke<P<ast::Block>> for MethodSelfFnDeclBuilder<F>
fn invoke(self, block: P<ast::Block>) -> 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,
Expand Down
2 changes: 2 additions & 0 deletions tests/test_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit ae4d278

Please sign in to comment.