diff options
| author | bors <bors@rust-lang.org> | 2015-05-24 11:12:34 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-05-24 11:12:34 +0000 |
| commit | ba0e1cd8147d452c356aacb29fb87568ca26f111 (patch) | |
| tree | 0cf03636be9210de94e30bb07467097aeb5273c7 /src/libsyntax/ext | |
| parent | cc56c20ba4ccc12f58e1c844b77168bc4805cbb6 (diff) | |
| parent | 82ded3cd03e001e82b9dce9aedac621a5292231b (diff) | |
| download | rust-ba0e1cd8147d452c356aacb29fb87568ca26f111.tar.gz rust-ba0e1cd8147d452c356aacb29fb87568ca26f111.zip | |
Auto merge of #25609 - nikomatsakis:const-fn, r=pnkfelix
This is a port of @eddyb's `const-fn` branch. I rebased it, tweaked a few things, and added tests as well as a feature gate. The set of tests is still pretty rudimentary, I'd appreciate suggestions on new tests to write. Also, a double-check that the feature-gate covers all necessary cases. One question: currently, the feature-gate allows the *use* of const functions from stable code, just not the definition. This seems to fit our usual strategy, and implies that we might (perhaps) allow some constant functions in libstd someday, even before stabilizing const-fn, if we were willing to commit to the existence of const fns but found some details of their impl unsatisfactory. r? @pnkfelix
Diffstat (limited to 'src/libsyntax/ext')
| -rw-r--r-- | src/libsyntax/ext/build.rs | 1 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/generic/mod.rs | 1 | ||||
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 6 |
3 files changed, 6 insertions, 2 deletions
diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 354a0bff749..8a80e291a53 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -1034,6 +1034,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { Vec::new(), ast::ItemFn(self.fn_decl(inputs, output), ast::Unsafety::Normal, + ast::Constness::NotConst, abi::Rust, generics, body)) diff --git a/src/libsyntax/ext/deriving/generic/mod.rs b/src/libsyntax/ext/deriving/generic/mod.rs index b9968ca9608..eab6c3ae725 100644 --- a/src/libsyntax/ext/deriving/generic/mod.rs +++ b/src/libsyntax/ext/deriving/generic/mod.rs @@ -880,6 +880,7 @@ impl<'a> MethodDef<'a> { abi: abi, explicit_self: explicit_self, unsafety: unsafety, + constness: ast::Constness::NotConst, decl: fn_decl }, body_block) }) diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 744849de445..aa74c27dc61 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -513,11 +513,12 @@ pub fn expand_item(it: P<ast::Item>, fld: &mut MacroExpander) /// Expand item_underscore fn expand_item_underscore(item: ast::Item_, fld: &mut MacroExpander) -> ast::Item_ { match item { - ast::ItemFn(decl, fn_style, abi, generics, body) => { + ast::ItemFn(decl, unsafety, constness, abi, generics, body) => { let (rewritten_fn_decl, rewritten_body) = expand_and_rename_fn_decl_and_block(decl, body, fld); let expanded_generics = fold::noop_fold_generics(generics,fld); - ast::ItemFn(rewritten_fn_decl, fn_style, abi, expanded_generics, rewritten_body) + ast::ItemFn(rewritten_fn_decl, unsafety, constness, abi, + expanded_generics, rewritten_body) } _ => noop_fold_item_underscore(item, fld) } @@ -1395,6 +1396,7 @@ fn expand_and_rename_method(sig: ast::MethodSig, body: P<ast::Block>, abi: sig.abi, explicit_self: fld.fold_explicit_self(sig.explicit_self), unsafety: sig.unsafety, + constness: sig.constness, decl: rewritten_fn_decl }, rewritten_body) } |
