From ef14e026e692c44ebd5d2c621094ae51d99b63d1 Mon Sep 17 00:00:00 2001 From: Marcel Hlopko Date: Thu, 11 Feb 2021 08:58:46 +0100 Subject: [PATCH] Rename whitelist -> allowlist and blacklist -> blocklist For the commandline arguments I added undocumented aliases to old flags, to stay backwards compatible. --- CHANGELOG.md | 36 ++ bindgen-integration/build.rs | 2 +- book/src/SUMMARY.md | 4 +- book/src/allowlisting.md | 31 ++ book/src/{blacklisting.md => blocklisting.md} | 13 +- book/src/cpp.md | 4 +- book/src/faq.md | 6 +- book/src/objc.md | 4 +- book/src/replacing-types.md | 2 +- book/src/whitelisting.md | 31 -- src/codegen/impl_debug.rs | 4 +- src/codegen/mod.rs | 10 +- src/ir/analysis/derive.rs | 10 +- src/ir/analysis/has_destructor.rs | 2 +- src/ir/analysis/has_float.rs | 2 +- src/ir/analysis/has_type_param_in_array.rs | 2 +- src/ir/analysis/has_vtable.rs | 2 +- src/ir/analysis/mod.rs | 4 +- src/ir/analysis/sizedness.rs | 2 +- src/ir/analysis/template_params.rs | 60 +-- src/ir/context.rs | 136 +++--- src/ir/dot.rs | 6 +- src/ir/enum_ty.rs | 2 +- src/ir/item.rs | 44 +- src/ir/template.rs | 4 +- src/ir/traversal.rs | 4 +- src/lib.rs | 213 +++++---- src/options.rs | 83 ++-- ...basic.rs => allowlist-namespaces-basic.rs} | 0 ...-namespaces.rs => allowlist-namespaces.rs} | 0 ...{whitelist_basic.rs => allowlist_basic.rs} | 10 +- .../{whitelist_fix.rs => allowlist_fix.rs} | 0 .../{whitelist_vars.rs => allowlist_vars.rs} | 0 ...=> allowlisted-item-references-no-hash.rs} | 16 +- ...lowlisted-item-references-no-partialeq.rs} | 16 +- ...=> allowlisted_item_references_no_copy.rs} | 16 +- ...um_whitelist.rs => anon_enum_allowlist.rs} | 0 ...l-debug.rs => blocklist-and-impl-debug.rs} | 6 +- ...list-function.rs => blocklist-function.rs} | 0 .../{blacklist-item.rs => blocklist-item.rs} | 0 ...ist.rs => derive-default-and-blocklist.rs} | 6 +- ...cklist.rs => derive-hash-and-blocklist.rs} | 6 +- ...listing.rs => derive-hash-blocklisting.rs} | 46 +- ...t.rs => derive-partialeq-and-blocklist.rs} | 6 +- ...t.rs => dynamic_loading_with_allowlist.rs} | 0 ...t.rs => dynamic_loading_with_blocklist.rs} | 0 ...elist.rs => inline_namespace_allowlist.rs} | 0 ...07-opaque-types-methods-being-generated.rs | 16 +- ...issue-944-derive-copy-and-blocklisting.rs} | 6 +- ...e-whitelisted.rs => module-allowlisted.rs} | 0 tests/expectations/tests/no-derive-debug.rs | 2 +- tests/expectations/tests/no-derive-default.rs | 2 +- ...-whitelisted.rs => no-hash-allowlisted.rs} | 0 ...elisted.rs => no-partialeq-allowlisted.rs} | 0 ...isting.rs => no-recursive-allowlisting.rs} | 0 ..._whitelisted.rs => no_copy_allowlisted.rs} | 0 ...whitelisted.rs => no_debug_allowlisted.rs} | 0 ...itelisted.rs => no_default_allowlisted.rs} | 0 .../{objc_whitelist.rs => objc_allowlist.rs} | 4 +- ...ype-referenced-by-allowlisted-function.rs} | 0 ...sic.hpp => allowlist-namespaces-basic.hpp} | 2 +- ...amespaces.hpp => allowlist-namespaces.hpp} | 2 +- ...hitelist_basic.hpp => allowlist_basic.hpp} | 6 +- .../{whitelist_fix.hpp => allowlist_fix.hpp} | 2 +- .../{whitelist_vars.h => allowlist_vars.h} | 0 .../allowlisted-item-references-no-hash.hpp | 7 + ...lowlisted-item-references-no-partialeq.hpp | 7 + .../allowlisted_item_references_no_copy.hpp | 7 + tests/headers/anon_enum_allowlist.h | 6 + tests/headers/anon_enum_whitelist.h | 6 - tests/headers/blacklist-and-impl-debug.hpp | 10 - tests/headers/blocklist-and-impl-debug.hpp | 10 + ...st-function.hpp => blocklist-function.hpp} | 2 +- ...{blacklist-item.hpp => blocklist-item.hpp} | 2 +- ...t.hpp => derive-default-and-blocklist.hpp} | 8 +- tests/headers/derive-hash-and-blacklist.hpp | 10 - tests/headers/derive-hash-and-blocklist.hpp | 10 + tests/headers/derive-hash-blacklisting.hpp | 17 - tests/headers/derive-hash-blocklisting.hpp | 17 + .../derive-partialeq-and-blacklist.hpp | 11 - .../derive-partialeq-and-blocklist.hpp | 11 + ...hpp => dynamic_loading_with_allowlist.hpp} | 2 +- ...hpp => dynamic_loading_with_blocklist.hpp} | 2 +- ...ist.hpp => inline_namespace_allowlist.hpp} | 2 +- tests/headers/issue-1285.h | 2 +- tests/headers/issue-410.hpp | 2 +- tests/headers/issue-447.hpp | 2 +- ...ssue-584-stylo-template-analysis-panic.hpp | 2 +- ...e-645-cannot-find-type-T-in-this-scope.hpp | 2 +- tests/headers/issue-662-part-2.hpp | 4 +- tests/headers/issue-674-1.hpp | 2 +- tests/headers/issue-674-2.hpp | 2 +- tests/headers/issue-674-3.hpp | 2 +- .../issue-769-bad-instantiation-test.hpp | 2 +- tests/headers/issue-801-opaque-sloppiness.hpp | 2 +- ...7-opaque-types-methods-being-generated.hpp | 8 +- tests/headers/issue-833-1.hpp | 2 +- tests/headers/issue-833.hpp | 2 +- tests/headers/issue-834.hpp | 2 +- ...issue-944-derive-copy-and-blacklisting.hpp | 10 - ...issue-944-derive-copy-and-blocklisting.hpp | 10 + tests/headers/maddness-is-avoidable.hpp | 2 +- ...whitelisted.hpp => module-allowlisted.hpp} | 0 tests/headers/no-derive-debug.h | 4 +- tests/headers/no-derive-default.h | 4 +- tests/headers/no-hash-allowlisted.hpp | 5 + tests/headers/no-hash-whitelisted.hpp | 5 - ...isted.hpp => no-partialeq-allowlisted.hpp} | 2 +- ...elisting.h => no-recursive-allowlisting.h} | 2 +- tests/headers/no_copy_allowlisted.hpp | 5 + tests/headers/no_copy_whitelisted.hpp | 5 - tests/headers/no_debug_allowlisted.hpp | 5 + tests/headers/no_debug_whitelisted.hpp | 5 - tests/headers/no_default_allowlisted.hpp | 5 + tests/headers/no_default_whitelisted.hpp | 5 - tests/headers/objc_allowlist.h | 24 ++ tests/headers/objc_whitelist.h | 24 -- tests/headers/opaque-tracing.hpp | 4 +- tests/headers/replaces_double.hpp | 2 +- ...type-referenced-by-allowlisted-function.h} | 2 +- tests/headers/type_alias_empty.hpp | 4 +- .../type_alias_template_specialized.hpp | 2 +- tests/headers/var-tracing.hpp | 2 +- .../whitelisted-item-references-no-hash.hpp | 7 - ...itelisted-item-references-no-partialeq.hpp | 7 - .../whitelisted_item_references_no_copy.hpp | 7 - tests/stylo.hpp | 2 +- tests/stylo_sanity.rs | 406 +++++++++--------- 128 files changed, 867 insertions(+), 778 deletions(-) create mode 100644 book/src/allowlisting.md rename book/src/{blacklisting.md => blocklisting.md} (61%) delete mode 100644 book/src/whitelisting.md rename tests/expectations/tests/{whitelist-namespaces-basic.rs => allowlist-namespaces-basic.rs} (100%) rename tests/expectations/tests/{whitelist-namespaces.rs => allowlist-namespaces.rs} (100%) rename tests/expectations/tests/{whitelist_basic.rs => allowlist_basic.rs} (75%) rename tests/expectations/tests/{whitelist_fix.rs => allowlist_fix.rs} (100%) rename tests/expectations/tests/{whitelist_vars.rs => allowlist_vars.rs} (100%) rename tests/expectations/tests/{whitelisted-item-references-no-hash.rs => allowlisted-item-references-no-hash.rs} (69%) rename tests/expectations/tests/{whitelisted-item-references-no-partialeq.rs => allowlisted-item-references-no-partialeq.rs} (70%) rename tests/expectations/tests/{whitelisted_item_references_no_copy.rs => allowlisted_item_references_no_copy.rs} (68%) rename tests/expectations/tests/{anon_enum_whitelist.rs => anon_enum_allowlist.rs} (100%) rename tests/expectations/tests/{blacklist-and-impl-debug.rs => blocklist-and-impl-debug.rs} (91%) rename tests/expectations/tests/{blacklist-function.rs => blocklist-function.rs} (100%) rename tests/expectations/tests/{blacklist-item.rs => blocklist-item.rs} (100%) rename tests/expectations/tests/{derive-default-and-blacklist.rs => derive-default-and-blocklist.rs} (90%) rename tests/expectations/tests/{derive-hash-and-blacklist.rs => derive-hash-and-blocklist.rs} (89%) rename tests/expectations/tests/{derive-hash-blacklisting.rs => derive-hash-blocklisting.rs} (52%) rename tests/expectations/tests/{derive-partialeq-and-blacklist.rs => derive-partialeq-and-blocklist.rs} (89%) rename tests/expectations/tests/{dynamic_loading_with_whitelist.rs => dynamic_loading_with_allowlist.rs} (100%) rename tests/expectations/tests/{dynamic_loading_with_blacklist.rs => dynamic_loading_with_blocklist.rs} (100%) rename tests/expectations/tests/{inline_namespace_whitelist.rs => inline_namespace_allowlist.rs} (100%) rename tests/expectations/tests/{issue-944-derive-copy-and-blacklisting.rs => issue-944-derive-copy-and-blocklisting.rs} (88%) rename tests/expectations/tests/{module-whitelisted.rs => module-allowlisted.rs} (100%) rename tests/expectations/tests/{no-hash-whitelisted.rs => no-hash-allowlisted.rs} (100%) rename tests/expectations/tests/{no-partialeq-whitelisted.rs => no-partialeq-allowlisted.rs} (100%) rename tests/expectations/tests/{no-recursive-whitelisting.rs => no-recursive-allowlisting.rs} (100%) rename tests/expectations/tests/{no_copy_whitelisted.rs => no_copy_allowlisted.rs} (100%) rename tests/expectations/tests/{no_debug_whitelisted.rs => no_debug_allowlisted.rs} (100%) rename tests/expectations/tests/{no_default_whitelisted.rs => no_default_allowlisted.rs} (100%) rename tests/expectations/tests/{objc_whitelist.rs => objc_allowlist.rs} (66%) rename tests/expectations/tests/{type-referenced-by-whitelisted-function.rs => type-referenced-by-allowlisted-function.rs} (100%) rename tests/headers/{whitelist-namespaces-basic.hpp => allowlist-namespaces-basic.hpp} (67%) rename tests/headers/{whitelist-namespaces.hpp => allowlist-namespaces.hpp} (64%) rename tests/headers/{whitelist_basic.hpp => allowlist_basic.hpp} (59%) rename tests/headers/{whitelist_fix.hpp => allowlist_fix.hpp} (58%) rename tests/headers/{whitelist_vars.h => allowlist_vars.h} (100%) create mode 100644 tests/headers/allowlisted-item-references-no-hash.hpp create mode 100644 tests/headers/allowlisted-item-references-no-partialeq.hpp create mode 100644 tests/headers/allowlisted_item_references_no_copy.hpp create mode 100644 tests/headers/anon_enum_allowlist.h delete mode 100644 tests/headers/anon_enum_whitelist.h delete mode 100644 tests/headers/blacklist-and-impl-debug.hpp create mode 100644 tests/headers/blocklist-and-impl-debug.hpp rename tests/headers/{blacklist-function.hpp => blocklist-function.hpp} (62%) rename tests/headers/{blacklist-item.hpp => blocklist-item.hpp} (63%) rename tests/headers/{derive-default-and-blacklist.hpp => derive-default-and-blocklist.hpp} (56%) delete mode 100644 tests/headers/derive-hash-and-blacklist.hpp create mode 100644 tests/headers/derive-hash-and-blocklist.hpp delete mode 100644 tests/headers/derive-hash-blacklisting.hpp create mode 100644 tests/headers/derive-hash-blocklisting.hpp delete mode 100644 tests/headers/derive-partialeq-and-blacklist.hpp create mode 100644 tests/headers/derive-partialeq-and-blocklist.hpp rename tests/headers/{dynamic_loading_with_whitelist.hpp => dynamic_loading_with_allowlist.hpp} (59%) rename tests/headers/{dynamic_loading_with_blacklist.hpp => dynamic_loading_with_blocklist.hpp} (71%) rename tests/headers/{inline_namespace_whitelist.hpp => inline_namespace_allowlist.hpp} (61%) delete mode 100644 tests/headers/issue-944-derive-copy-and-blacklisting.hpp create mode 100644 tests/headers/issue-944-derive-copy-and-blocklisting.hpp rename tests/headers/{module-whitelisted.hpp => module-allowlisted.hpp} (100%) create mode 100644 tests/headers/no-hash-allowlisted.hpp delete mode 100644 tests/headers/no-hash-whitelisted.hpp rename tests/headers/{no-partialeq-whitelisted.hpp => no-partialeq-allowlisted.hpp} (52%) rename tests/headers/{no-recursive-whitelisting.h => no-recursive-allowlisting.h} (61%) create mode 100644 tests/headers/no_copy_allowlisted.hpp delete mode 100644 tests/headers/no_copy_whitelisted.hpp create mode 100644 tests/headers/no_debug_allowlisted.hpp delete mode 100644 tests/headers/no_debug_whitelisted.hpp create mode 100644 tests/headers/no_default_allowlisted.hpp delete mode 100644 tests/headers/no_default_whitelisted.hpp create mode 100644 tests/headers/objc_allowlist.h delete mode 100644 tests/headers/objc_whitelist.h rename tests/headers/{type-referenced-by-whitelisted-function.h => type-referenced-by-allowlisted-function.h} (59%) delete mode 100644 tests/headers/whitelisted-item-references-no-hash.hpp delete mode 100644 tests/headers/whitelisted-item-references-no-partialeq.hpp delete mode 100644 tests/headers/whitelisted_item_references_no_copy.hpp diff --git a/CHANGELOG.md b/CHANGELOG.md index 3792ad80ee..46607f5186 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -127,6 +127,42 @@ ## Deprecated +* `bindgen::Builder::whitelist_type` is deprecated in favor of + `bindgen::Builder::allowlist_type`. [#1812][] + +* `bindgen::Builder::whitelist_function` is deprecated in favor of + `bindgen::Builder::allowlist_function`. [#1812][] + +* `bindgen::Builder::whitelist_var` is deprecated in favor of + `bindgen::Builder::allowlist_var`. [#1812][] + +* `--whitelist-type` is deprecated in favor of + `--allowlist-type`. [#1812][] + +* `--whitelist-function` is deprecated in favor of + `--allowlist-function`. [#1812][] + +* `--whitelist-var` is deprecated in favor of + `--allowlist-var`. [#1812][] + +* `bindgen::Builder::blacklist_type` is deprecated in favor of + `bindgen::Builder::blocklist_type`. [#1812][] + +* `bindgen::Builder::blacklist_function` is deprecated in favor of + `bindgen::Builder::blocklist_function`. [#1812][] + +* `bindgen::Builder::blacklist_item` is deprecated in favor of + `bindgen::Builder::blocklist_item`. [#1812][] + +* `--blacklist-type` is deprecated in favor of + `--blocklist-type`. [#1812][] + +* `--blacklist-function` is deprecated in favor of + `--blocklist-function`. [#1812][] + +* `--blacklist-item` is deprecated in favor of + `--blocklist-item`. [#1812][] + ## Removed ## Fixed diff --git a/bindgen-integration/build.rs b/bindgen-integration/build.rs index 1b9a79155a..f055f31f0d 100644 --- a/bindgen-integration/build.rs +++ b/bindgen-integration/build.rs @@ -160,7 +160,7 @@ fn main() { seen_hellos: Mutex::new(0), seen_funcs: Mutex::new(0), })) - .blacklist_function("my_prefixed_function_to_remove") + .blocklist_function("my_prefixed_function_to_remove") .constified_enum("my_prefixed_enum_to_be_constified") .opaque_type("my_prefixed_templated_foo") .generate() diff --git a/book/src/SUMMARY.md b/book/src/SUMMARY.md index 16291c3631..65ed0870fb 100644 --- a/book/src/SUMMARY.md +++ b/book/src/SUMMARY.md @@ -12,8 +12,8 @@ - [Publish Your Crate!](./tutorial-6.md) - [Command Line Usage](./command-line-usage.md) - [Customizing the Generated Bindings](./customizing-generated-bindings.md) - - [Whitelisting](./whitelisting.md) - - [Blacklisting](./blacklisting.md) + - [Allowlisting](./allowlisting.md) + - [Blocklisting](./blocklisting.md) - [Treating a Type as an Opaque Blob of Bytes](./opaque.md) - [Replacing One Type with Another](./replacing-types.md) - [Preventing the Derivation of `Copy` and `Clone`](./nocopy.md) diff --git a/book/src/allowlisting.md b/book/src/allowlisting.md new file mode 100644 index 0000000000..8c57eaf328 --- /dev/null +++ b/book/src/allowlisting.md @@ -0,0 +1,31 @@ +# Allowlisting + +Allowlisting allows us to be precise about which type, function, and global +variable definitions `bindgen` generates bindings for. By default, if we don't +specify any allowlisting rules, everything is considered allowlisted. This may +not be desirable because of either + +* the generated bindings contain a lot of extra definitions we don't plan on using, or +* the header file contains C++ features for which Rust does not have a + corresponding form (such as partial template specialization), and we would + like to avoid these definitions + +If we specify allowlisting rules, then `bindgen` will only generate bindings to +types, functions, and global variables that match the allowlisting rules, or are +transitively used by a definition that matches them. + +### Library + +* [`bindgen::Builder::allowlist_type`](https://docs.rs/bindgen/0.23.1/bindgen/struct.Builder.html#method.allowlist_type) +* [`bindgen::Builder::allowlist_function`](https://docs.rs/bindgen/0.23.1/bindgen/struct.Builder.html#method.allowlist_function) +* [`bindgen::Builder::allowlist_var`](https://docs.rs/bindgen/0.23.1/bindgen/struct.Builder.html#method.allowlist_var) + +### Command Line + +* `--allowlist-type ` +* `--allowlist-function ` +* `--allowlist-var ` + +### Annotations + +None. diff --git a/book/src/blacklisting.md b/book/src/blocklisting.md similarity index 61% rename from book/src/blacklisting.md rename to book/src/blocklisting.md index b56aacd983..1d6086164e 100644 --- a/book/src/blacklisting.md +++ b/book/src/blocklisting.md @@ -1,24 +1,25 @@ -# Blacklisting +# Blocklisting If you need to provide your own custom translation of some type (for example, because you need to wrap one of its fields in an `UnsafeCell`), you can -explicitly blacklist generation of its definition. Uses of the blacklisted type +explicitly blocklist + generation of its definition. Uses of the blocklisted type will still appear in other types' definitions. (If you don't want the type to appear in the bindings at all, [make it opaque](./opaque.md) instead of -blacklisting it.) +blocklisting it.) -Blacklisted types are pessimistically assumed not to be able to `derive` any +Blocklisted types are pessimistically assumed not to be able to `derive` any traits, which can transitively affect other types' ability to `derive` traits or not. ### Library -* [`bindgen::Builder::blacklist_type`](https://docs.rs/bindgen/0.31.3/bindgen/struct.Builder.html#method.blacklist_type) +* [`bindgen::Builder::blocklist_type`](https://docs.rs/bindgen/0.31.3/bindgen/struct.Builder.html#method.blocklist_type) ### Command Line -* `--blacklist-type ` +* `--blocklist-type ` ### Annotations diff --git a/book/src/cpp.md b/book/src/cpp.md index 6fef63912d..1be7a8a731 100644 --- a/book/src/cpp.md +++ b/book/src/cpp.md @@ -11,11 +11,11 @@ it ends in `.hpp`. If it doesn't, adding `-x c++` clang args can be used to force C++ mode. You probably also want to use `-std=c++14` or similar clang args as well. -You pretty much **must** use [whitelisting](./whitelisting.md) when working +You pretty much **must** use [allowlisting](./allowlisting.md) when working with C++ to avoid pulling in all of the `std::.*` types, many of which `bindgen` cannot handle. Additionally, you may want to mark other types as [opaque](./opaque.md) that `bindgen` stumbles on. It is recommended to mark -all of `std::.*` opaque, and to whitelist only precisely the functions and types +all of `std::.*` opaque, and to allowlist only precisely the functions and types you intend to use. You should read up on the [FAQs](./faq.md) as well. diff --git a/book/src/faq.md b/book/src/faq.md index 50ca075675..61e40e3586 100644 --- a/book/src/faq.md +++ b/book/src/faq.md @@ -4,13 +4,13 @@ -- [Why isn't `bindgen` generating methods for this whitelisted class?](#why-isnt-bindgen-generating-methods-for-this-whitelisted-class) +- [Why isn't `bindgen` generating methods for this allowlisted class?](#why-isnt-bindgen-generating-methods-for-this-allowlisted-class) - [Why isn't `bindgen` generating bindings to inline functions?](#why-isnt-bindgen-generating-bindings-to-inline-functions) - [Does `bindgen` support the C++ Standard Template Library (STL)?](#does-bindgen-support-the-c-standard-template-library-stl) -### Why isn't `bindgen` generating methods for this whitelisted class? +### Why isn't `bindgen` generating methods for this allowlisted class? Are the methods `inline` methods, or defined inline in the class? For example: @@ -62,7 +62,7 @@ STL. That ties our hands when it comes to linking: ["Why isn't `bindgen` generat As far as generating opaque blobs of bytes with the correct size and alignment, `bindgen` can do pretty well. This is typically enough to let you use types that transitively contain STL things. We generally recommend marking `std::.*` as -opaque, and then whitelisting only the specific things you need from the library +opaque, and then allowlisting only the specific things you need from the library you're binding to that is pulling in STL headers. ### How to deal with bindgen generated padding fields? diff --git a/book/src/objc.md b/book/src/objc.md index aad7ee60f7..55ec5e0b80 100644 --- a/book/src/objc.md +++ b/book/src/objc.md @@ -1,7 +1,7 @@ # Generating Bindings to Objective-C `bindgen` does not (yet) have full objective-c support but it can generate bindings -for a lot of the apple frameworks without too much blacklisting. +for a lot of the apple frameworks without too much blocklisting. In order to generate bindings, you will need `-x objective-c` as the clang args. If you'd like to use [block](https://crates.io/crates/block) you will need @@ -49,7 +49,7 @@ name and `id` is a pointer to the objective-c Object. `--target=arm64-apple-ios` as mentioned [here](https://github.com/rust-lang/rust-bindgen/issues/1211#issuecomment-569804287). * The generated bindings will almost certainly have some conflicts so you will -have to blacklist a few things. There are a few cases of the parameters being +have to blocklist a few things. There are a few cases of the parameters being poorly named in the objective-c headers. But if you're using anything with Core Foundation, you'll find that `time.h` as has a variable called timezone that conflicts with some of the things in `NSCalendar.h`. diff --git a/book/src/replacing-types.md b/book/src/replacing-types.md index cf3dd17ace..f47d945deb 100644 --- a/book/src/replacing-types.md +++ b/book/src/replacing-types.md @@ -24,4 +24,4 @@ That way, after code generation, the bindings for the `nsTArray` type are the ones that would be generated for `nsTArray_Simple`. Replacing is only available as an annotation. To replace a C or C++ definition -with a Rust definition, use [blacklisting](./blacklisting.md). +with a Rust definition, use [blocklisting](./blocklisting.md). diff --git a/book/src/whitelisting.md b/book/src/whitelisting.md deleted file mode 100644 index 749b56b051..0000000000 --- a/book/src/whitelisting.md +++ /dev/null @@ -1,31 +0,0 @@ -# Whitelisting - -Whitelisting allows us to be precise about which type, function, and global -variable definitions `bindgen` generates bindings for. By default, if we don't -specify any whitelisting rules, everything is considered whitelisted. This may -not be desirable because of either - -* the generated bindings contain a lot of extra definitions we don't plan on using, or -* the header file contains C++ features for which Rust does not have a - corresponding form (such as partial template specialization), and we would - like to avoid these definitions - -If we specify whitelisting rules, then `bindgen` will only generate bindings to -types, functions, and global variables that match the whitelisting rules, or are -transitively used by a definition that matches them. - -### Library - -* [`bindgen::Builder::whitelist_type`](https://docs.rs/bindgen/0.23.1/bindgen/struct.Builder.html#method.whitelist_type) -* [`bindgen::Builder::whitelist_function`](https://docs.rs/bindgen/0.23.1/bindgen/struct.Builder.html#method.whitelist_function) -* [`bindgen::Builder::whitelist_var`](https://docs.rs/bindgen/0.23.1/bindgen/struct.Builder.html#method.whitelist_var) - -### Command Line - -* `--whitelist-type ` -* `--whitelist-function ` -* `--whitelist-var ` - -### Annotations - -None. diff --git a/src/codegen/impl_debug.rs b/src/codegen/impl_debug.rs index ed1a5e25ea..b8fdd0d444 100644 --- a/src/codegen/impl_debug.rs +++ b/src/codegen/impl_debug.rs @@ -120,9 +120,9 @@ impl<'a> ImplDebug<'a> for Item { ) -> Option<(String, Vec)> { let name_ident = ctx.rust_ident(name); - // We don't know if blacklisted items `impl Debug` or not, so we can't + // We don't know if blocklisted items `impl Debug` or not, so we can't // add them to the format string we're building up. - if !ctx.whitelisted_items().contains(&self.id()) { + if !ctx.allowlisted_items().contains(&self.id()) { return None; } diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs index 6a7660f6c2..62271acf30 100644 --- a/src/codegen/mod.rs +++ b/src/codegen/mod.rs @@ -443,7 +443,7 @@ impl CodeGenerator for Item { return; } - if self.is_blacklisted(ctx) || result.seen(self.id()) { + if self.is_blocklisted(ctx) || result.seen(self.id()) { debug!( "::codegen: Ignoring hidden or seen: \ self = {:?}", @@ -457,7 +457,7 @@ impl CodeGenerator for Item { // TODO(emilio, #453): Figure out what to do when this happens // legitimately, we could track the opaque stuff and disable the // assertion there I guess. - warn!("Found non-whitelisted item in code generation: {:?}", self); + warn!("Found non-allowlisted item in code generation: {:?}", self); } result.set_seen(self.id()); @@ -725,7 +725,7 @@ impl CodeGenerator for Type { // These items don't need code generation, they only need to be // converted to rust types in fields, arguments, and such. // NOTE(emilio): If you add to this list, make sure to also add - // it to BindgenContext::compute_whitelisted_and_codegen_items. + // it to BindgenContext::compute_allowlisted_and_codegen_items. return; } TypeKind::TemplateInstantiation(ref inst) => { @@ -2261,8 +2261,8 @@ impl MethodCodegen for Method { // First of all, output the actual function. let function_item = ctx.resolve_item(self.signature()); - if function_item.is_blacklisted(ctx) { - // We shouldn't emit a method declaration if the function is blacklisted + if function_item.is_blocklisted(ctx) { + // We shouldn't emit a method declaration if the function is blocklisted return; } function_item.codegen(ctx, result, &()); diff --git a/src/ir/analysis/derive.rs b/src/ir/analysis/derive.rs index 6c50fa6cbf..fa4ce795da 100644 --- a/src/ir/analysis/derive.rs +++ b/src/ir/analysis/derive.rs @@ -138,9 +138,9 @@ impl<'ctx> CannotDerive<'ctx> { } fn constrain_type(&mut self, item: &Item, ty: &Type) -> CanDerive { - if !self.ctx.whitelisted_items().contains(&item.id()) { + if !self.ctx.allowlisted_items().contains(&item.id()) { trace!( - " cannot derive {} for blacklisted type", + " cannot derive {} for blocklisted type", self.derive_trait ); return CanDerive::No; @@ -640,10 +640,10 @@ impl<'ctx> MonotoneFramework for CannotDerive<'ctx> { } fn initial_worklist(&self) -> Vec { - // The transitive closure of all whitelisted items, including explicitly - // blacklisted items. + // The transitive closure of all allowlisted items, including explicitly + // blocklisted items. self.ctx - .whitelisted_items() + .allowlisted_items() .iter() .cloned() .flat_map(|i| { diff --git a/src/ir/analysis/has_destructor.rs b/src/ir/analysis/has_destructor.rs index ca4f2532a1..5fa22e3f0b 100644 --- a/src/ir/analysis/has_destructor.rs +++ b/src/ir/analysis/has_destructor.rs @@ -83,7 +83,7 @@ impl<'ctx> MonotoneFramework for HasDestructorAnalysis<'ctx> { } fn initial_worklist(&self) -> Vec { - self.ctx.whitelisted_items().iter().cloned().collect() + self.ctx.allowlisted_items().iter().cloned().collect() } fn constrain(&mut self, id: ItemId) -> ConstrainResult { diff --git a/src/ir/analysis/has_float.rs b/src/ir/analysis/has_float.rs index d21e651dfa..bbf2126f70 100644 --- a/src/ir/analysis/has_float.rs +++ b/src/ir/analysis/has_float.rs @@ -94,7 +94,7 @@ impl<'ctx> MonotoneFramework for HasFloat<'ctx> { } fn initial_worklist(&self) -> Vec { - self.ctx.whitelisted_items().iter().cloned().collect() + self.ctx.allowlisted_items().iter().cloned().collect() } fn constrain(&mut self, id: ItemId) -> ConstrainResult { diff --git a/src/ir/analysis/has_type_param_in_array.rs b/src/ir/analysis/has_type_param_in_array.rs index ebdb7e3486..aa52304758 100644 --- a/src/ir/analysis/has_type_param_in_array.rs +++ b/src/ir/analysis/has_type_param_in_array.rs @@ -100,7 +100,7 @@ impl<'ctx> MonotoneFramework for HasTypeParameterInArray<'ctx> { } fn initial_worklist(&self) -> Vec { - self.ctx.whitelisted_items().iter().cloned().collect() + self.ctx.allowlisted_items().iter().cloned().collect() } fn constrain(&mut self, id: ItemId) -> ConstrainResult { diff --git a/src/ir/analysis/has_vtable.rs b/src/ir/analysis/has_vtable.rs index d2a57d5af0..7f5f9117bf 100644 --- a/src/ir/analysis/has_vtable.rs +++ b/src/ir/analysis/has_vtable.rs @@ -147,7 +147,7 @@ impl<'ctx> MonotoneFramework for HasVtableAnalysis<'ctx> { } fn initial_worklist(&self) -> Vec { - self.ctx.whitelisted_items().iter().cloned().collect() + self.ctx.allowlisted_items().iter().cloned().collect() } fn constrain(&mut self, id: ItemId) -> ConstrainResult { diff --git a/src/ir/analysis/mod.rs b/src/ir/analysis/mod.rs index 2cb021f0c7..ec4d20f948 100644 --- a/src/ir/analysis/mod.rs +++ b/src/ir/analysis/mod.rs @@ -183,7 +183,7 @@ where { let mut dependencies = HashMap::default(); - for &item in ctx.whitelisted_items() { + for &item in ctx.allowlisted_items() { dependencies.entry(item).or_insert(vec![]); { @@ -192,7 +192,7 @@ where item.trace( ctx, &mut |sub_item: ItemId, edge_kind| { - if ctx.whitelisted_items().contains(&sub_item) && + if ctx.allowlisted_items().contains(&sub_item) && consider_edge(edge_kind) { dependencies diff --git a/src/ir/analysis/sizedness.rs b/src/ir/analysis/sizedness.rs index d8bced7279..a3ef75319c 100644 --- a/src/ir/analysis/sizedness.rs +++ b/src/ir/analysis/sizedness.rs @@ -194,7 +194,7 @@ impl<'ctx> MonotoneFramework for SizednessAnalysis<'ctx> { fn initial_worklist(&self) -> Vec { self.ctx - .whitelisted_items() + .allowlisted_items() .iter() .cloned() .filter_map(|id| id.as_type_id(self.ctx)) diff --git a/src/ir/analysis/template_params.rs b/src/ir/analysis/template_params.rs index f0d9b5e87d..c2f18b1f8d 100644 --- a/src/ir/analysis/template_params.rs +++ b/src/ir/analysis/template_params.rs @@ -137,13 +137,13 @@ use crate::{HashMap, HashSet}; /// analysis. If we didn't, then we would mistakenly determine that ever /// template parameter is always used. /// -/// The final wrinkle is handling of blacklisted types. Normally, we say that -/// the set of whitelisted items is the transitive closure of items explicitly -/// called out for whitelisting, *without* any items explicitly called out as -/// blacklisted. However, for the purposes of this analysis's correctness, we +/// The final wrinkle is handling of blocklisted types. Normally, we say that +/// the set of allowlisted items is the transitive closure of items explicitly +/// called out for allowlisting, *without* any items explicitly called out as +/// blocklisted. However, for the purposes of this analysis's correctness, we /// simplify and consider run the analysis on the full transitive closure of -/// whitelisted items. We do, however, treat instantiations of blacklisted items -/// specially; see `constrain_instantiation_of_blacklisted_template` and its +/// allowlisted items. We do, however, treat instantiations of blocklisted items +/// specially; see `constrain_instantiation_of_blocklisted_template` and its /// documentation for details. #[derive(Debug, Clone)] pub struct UsedTemplateParameters<'ctx> { @@ -155,10 +155,10 @@ pub struct UsedTemplateParameters<'ctx> { dependencies: HashMap>, - // The set of whitelisted items, without any blacklisted items reachable - // from the whitelisted items which would otherwise be considered - // whitelisted as well. - whitelisted_items: HashSet, + // The set of allowlisted items, without any blocklisted items reachable + // from the allowlisted items which would otherwise be considered + // allowlisted as well. + allowlisted_items: HashSet, } impl<'ctx> UsedTemplateParameters<'ctx> { @@ -221,19 +221,19 @@ impl<'ctx> UsedTemplateParameters<'ctx> { ) } - /// We say that blacklisted items use all of their template parameters. The - /// blacklisted type is most likely implemented explicitly by the user, + /// We say that blocklisted items use all of their template parameters. The + /// blocklisted type is most likely implemented explicitly by the user, /// since it won't be in the generated bindings, and we don't know exactly /// what they'll to with template parameters, but we can push the issue down /// the line to them. - fn constrain_instantiation_of_blacklisted_template( + fn constrain_instantiation_of_blocklisted_template( &self, this_id: ItemId, used_by_this_id: &mut ItemSet, instantiation: &TemplateInstantiation, ) { trace!( - " instantiation of blacklisted template, uses all template \ + " instantiation of blocklisted template, uses all template \ arguments" ); @@ -379,10 +379,10 @@ impl<'ctx> MonotoneFramework for UsedTemplateParameters<'ctx> { fn new(ctx: &'ctx BindgenContext) -> UsedTemplateParameters<'ctx> { let mut used = HashMap::default(); let mut dependencies = HashMap::default(); - let whitelisted_items: HashSet<_> = - ctx.whitelisted_items().iter().cloned().collect(); + let allowlisted_items: HashSet<_> = + ctx.allowlisted_items().iter().cloned().collect(); - let whitelisted_and_blacklisted_items: ItemSet = whitelisted_items + let allowlisted_and_blocklisted_items: ItemSet = allowlisted_items .iter() .cloned() .flat_map(|i| { @@ -398,7 +398,7 @@ impl<'ctx> MonotoneFramework for UsedTemplateParameters<'ctx> { }) .collect(); - for item in whitelisted_and_blacklisted_items { + for item in allowlisted_and_blocklisted_items { dependencies.entry(item).or_insert(vec![]); used.entry(item).or_insert(Some(ItemSet::new())); @@ -457,17 +457,17 @@ impl<'ctx> MonotoneFramework for UsedTemplateParameters<'ctx> { } if cfg!(feature = "testing_only_extra_assertions") { - // Invariant: The `used` map has an entry for every whitelisted - // item, as well as all explicitly blacklisted items that are - // reachable from whitelisted items. + // Invariant: The `used` map has an entry for every allowlisted + // item, as well as all explicitly blocklisted items that are + // reachable from allowlisted items. // // Invariant: the `dependencies` map has an entry for every - // whitelisted item. + // allowlisted item. // // (This is so that every item we call `constrain` on is guaranteed // to have a set of template parameters, and we can allow - // blacklisted templates to use all of their parameters). - for item in whitelisted_items.iter() { + // blocklisted templates to use all of their parameters). + for item in allowlisted_items.iter() { extra_assert!(used.contains_key(item)); extra_assert!(dependencies.contains_key(item)); item.trace( @@ -485,15 +485,15 @@ impl<'ctx> MonotoneFramework for UsedTemplateParameters<'ctx> { ctx: ctx, used: used, dependencies: dependencies, - whitelisted_items: whitelisted_items, + allowlisted_items: allowlisted_items, } } fn initial_worklist(&self) -> Vec { - // The transitive closure of all whitelisted items, including explicitly - // blacklisted items. + // The transitive closure of all allowlisted items, including explicitly + // blocklisted items. self.ctx - .whitelisted_items() + .allowlisted_items() .iter() .cloned() .flat_map(|i| { @@ -538,7 +538,7 @@ impl<'ctx> MonotoneFramework for UsedTemplateParameters<'ctx> { // template definition uses the corresponding template parameter. Some(&TypeKind::TemplateInstantiation(ref inst)) => { if self - .whitelisted_items + .allowlisted_items .contains(&inst.template_definition().into()) { self.constrain_instantiation( @@ -547,7 +547,7 @@ impl<'ctx> MonotoneFramework for UsedTemplateParameters<'ctx> { inst, ); } else { - self.constrain_instantiation_of_blacklisted_template( + self.constrain_instantiation_of_blocklisted_template( id, &mut used_by_this_id, inst, diff --git a/src/ir/context.rs b/src/ir/context.rs index 0207547a54..6a0f07d924 100644 --- a/src/ir/context.rs +++ b/src/ir/context.rs @@ -376,14 +376,14 @@ pub struct BindgenContext { /// Whether a bindgen complex was generated generated_bindgen_complex: Cell, - /// The set of `ItemId`s that are whitelisted. This the very first thing + /// The set of `ItemId`s that are allowlisted. This the very first thing /// computed after parsing our IR, and before running any of our analyses. - whitelisted: Option, + allowlisted: Option, - /// The set of `ItemId`s that are whitelisted for code generation _and_ that + /// The set of `ItemId`s that are allowlisted for code generation _and_ that /// we should generate accounting for the codegen options. /// - /// It's computed right after computing the whitelisted items. + /// It's computed right after computing the allowlisted items. codegen_items: Option, /// Map from an item's id to the set of template parameter items that it @@ -463,8 +463,8 @@ pub struct BindgenContext { has_float: Option>, } -/// A traversal of whitelisted items. -struct WhitelistedItemsTraversal<'ctx> { +/// A traversal of allowlisted items. +struct AllowlistedItemsTraversal<'ctx> { ctx: &'ctx BindgenContext, traversal: ItemTraversal< 'ctx, @@ -474,14 +474,14 @@ struct WhitelistedItemsTraversal<'ctx> { >, } -impl<'ctx> Iterator for WhitelistedItemsTraversal<'ctx> { +impl<'ctx> Iterator for AllowlistedItemsTraversal<'ctx> { type Item = ItemId; fn next(&mut self) -> Option { loop { let id = self.traversal.next()?; - if self.ctx.resolve_item(id).is_blacklisted(self.ctx) { + if self.ctx.resolve_item(id).is_blocklisted(self.ctx) { continue; } @@ -490,8 +490,8 @@ impl<'ctx> Iterator for WhitelistedItemsTraversal<'ctx> { } } -impl<'ctx> WhitelistedItemsTraversal<'ctx> { - /// Construct a new whitelisted items traversal. +impl<'ctx> AllowlistedItemsTraversal<'ctx> { + /// Construct a new allowlisted items traversal. pub fn new( ctx: &'ctx BindgenContext, roots: R, @@ -500,7 +500,7 @@ impl<'ctx> WhitelistedItemsTraversal<'ctx> { where R: IntoIterator, { - WhitelistedItemsTraversal { + AllowlistedItemsTraversal { ctx, traversal: ItemTraversal::new(ctx, roots, predicate), } @@ -559,7 +559,7 @@ If you encounter an error missing from this list, please file an issue or a PR!" target_info, options, generated_bindgen_complex: Cell::new(false), - whitelisted: None, + allowlisted: None, codegen_items: None, used_template_parameters: None, need_bitfield_allocation: Default::default(), @@ -718,8 +718,8 @@ If you encounter an error missing from this list, please file an issue or a PR!" } /// Ensure that every item (other than the root module) is in a module's - /// children list. This is to make sure that every whitelisted item get's - /// codegen'd, even if its parent is not whitelisted. See issue #769 for + /// children list. This is to make sure that every allowlisted item get's + /// codegen'd, even if its parent is not allowlisted. See issue #769 for /// details. fn add_item_to_module(&mut self, item: &Item) { assert!(item.id() != self.root_module); @@ -1024,7 +1024,7 @@ If you encounter an error missing from this list, please file an issue or a PR!" _ => continue, } - let path = item.path_for_whitelisting(self); + let path = item.path_for_allowlisting(self); let replacement = self.replacements.get(&path[1..]); if let Some(replacement) = replacement { @@ -1134,10 +1134,10 @@ If you encounter an error missing from this list, please file an issue or a PR!" self.assert_no_dangling_references(); - // Compute the whitelisted set after processing replacements and + // Compute the allowlisted set after processing replacements and // resolving type refs, as those are the final mutations of the IR // graph, and their completion means that the IR graph is now frozen. - self.compute_whitelisted_and_codegen_items(); + self.compute_allowlisted_and_codegen_items(); // Make sure to do this after processing replacements, since that messes // with the parentage and module children, and we want to assert that it @@ -1293,14 +1293,14 @@ If you encounter an error missing from this list, please file an issue or a PR!" fn find_used_template_parameters(&mut self) { let _t = self.timer("find_used_template_parameters"); - if self.options.whitelist_recursively { + if self.options.allowlist_recursively { let used_params = analyze::(self); self.used_template_parameters = Some(used_params); } else { - // If you aren't recursively whitelisting, then we can't really make + // If you aren't recursively allowlisting, then we can't really make // any sense of template parameter usage, and you're on your own. let mut used_params = HashMap::default(); - for &id in self.whitelisted_items() { + for &id in self.allowlisted_items() { used_params.entry(id).or_insert( id.self_template_params(self) .into_iter() @@ -1319,9 +1319,9 @@ If you encounter an error missing from this list, please file an issue or a PR!" /// template usage information is only computed as we enter the codegen /// phase. /// - /// If the item is blacklisted, then we say that it always uses the template + /// If the item is blocklisted, then we say that it always uses the template /// parameter. This is a little subtle. The template parameter usage - /// analysis only considers whitelisted items, and if any blacklisted item + /// analysis only considers allowlisted items, and if any blocklisted item /// shows up in the generated bindings, it is the user's responsibility to /// manually provide a definition for them. To give them the most /// flexibility when doing that, we assume that they use every template @@ -1336,7 +1336,7 @@ If you encounter an error missing from this list, please file an issue or a PR!" "We only compute template parameter usage as we enter codegen" ); - if self.resolve_item(item).is_blacklisted(self) { + if self.resolve_item(item).is_blocklisted(self) { return true; } @@ -2194,15 +2194,15 @@ If you encounter an error missing from this list, please file an issue or a PR!" self.current_module = previous_id; } - /// Iterate over all (explicitly or transitively) whitelisted items. + /// Iterate over all (explicitly or transitively) allowlisted items. /// - /// If no items are explicitly whitelisted, then all items are considered - /// whitelisted. - pub fn whitelisted_items(&self) -> &ItemSet { + /// If no items are explicitly allowlisted, then all items are considered + /// allowlisted. + pub fn allowlisted_items(&self) -> &ItemSet { assert!(self.in_codegen_phase()); assert!(self.current_module == self.root_module); - self.whitelisted.as_ref().unwrap() + self.allowlisted.as_ref().unwrap() } /// Get a reference to the set of items we should generate. @@ -2212,12 +2212,12 @@ If you encounter an error missing from this list, please file an issue or a PR!" self.codegen_items.as_ref().unwrap() } - /// Compute the whitelisted items set and populate `self.whitelisted`. - fn compute_whitelisted_and_codegen_items(&mut self) { + /// Compute the allowlisted items set and populate `self.allowlisted`. + fn compute_allowlisted_and_codegen_items(&mut self) { assert!(self.in_codegen_phase()); assert!(self.current_module == self.root_module); - assert!(self.whitelisted.is_none()); - let _t = self.timer("compute_whitelisted_and_codegen_items"); + assert!(self.allowlisted.is_none()); + let _t = self.timer("compute_allowlisted_and_codegen_items"); let roots = { let mut roots = self @@ -2225,11 +2225,11 @@ If you encounter an error missing from this list, please file an issue or a PR!" // Only consider roots that are enabled for codegen. .filter(|&(_, item)| item.is_enabled_for_codegen(self)) .filter(|&(_, item)| { - // If nothing is explicitly whitelisted, then everything is fair + // If nothing is explicitly allowlisted, then everything is fair // game. - if self.options().whitelisted_types.is_empty() && - self.options().whitelisted_functions.is_empty() && - self.options().whitelisted_vars.is_empty() + if self.options().allowlisted_types.is_empty() && + self.options().allowlisted_functions.is_empty() && + self.options().allowlisted_vars.is_empty() { return true; } @@ -2240,25 +2240,25 @@ If you encounter an error missing from this list, please file an issue or a PR!" return true; } - let name = item.path_for_whitelisting(self)[1..].join("::"); - debug!("whitelisted_items: testing {:?}", name); + let name = item.path_for_allowlisting(self)[1..].join("::"); + debug!("allowlisted_items: testing {:?}", name); match *item.kind() { ItemKind::Module(..) => true, ItemKind::Function(_) => { - self.options().whitelisted_functions.matches(&name) + self.options().allowlisted_functions.matches(&name) } ItemKind::Var(_) => { - self.options().whitelisted_vars.matches(&name) + self.options().allowlisted_vars.matches(&name) } ItemKind::Type(ref ty) => { - if self.options().whitelisted_types.matches(&name) { + if self.options().allowlisted_types.matches(&name) { return true; } - // Auto-whitelist types that don't need code - // generation if not whitelisting recursively, to + // Auto-allowlist types that don't need code + // generation if not allowlisting recursively, to // make the #[derive] analysis not be lame. - if !self.options().whitelist_recursively { + if !self.options().allowlist_recursively { match *ty.kind() { TypeKind::Void | TypeKind::NullPtr | @@ -2278,7 +2278,7 @@ If you encounter an error missing from this list, please file an issue or a PR!" } // Unnamed top-level enums are special and we - // whitelist them via the `whitelisted_vars` filter, + // allowlist them via the `allowlisted_vars` filter, // since they're effectively top-level constants, // and there's no way for them to be referenced // consistently. @@ -2297,12 +2297,12 @@ If you encounter an error missing from this list, please file an issue or a PR!" } let mut prefix_path = - parent.path_for_whitelisting(self).clone(); + parent.path_for_allowlisting(self).clone(); enum_.variants().iter().any(|variant| { prefix_path.push(variant.name().into()); let name = prefix_path[1..].join("::"); prefix_path.pop().unwrap(); - self.options().whitelisted_vars.matches(&name) + self.options().allowlisted_vars.matches(&name) }) } } @@ -2317,48 +2317,48 @@ If you encounter an error missing from this list, please file an issue or a PR!" roots }; - let whitelisted_items_predicate = - if self.options().whitelist_recursively { + let allowlisted_items_predicate = + if self.options().allowlist_recursively { traversal::all_edges } else { - // Only follow InnerType edges from the whitelisted roots. + // Only follow InnerType edges from the allowlisted roots. // Such inner types (e.g. anonymous structs/unions) are - // always emitted by codegen, and they need to be whitelisted + // always emitted by codegen, and they need to be allowlisted // to make sure they are processed by e.g. the derive analysis. traversal::only_inner_type_edges }; - let whitelisted = WhitelistedItemsTraversal::new( + let allowlisted = AllowlistedItemsTraversal::new( self, roots.clone(), - whitelisted_items_predicate, + allowlisted_items_predicate, ) .collect::(); - let codegen_items = if self.options().whitelist_recursively { - WhitelistedItemsTraversal::new( + let codegen_items = if self.options().allowlist_recursively { + AllowlistedItemsTraversal::new( self, roots.clone(), traversal::codegen_edges, ) .collect::() } else { - whitelisted.clone() + allowlisted.clone() }; - self.whitelisted = Some(whitelisted); + self.allowlisted = Some(allowlisted); self.codegen_items = Some(codegen_items); - for item in self.options().whitelisted_functions.unmatched_items() { - warn!("unused option: --whitelist-function {}", item); + for item in self.options().allowlisted_functions.unmatched_items() { + warn!("unused option: --allowlist-function {}", item); } - for item in self.options().whitelisted_vars.unmatched_items() { - warn!("unused option: --whitelist-var {}", item); + for item in self.options().allowlisted_vars.unmatched_items() { + warn!("unused option: --allowlist-var {}", item); } - for item in self.options().whitelisted_types.unmatched_items() { - warn!("unused option: --whitelist-type {}", item); + for item in self.options().allowlisted_types.unmatched_items() { + warn!("unused option: --allowlist-type {}", item); } } @@ -2575,31 +2575,31 @@ If you encounter an error missing from this list, please file an issue or a PR!" /// Check if `--no-partialeq` flag is enabled for this item. pub fn no_partialeq_by_name(&self, item: &Item) -> bool { - let name = item.path_for_whitelisting(self)[1..].join("::"); + let name = item.path_for_allowlisting(self)[1..].join("::"); self.options().no_partialeq_types.matches(&name) } /// Check if `--no-copy` flag is enabled for this item. pub fn no_copy_by_name(&self, item: &Item) -> bool { - let name = item.path_for_whitelisting(self)[1..].join("::"); + let name = item.path_for_allowlisting(self)[1..].join("::"); self.options().no_copy_types.matches(&name) } /// Check if `--no-debug` flag is enabled for this item. pub fn no_debug_by_name(&self, item: &Item) -> bool { - let name = item.path_for_whitelisting(self)[1..].join("::"); + let name = item.path_for_allowlisting(self)[1..].join("::"); self.options().no_debug_types.matches(&name) } /// Check if `--no-default` flag is enabled for this item. pub fn no_default_by_name(&self, item: &Item) -> bool { - let name = item.path_for_whitelisting(self)[1..].join("::"); + let name = item.path_for_allowlisting(self)[1..].join("::"); self.options().no_default_types.matches(&name) } /// Check if `--no-hash` flag is enabled for this item. pub fn no_hash_by_name(&self, item: &Item) -> bool { - let name = item.path_for_whitelisting(self)[1..].join("::"); + let name = item.path_for_allowlisting(self)[1..].join("::"); self.options().no_hash_types.matches(&name) } } diff --git a/src/ir/dot.rs b/src/ir/dot.rs index 6bf75bfa77..f7d07f19e2 100644 --- a/src/ir/dot.rs +++ b/src/ir/dot.rs @@ -32,13 +32,13 @@ where let mut err: Option> = None; for (id, item) in ctx.items() { - let is_whitelisted = ctx.whitelisted_items().contains(&id); + let is_allowlisted = ctx.allowlisted_items().contains(&id); writeln!( &mut dot_file, r#"{} [fontname="courier", color={}, label=< "#, id.as_usize(), - if is_whitelisted { "black" } else { "gray" } + if is_allowlisted { "black" } else { "gray" } )?; item.dot_attributes(ctx, &mut dot_file)?; writeln!(&mut dot_file, r#"
>];"#)?; @@ -56,7 +56,7 @@ where id.as_usize(), sub_id.as_usize(), edge_kind, - if is_whitelisted { "black" } else { "gray" } + if is_allowlisted { "black" } else { "gray" } ) { Ok(_) => {} Err(e) => err = Some(Err(e)), diff --git a/src/ir/enum_ty.rs b/src/ir/enum_ty.rs index dde4bb1835..c6cd89ce97 100644 --- a/src/ir/enum_ty.rs +++ b/src/ir/enum_ty.rs @@ -152,7 +152,7 @@ impl Enum { enums: &RegexSet, item: &Item, ) -> bool { - let path = item.path_for_whitelisting(ctx); + let path = item.path_for_allowlisting(ctx); let enum_ty = item.expect_type(); if enums.matches(&path[1..].join("::")) { diff --git a/src/ir/item.rs b/src/ir/item.rs index e9abed7032..45415045fe 100644 --- a/src/ir/item.rs +++ b/src/ir/item.rs @@ -273,10 +273,10 @@ impl Trace for Item { where T: Tracer, { - // Even if this item is blacklisted/hidden, we want to trace it. It is + // Even if this item is blocklisted/hidden, we want to trace it. It is // traversal iterators' consumers' responsibility to filter items as // needed. Generally, this filtering happens in the implementation of - // `Iterator` for `WhitelistedItems`. Fully tracing blacklisted items is + // `Iterator` for `allowlistedItems`. Fully tracing blocklisted items is // necessary for things like the template parameter usage analysis to // function correctly. @@ -301,12 +301,12 @@ impl Trace for Item { } ItemKind::Module(_) => { // Module -> children edges are "weak", and we do not want to - // trace them. If we did, then whitelisting wouldn't work as + // trace them. If we did, then allowlisting wouldn't work as // expected: everything in every module would end up - // whitelisted. + // allowlisted. // // TODO: make a new edge kind for module -> children edges and - // filter them during whitelisting traversals. + // filter them during allowlisting traversals. } } } @@ -400,9 +400,9 @@ pub struct Item { /// considerably faster in those cases. canonical_name: LazyCell, - /// The path to use for whitelisting and other name-based checks, as - /// returned by `path_for_whitelisting`, lazily constructed. - path_for_whitelisting: LazyCell>, + /// The path to use for allowlisting and other name-based checks, as + /// returned by `path_for_allowlisting`, lazily constructed. + path_for_allowlisting: LazyCell>, /// A doc comment over the item, if any. comment: Option, @@ -440,7 +440,7 @@ impl Item { local_id: LazyCell::new(), next_child_local_id: Cell::new(1), canonical_name: LazyCell::new(), - path_for_whitelisting: LazyCell::new(), + path_for_allowlisting: LazyCell::new(), parent_id: parent_id, comment: comment, annotations: annotations.unwrap_or_default(), @@ -623,10 +623,10 @@ impl Item { &self.annotations } - /// Whether this item should be blacklisted. + /// Whether this item should be blocklisted. /// /// This may be due to either annotations or to other kind of configuration. - pub fn is_blacklisted(&self, ctx: &BindgenContext) -> bool { + pub fn is_blocklisted(&self, ctx: &BindgenContext) -> bool { debug_assert!( ctx.in_codegen_phase(), "You're not supposed to call this yet" @@ -635,18 +635,18 @@ impl Item { return true; } - let path = self.path_for_whitelisting(ctx); + let path = self.path_for_allowlisting(ctx); let name = path[1..].join("::"); - ctx.options().blacklisted_items.matches(&name) || + ctx.options().blocklisted_items.matches(&name) || match self.kind { ItemKind::Type(..) => { - ctx.options().blacklisted_types.matches(&name) || + ctx.options().blocklisted_types.matches(&name) || ctx.is_replaced_type(&path, self.id) } ItemKind::Function(..) => { - ctx.options().blacklisted_functions.matches(&name) + ctx.options().blocklisted_functions.matches(&name) } - // TODO: Add constant / namespace blacklisting? + // TODO: Add constant / namespace blocklisting? ItemKind::Var(..) | ItemKind::Module(..) => false, } } @@ -1012,10 +1012,10 @@ impl Item { } } - /// Returns the path we should use for whitelisting / blacklisting, which + /// Returns the path we should use for allowlisting / blocklisting, which /// doesn't include user-mangling. - pub fn path_for_whitelisting(&self, ctx: &BindgenContext) -> &Vec { - self.path_for_whitelisting + pub fn path_for_allowlisting(&self, ctx: &BindgenContext) -> &Vec { + self.path_for_allowlisting .borrow_with(|| self.compute_path(ctx, UserMangled::No)) } @@ -1081,7 +1081,7 @@ impl IsOpaque for Item { ); self.annotations.opaque() || self.as_type().map_or(false, |ty| ty.is_opaque(ctx, self)) || - ctx.opaque_by_name(&self.path_for_whitelisting(ctx)) + ctx.opaque_by_name(&self.path_for_allowlisting(ctx)) } } @@ -1390,7 +1390,7 @@ impl ClangItemParser for Item { if cursor.kind() == CXCursor_UnexposedDecl { Err(ParseError::Recurse) } else { - // We whitelist cursors here known to be unhandled, to prevent being + // We allowlist cursors here known to be unhandled, to prevent being // too noisy about this. match cursor.kind() { CXCursor_MacroDefinition | @@ -1918,7 +1918,7 @@ impl ItemCanonicalPath for Item { /// not. /// /// Most of the callers probably want just yes, but the ones dealing with -/// whitelisting and blacklisting don't. +/// allowlisting and blocklisting don't. #[derive(Copy, Clone, Debug, PartialEq)] enum UserMangled { No, diff --git a/src/ir/template.rs b/src/ir/template.rs index 8c625d1d92..b519fff132 100644 --- a/src/ir/template.rs +++ b/src/ir/template.rs @@ -306,13 +306,13 @@ impl IsOpaque for TemplateInstantiation { // correct fix is to make `canonical_{name,path}` include template // arguments properly. - let mut path = item.path_for_whitelisting(ctx).clone(); + let mut path = item.path_for_allowlisting(ctx).clone(); let args: Vec<_> = self .template_arguments() .iter() .map(|arg| { let arg_path = - ctx.resolve_item(*arg).path_for_whitelisting(ctx); + ctx.resolve_item(*arg).path_for_allowlisting(ctx); arg_path[1..].join("::") }) .collect(); diff --git a/src/ir/traversal.rs b/src/ir/traversal.rs index e4a447032b..430dd02796 100644 --- a/src/ir/traversal.rs +++ b/src/ir/traversal.rs @@ -201,7 +201,7 @@ pub fn all_edges(_: &BindgenContext, _: Edge) -> bool { /// A `TraversalPredicate` implementation that only follows /// `EdgeKind::InnerType` edges, and therefore traversals using this predicate /// will only visit the traversal's roots and their inner types. This is used -/// in no-recursive-whitelist mode, where inner types such as anonymous +/// in no-recursive-allowlist mode, where inner types such as anonymous /// structs/unions still need to be processed. pub fn only_inner_type_edges(_: &BindgenContext, edge: Edge) -> bool { edge.kind == EdgeKind::InnerType @@ -377,7 +377,7 @@ pub trait Trace { /// An graph traversal of the transitive closure of references between items. /// -/// See `BindgenContext::whitelisted_items` for more information. +/// See `BindgenContext::allowlisted_items` for more information. pub struct ItemTraversal<'ctx, Storage, Queue, Predicate> where Storage: TraversalStorage<'ctx>, diff --git a/src/lib.rs b/src/lib.rs index 06ba8e6377..945d3065f1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -177,8 +177,8 @@ impl Default for CodegenConfig { /// /// // Configure and generate bindings. /// let bindings = builder().header("path/to/input/header") -/// .whitelist_type("SomeCoolClass") -/// .whitelist_function("do_some_cool_thing") +/// .allowlist_type("SomeCoolClass") +/// .allowlist_function("do_some_cool_thing") /// .generate()?; /// /// // Write the generated bindings to an output file. @@ -304,13 +304,13 @@ impl Builder { (&self.options.type_alias, "--type-alias"), (&self.options.new_type_alias, "--new-type-alias"), (&self.options.new_type_alias_deref, "--new-type-alias-deref"), - (&self.options.blacklisted_types, "--blacklist-type"), - (&self.options.blacklisted_functions, "--blacklist-function"), - (&self.options.blacklisted_items, "--blacklist-item"), + (&self.options.blocklisted_types, "--blocklist-type"), + (&self.options.blocklisted_functions, "--blocklist-function"), + (&self.options.blocklisted_items, "--blocklist-item"), (&self.options.opaque_types, "--opaque-type"), - (&self.options.whitelisted_functions, "--whitelist-function"), - (&self.options.whitelisted_types, "--whitelist-type"), - (&self.options.whitelisted_vars, "--whitelist-var"), + (&self.options.allowlisted_functions, "--allowlist-function"), + (&self.options.allowlisted_types, "--allowlist-type"), + (&self.options.allowlisted_vars, "--allowlist-var"), (&self.options.no_partialeq_types, "--no-partialeq"), (&self.options.no_copy_types, "--no-copy"), (&self.options.no_debug_types, "--no-debug"), @@ -379,8 +379,8 @@ impl Builder { output_vector.push("--no-doc-comments".into()); } - if !self.options.whitelist_recursively { - output_vector.push("--no-recursive-whitelist".into()); + if !self.options.allowlist_recursively { + output_vector.push("--no-recursive-allowlist".into()); } if self.options.objc_extern_crate { @@ -661,9 +661,9 @@ impl Builder { self } - /// Whether to whitelist recursively or not. Defaults to true. + /// Whether to allowlist recursively or not. Defaults to true. /// - /// Given that we have explicitly whitelisted the "initiate_dance_party" + /// Given that we have explicitly allowlisted the "initiate_dance_party" /// function in this C header: /// /// ```c @@ -676,20 +676,20 @@ impl Builder { /// /// We would normally generate bindings to both the `initiate_dance_party` /// function and the `MoonBoots` struct that it transitively references. By - /// configuring with `whitelist_recursively(false)`, `bindgen` will not emit - /// bindings for anything except the explicitly whitelisted items, and there + /// configuring with `allowlist_recursively(false)`, `bindgen` will not emit + /// bindings for anything except the explicitly allowlisted items, and there /// would be no emitted struct definition for `MoonBoots`. However, the /// `initiate_dance_party` function would still reference `MoonBoots`! /// /// **Disabling this feature will almost certainly cause `bindgen` to emit /// bindings that will not compile!** If you disable this feature, then it /// is *your* responsibility to provide definitions for every type that is - /// referenced from an explicitly whitelisted item. One way to provide the + /// referenced from an explicitly allowlisted item. One way to provide the /// definitions is by using the [`Builder::raw_line`](#method.raw_line) /// method, another would be to define them in Rust and then `include!(...)` /// the bindings immediately afterwards. - pub fn whitelist_recursively(mut self, doit: bool) -> Self { - self.options.whitelist_recursively = doit; + pub fn allowlist_recursively(mut self, doit: bool) -> Self { + self.options.allowlist_recursively = doit; self } @@ -727,30 +727,53 @@ impl Builder { /// Hide the given type from the generated bindings. Regular expressions are /// supported. - #[deprecated(note = "Use blacklist_type instead")] + #[deprecated(note = "Use blocklist_type instead")] pub fn hide_type>(self, arg: T) -> Builder { - self.blacklist_type(arg) + self.blocklist_type(arg) + } + + /// Hide the given type from the generated bindings. Regular expressions are + /// supported. + #[deprecated(note = "Use blocklist_type instead")] + pub fn blacklist_type>(self, arg: T) -> Builder { + self.blocklist_type(arg) } /// Hide the given type from the generated bindings. Regular expressions are /// supported. /// - /// To blacklist types prefixed with "mylib" use `"mylib_.*"`. + /// To blocklist types prefixed with "mylib" use `"mylib_.*"`. /// For more complicated expressions check /// [regex](https://docs.rs/regex/*/regex/) docs - pub fn blacklist_type>(mut self, arg: T) -> Builder { - self.options.blacklisted_types.insert(arg); + pub fn blocklist_type>(mut self, arg: T) -> Builder { + self.options.blocklisted_types.insert(arg); self } + /// Hide the given function from the generated bindings. Regular expressions + /// are supported. + #[deprecated(note = "Use blocklist_function instead")] + pub fn blacklist_function>(self, arg: T) -> Builder { + self.blocklist_function(arg) + } + /// Hide the given function from the generated bindings. Regular expressions /// are supported. /// - /// To blacklist functions prefixed with "mylib" use `"mylib_.*"`. + /// To blocklist functions prefixed with "mylib" use `"mylib_.*"`. /// For more complicated expressions check /// [regex](https://docs.rs/regex/*/regex/) docs - pub fn blacklist_function>(mut self, arg: T) -> Builder { - self.options.blacklisted_functions.insert(arg); + pub fn blocklist_function>(mut self, arg: T) -> Builder { + self.options.blocklisted_functions.insert(arg); + self + } + + /// Hide the given item from the generated bindings, regardless of + /// whether it's a type, function, module, etc. Regular + /// expressions are supported. + #[deprecated(note = "Use blocklist_item instead")] + pub fn blacklist_item>(mut self, arg: T) -> Builder { + self.options.blocklisted_items.insert(arg); self } @@ -758,11 +781,11 @@ impl Builder { /// whether it's a type, function, module, etc. Regular /// expressions are supported. /// - /// To blacklist items prefixed with "mylib" use `"mylib_.*"`. + /// To blocklist items prefixed with "mylib" use `"mylib_.*"`. /// For more complicated expressions check /// [regex](https://docs.rs/regex/*/regex/) docs - pub fn blacklist_item>(mut self, arg: T) -> Builder { - self.options.blacklisted_items.insert(arg); + pub fn blocklist_item>(mut self, arg: T) -> Builder { + self.options.blocklisted_items.insert(arg); self } @@ -777,64 +800,86 @@ impl Builder { self } - /// Whitelist the given type so that it (and all types that it transitively + /// Allowlist the given type so that it (and all types that it transitively /// refers to) appears in the generated bindings. Regular expressions are /// supported. - #[deprecated(note = "use whitelist_type instead")] + #[deprecated(note = "use allowlist_type instead")] pub fn whitelisted_type>(self, arg: T) -> Builder { - self.whitelist_type(arg) + self.allowlist_type(arg) + } + + /// Allowlist the given type so that it (and all types that it transitively + /// refers to) appears in the generated bindings. Regular expressions are + /// supported. + #[deprecated(note = "use allowlist_type instead")] + pub fn whitelist_type>(self, arg: T) -> Builder { + self.allowlist_type(arg) } - /// Whitelist the given type so that it (and all types that it transitively + /// Allowlist the given type so that it (and all types that it transitively /// refers to) appears in the generated bindings. Regular expressions are /// supported. /// - /// To whitelist types prefixed with "mylib" use `"mylib_.*"`. + /// To allowlist types prefixed with "mylib" use `"mylib_.*"`. /// For more complicated expressions check /// [regex](https://docs.rs/regex/*/regex/) docs - pub fn whitelist_type>(mut self, arg: T) -> Builder { - self.options.whitelisted_types.insert(arg); + pub fn allowlist_type>(mut self, arg: T) -> Builder { + self.options.allowlisted_types.insert(arg); self } - /// Whitelist the given function so that it (and all types that it + /// Allowlist the given function so that it (and all types that it /// transitively refers to) appears in the generated bindings. Regular /// expressions are supported. /// - /// To whitelist functions prefixed with "mylib" use `"mylib_.*"`. + /// To allowlist functions prefixed with "mylib" use `"mylib_.*"`. /// For more complicated expressions check /// [regex](https://docs.rs/regex/*/regex/) docs - pub fn whitelist_function>(mut self, arg: T) -> Builder { - self.options.whitelisted_functions.insert(arg); + pub fn allowlist_function>(mut self, arg: T) -> Builder { + self.options.allowlisted_functions.insert(arg); self } - /// Whitelist the given function. + /// Allowlist the given function. + /// + /// Deprecated: use allowlist_function instead. + #[deprecated(note = "use allowlist_function instead")] + pub fn whitelist_function>(self, arg: T) -> Builder { + self.allowlist_function(arg) + } + + /// Allowlist the given function. /// - /// Deprecated: use whitelist_function instead. - #[deprecated(note = "use whitelist_function instead")] + /// Deprecated: use allowlist_function instead. + #[deprecated(note = "use allowlist_function instead")] pub fn whitelisted_function>(self, arg: T) -> Builder { - self.whitelist_function(arg) + self.allowlist_function(arg) } - /// Whitelist the given variable so that it (and all types that it + /// Allowlist the given variable so that it (and all types that it /// transitively refers to) appears in the generated bindings. Regular /// expressions are supported. /// - /// To whitelist variables prefixed with "mylib" use `"mylib_.*"`. + /// To allowlist variables prefixed with "mylib" use `"mylib_.*"`. /// For more complicated expressions check /// [regex](https://docs.rs/regex/*/regex/) docs - pub fn whitelist_var>(mut self, arg: T) -> Builder { - self.options.whitelisted_vars.insert(arg); + pub fn allowlist_var>(mut self, arg: T) -> Builder { + self.options.allowlisted_vars.insert(arg); self } - /// Whitelist the given variable. + /// Deprecated: use allowlist_var instead. + #[deprecated(note = "use allowlist_var instead")] + pub fn whitelist_var>(self, arg: T) -> Builder { + self.allowlist_var(arg) + } + + /// Allowlist the given variable. /// - /// Deprecated: use whitelist_var instead. - #[deprecated(note = "use whitelist_var instead")] + /// Deprecated: use allowlist_var instead. + #[deprecated(note = "use allowlist_var instead")] pub fn whitelisted_var>(self, arg: T) -> Builder { - self.whitelist_var(arg) + self.allowlist_var(arg) } /// Set the default style of code to generate for enums @@ -1163,7 +1208,7 @@ impl Builder { /// This method disables that behavior. /// /// Note that this intentionally does not change the names used for - /// whitelisting and blacklisting, which should still be mangled with the + /// allowlisting and blocklisting, which should still be mangled with the /// namespaces. /// /// Note, also, that this option may cause bindgen to generate duplicate @@ -1533,17 +1578,17 @@ impl Builder { /// Configuration options for generated bindings. #[derive(Debug)] struct BindgenOptions { - /// The set of types that have been blacklisted and should not appear + /// The set of types that have been blocklisted and should not appear /// anywhere in the generated code. - blacklisted_types: RegexSet, + blocklisted_types: RegexSet, - /// The set of functions that have been blacklisted and should not appear + /// The set of functions that have been blocklisted and should not appear /// in the generated code. - blacklisted_functions: RegexSet, + blocklisted_functions: RegexSet, /// The set of items, regardless of item-type, that have been - /// blacklisted and should not appear in the generated code. - blacklisted_items: RegexSet, + /// blocklisted and should not appear in the generated code. + blocklisted_items: RegexSet, /// The set of types that should be treated as opaque structures in the /// generated code. @@ -1556,15 +1601,15 @@ struct BindgenOptions { /// code. /// /// This includes all types transitively reachable from any type in this - /// set. One might think of whitelisted types/vars/functions as GC roots, + /// set. One might think of allowlisted types/vars/functions as GC roots, /// and the generated Rust code as including everything that gets marked. - whitelisted_types: RegexSet, + allowlisted_types: RegexSet, - /// Whitelisted functions. See docs for `whitelisted_types` for more. - whitelisted_functions: RegexSet, + /// Allowlisted functions. See docs for `allowlisted_types` for more. + allowlisted_functions: RegexSet, - /// Whitelisted variables. See docs for `whitelisted_types` for more. - whitelisted_vars: RegexSet, + /// Allowlisted variables. See docs for `allowlisted_types` for more. + allowlisted_vars: RegexSet, /// The default style of code to generate for enums default_enum_style: codegen::EnumVariation, @@ -1736,8 +1781,8 @@ struct BindgenOptions { /// Whether to generate inline functions. Defaults to false. generate_inline_functions: bool, - /// Whether to whitelist types recursively. Defaults to true. - whitelist_recursively: bool, + /// Whether to allowlist types recursively. Defaults to true. + allowlist_recursively: bool, /// Instead of emitting 'use objc;' to files generated from objective c files, /// generate '#[macro_use] extern crate objc;' @@ -1777,7 +1822,7 @@ struct BindgenOptions { /// Whether we should record which items in the regex sets ever matched. /// - /// This may be a bit slower, but will enable reporting of unused whitelist + /// This may be a bit slower, but will enable reporting of unused allowlist /// items via the `error!` log. record_matches: bool, @@ -1829,12 +1874,12 @@ impl ::std::panic::UnwindSafe for BindgenOptions {} impl BindgenOptions { fn build(&mut self) { let mut regex_sets = [ - &mut self.whitelisted_vars, - &mut self.whitelisted_types, - &mut self.whitelisted_functions, - &mut self.blacklisted_types, - &mut self.blacklisted_functions, - &mut self.blacklisted_items, + &mut self.allowlisted_vars, + &mut self.allowlisted_types, + &mut self.allowlisted_functions, + &mut self.blocklisted_types, + &mut self.blocklisted_functions, + &mut self.blocklisted_items, &mut self.opaque_types, &mut self.bitfield_enums, &mut self.constified_enums, @@ -1878,14 +1923,14 @@ impl Default for BindgenOptions { BindgenOptions { rust_target, rust_features: rust_target.into(), - blacklisted_types: Default::default(), - blacklisted_functions: Default::default(), - blacklisted_items: Default::default(), + blocklisted_types: Default::default(), + blocklisted_functions: Default::default(), + blocklisted_items: Default::default(), opaque_types: Default::default(), rustfmt_path: Default::default(), - whitelisted_types: Default::default(), - whitelisted_functions: Default::default(), - whitelisted_vars: Default::default(), + allowlisted_types: Default::default(), + allowlisted_functions: Default::default(), + allowlisted_vars: Default::default(), default_enum_style: Default::default(), bitfield_enums: Default::default(), newtype_enums: Default::default(), @@ -1934,7 +1979,7 @@ impl Default for BindgenOptions { conservative_inline_namespaces: false, generate_comments: true, generate_inline_functions: false, - whitelist_recursively: true, + allowlist_recursively: true, generate_block: false, objc_extern_crate: false, block_extern_crate: false, @@ -2520,8 +2565,8 @@ fn commandline_flag_unit_test_function() { //Test 2 let bindings = crate::builder() .header("input_header") - .whitelist_type("Distinct_Type") - .whitelist_function("safe_function"); + .allowlist_type("Distinct_Type") + .allowlist_function("safe_function"); let command_line_flags = bindings.command_line_flags(); let test_cases = vec![ @@ -2530,9 +2575,9 @@ fn commandline_flag_unit_test_function() { "--no-derive-default", "--generate", "functions,types,vars,methods,constructors,destructors", - "--whitelist-type", + "--allowlist-type", "Distinct_Type", - "--whitelist-function", + "--allowlist-function", "safe_function", ] .iter() diff --git a/src/options.rs b/src/options.rs index 63e48dc830..2289ad09bd 100644 --- a/src/options.rs +++ b/src/options.rs @@ -136,22 +136,25 @@ where .takes_value(true) .multiple(true) .number_of_values(1), - Arg::with_name("blacklist-type") - .long("blacklist-type") + Arg::with_name("blocklist-type") + .alias("blacklist-type") + .long("blocklist-type") .help("Mark as hidden.") .value_name("type") .takes_value(true) .multiple(true) .number_of_values(1), - Arg::with_name("blacklist-function") - .long("blacklist-function") + Arg::with_name("blocklist-function") + .alias("blacklist-function") + .long("blocklist-function") .help("Mark as hidden.") .value_name("function") .takes_value(true) .multiple(true) .number_of_values(1), - Arg::with_name("blacklist-item") - .long("blacklist-item") + Arg::with_name("blocklist-item") + .alias("blacklist-item") + .long("blocklist-item") .help("Mark as hidden.") .value_name("item") .takes_value(true) @@ -210,12 +213,13 @@ where "Avoid including doc comments in the output, see: \ https://github.com/rust-lang/rust-bindgen/issues/426", ), - Arg::with_name("no-recursive-whitelist") - .long("no-recursive-whitelist") + Arg::with_name("no-recursive-allowlist") + .long("no-recursive-allowlist") + .alias("no-recursive-whitelist") .help( - "Disable whitelisting types recursively. This will cause \ + "Disable allowlisting types recursively. This will cause \ bindgen to emit Rust code that won't compile! See the \ - `bindgen::Builder::whitelist_recursively` method's \ + `bindgen::Builder::allowlist_recursively` method's \ documentation for details.", ), Arg::with_name("objc-extern-crate") @@ -364,11 +368,12 @@ where Arg::with_name("use-msvc-mangling") .long("use-msvc-mangling") .help("MSVC C++ ABI mangling. DEPRECATED: Has no effect."), - Arg::with_name("whitelist-function") - .long("whitelist-function") + Arg::with_name("allowlist-function") + .long("allowlist-function") + .alias("whitelist-function") .help( - "Whitelist all the free-standing functions matching \ - . Other non-whitelisted functions will not be \ + "Allowlist all the free-standing functions matching \ + . Other non-allowlisted functions will not be \ generated.", ) .value_name("regex") @@ -378,21 +383,23 @@ where Arg::with_name("generate-inline-functions") .long("generate-inline-functions") .help("Generate inline functions."), - Arg::with_name("whitelist-type") - .long("whitelist-type") + Arg::with_name("allowlist-type") + .long("allowlist-type") + .alias("whitelist-type") .help( - "Only generate types matching . Other non-whitelisted types will \ + "Only generate types matching . Other non-allowlisted types will \ not be generated.", ) .value_name("regex") .takes_value(true) .multiple(true) .number_of_values(1), - Arg::with_name("whitelist-var") - .long("whitelist-var") + Arg::with_name("allowlist-var") + .long("allowlist-var") + .alias("whitelist-var") .help( - "Whitelist all the free-standing variables matching \ - . Other non-whitelisted variables will not be \ + "Allowlist all the free-standing variables matching \ + . Other non-allowlisted variables will not be \ generated.", ) .value_name("regex") @@ -582,21 +589,21 @@ where } } - if let Some(hidden_types) = matches.values_of("blacklist-type") { + if let Some(hidden_types) = matches.values_of("blocklist-type") { for ty in hidden_types { - builder = builder.blacklist_type(ty); + builder = builder.blocklist_type(ty); } } - if let Some(hidden_functions) = matches.values_of("blacklist-function") { + if let Some(hidden_functions) = matches.values_of("blocklist-function") { for fun in hidden_functions { - builder = builder.blacklist_function(fun); + builder = builder.blocklist_function(fun); } } - if let Some(hidden_identifiers) = matches.values_of("blacklist-item") { + if let Some(hidden_identifiers) = matches.values_of("blocklist-item") { for id in hidden_identifiers { - builder = builder.blacklist_item(id); + builder = builder.blocklist_item(id); } } @@ -758,8 +765,8 @@ where builder = builder.generate_comments(false); } - if matches.is_present("no-recursive-whitelist") { - builder = builder.whitelist_recursively(false); + if matches.is_present("no-recursive-allowlist") { + builder = builder.allowlist_recursively(false); } if matches.is_present("objc-extern-crate") { @@ -809,21 +816,21 @@ where builder = builder.generate_inline_functions(true); } - if let Some(whitelist) = matches.values_of("whitelist-function") { - for regex in whitelist { - builder = builder.whitelist_function(regex); + if let Some(allowlist) = matches.values_of("allowlist-function") { + for regex in allowlist { + builder = builder.allowlist_function(regex); } } - if let Some(whitelist) = matches.values_of("whitelist-type") { - for regex in whitelist { - builder = builder.whitelist_type(regex); + if let Some(allowlist) = matches.values_of("allowlist-type") { + for regex in allowlist { + builder = builder.allowlist_type(regex); } } - if let Some(whitelist) = matches.values_of("whitelist-var") { - for regex in whitelist { - builder = builder.whitelist_var(regex); + if let Some(allowlist) = matches.values_of("allowlist-var") { + for regex in allowlist { + builder = builder.allowlist_var(regex); } } diff --git a/tests/expectations/tests/whitelist-namespaces-basic.rs b/tests/expectations/tests/allowlist-namespaces-basic.rs similarity index 100% rename from tests/expectations/tests/whitelist-namespaces-basic.rs rename to tests/expectations/tests/allowlist-namespaces-basic.rs diff --git a/tests/expectations/tests/whitelist-namespaces.rs b/tests/expectations/tests/allowlist-namespaces.rs similarity index 100% rename from tests/expectations/tests/whitelist-namespaces.rs rename to tests/expectations/tests/allowlist-namespaces.rs diff --git a/tests/expectations/tests/whitelist_basic.rs b/tests/expectations/tests/allowlist_basic.rs similarity index 75% rename from tests/expectations/tests/whitelist_basic.rs rename to tests/expectations/tests/allowlist_basic.rs index 7806923c71..4e72e8b6dd 100644 --- a/tests/expectations/tests/whitelist_basic.rs +++ b/tests/expectations/tests/allowlist_basic.rs @@ -7,23 +7,23 @@ #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct WhitelistMe { +pub struct AllowlistMe { pub foo: ::std::os::raw::c_int, - pub bar: WhitelistMe_Inner, + pub bar: AllowlistMe_Inner, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct WhitelistMe_Inner { +pub struct AllowlistMe_Inner { pub bar: T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } -impl Default for WhitelistMe_Inner { +impl Default for AllowlistMe_Inner { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } -impl Default for WhitelistMe { +impl Default for AllowlistMe { fn default() -> Self { unsafe { ::std::mem::zeroed() } } diff --git a/tests/expectations/tests/whitelist_fix.rs b/tests/expectations/tests/allowlist_fix.rs similarity index 100% rename from tests/expectations/tests/whitelist_fix.rs rename to tests/expectations/tests/allowlist_fix.rs diff --git a/tests/expectations/tests/whitelist_vars.rs b/tests/expectations/tests/allowlist_vars.rs similarity index 100% rename from tests/expectations/tests/whitelist_vars.rs rename to tests/expectations/tests/allowlist_vars.rs diff --git a/tests/expectations/tests/whitelisted-item-references-no-hash.rs b/tests/expectations/tests/allowlisted-item-references-no-hash.rs similarity index 69% rename from tests/expectations/tests/whitelisted-item-references-no-hash.rs rename to tests/expectations/tests/allowlisted-item-references-no-hash.rs index e1217bc505..bc3fde1ded 100644 --- a/tests/expectations/tests/whitelisted-item-references-no-hash.rs +++ b/tests/expectations/tests/allowlisted-item-references-no-hash.rs @@ -25,29 +25,29 @@ fn bindgen_test_layout_NoHash() { } #[repr(C)] #[derive(Debug, Default, Copy, Clone)] -pub struct WhitelistMe { +pub struct AllowlistMe { pub a: NoHash, } #[test] -fn bindgen_test_layout_WhitelistMe() { +fn bindgen_test_layout_AllowlistMe() { assert_eq!( - ::std::mem::size_of::(), + ::std::mem::size_of::(), 1usize, - concat!("Size of: ", stringify!(WhitelistMe)) + concat!("Size of: ", stringify!(AllowlistMe)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 1usize, - concat!("Alignment of ", stringify!(WhitelistMe)) + concat!("Alignment of ", stringify!(AllowlistMe)) ); assert_eq!( unsafe { - &(*(::std::ptr::null::())).a as *const _ as usize + &(*(::std::ptr::null::())).a as *const _ as usize }, 0usize, concat!( "Offset of field: ", - stringify!(WhitelistMe), + stringify!(AllowlistMe), "::", stringify!(a) ) diff --git a/tests/expectations/tests/whitelisted-item-references-no-partialeq.rs b/tests/expectations/tests/allowlisted-item-references-no-partialeq.rs similarity index 70% rename from tests/expectations/tests/whitelisted-item-references-no-partialeq.rs rename to tests/expectations/tests/allowlisted-item-references-no-partialeq.rs index 2aabc1018b..f26f692391 100644 --- a/tests/expectations/tests/whitelisted-item-references-no-partialeq.rs +++ b/tests/expectations/tests/allowlisted-item-references-no-partialeq.rs @@ -25,29 +25,29 @@ fn bindgen_test_layout_NoPartialEq() { } #[repr(C)] #[derive(Debug, Default, Copy, Clone)] -pub struct WhitelistMe { +pub struct AllowlistMe { pub a: NoPartialEq, } #[test] -fn bindgen_test_layout_WhitelistMe() { +fn bindgen_test_layout_AllowlistMe() { assert_eq!( - ::std::mem::size_of::(), + ::std::mem::size_of::(), 1usize, - concat!("Size of: ", stringify!(WhitelistMe)) + concat!("Size of: ", stringify!(AllowlistMe)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 1usize, - concat!("Alignment of ", stringify!(WhitelistMe)) + concat!("Alignment of ", stringify!(AllowlistMe)) ); assert_eq!( unsafe { - &(*(::std::ptr::null::())).a as *const _ as usize + &(*(::std::ptr::null::())).a as *const _ as usize }, 0usize, concat!( "Offset of field: ", - stringify!(WhitelistMe), + stringify!(AllowlistMe), "::", stringify!(a) ) diff --git a/tests/expectations/tests/whitelisted_item_references_no_copy.rs b/tests/expectations/tests/allowlisted_item_references_no_copy.rs similarity index 68% rename from tests/expectations/tests/whitelisted_item_references_no_copy.rs rename to tests/expectations/tests/allowlisted_item_references_no_copy.rs index d13ede59e6..a5cb17b238 100644 --- a/tests/expectations/tests/whitelisted_item_references_no_copy.rs +++ b/tests/expectations/tests/allowlisted_item_references_no_copy.rs @@ -25,29 +25,29 @@ fn bindgen_test_layout_NoCopy() { } #[repr(C)] #[derive(Debug, Default)] -pub struct WhitelistMe { +pub struct AllowlistMe { pub a: NoCopy, } #[test] -fn bindgen_test_layout_WhitelistMe() { +fn bindgen_test_layout_AllowlistMe() { assert_eq!( - ::std::mem::size_of::(), + ::std::mem::size_of::(), 1usize, - concat!("Size of: ", stringify!(WhitelistMe)) + concat!("Size of: ", stringify!(AllowlistMe)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 1usize, - concat!("Alignment of ", stringify!(WhitelistMe)) + concat!("Alignment of ", stringify!(AllowlistMe)) ); assert_eq!( unsafe { - &(*(::std::ptr::null::())).a as *const _ as usize + &(*(::std::ptr::null::())).a as *const _ as usize }, 0usize, concat!( "Offset of field: ", - stringify!(WhitelistMe), + stringify!(AllowlistMe), "::", stringify!(a) ) diff --git a/tests/expectations/tests/anon_enum_whitelist.rs b/tests/expectations/tests/anon_enum_allowlist.rs similarity index 100% rename from tests/expectations/tests/anon_enum_whitelist.rs rename to tests/expectations/tests/anon_enum_allowlist.rs diff --git a/tests/expectations/tests/blacklist-and-impl-debug.rs b/tests/expectations/tests/blocklist-and-impl-debug.rs similarity index 91% rename from tests/expectations/tests/blacklist-and-impl-debug.rs rename to tests/expectations/tests/blocklist-and-impl-debug.rs index 2609b2e864..f272f9beac 100644 --- a/tests/expectations/tests/blacklist-and-impl-debug.rs +++ b/tests/expectations/tests/blocklist-and-impl-debug.rs @@ -5,12 +5,12 @@ non_upper_case_globals )] -pub struct BlacklistMe(u8); +pub struct BlocklistMe(u8); -/// Because this type contains a blacklisted type, it should not derive Debug. +/// Because this type contains a blocklisted type, it should not derive Debug. #[repr(C)] pub struct ShouldManuallyImplDebug { - pub a: BlacklistMe, + pub a: BlocklistMe, } #[test] fn bindgen_test_layout_ShouldManuallyImplDebug() { diff --git a/tests/expectations/tests/blacklist-function.rs b/tests/expectations/tests/blocklist-function.rs similarity index 100% rename from tests/expectations/tests/blacklist-function.rs rename to tests/expectations/tests/blocklist-function.rs diff --git a/tests/expectations/tests/blacklist-item.rs b/tests/expectations/tests/blocklist-item.rs similarity index 100% rename from tests/expectations/tests/blacklist-item.rs rename to tests/expectations/tests/blocklist-item.rs diff --git a/tests/expectations/tests/derive-default-and-blacklist.rs b/tests/expectations/tests/derive-default-and-blocklist.rs similarity index 90% rename from tests/expectations/tests/derive-default-and-blacklist.rs rename to tests/expectations/tests/derive-default-and-blocklist.rs index ce0f252890..fca9c7f3cb 100644 --- a/tests/expectations/tests/derive-default-and-blacklist.rs +++ b/tests/expectations/tests/derive-default-and-blocklist.rs @@ -5,13 +5,13 @@ non_upper_case_globals )] -pub struct BlacklistMe(u8); +pub struct BlocklistMe(u8); -/// Because this type contains a blacklisted type, it should not derive +/// Because this type contains a blocklisted type, it should not derive /// Default. Instead, we should emit a `mem::zeroed` implementation. #[repr(C)] pub struct ShouldNotDeriveDefault { - pub a: BlacklistMe, + pub a: BlocklistMe, } #[test] fn bindgen_test_layout_ShouldNotDeriveDefault() { diff --git a/tests/expectations/tests/derive-hash-and-blacklist.rs b/tests/expectations/tests/derive-hash-and-blocklist.rs similarity index 89% rename from tests/expectations/tests/derive-hash-and-blacklist.rs rename to tests/expectations/tests/derive-hash-and-blocklist.rs index 458081a457..ba606a25fe 100644 --- a/tests/expectations/tests/derive-hash-and-blacklist.rs +++ b/tests/expectations/tests/derive-hash-and-blocklist.rs @@ -5,12 +5,12 @@ non_upper_case_globals )] -pub struct BlacklistMe(u8); +pub struct BlocklistMe(u8); -/// Because this type contains a blacklisted type, it should not derive Hash. +/// Because this type contains a blocklisted type, it should not derive Hash. #[repr(C)] pub struct ShouldNotDeriveHash { - pub a: BlacklistMe, + pub a: BlocklistMe, } #[test] fn bindgen_test_layout_ShouldNotDeriveHash() { diff --git a/tests/expectations/tests/derive-hash-blacklisting.rs b/tests/expectations/tests/derive-hash-blocklisting.rs similarity index 52% rename from tests/expectations/tests/derive-hash-blacklisting.rs rename to tests/expectations/tests/derive-hash-blocklisting.rs index 0424077b83..f9dbc824cf 100644 --- a/tests/expectations/tests/derive-hash-blacklisting.rs +++ b/tests/expectations/tests/derive-hash-blocklisting.rs @@ -7,78 +7,78 @@ #[repr(C)] #[derive(Debug, Hash, Copy, Clone, PartialEq, Eq)] -pub struct Blacklisted { +pub struct Blocklisted { t: T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } -/// This would derive(Hash, Eq, PartialEq) if it didn't contain a blacklisted type, +/// This would derive(Hash, Eq, PartialEq) if it didn't contain a blocklisted type, /// causing us to conservatively avoid deriving hash/Eq/PartialEq for it. #[repr(C)] -pub struct WhitelistedOne { - pub a: Blacklisted<::std::os::raw::c_int>, +pub struct AllowlistedOne { + pub a: Blocklisted<::std::os::raw::c_int>, } #[test] -fn bindgen_test_layout_WhitelistedOne() { +fn bindgen_test_layout_AllowlistedOne() { assert_eq!( - ::std::mem::size_of::(), + ::std::mem::size_of::(), 4usize, - concat!("Size of: ", stringify!(WhitelistedOne)) + concat!("Size of: ", stringify!(AllowlistedOne)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 4usize, - concat!("Alignment of ", stringify!(WhitelistedOne)) + concat!("Alignment of ", stringify!(AllowlistedOne)) ); assert_eq!( unsafe { - &(*(::std::ptr::null::())).a as *const _ as usize + &(*(::std::ptr::null::())).a as *const _ as usize }, 0usize, concat!( "Offset of field: ", - stringify!(WhitelistedOne), + stringify!(AllowlistedOne), "::", stringify!(a) ) ); } -impl Default for WhitelistedOne { +impl Default for AllowlistedOne { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } -/// This can't derive(Hash/Eq) even if it didn't contain a blacklisted type. +/// This can't derive(Hash/Eq) even if it didn't contain a blocklisted type. #[repr(C)] -pub struct WhitelistedTwo { - pub b: Blacklisted, +pub struct AllowlistedTwo { + pub b: Blocklisted, } #[test] -fn bindgen_test_layout_WhitelistedTwo() { +fn bindgen_test_layout_AllowlistedTwo() { assert_eq!( - ::std::mem::size_of::(), + ::std::mem::size_of::(), 4usize, - concat!("Size of: ", stringify!(WhitelistedTwo)) + concat!("Size of: ", stringify!(AllowlistedTwo)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 4usize, - concat!("Alignment of ", stringify!(WhitelistedTwo)) + concat!("Alignment of ", stringify!(AllowlistedTwo)) ); assert_eq!( unsafe { - &(*(::std::ptr::null::())).b as *const _ as usize + &(*(::std::ptr::null::())).b as *const _ as usize }, 0usize, concat!( "Offset of field: ", - stringify!(WhitelistedTwo), + stringify!(AllowlistedTwo), "::", stringify!(b) ) ); } -impl Default for WhitelistedTwo { +impl Default for AllowlistedTwo { fn default() -> Self { unsafe { ::std::mem::zeroed() } } diff --git a/tests/expectations/tests/derive-partialeq-and-blacklist.rs b/tests/expectations/tests/derive-partialeq-and-blocklist.rs similarity index 89% rename from tests/expectations/tests/derive-partialeq-and-blacklist.rs rename to tests/expectations/tests/derive-partialeq-and-blocklist.rs index 88bccdff21..b211933d7c 100644 --- a/tests/expectations/tests/derive-partialeq-and-blacklist.rs +++ b/tests/expectations/tests/derive-partialeq-and-blocklist.rs @@ -5,13 +5,13 @@ non_upper_case_globals )] -pub struct BlacklistMe(u8); +pub struct BlocklistMe(u8); -/// Because this type contains a blacklisted type, it should not derive +/// Because this type contains a blocklisted type, it should not derive /// PartialEq. #[repr(C)] pub struct ShouldNotDerivePartialEq { - pub a: BlacklistMe, + pub a: BlocklistMe, } #[test] fn bindgen_test_layout_ShouldNotDerivePartialEq() { diff --git a/tests/expectations/tests/dynamic_loading_with_whitelist.rs b/tests/expectations/tests/dynamic_loading_with_allowlist.rs similarity index 100% rename from tests/expectations/tests/dynamic_loading_with_whitelist.rs rename to tests/expectations/tests/dynamic_loading_with_allowlist.rs diff --git a/tests/expectations/tests/dynamic_loading_with_blacklist.rs b/tests/expectations/tests/dynamic_loading_with_blocklist.rs similarity index 100% rename from tests/expectations/tests/dynamic_loading_with_blacklist.rs rename to tests/expectations/tests/dynamic_loading_with_blocklist.rs diff --git a/tests/expectations/tests/inline_namespace_whitelist.rs b/tests/expectations/tests/inline_namespace_allowlist.rs similarity index 100% rename from tests/expectations/tests/inline_namespace_whitelist.rs rename to tests/expectations/tests/inline_namespace_allowlist.rs diff --git a/tests/expectations/tests/issue-807-opaque-types-methods-being-generated.rs b/tests/expectations/tests/issue-807-opaque-types-methods-being-generated.rs index bad51ff43b..7fd9caa309 100644 --- a/tests/expectations/tests/issue-807-opaque-types-methods-being-generated.rs +++ b/tests/expectations/tests/issue-807-opaque-types-methods-being-generated.rs @@ -104,30 +104,30 @@ extern "C" { } #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] -pub struct Whitelisted { +pub struct Allowlisted { pub some_member: Opaque, } #[test] -fn bindgen_test_layout_Whitelisted() { +fn bindgen_test_layout_Allowlisted() { assert_eq!( - ::std::mem::size_of::(), + ::std::mem::size_of::(), 1usize, - concat!("Size of: ", stringify!(Whitelisted)) + concat!("Size of: ", stringify!(Allowlisted)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 1usize, - concat!("Alignment of ", stringify!(Whitelisted)) + concat!("Alignment of ", stringify!(Allowlisted)) ); assert_eq!( unsafe { - &(*(::std::ptr::null::())).some_member as *const _ + &(*(::std::ptr::null::())).some_member as *const _ as usize }, 0usize, concat!( "Offset of field: ", - stringify!(Whitelisted), + stringify!(Allowlisted), "::", stringify!(some_member) ) diff --git a/tests/expectations/tests/issue-944-derive-copy-and-blacklisting.rs b/tests/expectations/tests/issue-944-derive-copy-and-blocklisting.rs similarity index 88% rename from tests/expectations/tests/issue-944-derive-copy-and-blacklisting.rs rename to tests/expectations/tests/issue-944-derive-copy-and-blocklisting.rs index bcb5550fe8..51e97964d3 100644 --- a/tests/expectations/tests/issue-944-derive-copy-and-blacklisting.rs +++ b/tests/expectations/tests/issue-944-derive-copy-and-blocklisting.rs @@ -5,12 +5,12 @@ non_upper_case_globals )] -pub struct BlacklistMe(u8); +pub struct BlocklistMe(u8); -/// Because this type contains a blacklisted type, it should not derive Copy. +/// Because this type contains a blocklisted type, it should not derive Copy. #[repr(C)] pub struct ShouldNotBeCopy { - pub a: BlacklistMe, + pub a: BlocklistMe, } #[test] fn bindgen_test_layout_ShouldNotBeCopy() { diff --git a/tests/expectations/tests/module-whitelisted.rs b/tests/expectations/tests/module-allowlisted.rs similarity index 100% rename from tests/expectations/tests/module-whitelisted.rs rename to tests/expectations/tests/module-allowlisted.rs diff --git a/tests/expectations/tests/no-derive-debug.rs b/tests/expectations/tests/no-derive-debug.rs index 0ddc5e2355..d58093ec02 100644 --- a/tests/expectations/tests/no-derive-debug.rs +++ b/tests/expectations/tests/no-derive-debug.rs @@ -11,7 +11,7 @@ pub struct foo { bar: ::std::os::raw::c_int, } -/// bar should compile. It will normally derive debug, but our blacklist of foo +/// bar should compile. It will normally derive debug, but our blocklist of foo /// and replacement for another type that doesn't implement it would prevent it /// from building if --no-derive-debug didn't work. #[repr(C)] diff --git a/tests/expectations/tests/no-derive-default.rs b/tests/expectations/tests/no-derive-default.rs index 995b1320e3..eda13aad68 100644 --- a/tests/expectations/tests/no-derive-default.rs +++ b/tests/expectations/tests/no-derive-default.rs @@ -11,7 +11,7 @@ pub struct foo { bar: ::std::os::raw::c_int, } -/// bar should compile. It will normally derive default, but our blacklist of foo +/// bar should compile. It will normally derive default, but our blocklist of foo /// and replacement for another type that doesn't implement it would prevent it /// from building if --no-derive-default didn't work. #[repr(C)] diff --git a/tests/expectations/tests/no-hash-whitelisted.rs b/tests/expectations/tests/no-hash-allowlisted.rs similarity index 100% rename from tests/expectations/tests/no-hash-whitelisted.rs rename to tests/expectations/tests/no-hash-allowlisted.rs diff --git a/tests/expectations/tests/no-partialeq-whitelisted.rs b/tests/expectations/tests/no-partialeq-allowlisted.rs similarity index 100% rename from tests/expectations/tests/no-partialeq-whitelisted.rs rename to tests/expectations/tests/no-partialeq-allowlisted.rs diff --git a/tests/expectations/tests/no-recursive-whitelisting.rs b/tests/expectations/tests/no-recursive-allowlisting.rs similarity index 100% rename from tests/expectations/tests/no-recursive-whitelisting.rs rename to tests/expectations/tests/no-recursive-allowlisting.rs diff --git a/tests/expectations/tests/no_copy_whitelisted.rs b/tests/expectations/tests/no_copy_allowlisted.rs similarity index 100% rename from tests/expectations/tests/no_copy_whitelisted.rs rename to tests/expectations/tests/no_copy_allowlisted.rs diff --git a/tests/expectations/tests/no_debug_whitelisted.rs b/tests/expectations/tests/no_debug_allowlisted.rs similarity index 100% rename from tests/expectations/tests/no_debug_whitelisted.rs rename to tests/expectations/tests/no_debug_allowlisted.rs diff --git a/tests/expectations/tests/no_default_whitelisted.rs b/tests/expectations/tests/no_default_allowlisted.rs similarity index 100% rename from tests/expectations/tests/no_default_whitelisted.rs rename to tests/expectations/tests/no_default_allowlisted.rs diff --git a/tests/expectations/tests/objc_whitelist.rs b/tests/expectations/tests/objc_allowlist.rs similarity index 66% rename from tests/expectations/tests/objc_whitelist.rs rename to tests/expectations/tests/objc_allowlist.rs index 213f1024ba..dcec0fd12e 100644 --- a/tests/expectations/tests/objc_whitelist.rs +++ b/tests/expectations/tests/objc_allowlist.rs @@ -10,5 +10,5 @@ extern crate objc; #[allow(non_camel_case_types)] pub type id = *mut objc::runtime::Object; -impl WhitelistMe_InterestingCategory for WhitelistMe {} -pub trait WhitelistMe_InterestingCategory: Sized + std::ops::Deref {} +impl AllowlistMe_InterestingCategory for AllowlistMe {} +pub trait AllowlistMe_InterestingCategory: Sized + std::ops::Deref {} diff --git a/tests/expectations/tests/type-referenced-by-whitelisted-function.rs b/tests/expectations/tests/type-referenced-by-allowlisted-function.rs similarity index 100% rename from tests/expectations/tests/type-referenced-by-whitelisted-function.rs rename to tests/expectations/tests/type-referenced-by-allowlisted-function.rs diff --git a/tests/headers/whitelist-namespaces-basic.hpp b/tests/headers/allowlist-namespaces-basic.hpp similarity index 67% rename from tests/headers/whitelist-namespaces-basic.hpp rename to tests/headers/allowlist-namespaces-basic.hpp index 2eaa87403e..fb4dd1be37 100644 --- a/tests/headers/whitelist-namespaces-basic.hpp +++ b/tests/headers/allowlist-namespaces-basic.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --enable-cxx-namespaces --whitelist-type outer::inner::Helper +// bindgen-flags: --enable-cxx-namespaces --allowlist-type outer::inner::Helper namespace outer { namespace inner { diff --git a/tests/headers/whitelist-namespaces.hpp b/tests/headers/allowlist-namespaces.hpp similarity index 64% rename from tests/headers/whitelist-namespaces.hpp rename to tests/headers/allowlist-namespaces.hpp index d34cbe9430..2cffe9d3dd 100644 --- a/tests/headers/whitelist-namespaces.hpp +++ b/tests/headers/allowlist-namespaces.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --enable-cxx-namespaces --whitelist-type '.*' +// bindgen-flags: --enable-cxx-namespaces --allowlist-type '.*' namespace outer { namespace inner { diff --git a/tests/headers/whitelist_basic.hpp b/tests/headers/allowlist_basic.hpp similarity index 59% rename from tests/headers/whitelist_basic.hpp rename to tests/headers/allowlist_basic.hpp index 8424f75a8e..ef858c95da 100644 --- a/tests/headers/whitelist_basic.hpp +++ b/tests/headers/allowlist_basic.hpp @@ -1,7 +1,7 @@ -// bindgen-flags: --whitelist-type WhitelistMe +// bindgen-flags: --allowlist-type AllowlistMe template -class WhitelistMe { +class AllowlistMe { class Inner { T bar; }; @@ -10,7 +10,7 @@ class WhitelistMe { Inner bar; }; -struct DontWhitelistMe { +struct DontAllowlistMe { void* foo; double _Complex noComplexGenerated; }; diff --git a/tests/headers/whitelist_fix.hpp b/tests/headers/allowlist_fix.hpp similarity index 58% rename from tests/headers/whitelist_fix.hpp rename to tests/headers/allowlist_fix.hpp index d0abda540d..ff810fc6e0 100644 --- a/tests/headers/whitelist_fix.hpp +++ b/tests/headers/allowlist_fix.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --whitelist-function 'Servo_.*' --blacklist-type Test --raw-line "pub enum Test {}" +// bindgen-flags: --allowlist-function 'Servo_.*' --blocklist-type Test --raw-line "pub enum Test {}" struct Test {}; extern "C" void Servo_Test(Test* a); diff --git a/tests/headers/whitelist_vars.h b/tests/headers/allowlist_vars.h similarity index 100% rename from tests/headers/whitelist_vars.h rename to tests/headers/allowlist_vars.h diff --git a/tests/headers/allowlisted-item-references-no-hash.hpp b/tests/headers/allowlisted-item-references-no-hash.hpp new file mode 100644 index 0000000000..56c2a39fba --- /dev/null +++ b/tests/headers/allowlisted-item-references-no-hash.hpp @@ -0,0 +1,7 @@ +// bindgen-flags: --with-derive-hash --allowlist-type "AllowlistMe" --no-hash "NoHash" + +struct NoHash {}; + +class AllowlistMe { + NoHash a; +}; diff --git a/tests/headers/allowlisted-item-references-no-partialeq.hpp b/tests/headers/allowlisted-item-references-no-partialeq.hpp new file mode 100644 index 0000000000..d85fb6b754 --- /dev/null +++ b/tests/headers/allowlisted-item-references-no-partialeq.hpp @@ -0,0 +1,7 @@ +// bindgen-flags: --with-derive-partialeq --allowlist-type "AllowlistMe" --no-partialeq "NoPartialEq" + +struct NoPartialEq {}; + +class AllowlistMe { + NoPartialEq a; +}; diff --git a/tests/headers/allowlisted_item_references_no_copy.hpp b/tests/headers/allowlisted_item_references_no_copy.hpp new file mode 100644 index 0000000000..9feb30549a --- /dev/null +++ b/tests/headers/allowlisted_item_references_no_copy.hpp @@ -0,0 +1,7 @@ +// bindgen-flags: --allowlist-type "AllowlistMe" --no-copy "NoCopy" + +struct NoCopy {}; + +class AllowlistMe { + NoCopy a; +}; diff --git a/tests/headers/anon_enum_allowlist.h b/tests/headers/anon_enum_allowlist.h new file mode 100644 index 0000000000..94119a8773 --- /dev/null +++ b/tests/headers/anon_enum_allowlist.h @@ -0,0 +1,6 @@ +// bindgen-flags: --allowlist-var "NODE_.*" --rustified-enum ".*" + +enum { + NODE_FLAG_FOO, + NODE_FLAG_BAR, +}; diff --git a/tests/headers/anon_enum_whitelist.h b/tests/headers/anon_enum_whitelist.h deleted file mode 100644 index a35e4886c3..0000000000 --- a/tests/headers/anon_enum_whitelist.h +++ /dev/null @@ -1,6 +0,0 @@ -// bindgen-flags: --whitelist-var "NODE_.*" --rustified-enum ".*" - -enum { - NODE_FLAG_FOO, - NODE_FLAG_BAR, -}; diff --git a/tests/headers/blacklist-and-impl-debug.hpp b/tests/headers/blacklist-and-impl-debug.hpp deleted file mode 100644 index b4b39fe40d..0000000000 --- a/tests/headers/blacklist-and-impl-debug.hpp +++ /dev/null @@ -1,10 +0,0 @@ -// bindgen-flags: --impl-debug --blacklist-type BlacklistMe --raw-line 'pub struct BlacklistMe(u8);' - -struct BlacklistMe {}; - -/** - * Because this type contains a blacklisted type, it should not derive Debug. - */ -struct ShouldManuallyImplDebug { - BlacklistMe a; -}; diff --git a/tests/headers/blocklist-and-impl-debug.hpp b/tests/headers/blocklist-and-impl-debug.hpp new file mode 100644 index 0000000000..14e17537e1 --- /dev/null +++ b/tests/headers/blocklist-and-impl-debug.hpp @@ -0,0 +1,10 @@ +// bindgen-flags: --impl-debug --blocklist-type BlocklistMe --raw-line 'pub struct BlocklistMe(u8);' + +struct BlocklistMe {}; + +/** + * Because this type contains a blocklisted type, it should not derive Debug. + */ +struct ShouldManuallyImplDebug { + BlocklistMe a; +}; diff --git a/tests/headers/blacklist-function.hpp b/tests/headers/blocklist-function.hpp similarity index 62% rename from tests/headers/blacklist-function.hpp rename to tests/headers/blocklist-function.hpp index 8087295cc1..d7c8bb35d7 100644 --- a/tests/headers/blacklist-function.hpp +++ b/tests/headers/blocklist-function.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --blacklist-function "ExternFunction" --blacklist-function "foo::NamespacedFunction" --blacklist-function "C_ClassMethod" --enable-cxx-namespaces +// bindgen-flags: --blocklist-function "ExternFunction" --blocklist-function "foo::NamespacedFunction" --blocklist-function "C_ClassMethod" --enable-cxx-namespaces extern "C" void ExternFunction(); diff --git a/tests/headers/blacklist-item.hpp b/tests/headers/blocklist-item.hpp similarity index 63% rename from tests/headers/blacklist-item.hpp rename to tests/headers/blocklist-item.hpp index 8d569dde98..2d795d5a5a 100644 --- a/tests/headers/blacklist-item.hpp +++ b/tests/headers/blocklist-item.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --blacklist-item "SomeFunction" --blacklist-item "SOME_DEFUN" --blacklist-item "someVar" --blacklist-item "ExternFunction" --blacklist-item "foo::NamespacedFunction" --blacklist-item "someClass.*" --enable-cxx-namespaces +// bindgen-flags: --blocklist-item "SomeFunction" --blocklist-item "SOME_DEFUN" --blocklist-item "someVar" --blocklist-item "ExternFunction" --blocklist-item "foo::NamespacedFunction" --blocklist-item "someClass.*" --enable-cxx-namespaces void SomeFunction(); extern int someVar; diff --git a/tests/headers/derive-default-and-blacklist.hpp b/tests/headers/derive-default-and-blocklist.hpp similarity index 56% rename from tests/headers/derive-default-and-blacklist.hpp rename to tests/headers/derive-default-and-blocklist.hpp index 7a2b7505d5..20d938ccf2 100644 --- a/tests/headers/derive-default-and-blacklist.hpp +++ b/tests/headers/derive-default-and-blocklist.hpp @@ -1,14 +1,14 @@ -// bindgen-flags: --blacklist-type BlacklistMe --raw-line 'pub struct BlacklistMe(u8);' +// bindgen-flags: --blocklist-type BlocklistMe --raw-line 'pub struct BlocklistMe(u8);' // Note that we do not explicitly provide the `--with-derive-default` flag // above, since it is added by the test runner implicitly. -struct BlacklistMe {}; +struct BlocklistMe {}; /** - * Because this type contains a blacklisted type, it should not derive + * Because this type contains a blocklisted type, it should not derive * Default. Instead, we should emit a `mem::zeroed` implementation. */ struct ShouldNotDeriveDefault { - BlacklistMe a; + BlocklistMe a; }; diff --git a/tests/headers/derive-hash-and-blacklist.hpp b/tests/headers/derive-hash-and-blacklist.hpp deleted file mode 100644 index 4b3a4a535b..0000000000 --- a/tests/headers/derive-hash-and-blacklist.hpp +++ /dev/null @@ -1,10 +0,0 @@ -// bindgen-flags: --with-derive-hash --blacklist-type BlacklistMe --raw-line 'pub struct BlacklistMe(u8);' - -struct BlacklistMe {}; - -/** - * Because this type contains a blacklisted type, it should not derive Hash. - */ -struct ShouldNotDeriveHash { - BlacklistMe a; -}; diff --git a/tests/headers/derive-hash-and-blocklist.hpp b/tests/headers/derive-hash-and-blocklist.hpp new file mode 100644 index 0000000000..51a3372fcf --- /dev/null +++ b/tests/headers/derive-hash-and-blocklist.hpp @@ -0,0 +1,10 @@ +// bindgen-flags: --with-derive-hash --blocklist-type BlocklistMe --raw-line 'pub struct BlocklistMe(u8);' + +struct BlocklistMe {}; + +/** + * Because this type contains a blocklisted type, it should not derive Hash. + */ +struct ShouldNotDeriveHash { + BlocklistMe a; +}; diff --git a/tests/headers/derive-hash-blacklisting.hpp b/tests/headers/derive-hash-blacklisting.hpp deleted file mode 100644 index e3256a0118..0000000000 --- a/tests/headers/derive-hash-blacklisting.hpp +++ /dev/null @@ -1,17 +0,0 @@ -// bindgen-flags: --with-derive-hash --with-derive-partialord --with-derive-ord --with-derive-partialeq --with-derive-eq --whitelist-type 'Whitelisted.*' --blacklist-type Blacklisted --raw-line "#[repr(C)] #[derive(Debug, Hash, Copy, Clone, PartialEq, Eq)] pub struct Blacklisted {t: T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell> }" -// -template -struct Blacklisted { - T t; -}; - -/// This would derive(Hash, Eq, PartialEq) if it didn't contain a blacklisted type, -/// causing us to conservatively avoid deriving hash/Eq/PartialEq for it. -struct WhitelistedOne { - Blacklisted a; -}; - -/// This can't derive(Hash/Eq) even if it didn't contain a blacklisted type. -struct WhitelistedTwo { - Blacklisted b; -}; diff --git a/tests/headers/derive-hash-blocklisting.hpp b/tests/headers/derive-hash-blocklisting.hpp new file mode 100644 index 0000000000..4e20e3925a --- /dev/null +++ b/tests/headers/derive-hash-blocklisting.hpp @@ -0,0 +1,17 @@ +// bindgen-flags: --with-derive-hash --with-derive-partialord --with-derive-ord --with-derive-partialeq --with-derive-eq --allowlist-type 'Allowlisted.*' --blocklist-type Blocklisted --raw-line "#[repr(C)] #[derive(Debug, Hash, Copy, Clone, PartialEq, Eq)] pub struct Blocklisted {t: T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell> }" +// +template +struct Blocklisted { + T t; +}; + +/// This would derive(Hash, Eq, PartialEq) if it didn't contain a blocklisted type, +/// causing us to conservatively avoid deriving hash/Eq/PartialEq for it. +struct AllowlistedOne { + Blocklisted a; +}; + +/// This can't derive(Hash/Eq) even if it didn't contain a blocklisted type. +struct AllowlistedTwo { + Blocklisted b; +}; diff --git a/tests/headers/derive-partialeq-and-blacklist.hpp b/tests/headers/derive-partialeq-and-blacklist.hpp deleted file mode 100644 index a996eee873..0000000000 --- a/tests/headers/derive-partialeq-and-blacklist.hpp +++ /dev/null @@ -1,11 +0,0 @@ -// bindgen-flags: --with-derive-partialeq --blacklist-type BlacklistMe --raw-line 'pub struct BlacklistMe(u8);' - -struct BlacklistMe {}; - -/** - * Because this type contains a blacklisted type, it should not derive - * PartialEq. - */ -struct ShouldNotDerivePartialEq { - BlacklistMe a; -}; diff --git a/tests/headers/derive-partialeq-and-blocklist.hpp b/tests/headers/derive-partialeq-and-blocklist.hpp new file mode 100644 index 0000000000..953d067714 --- /dev/null +++ b/tests/headers/derive-partialeq-and-blocklist.hpp @@ -0,0 +1,11 @@ +// bindgen-flags: --with-derive-partialeq --blocklist-type BlocklistMe --raw-line 'pub struct BlocklistMe(u8);' + +struct BlocklistMe {}; + +/** + * Because this type contains a blocklisted type, it should not derive + * PartialEq. + */ +struct ShouldNotDerivePartialEq { + BlocklistMe a; +}; diff --git a/tests/headers/dynamic_loading_with_whitelist.hpp b/tests/headers/dynamic_loading_with_allowlist.hpp similarity index 59% rename from tests/headers/dynamic_loading_with_whitelist.hpp rename to tests/headers/dynamic_loading_with_allowlist.hpp index 33bfe805e2..995fbdd531 100644 --- a/tests/headers/dynamic_loading_with_whitelist.hpp +++ b/tests/headers/dynamic_loading_with_allowlist.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --dynamic-loading TestLib --whitelist-function baz --whitelist-function foo --whitelist-function bazz +// bindgen-flags: --dynamic-loading TestLib --allowlist-function baz --allowlist-function foo --allowlist-function bazz class X { int _x; diff --git a/tests/headers/dynamic_loading_with_blacklist.hpp b/tests/headers/dynamic_loading_with_blocklist.hpp similarity index 71% rename from tests/headers/dynamic_loading_with_blacklist.hpp rename to tests/headers/dynamic_loading_with_blocklist.hpp index 2988ba691e..81266d1f40 100644 --- a/tests/headers/dynamic_loading_with_blacklist.hpp +++ b/tests/headers/dynamic_loading_with_blocklist.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --dynamic-loading TestLib --blacklist-function baz +// bindgen-flags: --dynamic-loading TestLib --blocklist-function baz class X { int _x; diff --git a/tests/headers/inline_namespace_whitelist.hpp b/tests/headers/inline_namespace_allowlist.hpp similarity index 61% rename from tests/headers/inline_namespace_whitelist.hpp rename to tests/headers/inline_namespace_allowlist.hpp index 30047bbec1..90e46dfb84 100644 --- a/tests/headers/inline_namespace_whitelist.hpp +++ b/tests/headers/inline_namespace_allowlist.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --enable-cxx-namespaces --whitelist-type=std::string -- -std=c++11 +// bindgen-flags: --enable-cxx-namespaces --allowlist-type=std::string -- -std=c++11 namespace std { inline namespace bar { diff --git a/tests/headers/issue-1285.h b/tests/headers/issue-1285.h index 7fb742ecf7..a2817d84b4 100644 --- a/tests/headers/issue-1285.h +++ b/tests/headers/issue-1285.h @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash --no-recursive-whitelist --whitelist-type "foo" +// bindgen-flags: --with-derive-hash --no-recursive-allowlist --allowlist-type "foo" struct foo { union { diff --git a/tests/headers/issue-410.hpp b/tests/headers/issue-410.hpp index b5d502f33e..d4f3de3d1c 100644 --- a/tests/headers/issue-410.hpp +++ b/tests/headers/issue-410.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --enable-cxx-namespaces --whitelist-type JS::Value --rustified-enum ".*" +// bindgen-flags: --enable-cxx-namespaces --allowlist-type JS::Value --rustified-enum ".*" namespace JS { class Value; diff --git a/tests/headers/issue-447.hpp b/tests/headers/issue-447.hpp index 017838c42f..43765fa9ee 100644 --- a/tests/headers/issue-447.hpp +++ b/tests/headers/issue-447.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --enable-cxx-namespaces --whitelist-type JSAutoCompartment -- -std=c++11 +// bindgen-flags: --enable-cxx-namespaces --allowlist-type JSAutoCompartment -- -std=c++11 namespace mozilla { template class a {}; diff --git a/tests/headers/issue-584-stylo-template-analysis-panic.hpp b/tests/headers/issue-584-stylo-template-analysis-panic.hpp index 3bf00e5da9..5f11ea3c9c 100644 --- a/tests/headers/issue-584-stylo-template-analysis-panic.hpp +++ b/tests/headers/issue-584-stylo-template-analysis-panic.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --blacklist-type RefPtr --whitelist-function 'Servo_.*' --raw-line 'pub type RefPtr = T;' -- -std=c++14 +// bindgen-flags: --blocklist-type RefPtr --allowlist-function 'Servo_.*' --raw-line 'pub type RefPtr = T;' -- -std=c++14 template class RefPtr; class b; class A { diff --git a/tests/headers/issue-645-cannot-find-type-T-in-this-scope.hpp b/tests/headers/issue-645-cannot-find-type-T-in-this-scope.hpp index f817f34dce..8e07a8a0fd 100644 --- a/tests/headers/issue-645-cannot-find-type-T-in-this-scope.hpp +++ b/tests/headers/issue-645-cannot-find-type-T-in-this-scope.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --blacklist-type RefPtr --raw-line "#[derive(Clone, Copy, Debug)] pub struct RefPtr(T);" --whitelist-type "HasRefPtr" -- -std=c++14 +// bindgen-flags: --blocklist-type RefPtr --raw-line "#[derive(Clone, Copy, Debug)] pub struct RefPtr(T);" --allowlist-type "HasRefPtr" -- -std=c++14 template class RefPtr {}; diff --git a/tests/headers/issue-662-part-2.hpp b/tests/headers/issue-662-part-2.hpp index 84edb39778..1330c34280 100644 --- a/tests/headers/issue-662-part-2.hpp +++ b/tests/headers/issue-662-part-2.hpp @@ -1,7 +1,7 @@ -// bindgen-flags: --blacklist-type RefPtr --raw-line '#[derive(Clone, Copy, Debug)] pub struct RefPtr(T);' -- --std=c++14 +// bindgen-flags: --blocklist-type RefPtr --raw-line '#[derive(Clone, Copy, Debug)] pub struct RefPtr(T);' -- --std=c++14 // This is pretty much the same as the other issue 662 test case, but this time -// we blacklist RefPtr to exercise the instantiation-of-a-blacklisted-template +// we blocklist RefPtr to exercise the instantiation-of-a-blocklisted-template // path in the template analysis. template class RefPtr {}; diff --git a/tests/headers/issue-674-1.hpp b/tests/headers/issue-674-1.hpp index aa3c6118db..7fc781c1da 100644 --- a/tests/headers/issue-674-1.hpp +++ b/tests/headers/issue-674-1.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --enable-cxx-namespaces --whitelist-type CapturingContentInfo --opaque-type 'mozilla::Maybe' -- -std=c++14 +// bindgen-flags: --enable-cxx-namespaces --allowlist-type CapturingContentInfo --opaque-type 'mozilla::Maybe' -- -std=c++14 namespace mozilla { template class Maybe { using ValueType = T; }; diff --git a/tests/headers/issue-674-2.hpp b/tests/headers/issue-674-2.hpp index 58abcae24e..86d2b6488d 100644 --- a/tests/headers/issue-674-2.hpp +++ b/tests/headers/issue-674-2.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --enable-cxx-namespaces --whitelist-type StaticRefPtr --opaque-type 'JS::Rooted' -- -std=c++14 +// bindgen-flags: --enable-cxx-namespaces --allowlist-type StaticRefPtr --opaque-type 'JS::Rooted' -- -std=c++14 namespace JS { template class Rooted { using ElementType = T; }; diff --git a/tests/headers/issue-674-3.hpp b/tests/headers/issue-674-3.hpp index 2794c19299..20aa463c9e 100644 --- a/tests/headers/issue-674-3.hpp +++ b/tests/headers/issue-674-3.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --enable-cxx-namespaces --whitelist-type nsCSSValue --opaque-type 'nsRefPtrHashtable' -- -std=c++14 +// bindgen-flags: --enable-cxx-namespaces --allowlist-type nsCSSValue --opaque-type 'nsRefPtrHashtable' -- -std=c++14 template class nsRefPtrHashtable { typedef PtrType *UserDataType; diff --git a/tests/headers/issue-769-bad-instantiation-test.hpp b/tests/headers/issue-769-bad-instantiation-test.hpp index 1be89a6628..13c6dd1ce6 100644 --- a/tests/headers/issue-769-bad-instantiation-test.hpp +++ b/tests/headers/issue-769-bad-instantiation-test.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --enable-cxx-namespaces --whitelist-type Rooted +// bindgen-flags: --enable-cxx-namespaces --allowlist-type Rooted template class Rooted { diff --git a/tests/headers/issue-801-opaque-sloppiness.hpp b/tests/headers/issue-801-opaque-sloppiness.hpp index 678586342e..6b707f4ede 100644 --- a/tests/headers/issue-801-opaque-sloppiness.hpp +++ b/tests/headers/issue-801-opaque-sloppiness.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --opaque-type "B" --whitelist-type "C" --with-derive-hash --with-derive-partialeq --with-derive-eq +// bindgen-flags: --opaque-type "B" --allowlist-type "C" --with-derive-hash --with-derive-partialeq --with-derive-eq class A; diff --git a/tests/headers/issue-807-opaque-types-methods-being-generated.hpp b/tests/headers/issue-807-opaque-types-methods-being-generated.hpp index 91f221ce23..de98b32a15 100644 --- a/tests/headers/issue-807-opaque-types-methods-being-generated.hpp +++ b/tests/headers/issue-807-opaque-types-methods-being-generated.hpp @@ -1,12 +1,12 @@ -// bindgen-flags: --whitelist-type Whitelisted --opaque-type Opaque --with-derive-hash --with-derive-partialeq --with-derive-eq -- -std=c++11 +// bindgen-flags: --allowlist-type Allowlisted --opaque-type Opaque --with-derive-hash --with-derive-partialeq --with-derive-eq -- -std=c++11 -// These types are not explicitly whitelisted, but are reachable through the +// These types are not explicitly allowlisted, but are reachable through the // opaque type. class Pupper {}; class Doggo {}; class SuchWow {}; -// These types are not whitelisted, and would be reachable through `Opaque` if +// These types are not allowlisted, and would be reachable through `Opaque` if // it were not marked opaque, but since it is, there should be no bindings // generated for them. class NoBindingsShouldBeGeneratedForMe1 {}; @@ -31,6 +31,6 @@ class Opaque SuchWow eleven_out_of_ten(); }; -class Whitelisted { +class Allowlisted { Opaque some_member; }; diff --git a/tests/headers/issue-833-1.hpp b/tests/headers/issue-833-1.hpp index 30bf85f2d0..d66ee01fa7 100644 --- a/tests/headers/issue-833-1.hpp +++ b/tests/headers/issue-833-1.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --generate functions --whitelist-function func --raw-line "#[repr(C)] pub struct nsTArray { pub hdr: *const () }" +// bindgen-flags: --generate functions --allowlist-function func --raw-line "#[repr(C)] pub struct nsTArray { pub hdr: *const () }" template class nsTArray { diff --git a/tests/headers/issue-833.hpp b/tests/headers/issue-833.hpp index ea0d2add71..f8b708bf16 100644 --- a/tests/headers/issue-833.hpp +++ b/tests/headers/issue-833.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --generate functions --whitelist-function func --raw-line "#[repr(C)] pub struct nsTArray { pub hdr: *const T }" +// bindgen-flags: --generate functions --allowlist-function func --raw-line "#[repr(C)] pub struct nsTArray { pub hdr: *const T }" template class nsTArray { diff --git a/tests/headers/issue-834.hpp b/tests/headers/issue-834.hpp index c06e89fdb4..6479701262 100644 --- a/tests/headers/issue-834.hpp +++ b/tests/headers/issue-834.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --whitelist-type U --generate types +// bindgen-flags: --allowlist-type U --generate types struct T {}; struct U { diff --git a/tests/headers/issue-944-derive-copy-and-blacklisting.hpp b/tests/headers/issue-944-derive-copy-and-blacklisting.hpp deleted file mode 100644 index 657e0d849f..0000000000 --- a/tests/headers/issue-944-derive-copy-and-blacklisting.hpp +++ /dev/null @@ -1,10 +0,0 @@ -// bindgen-flags: --blacklist-type BlacklistMe --raw-line 'pub struct BlacklistMe(u8);' - -struct BlacklistMe {}; - -/** - * Because this type contains a blacklisted type, it should not derive Copy. - */ -struct ShouldNotBeCopy { - BlacklistMe a; -}; diff --git a/tests/headers/issue-944-derive-copy-and-blocklisting.hpp b/tests/headers/issue-944-derive-copy-and-blocklisting.hpp new file mode 100644 index 0000000000..5e94dfabd4 --- /dev/null +++ b/tests/headers/issue-944-derive-copy-and-blocklisting.hpp @@ -0,0 +1,10 @@ +// bindgen-flags: --blocklist-type BlocklistMe --raw-line 'pub struct BlocklistMe(u8);' + +struct BlocklistMe {}; + +/** + * Because this type contains a blocklisted type, it should not derive Copy. + */ +struct ShouldNotBeCopy { + BlocklistMe a; +}; diff --git a/tests/headers/maddness-is-avoidable.hpp b/tests/headers/maddness-is-avoidable.hpp index 46d7495ead..47a7ffbfac 100644 --- a/tests/headers/maddness-is-avoidable.hpp +++ b/tests/headers/maddness-is-avoidable.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --blacklist-type RefPtr_Proxy_member_function +// bindgen-flags: --blocklist-type RefPtr_Proxy_member_function template class RefPtr { diff --git a/tests/headers/module-whitelisted.hpp b/tests/headers/module-allowlisted.hpp similarity index 100% rename from tests/headers/module-whitelisted.hpp rename to tests/headers/module-allowlisted.hpp diff --git a/tests/headers/no-derive-debug.h b/tests/headers/no-derive-debug.h index c780d2d8f8..d11ca0ad92 100644 --- a/tests/headers/no-derive-debug.h +++ b/tests/headers/no-derive-debug.h @@ -1,11 +1,11 @@ -// bindgen-flags: --no-derive-debug --blacklist-type foo --raw-line "#[repr(C)] #[derive(Copy, Clone, Default)] pub struct foo { bar: ::std::os::raw::c_int, }" +// bindgen-flags: --no-derive-debug --blocklist-type foo --raw-line "#[repr(C)] #[derive(Copy, Clone, Default)] pub struct foo { bar: ::std::os::raw::c_int, }" struct foo { int bar; }; /** - * bar should compile. It will normally derive debug, but our blacklist of foo + * bar should compile. It will normally derive debug, but our blocklist of foo * and replacement for another type that doesn't implement it would prevent it * from building if --no-derive-debug didn't work. */ diff --git a/tests/headers/no-derive-default.h b/tests/headers/no-derive-default.h index 207b93b62f..d184ee3a98 100644 --- a/tests/headers/no-derive-default.h +++ b/tests/headers/no-derive-default.h @@ -1,11 +1,11 @@ -// bindgen-flags: --no-derive-default --blacklist-type foo --raw-line "#[repr(C)] #[derive(Copy, Clone, Debug)] pub struct foo { bar: ::std::os::raw::c_int, }" +// bindgen-flags: --no-derive-default --blocklist-type foo --raw-line "#[repr(C)] #[derive(Copy, Clone, Debug)] pub struct foo { bar: ::std::os::raw::c_int, }" struct foo { int bar; }; /** - * bar should compile. It will normally derive default, but our blacklist of foo + * bar should compile. It will normally derive default, but our blocklist of foo * and replacement for another type that doesn't implement it would prevent it * from building if --no-derive-default didn't work. */ diff --git a/tests/headers/no-hash-allowlisted.hpp b/tests/headers/no-hash-allowlisted.hpp new file mode 100644 index 0000000000..0f60817da6 --- /dev/null +++ b/tests/headers/no-hash-allowlisted.hpp @@ -0,0 +1,5 @@ +// bindgen-flags: --with-derive-hash --allowlist-type "NoHash" --no-hash "NoHash" + +class NoHash { + int i; +}; diff --git a/tests/headers/no-hash-whitelisted.hpp b/tests/headers/no-hash-whitelisted.hpp deleted file mode 100644 index 77c9086438..0000000000 --- a/tests/headers/no-hash-whitelisted.hpp +++ /dev/null @@ -1,5 +0,0 @@ -// bindgen-flags: --with-derive-hash --whitelist-type "NoHash" --no-hash "NoHash" - -class NoHash { - int i; -}; diff --git a/tests/headers/no-partialeq-whitelisted.hpp b/tests/headers/no-partialeq-allowlisted.hpp similarity index 52% rename from tests/headers/no-partialeq-whitelisted.hpp rename to tests/headers/no-partialeq-allowlisted.hpp index dba4e91f76..ced1b42a7b 100644 --- a/tests/headers/no-partialeq-whitelisted.hpp +++ b/tests/headers/no-partialeq-allowlisted.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-partialeq --whitelist-type "NoPartialEq" --no-partialeq "NoPartialEq" +// bindgen-flags: --with-derive-partialeq --allowlist-type "NoPartialEq" --no-partialeq "NoPartialEq" class NoPartialEq { int i; diff --git a/tests/headers/no-recursive-whitelisting.h b/tests/headers/no-recursive-allowlisting.h similarity index 61% rename from tests/headers/no-recursive-whitelisting.h rename to tests/headers/no-recursive-allowlisting.h index c94cc491eb..1c6617110b 100644 --- a/tests/headers/no-recursive-whitelisting.h +++ b/tests/headers/no-recursive-allowlisting.h @@ -1,4 +1,4 @@ -// bindgen-flags: --no-recursive-whitelist --whitelist-type "Foo" --raw-line "pub enum Bar {}" --rustified-enum ".*" +// bindgen-flags: --no-recursive-allowlist --allowlist-type "Foo" --raw-line "pub enum Bar {}" --rustified-enum ".*" struct Bar; diff --git a/tests/headers/no_copy_allowlisted.hpp b/tests/headers/no_copy_allowlisted.hpp new file mode 100644 index 0000000000..f3b922cae1 --- /dev/null +++ b/tests/headers/no_copy_allowlisted.hpp @@ -0,0 +1,5 @@ +// bindgen-flags: --allowlist-type "NoCopy" --no-copy "NoCopy" + +class NoCopy { + int i; +}; diff --git a/tests/headers/no_copy_whitelisted.hpp b/tests/headers/no_copy_whitelisted.hpp deleted file mode 100644 index db44a8a7eb..0000000000 --- a/tests/headers/no_copy_whitelisted.hpp +++ /dev/null @@ -1,5 +0,0 @@ -// bindgen-flags: --whitelist-type "NoCopy" --no-copy "NoCopy" - -class NoCopy { - int i; -}; diff --git a/tests/headers/no_debug_allowlisted.hpp b/tests/headers/no_debug_allowlisted.hpp new file mode 100644 index 0000000000..3e3633e475 --- /dev/null +++ b/tests/headers/no_debug_allowlisted.hpp @@ -0,0 +1,5 @@ +// bindgen-flags: --allowlist-type "NoDebug" --no-debug "NoDebug" + +class NoDebug { + int i; +}; diff --git a/tests/headers/no_debug_whitelisted.hpp b/tests/headers/no_debug_whitelisted.hpp deleted file mode 100644 index 7a855e8115..0000000000 --- a/tests/headers/no_debug_whitelisted.hpp +++ /dev/null @@ -1,5 +0,0 @@ -// bindgen-flags: --whitelist-type "NoDebug" --no-debug "NoDebug" - -class NoDebug { - int i; -}; diff --git a/tests/headers/no_default_allowlisted.hpp b/tests/headers/no_default_allowlisted.hpp new file mode 100644 index 0000000000..8a604081f7 --- /dev/null +++ b/tests/headers/no_default_allowlisted.hpp @@ -0,0 +1,5 @@ +// bindgen-flags: --allowlist-type "NoDefault" --no-default "NoDefault" + +class NoDefault { + int i; +}; diff --git a/tests/headers/no_default_whitelisted.hpp b/tests/headers/no_default_whitelisted.hpp deleted file mode 100644 index 12676be6d2..0000000000 --- a/tests/headers/no_default_whitelisted.hpp +++ /dev/null @@ -1,5 +0,0 @@ -// bindgen-flags: --whitelist-type "NoDefault" --no-default "NoDefault" - -class NoDefault { - int i; -}; diff --git a/tests/headers/objc_allowlist.h b/tests/headers/objc_allowlist.h new file mode 100644 index 0000000000..8c939960b0 --- /dev/null +++ b/tests/headers/objc_allowlist.h @@ -0,0 +1,24 @@ +// bindgen-flags: --objc-extern-crate --allowlist-type AllowlistMe --allowlist-type AllowlistMe_InterestingCategory -- -x objective-c +// bindgen-osx-only + + +// Protocol should be included, since it is used by the AllowlistMe +@protocol SomeProtocol +-(void)protocolMethod; ++(void)protocolClassMethod; +@end + +// The allowlisted item +@interface AllowlistMe +-(void)method; ++(void)classMethod; +@end + +// This was also explicitly allowlisted +@interface AllowlistMe (InterestingCategory) +@end + +// This was not automatically allowlisted +@interface AllowlistMe (IgnoredCategory) +@end + diff --git a/tests/headers/objc_whitelist.h b/tests/headers/objc_whitelist.h deleted file mode 100644 index 8a3bb86917..0000000000 --- a/tests/headers/objc_whitelist.h +++ /dev/null @@ -1,24 +0,0 @@ -// bindgen-flags: --objc-extern-crate --whitelist-type WhitelistMe --whitelist-type WhitelistMe_InterestingCategory -- -x objective-c -// bindgen-osx-only - - -// Protocol should be included, since it is used by the WhitelistMe -@protocol SomeProtocol --(void)protocolMethod; -+(void)protocolClassMethod; -@end - -// The whitelisted item -@interface WhitelistMe --(void)method; -+(void)classMethod; -@end - -// This was also explicitly whitelisted -@interface WhitelistMe (InterestingCategory) -@end - -// This was not automatically whitelisted -@interface WhitelistMe (IgnoredCategory) -@end - diff --git a/tests/headers/opaque-tracing.hpp b/tests/headers/opaque-tracing.hpp index 9f7319cccd..cf65276a68 100644 --- a/tests/headers/opaque-tracing.hpp +++ b/tests/headers/opaque-tracing.hpp @@ -1,8 +1,8 @@ -// bindgen-flags: --opaque-type ".*" --whitelist-function=foo --with-derive-hash --with-derive-partialeq --with-derive-eq +// bindgen-flags: --opaque-type ".*" --allowlist-function=foo --with-derive-hash --with-derive-partialeq --with-derive-eq class Container; -// The whitelist tracing should reach the Container type, even though it's +// The allowlist tracing should reach the Container type, even though it's // marked as opaque. void foo(Container* c); diff --git a/tests/headers/replaces_double.hpp b/tests/headers/replaces_double.hpp index 1a78b0d92b..ce6a8dbb45 100644 --- a/tests/headers/replaces_double.hpp +++ b/tests/headers/replaces_double.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --blacklist-type Wrapper -- --std=c++11 +// bindgen-flags: --blocklist-type Wrapper -- --std=c++11 template struct Wrapper { diff --git a/tests/headers/type-referenced-by-whitelisted-function.h b/tests/headers/type-referenced-by-allowlisted-function.h similarity index 59% rename from tests/headers/type-referenced-by-whitelisted-function.h rename to tests/headers/type-referenced-by-allowlisted-function.h index 86b0030300..bf675bc9a7 100644 --- a/tests/headers/type-referenced-by-whitelisted-function.h +++ b/tests/headers/type-referenced-by-allowlisted-function.h @@ -1,4 +1,4 @@ -// bindgen-flags: --whitelist-function dl_iterate_phdr +// bindgen-flags: --allowlist-function dl_iterate_phdr struct dl_phdr_info { int x; diff --git a/tests/headers/type_alias_empty.hpp b/tests/headers/type_alias_empty.hpp index f0760c8ffd..bcccc3c85e 100644 --- a/tests/headers/type_alias_empty.hpp +++ b/tests/headers/type_alias_empty.hpp @@ -1,6 +1,6 @@ -// bindgen-flags: --whitelist-type bool_constant -- -std=c++11 +// bindgen-flags: --allowlist-type bool_constant -- -std=c++11 -// NB: The --whitelist-type is done to trigger the traversal of the types on +// NB: The --allowlist-type is done to trigger the traversal of the types on // codegen in order to trigger #67. template diff --git a/tests/headers/type_alias_template_specialized.hpp b/tests/headers/type_alias_template_specialized.hpp index a2d32b56a1..f7403a36d0 100644 --- a/tests/headers/type_alias_template_specialized.hpp +++ b/tests/headers/type_alias_template_specialized.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --whitelist-type Rooted -- -std=c++14 +// bindgen-flags: --allowlist-type Rooted -- -std=c++14 template using MaybeWrapped = a; class Rooted { diff --git a/tests/headers/var-tracing.hpp b/tests/headers/var-tracing.hpp index 0d0b0ccac2..ef002a00f5 100644 --- a/tests/headers/var-tracing.hpp +++ b/tests/headers/var-tracing.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --whitelist-type Baz +// bindgen-flags: --allowlist-type Baz struct Bar { const int m_baz; diff --git a/tests/headers/whitelisted-item-references-no-hash.hpp b/tests/headers/whitelisted-item-references-no-hash.hpp deleted file mode 100644 index e656d32d0e..0000000000 --- a/tests/headers/whitelisted-item-references-no-hash.hpp +++ /dev/null @@ -1,7 +0,0 @@ -// bindgen-flags: --with-derive-hash --whitelist-type "WhitelistMe" --no-hash "NoHash" - -struct NoHash {}; - -class WhitelistMe { - NoHash a; -}; diff --git a/tests/headers/whitelisted-item-references-no-partialeq.hpp b/tests/headers/whitelisted-item-references-no-partialeq.hpp deleted file mode 100644 index d9d3d4311f..0000000000 --- a/tests/headers/whitelisted-item-references-no-partialeq.hpp +++ /dev/null @@ -1,7 +0,0 @@ -// bindgen-flags: --with-derive-partialeq --whitelist-type "WhitelistMe" --no-partialeq "NoPartialEq" - -struct NoPartialEq {}; - -class WhitelistMe { - NoPartialEq a; -}; diff --git a/tests/headers/whitelisted_item_references_no_copy.hpp b/tests/headers/whitelisted_item_references_no_copy.hpp deleted file mode 100644 index 755bbbdd49..0000000000 --- a/tests/headers/whitelisted_item_references_no_copy.hpp +++ /dev/null @@ -1,7 +0,0 @@ -// bindgen-flags: --whitelist-type "WhitelistMe" --no-copy "NoCopy" - -struct NoCopy {}; - -class WhitelistMe { - NoCopy a; -}; diff --git a/tests/stylo.hpp b/tests/stylo.hpp index d6eabc3542..8810290365 100644 --- a/tests/stylo.hpp +++ b/tests/stylo.hpp @@ -103701,7 +103701,7 @@ class nsIExpandedPrincipal : public nsISupports { template struct COMTypeInfo; - virtual nsresult GetWhiteList(nsTArray > **aWhiteList) = 0; + virtual nsresult GetAllowList(nsTArray > **anAllowList) = 0; }; diff --git a/tests/stylo_sanity.rs b/tests/stylo_sanity.rs index 88d87adbf2..2ea77628a0 100755 --- a/tests/stylo_sanity.rs +++ b/tests/stylo_sanity.rs @@ -30,209 +30,209 @@ fn sanity_check_can_generate_stylo_bindings() { .time_phases(true) .disable_header_comment() .header(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/stylo.hpp")) - .whitelist_function("Servo_.*") - .whitelist_function("Gecko_.*") - .blacklist_type("nsACString_internal") - .blacklist_type("nsAString_internal") - .blacklist_type("mozilla::css::URLValue") - .blacklist_type("RawGeckoAnimationPropertySegment") - .blacklist_type("RawGeckoComputedTiming") - .blacklist_type("RawGeckoDocument") - .blacklist_type("RawGeckoElement") - .blacklist_type("RawGeckoKeyframeList") - .blacklist_type("RawGeckoComputedKeyframeValuesList") - .blacklist_type("RawGeckoFontFaceRuleList") - .blacklist_type("RawGeckoNode") - .blacklist_type("RawGeckoAnimationValueList") - .blacklist_type("RawServoAnimationValue") - .blacklist_type("RawServoAnimationValueMap") - .blacklist_type("RawServoDeclarationBlock") - .blacklist_type("RawGeckoPresContext") - .blacklist_type("RawGeckoPresContextOwned") - .blacklist_type("RawGeckoStyleAnimationList") - .blacklist_type("RawGeckoURLExtraData") - .blacklist_type("RefPtr") - .blacklist_type("CSSPseudoClassType") - .blacklist_type("TraversalRootBehavior") - .blacklist_type("ComputedTimingFunction_BeforeFlag") - .blacklist_type("FontFamilyList") - .blacklist_type("FontFamilyType") - .blacklist_type("Keyframe") - .blacklist_type("ServoBundledURI") - .blacklist_type("ServoElementSnapshot") - .blacklist_type("SheetParsingMode") - .blacklist_type("StyleBasicShape") - .blacklist_type("StyleBasicShapeType") - .blacklist_type("StyleShapeSource") - .blacklist_type("nsCSSFontFaceRule") - .blacklist_type("nsCSSKeyword") - .blacklist_type("nsCSSPropertyID") - .blacklist_type("nsCSSShadowArray") - .blacklist_type("nsCSSUnit") - .blacklist_type("nsCSSValue") - .blacklist_type("nsCSSValueSharedList") - .blacklist_type("nsChangeHint") - .blacklist_type("nsCursorImage") - .blacklist_type("nsFont") - .blacklist_type("nsIAtom") - .blacklist_type("nsMediaFeature") - .blacklist_type("nsRestyleHint") - .blacklist_type("nsStyleBackground") - .blacklist_type("nsStyleBorder") - .blacklist_type("nsStyleColor") - .blacklist_type("nsStyleColumn") - .blacklist_type("nsStyleContent") - .blacklist_type("nsStyleContentData") - .blacklist_type("nsStyleContentType") - .blacklist_type("nsStyleContext") - .blacklist_type("nsStyleCoord") - .blacklist_type("nsStyleCoord_Calc") - .blacklist_type("nsStyleCoord_CalcValue") - .blacklist_type("nsStyleDisplay") - .blacklist_type("nsStyleEffects") - .blacklist_type("nsStyleFilter") - .blacklist_type("nsStyleFont") - .blacklist_type("nsStyleGradient") - .blacklist_type("nsStyleGradientStop") - .blacklist_type("nsStyleImage") - .blacklist_type("nsStyleImageLayers") - .blacklist_type("nsStyleImageLayers_Layer") - .blacklist_type("nsStyleImageLayers_LayerType") - .blacklist_type("nsStyleImageRequest") - .blacklist_type("nsStyleList") - .blacklist_type("nsStyleMargin") - .blacklist_type("nsStyleOutline") - .blacklist_type("nsStylePadding") - .blacklist_type("nsStylePosition") - .blacklist_type("nsStyleQuoteValues") - .blacklist_type("nsStyleSVG") - .blacklist_type("nsStyleSVGPaint") - .blacklist_type("nsStyleSVGReset") - .blacklist_type("nsStyleTable") - .blacklist_type("nsStyleTableBorder") - .blacklist_type("nsStyleText") - .blacklist_type("nsStyleTextReset") - .blacklist_type("nsStyleUIReset") - .blacklist_type("nsStyleUnion") - .blacklist_type("nsStyleUnit") - .blacklist_type("nsStyleUserInterface") - .blacklist_type("nsStyleVariables") - .blacklist_type("nsStyleVisibility") - .blacklist_type("nsStyleXUL") - .blacklist_type("nsTimingFunction") - .blacklist_type("nscolor") - .blacklist_type("nscoord") - .blacklist_type("nsresult") - .blacklist_type("Loader") - .blacklist_type("ServoStyleSheet") - .blacklist_type("EffectCompositor_CascadeLevel") - .blacklist_type("UpdateAnimationsTasks") - .blacklist_type("nsTArrayBorrowed_uintptr_t") - .blacklist_type("ServoCssRulesStrong") - .blacklist_type("ServoCssRulesBorrowed") - .blacklist_type("ServoCssRulesBorrowedOrNull") - .blacklist_type("ServoCssRules") - .blacklist_type("RawServoStyleSheetStrong") - .blacklist_type("RawServoStyleSheetBorrowed") - .blacklist_type("RawServoStyleSheetBorrowedOrNull") - .blacklist_type("RawServoStyleSheet") - .blacklist_type("ServoComputedValuesStrong") - .blacklist_type("ServoComputedValuesBorrowed") - .blacklist_type("ServoComputedValuesBorrowedOrNull") - .blacklist_type("ServoComputedValues") - .blacklist_type("RawServoDeclarationBlockStrong") - .blacklist_type("RawServoDeclarationBlockBorrowed") - .blacklist_type("RawServoDeclarationBlockBorrowedOrNull") - .blacklist_type("RawServoStyleRuleStrong") - .blacklist_type("RawServoStyleRuleBorrowed") - .blacklist_type("RawServoStyleRuleBorrowedOrNull") - .blacklist_type("RawServoStyleRule") - .blacklist_type("RawServoImportRuleStrong") - .blacklist_type("RawServoImportRuleBorrowed") - .blacklist_type("RawServoImportRuleBorrowedOrNull") - .blacklist_type("RawServoImportRule") - .blacklist_type("RawServoAnimationValueStrong") - .blacklist_type("RawServoAnimationValueBorrowed") - .blacklist_type("RawServoAnimationValueBorrowedOrNull") - .blacklist_type("RawServoAnimationValueMapStrong") - .blacklist_type("RawServoAnimationValueMapBorrowed") - .blacklist_type("RawServoAnimationValueMapBorrowedOrNull") - .blacklist_type("RawServoMediaListStrong") - .blacklist_type("RawServoMediaListBorrowed") - .blacklist_type("RawServoMediaListBorrowedOrNull") - .blacklist_type("RawServoMediaList") - .blacklist_type("RawServoMediaRuleStrong") - .blacklist_type("RawServoMediaRuleBorrowed") - .blacklist_type("RawServoMediaRuleBorrowedOrNull") - .blacklist_type("RawServoMediaRule") - .blacklist_type("RawServoNamespaceRuleStrong") - .blacklist_type("RawServoNamespaceRuleBorrowed") - .blacklist_type("RawServoNamespaceRuleBorrowedOrNull") - .blacklist_type("RawServoNamespaceRule") - .blacklist_type("RawServoStyleSetOwned") - .blacklist_type("RawServoStyleSetOwnedOrNull") - .blacklist_type("RawServoStyleSetBorrowed") - .blacklist_type("RawServoStyleSetBorrowedOrNull") - .blacklist_type("RawServoStyleSetBorrowedMut") - .blacklist_type("RawServoStyleSetBorrowedMutOrNull") - .blacklist_type("RawServoStyleSet") - .blacklist_type("StyleChildrenIteratorOwned") - .blacklist_type("StyleChildrenIteratorOwnedOrNull") - .blacklist_type("StyleChildrenIteratorBorrowed") - .blacklist_type("StyleChildrenIteratorBorrowedOrNull") - .blacklist_type("StyleChildrenIteratorBorrowedMut") - .blacklist_type("StyleChildrenIteratorBorrowedMutOrNull") - .blacklist_type("StyleChildrenIterator") - .blacklist_type("ServoElementSnapshotOwned") - .blacklist_type("ServoElementSnapshotOwnedOrNull") - .blacklist_type("ServoElementSnapshotBorrowed") - .blacklist_type("ServoElementSnapshotBorrowedOrNull") - .blacklist_type("ServoElementSnapshotBorrowedMut") - .blacklist_type("ServoElementSnapshotBorrowedMutOrNull") - .blacklist_type("RawGeckoNodeBorrowed") - .blacklist_type("RawGeckoNodeBorrowedOrNull") - .blacklist_type("RawGeckoElementBorrowed") - .blacklist_type("RawGeckoElementBorrowedOrNull") - .blacklist_type("RawGeckoDocumentBorrowed") - .blacklist_type("RawGeckoDocumentBorrowedOrNull") - .blacklist_type("RawServoDeclarationBlockStrongBorrowed") - .blacklist_type("RawServoDeclarationBlockStrongBorrowedOrNull") - .blacklist_type("RawGeckoPresContextBorrowed") - .blacklist_type("RawGeckoPresContextBorrowedOrNull") - .blacklist_type("RawGeckoStyleAnimationListBorrowed") - .blacklist_type("RawGeckoStyleAnimationListBorrowedOrNull") - .blacklist_type("nsCSSValueBorrowed") - .blacklist_type("nsCSSValueBorrowedOrNull") - .blacklist_type("nsCSSValueBorrowedMut") - .blacklist_type("nsCSSValueBorrowedMutOrNull") - .blacklist_type("nsTimingFunctionBorrowed") - .blacklist_type("nsTimingFunctionBorrowedOrNull") - .blacklist_type("nsTimingFunctionBorrowedMut") - .blacklist_type("nsTimingFunctionBorrowedMutOrNull") - .blacklist_type("RawGeckoAnimationPropertySegmentBorrowed") - .blacklist_type("RawGeckoAnimationPropertySegmentBorrowedOrNull") - .blacklist_type("RawGeckoAnimationPropertySegmentBorrowedMut") - .blacklist_type("RawGeckoAnimationPropertySegmentBorrowedMutOrNull") - .blacklist_type("RawGeckoAnimationValueListBorrowed") - .blacklist_type("RawGeckoAnimationValueListBorrowedOrNull") - .blacklist_type("RawGeckoAnimationValueListBorrowedMut") - .blacklist_type("RawGeckoAnimationValueListBorrowedMutOrNull") - .blacklist_type("RawGeckoComputedTimingBorrowed") - .blacklist_type("RawGeckoComputedTimingBorrowedOrNull") - .blacklist_type("RawGeckoComputedTimingBorrowedMut") - .blacklist_type("RawGeckoComputedTimingBorrowedMutOrNull") - .blacklist_type("RawGeckoKeyframeListBorrowed") - .blacklist_type("RawGeckoKeyframeListBorrowedOrNull") - .blacklist_type("RawGeckoKeyframeListBorrowedMut") - .blacklist_type("RawGeckoKeyframeListBorrowedMutOrNull") - .blacklist_type("RawGeckoComputedKeyframeValuesListBorrowed") - .blacklist_type("RawGeckoComputedKeyframeValuesListBorrowedOrNull") - .blacklist_type("RawGeckoComputedKeyframeValuesListBorrowedMut") - .blacklist_type("RawGeckoComputedKeyframeValuesListBorrowedMutOrNull") - .blacklist_type("RawGeckoFontFaceRuleListBorrowed") - .blacklist_type("RawGeckoFontFaceRuleListBorrowedOrNull") - .blacklist_type("RawGeckoFontFaceRuleListBorrowedMut") - .blacklist_type("RawGeckoFontFaceRuleListBorrowedMutOrNull") + .allowlist_function("Servo_.*") + .allowlist_function("Gecko_.*") + .blocklist_type("nsACString_internal") + .blocklist_type("nsAString_internal") + .blocklist_type("mozilla::css::URLValue") + .blocklist_type("RawGeckoAnimationPropertySegment") + .blocklist_type("RawGeckoComputedTiming") + .blocklist_type("RawGeckoDocument") + .blocklist_type("RawGeckoElement") + .blocklist_type("RawGeckoKeyframeList") + .blocklist_type("RawGeckoComputedKeyframeValuesList") + .blocklist_type("RawGeckoFontFaceRuleList") + .blocklist_type("RawGeckoNode") + .blocklist_type("RawGeckoAnimationValueList") + .blocklist_type("RawServoAnimationValue") + .blocklist_type("RawServoAnimationValueMap") + .blocklist_type("RawServoDeclarationBlock") + .blocklist_type("RawGeckoPresContext") + .blocklist_type("RawGeckoPresContextOwned") + .blocklist_type("RawGeckoStyleAnimationList") + .blocklist_type("RawGeckoURLExtraData") + .blocklist_type("RefPtr") + .blocklist_type("CSSPseudoClassType") + .blocklist_type("TraversalRootBehavior") + .blocklist_type("ComputedTimingFunction_BeforeFlag") + .blocklist_type("FontFamilyList") + .blocklist_type("FontFamilyType") + .blocklist_type("Keyframe") + .blocklist_type("ServoBundledURI") + .blocklist_type("ServoElementSnapshot") + .blocklist_type("SheetParsingMode") + .blocklist_type("StyleBasicShape") + .blocklist_type("StyleBasicShapeType") + .blocklist_type("StyleShapeSource") + .blocklist_type("nsCSSFontFaceRule") + .blocklist_type("nsCSSKeyword") + .blocklist_type("nsCSSPropertyID") + .blocklist_type("nsCSSShadowArray") + .blocklist_type("nsCSSUnit") + .blocklist_type("nsCSSValue") + .blocklist_type("nsCSSValueSharedList") + .blocklist_type("nsChangeHint") + .blocklist_type("nsCursorImage") + .blocklist_type("nsFont") + .blocklist_type("nsIAtom") + .blocklist_type("nsMediaFeature") + .blocklist_type("nsRestyleHint") + .blocklist_type("nsStyleBackground") + .blocklist_type("nsStyleBorder") + .blocklist_type("nsStyleColor") + .blocklist_type("nsStyleColumn") + .blocklist_type("nsStyleContent") + .blocklist_type("nsStyleContentData") + .blocklist_type("nsStyleContentType") + .blocklist_type("nsStyleContext") + .blocklist_type("nsStyleCoord") + .blocklist_type("nsStyleCoord_Calc") + .blocklist_type("nsStyleCoord_CalcValue") + .blocklist_type("nsStyleDisplay") + .blocklist_type("nsStyleEffects") + .blocklist_type("nsStyleFilter") + .blocklist_type("nsStyleFont") + .blocklist_type("nsStyleGradient") + .blocklist_type("nsStyleGradientStop") + .blocklist_type("nsStyleImage") + .blocklist_type("nsStyleImageLayers") + .blocklist_type("nsStyleImageLayers_Layer") + .blocklist_type("nsStyleImageLayers_LayerType") + .blocklist_type("nsStyleImageRequest") + .blocklist_type("nsStyleList") + .blocklist_type("nsStyleMargin") + .blocklist_type("nsStyleOutline") + .blocklist_type("nsStylePadding") + .blocklist_type("nsStylePosition") + .blocklist_type("nsStyleQuoteValues") + .blocklist_type("nsStyleSVG") + .blocklist_type("nsStyleSVGPaint") + .blocklist_type("nsStyleSVGReset") + .blocklist_type("nsStyleTable") + .blocklist_type("nsStyleTableBorder") + .blocklist_type("nsStyleText") + .blocklist_type("nsStyleTextReset") + .blocklist_type("nsStyleUIReset") + .blocklist_type("nsStyleUnion") + .blocklist_type("nsStyleUnit") + .blocklist_type("nsStyleUserInterface") + .blocklist_type("nsStyleVariables") + .blocklist_type("nsStyleVisibility") + .blocklist_type("nsStyleXUL") + .blocklist_type("nsTimingFunction") + .blocklist_type("nscolor") + .blocklist_type("nscoord") + .blocklist_type("nsresult") + .blocklist_type("Loader") + .blocklist_type("ServoStyleSheet") + .blocklist_type("EffectCompositor_CascadeLevel") + .blocklist_type("UpdateAnimationsTasks") + .blocklist_type("nsTArrayBorrowed_uintptr_t") + .blocklist_type("ServoCssRulesStrong") + .blocklist_type("ServoCssRulesBorrowed") + .blocklist_type("ServoCssRulesBorrowedOrNull") + .blocklist_type("ServoCssRules") + .blocklist_type("RawServoStyleSheetStrong") + .blocklist_type("RawServoStyleSheetBorrowed") + .blocklist_type("RawServoStyleSheetBorrowedOrNull") + .blocklist_type("RawServoStyleSheet") + .blocklist_type("ServoComputedValuesStrong") + .blocklist_type("ServoComputedValuesBorrowed") + .blocklist_type("ServoComputedValuesBorrowedOrNull") + .blocklist_type("ServoComputedValues") + .blocklist_type("RawServoDeclarationBlockStrong") + .blocklist_type("RawServoDeclarationBlockBorrowed") + .blocklist_type("RawServoDeclarationBlockBorrowedOrNull") + .blocklist_type("RawServoStyleRuleStrong") + .blocklist_type("RawServoStyleRuleBorrowed") + .blocklist_type("RawServoStyleRuleBorrowedOrNull") + .blocklist_type("RawServoStyleRule") + .blocklist_type("RawServoImportRuleStrong") + .blocklist_type("RawServoImportRuleBorrowed") + .blocklist_type("RawServoImportRuleBorrowedOrNull") + .blocklist_type("RawServoImportRule") + .blocklist_type("RawServoAnimationValueStrong") + .blocklist_type("RawServoAnimationValueBorrowed") + .blocklist_type("RawServoAnimationValueBorrowedOrNull") + .blocklist_type("RawServoAnimationValueMapStrong") + .blocklist_type("RawServoAnimationValueMapBorrowed") + .blocklist_type("RawServoAnimationValueMapBorrowedOrNull") + .blocklist_type("RawServoMediaListStrong") + .blocklist_type("RawServoMediaListBorrowed") + .blocklist_type("RawServoMediaListBorrowedOrNull") + .blocklist_type("RawServoMediaList") + .blocklist_type("RawServoMediaRuleStrong") + .blocklist_type("RawServoMediaRuleBorrowed") + .blocklist_type("RawServoMediaRuleBorrowedOrNull") + .blocklist_type("RawServoMediaRule") + .blocklist_type("RawServoNamespaceRuleStrong") + .blocklist_type("RawServoNamespaceRuleBorrowed") + .blocklist_type("RawServoNamespaceRuleBorrowedOrNull") + .blocklist_type("RawServoNamespaceRule") + .blocklist_type("RawServoStyleSetOwned") + .blocklist_type("RawServoStyleSetOwnedOrNull") + .blocklist_type("RawServoStyleSetBorrowed") + .blocklist_type("RawServoStyleSetBorrowedOrNull") + .blocklist_type("RawServoStyleSetBorrowedMut") + .blocklist_type("RawServoStyleSetBorrowedMutOrNull") + .blocklist_type("RawServoStyleSet") + .blocklist_type("StyleChildrenIteratorOwned") + .blocklist_type("StyleChildrenIteratorOwnedOrNull") + .blocklist_type("StyleChildrenIteratorBorrowed") + .blocklist_type("StyleChildrenIteratorBorrowedOrNull") + .blocklist_type("StyleChildrenIteratorBorrowedMut") + .blocklist_type("StyleChildrenIteratorBorrowedMutOrNull") + .blocklist_type("StyleChildrenIterator") + .blocklist_type("ServoElementSnapshotOwned") + .blocklist_type("ServoElementSnapshotOwnedOrNull") + .blocklist_type("ServoElementSnapshotBorrowed") + .blocklist_type("ServoElementSnapshotBorrowedOrNull") + .blocklist_type("ServoElementSnapshotBorrowedMut") + .blocklist_type("ServoElementSnapshotBorrowedMutOrNull") + .blocklist_type("RawGeckoNodeBorrowed") + .blocklist_type("RawGeckoNodeBorrowedOrNull") + .blocklist_type("RawGeckoElementBorrowed") + .blocklist_type("RawGeckoElementBorrowedOrNull") + .blocklist_type("RawGeckoDocumentBorrowed") + .blocklist_type("RawGeckoDocumentBorrowedOrNull") + .blocklist_type("RawServoDeclarationBlockStrongBorrowed") + .blocklist_type("RawServoDeclarationBlockStrongBorrowedOrNull") + .blocklist_type("RawGeckoPresContextBorrowed") + .blocklist_type("RawGeckoPresContextBorrowedOrNull") + .blocklist_type("RawGeckoStyleAnimationListBorrowed") + .blocklist_type("RawGeckoStyleAnimationListBorrowedOrNull") + .blocklist_type("nsCSSValueBorrowed") + .blocklist_type("nsCSSValueBorrowedOrNull") + .blocklist_type("nsCSSValueBorrowedMut") + .blocklist_type("nsCSSValueBorrowedMutOrNull") + .blocklist_type("nsTimingFunctionBorrowed") + .blocklist_type("nsTimingFunctionBorrowedOrNull") + .blocklist_type("nsTimingFunctionBorrowedMut") + .blocklist_type("nsTimingFunctionBorrowedMutOrNull") + .blocklist_type("RawGeckoAnimationPropertySegmentBorrowed") + .blocklist_type("RawGeckoAnimationPropertySegmentBorrowedOrNull") + .blocklist_type("RawGeckoAnimationPropertySegmentBorrowedMut") + .blocklist_type("RawGeckoAnimationPropertySegmentBorrowedMutOrNull") + .blocklist_type("RawGeckoAnimationValueListBorrowed") + .blocklist_type("RawGeckoAnimationValueListBorrowedOrNull") + .blocklist_type("RawGeckoAnimationValueListBorrowedMut") + .blocklist_type("RawGeckoAnimationValueListBorrowedMutOrNull") + .blocklist_type("RawGeckoComputedTimingBorrowed") + .blocklist_type("RawGeckoComputedTimingBorrowedOrNull") + .blocklist_type("RawGeckoComputedTimingBorrowedMut") + .blocklist_type("RawGeckoComputedTimingBorrowedMutOrNull") + .blocklist_type("RawGeckoKeyframeListBorrowed") + .blocklist_type("RawGeckoKeyframeListBorrowedOrNull") + .blocklist_type("RawGeckoKeyframeListBorrowedMut") + .blocklist_type("RawGeckoKeyframeListBorrowedMutOrNull") + .blocklist_type("RawGeckoComputedKeyframeValuesListBorrowed") + .blocklist_type("RawGeckoComputedKeyframeValuesListBorrowedOrNull") + .blocklist_type("RawGeckoComputedKeyframeValuesListBorrowedMut") + .blocklist_type("RawGeckoComputedKeyframeValuesListBorrowedMutOrNull") + .blocklist_type("RawGeckoFontFaceRuleListBorrowed") + .blocklist_type("RawGeckoFontFaceRuleListBorrowedOrNull") + .blocklist_type("RawGeckoFontFaceRuleListBorrowedMut") + .blocklist_type("RawGeckoFontFaceRuleListBorrowedMutOrNull") .raw_line(r#"pub use nsstring::{nsACString, nsAString, nsString};"#) .raw_line(r#"type nsACString_internal = nsACString;"#) .raw_line(r#"type nsAString_internal = nsAString;"#)