Skip to content

allowlist entries like allowlist_function show no warning when they don't match anything. #2167

@noahgibbs

Description

@noahgibbs

It would be useful if bindgen printed a warning when allowlist_function, allowlist_type, allowlist_var and allowlist_file resulted in no symbols being matched. I know you can't always predict how many symbols are matched with a regexp. But presumably an allowlist entry exists to try to match something.

Right now it silently fails to emit a binding with no warning/error that can be checked for.

A similar warning for header() would also be nice.

(I apologise if there's an optional warning I could turn on. I haven't found one yet.)

Input C/C++ Header

int non_matched_function(int arg);

Bindgen Invocation

  let bindings = bindgen::builder()
    .header("foo.h")
    .allowlist_function("doesnt_match_anything")
    .generate()
    .expect("Unable to generate bindings");

  bindings.write_to_file("./bindings.inc.rs").expect("Couldn't write bindings!");

Actual Results

Bindings are correct (empty). But no warning message is shown.

Expected Results

A warning, such as "allowlist_function doesnt_match_anything matched no symbols!" and possibly "header file foo.h contained no matched symbols."

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions