summaryrefslogtreecommitdiff
path: root/src/codegen/mod.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2017-08-04 12:20:35 -0500
committerGitHub <noreply@github.com>2017-08-04 12:20:35 -0500
commitde180c42e52d6b9236a11ba887a6896b4ffae819 (patch)
treeca47cc6347b7d41e7ccc27d828d817ec0e9252d3 /src/codegen/mod.rs
parent04fdb10212e729f77343f8548db2f8fdf83a5af9 (diff)
parent0bb7b9f1c4652f63f41eba4064b79c044fd3d955 (diff)
Auto merge of #859 - tmfink:feature-832-custom-rust-target, r=fitzgen
Feature 832 custom rust target Addresses #832. Instead of specifying whether or not to use stable, specify the Rust release to support (one of several stable/beta releases or nightly). The `--unstable-rust` option is still accepted and implies `--rust-target nightly`. The definitions of `RustTarget` and `RustFeatures` are created with macros. In order to keep the test outputs the same, `bindgen-flags: --rust-target 1.0` was added to test headers. **Todo:** - [x] Create `RustFeatures`/`RustTarget` structs - [x] Replace uses of `unstable` with `RustFeatures` query - [x] Add new tests - [x] Fix doc comments TODOs
Diffstat (limited to 'src/codegen/mod.rs')
-rw-r--r--src/codegen/mod.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs
index 5c00a53d..ef6f031f 100644
--- a/src/codegen/mod.rs
+++ b/src/codegen/mod.rs
@@ -350,7 +350,7 @@ impl CodeGenerator for Module {
}
if item.id() == ctx.root_module() {
- if result.saw_union && !ctx.options().unstable_rust {
+ if result.saw_union && !ctx.options().rust_features().untagged_union() {
utils::prepend_union_types(ctx, &mut *result);
}
if result.saw_incomplete_array {
@@ -911,8 +911,8 @@ impl<'a> FieldCodegen<'a> for FieldData {
let field_ty = ctx.resolve_type(self.ty());
let ty = self.ty().to_rust_ty_or_opaque(ctx, &());
- // NB: In unstable rust we use proper `union` types.
- let ty = if parent.is_union() && !ctx.options().unstable_rust {
+ // NB: If supported, we use proper `union` types.
+ let ty = if parent.is_union() && !ctx.options().rust_features().untagged_union() {
if ctx.options().enable_cxx_namespaces {
quote_ty!(ctx.ext_cx(), root::__BindgenUnionField<$ty>)
} else {
@@ -1052,8 +1052,8 @@ impl BitfieldUnit {
-> P<ast::Item> {
let ctor_name = self.ctor_name(ctx);
- // If we're generating unstable Rust, add the const.
- let fn_prefix = if ctx.options().unstable_rust {
+ // If supported, add the const.
+ let fn_prefix = if ctx.options().rust_features().const_fn() {
quote_tokens!(ctx.ext_cx(), pub const fn)
} else {
quote_tokens!(ctx.ext_cx(), pub fn)
@@ -1115,8 +1115,8 @@ impl Bitfield {
let offset = self.offset_into_unit();
let mask = self.mask();
- // If we're generating unstable Rust, add the const.
- let fn_prefix = if ctx.options().unstable_rust {
+ // If supported, add the const.
+ let fn_prefix = if ctx.options().rust_features().const_fn() {
quote_tokens!(ctx.ext_cx(), pub const fn)
} else {
quote_tokens!(ctx.ext_cx(), pub fn)
@@ -1445,7 +1445,7 @@ impl CodeGenerator for CompInfo {
}
let canonical_name = item.canonical_name(ctx);
- let builder = if is_union && ctx.options().unstable_rust {
+ let builder = if is_union && ctx.options().rust_features().untagged_union() {
aster::AstBuilder::new()
.item()
.pub_()
@@ -1552,7 +1552,7 @@ impl CodeGenerator for CompInfo {
());
}
- if is_union && !ctx.options().unstable_rust {
+ if is_union && !ctx.options().rust_features().untagged_union() {
let layout = layout.expect("Unable to get layout information?");
let ty = BlobTyBuilder::new(layout).build();
let field = StructFieldBuilder::named("bindgen_union_field")