Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: resolve path types for 'both' style #615

Closed
wants to merge 3 commits into from

Conversation

Wodann
Copy link
Contributor

@Wodann Wodann commented Nov 1, 2020

Potentially fixes #215.

Types of structs were not being resolved when the style was set to 'both', resulting in the struct keyword not being added to struct field types. This caused compiler errors complaining about missing forward declarations.

@Wodann
Copy link
Contributor Author

Wodann commented Nov 1, 2020

I couldn't test these changes locally because cargo test fails with the following error - even on latest:

test bin_explicit_release_build ... ok
test lib_explicit_release_build ... FAILED
test bin_default_uses_debug_build ... ok
test bin_explicit_debug_build ... ok
test lib_explicit_debug_build ... FAILED
test lib_default_uses_debug_build ... FAILED

---- lib_explicit_release_build stdout ----
thread 'lib_explicit_release_build' panicked at 'build should succeed: CargoExpand("expand-dep", Compile("   Compiling dep v0.1.0 (E:\\dev\\src\\rust\\cbindgen\\tests\\rust\\expand_dep\\dep)\n     Running `rustc --crate-name dep --edition=2018 dep\\src\\lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C embed-bitcode=no -C metadata=ac7708978d9e5b8b -C extra-filename=-ac7708978d9e5b8b --out-dir C:\\Users\\Remco\\AppData\\Local\\Temp\\cbindgen-test-output-RHdj9Z\\release\\deps -L dependency=C:\\Users\\Remco\\AppData\\Local\\Temp\\cbindgen-test-output-RHdj9Z\\release\\deps`\n   Compiling expand-dep v0.1.0 (E:\\dev\\src\\rust\\cbindgen\\tests\\rust\\expand_dep)\n     Running `rustc --crate-name expand_dep --edition=2018 src\\lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C embed-bitcode=no -Z unstable-options --pretty=expanded -C metadata=46e5aad5969eaffb -C extra-filename=-46e5aad5969eaffb --out-dir C:\\Users\\Remco\\AppData\\Local\\Temp\\cbindgen-test-output-RHdj9Z\\release\\deps -L dependency=C:\\Users\\Remco\\AppData\\Local\\Temp\\cbindgen-test-output-RHdj9Z\\release\\deps --extern dep=C:\\Users\\Remco\\AppData\\Local\\Temp\\cbindgen-test-output-RHdj9Z\\release\\deps\\libdep-ac7708978d9e5b8b.rmeta`\nerror: the option `Z` is only accepted on the nightly compiler\n\nerror: could not compile `expand-dep`.\n\nCaused by:\n  process didn\'t exit successfully: `rustc --crate-name expand_dep --edition=2018 src\\lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C embed-bitcode=no -Z unstable-options --pretty=expanded -C metadata=46e5aad5969eaffb -C extra-filename=-46e5aad5969eaffb --out-dir C:\\Users\\Remco\\AppData\\Local\\Temp\\cbindgen-test-output-RHdj9Z\\release\\deps -L dependency=C:\\Users\\Remco\\AppData\\Local\\Temp\\cbindgen-test-output-RHdj9Z\\release\\deps --extern dep=C:\\Users\\Remco\\AppData\\Local\\Temp\\cbindgen-test-output-RHdj9Z\\release\\deps\\libdep-ac7708978d9e5b8b.rmeta` (exit code: 1)\nwarning: build failed, waiting for other jobs to finish...\nerror: build failed\n"))', tests\profile.rs:25:24
stack backtrace:
   0:     0x7ff6395d8ab9 - std::backtrace_rs::backtrace::dbghelp::trace
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39\/library\std\src\..\..\backtrace\src\backtrace\dbghelp.rs:98
   1:     0x7ff6395d8ab9 - std::backtrace_rs::backtrace::trace_unsynchronized
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39\/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
   2:     0x7ff6395d8ab9 - std::sys_common::backtrace::_print_fmt
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39\/library\std\src\sys_common\backtrace.rs:79
   3:     0x7ff6395d8ab9 - std::sys_common::backtrace::_print::{{impl}}::fmt
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39\/library\std\src\sys_common\backtrace.rs:58
   4:     0x7ff6395f7cdb - core::fmt::write
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39\/library\core\src\fmt\mod.rs:1082
   5:     0x7ff6390f1d9c - std::io::Write::write_fmt<test::helpers::sink::Sink>
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39\library\std\src\io\mod.rs:1514
   6:     0x7ff6395d1248 - std::io::impls::{{impl}}::write_fmt<Write>
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39\/library\std\src\io\impls.rs:176
   7:     0x7ff6395dc2fb - std::sys_common::backtrace::_print
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39\/library\std\src\sys_common\backtrace.rs:61
   8:     0x7ff6395dc2fb - std::sys_common::backtrace::print
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39\/library\std\src\sys_common\backtrace.rs:48
   9:     0x7ff6395dc2fb - std::panicking::default_hook::{{closure}}
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39\/library\std\src\panicking.rs:200
  10:     0x7ff6395dbed8 - std::panicking::default_hook
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39\/library\std\src\panicking.rs:216
  11:     0x7ff6395dcadf - std::panicking::rust_panic_with_hook
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39\/library\std\src\panicking.rs:569
  12:     0x7ff6395dc645 - std::panicking::begin_panic_handler::{{closure}}
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39\/library\std\src\panicking.rs:476
  13:     0x7ff6395d936f - std::sys_common::backtrace::__rust_end_short_backtrace<closure-0,!>
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39\/library\std\src\sys_common\backtrace.rs:153
  14:     0x7ff6395dc5f9 - std::panicking::begin_panic_handler
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39\/library\std\src\panicking.rs:475
  15:     0x7ff6395f5a40 - core::panicking::panic_fmt
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39\/library\core\src\panicking.rs:85
  16:     0x7ff6395f5863 - core::option::expect_none_failed
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39\/library\core\src\option.rs:1221
  17:     0x7ff63907bb33 - core::result::Result<cbindgen::bindgen::bindings::Bindings, cbindgen::bindgen::error::Error>::expect<cbindgen::bindgen::bindings::Bindings,cbindgen::bindgen::error::Error>
                               at C:\Users\Remco\.rustup\toolchains\1.47.0-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\result.rs:933
  18:     0x7ff63907851a - profile::build_using_lib
                               at E:\dev\src\rust\cbindgen\tests\profile.rs:25
  19:     0x7ff6390e9139 - profile::lib_explicit_release_build::{{closure}}
                               at E:\dev\src\rust\cbindgen\tests\profile.rs:79
  20:     0x7ff6390456ab - core::ops::function::FnOnce::call_once<closure-0,tuple<>>
                               at C:\Users\Remco\.rustup\toolchains\1.47.0-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\ops\function.rs:227      
  21:     0x7ff63913e94e - serial_test::serial_core
                               at C:\Users\Remco\.cargo\registry\src\github.com-1ecc6299db9ec823\serial_test-0.5.0\src\lib.rs:64
  22:     0x7ff639078a5b - profile::lib_explicit_release_build
                               at E:\dev\src\rust\cbindgen\tests\profile.rs:77
  23:     0x7ff6390e907e - profile::lib_explicit_release_build::{{closure}}
                               at E:\dev\src\rust\cbindgen\tests\profile.rs:78
  24:     0x7ff63904584b - core::ops::function::FnOnce::call_once<closure-0,tuple<>>
                               at C:\Users\Remco\.rustup\toolchains\1.47.0-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\ops\function.rs:227      
  25:     0x7ff6391236f6 - core::ops::function::FnOnce::call_once
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39\library\core\src\ops\function.rs:227
  26:     0x7ff6391236f6 - test::__rust_begin_short_backtrace<fn()>
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39\/library\test\src\lib.rs:517
  27:     0x7ff639121041 - alloc::boxed::{{impl}}::call_once
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39\library\alloc\src\boxed.rs:1042
  28:     0x7ff639121041 - std::panic::{{impl}}::call_once
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39\library\std\src\panic.rs:308
  29:     0x7ff639121041 - std::panicking::try::do_call
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39\library\std\src\panicking.rs:373
  30:     0x7ff639121041 - std::panicking::try
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39\library\std\src\panicking.rs:337
  31:     0x7ff639121041 - std::panic::catch_unwind
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39\library\std\src\panic.rs:379
  32:     0x7ff639121041 - test::run_test_in_process
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39\/library\test\src\lib.rs:544
  33:     0x7ff639121041 - test::run_test::run_test_inner::{{closure}}
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39\/library\test\src\lib.rs:450
  34:     0x7ff6390f10e6 - std::sys_common::backtrace::__rust_begin_short_backtrace<closure-0,tuple<>>
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39\library\std\src\sys_common\backtrace.rs:137
  35:     0x7ff6390f10e6 - std::sys_common::backtrace::__rust_begin_short_backtrace<closure-0,tuple<>>
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39\library\std\src\sys_common\backtrace.rs:137
  36:     0x7ff6390f7f7e - std::thread::{{impl}}::spawn_unchecked::{{closure}}::{{closure}}
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39\library\std\src\thread\mod.rs:458
  37:     0x7ff6390f7f7e - std::panic::{{impl}}::call_once
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39\library\std\src\panic.rs:308
  38:     0x7ff6390f7f7e - std::panicking::try::do_call
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39\library\std\src\panicking.rs:373
  39:     0x7ff6390f7f7e - std::panicking::try
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39\library\std\src\panicking.rs:337
  40:     0x7ff6390f7f7e - std::panic::catch_unwind
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39\library\std\src\panic.rs:379
  41:     0x7ff6390f7f7e - std::thread::{{impl}}::spawn_unchecked::{{closure}}
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39\library\std\src\thread\mod.rs:457
  42:     0x7ff6390f7f7e - core::ops::function::FnOnce::call_once<closure-0,tuple<>>
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39\library\core\src\ops\function.rs:227
  43:     0x7ff6395e682a - alloc::boxed::{{impl}}::call_once
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39\library\alloc\src\boxed.rs:1042
  44:     0x7ff6395e682a - alloc::boxed::{{impl}}::call_once
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39\library\alloc\src\boxed.rs:1042
  45:     0x7ff6395e682a - std::sys::windows::thread::{{impl}}::new::thread_start
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39\/library\std\src\sys\windows\thread.rs:56
  46:     0x7ff9804e7034 - BaseThreadInitThunk
  47:     0x7ff9812fcec1 - RtlUserThreadStart

@Wodann
Copy link
Contributor Author

Wodann commented Nov 1, 2020

@eqrion @emilio is there an easy way of updating the expectations to include struct in struct field types for the 'both' style? Or should I manually update all of the .both files?

@emilio
Copy link
Collaborator

emilio commented Nov 1, 2020

Running cargo +nightly test should automatically update them. It might be that the tests introduced in #615 don't work on Windows. If you comment them out do the rest of the tests pass?

@emilio
Copy link
Collaborator

emilio commented Nov 1, 2020

Err, in #607 I mean.

@emilio
Copy link
Collaborator

emilio commented Nov 1, 2020

Here's a patch which updates the existing tests fwiw, though we also need a test for what this fixes... 0001-Test-updates.txt

@emilio
Copy link
Collaborator

emilio commented Nov 1, 2020

The fix looks sensible though, thanks for digging into it!

@Wodann
Copy link
Contributor Author

Wodann commented Nov 1, 2020

Running cargo +nightly test should automatically update them. It might be that the tests introduced in #615 don't work on Windows. If you comment them out do the rest of the tests pass?

Thanks; I am running on Windows. Those initial tests pass when I use that command but all other test fail due invalid paths:

---- test_workspace stdout ----
Running: "E:\\dev\\src\\rust\\cbindgen\\target\\debug\\cbindgen" "--lang" "c" "--cpp-compat" "--style" "type" "E:\\dev\\src\\rust\\cbindgen\\tests\\rust\\workspace"
Running: "gcc" "-D" "DEFINED" "-I" "E:\\dev\\src\\rust\\cbindgen\\tests" "-Wall" "-Werror" "-Wno-attributes" "-Wno-unused-const-variable" "-Wno-return-type-c-linkage" "-D" "CBINDGEN_STYLE_TYPE" "-o" "C:\\Users\\Remco\\AppData\\Local\\Temp\\cbindgen-test-outputQDc2OQ\\workspace.compat.o" "-c" "E:\\dev\\src\\rust\\cbindgen\\tests\\expectations\\workspace.compat.c"
thread 'test_workspace' panicked at 'failed to compile: Os { code: 2, kind: NotFound, message: "The system cannot find the file specified." }', tests\tests.rs:121:32

Here's a patch which updates the existing tests fwiw, though we also need a test for what this fixes... 0001-Test-updates.txt

Thanks for the patch. That makes life a lot easier 🙂

I'll add a test with an incomplete type. Currently it will never work for the tag style though. Can I exclude that test-case, or is that an issue?

@emilio
Copy link
Collaborator

emilio commented Nov 2, 2020

Thanks; I am running on Windows. Those initial tests pass when I use that command but all other test fail due invalid paths:

It seems you don't have gcc in your path, if you have clang or another compiler in the path you could do CC=clang CXX=clang++ cargo +nightly test or such, for example.

@Wodann
Copy link
Contributor Author

Wodann commented Nov 2, 2020

Thanks. I fixed my WSL2 and was able to get cargo +nightly test to work.

It seems that some expectations were missing; even before my changes. I added those, and will make sure to add an additional test for forward declarations tomorrow.

@Wodann
Copy link
Contributor Author

Wodann commented Nov 5, 2020

I've added a forward_declaration.rs test, but it will always fail for the Style::Type and C++ test (which defaults to Style::Type it seems).

I don't think the Style::Type can ever work with forward declarations, because there is no struct name. How would you recommend I proceed? Should I add functionality for specifying which styles to run a test for?

Also, it seems that the style option is broken; i.e. it does not actually default to Both, even though the docs say so:

# Codegen Options

# When generating a C header, the kind of declaration style to use for structs
# or enums.
#
# possible values:
# * "type": typedef struct { ... } MyType;
# * "tag": struct MyType { ... };
# * "both": typedef struct MyType { ... } MyType;
#
# default: "both"
style = "both"

@@ -0,0 +1,40 @@
#if defined(CBINDGEN_STYLE_TYPE)
/* ANONYMOUS STRUCTS DO NOT SUPPORT FORWARD DECLARATIONS!
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried several things to avoid the test for Style::Type to fail, but this was the only way to actually get it to work. Forward declaration just cannot work for that style, and this allows me to completely skip the compilation test - thus succeeding.

@Wodann
Copy link
Contributor Author

Wodann commented Nov 8, 2020

I've added a test and got the build to succeed.

If there's anything else I can improve, please let me know.

@Wodann
Copy link
Contributor Author

Wodann commented Nov 13, 2020

@emilio should I split the PR into multiple ones?

@emilio
Copy link
Collaborator

emilio commented Nov 13, 2020

No, it's fine, I just need to get to reviewing these, sorry for the lag (been swamped with other stuff lately)

Copy link
Collaborator

@emilio emilio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good. I took the liberty of rebasing for you (but kept you as the author of course).

Thanks for the fix!

@emilio emilio closed this in 68a1e65 Nov 25, 2020
@petrochenkov
Copy link
Contributor

I've noticed that cbindgen adds a lot of struct/union noise on master compared to previous versions, and the search led me to this PR.

@Wodann

Types of structs were not being resolved when the style was set to 'both', resulting in the struct keyword not being added to struct field types.

This was by design, as I understand.
Why do you need structs if the structures are defined in "both" style as typedef struct Foo { ... } Foo;?

Looks like the issue in #215 (comment) was with incorrect forward declarations rather than with missing structs?
Although it's not clear since the code snippet is incomplete.

@petrochenkov
Copy link
Contributor

petrochenkov commented Nov 25, 2020

This looks like a regression to me.

@emilio
Copy link
Collaborator

emilio commented Nov 26, 2020

The main issue this fixes is something like recursive structs where you have:

typedef struct Foo {
  Foo* bar;
} Foo;

@emilio
Copy link
Collaborator

emilio commented Nov 26, 2020

(Where you do need the struct in the member)

@emilio
Copy link
Collaborator

emilio commented Nov 26, 2020

So yeah, while I agree it's more noisy, it's more correct too.

@emilio
Copy link
Collaborator

emilio commented Nov 26, 2020

So we could reduce the noise level a bit by resolving or outputting ctypes only when necessary, and should be relatively straight-forward...

@petrochenkov would you be fine with outputting ctypes for styles that generate typedefs only on members, or something of that sort? That'd be the easiest check, we could potentially go smarter and try to detect the self-referencing case, but not sure to what extent it's worth it.

@petrochenkov
Copy link
Contributor

I see, the recursive case is a legitimate one.
I'll look at this in more detail in couple of days.

@petrochenkov
Copy link
Contributor

One more thing - the forward_declaration test doesn't actually work.
Block comments /* ... */ have higher "priority" here than preprocessor directives, so

#if defined(CBINDGEN_STYLE_TYPE)
/* ANONYMOUS STRUCTS DO NOT SUPPORT FORWARD DECLARATIONS!
#endif

...

#if defined(CBINDGEN_STYLE_TYPE)
*/
#endif

is equivalent to just

#if defined(CBINDGEN_STYLE_TYPE)
/* ... */
#endif

@petrochenkov
Copy link
Contributor

Ok, this is not trivial to fix, so I'll leave this for later (if I get to #592 I'll try to fix this as well).

What I think is a proper solution: when we do the topological sort of items to satisfy dependencies and detect cycles

  • we insert forward declaration nodes (typedef struct Foo Foo;) until there are no cycles
  • we add tag to items involved in the forward declarations even in Style::Type mode, so the generated code compiles in all modes.

@Wodann
Copy link
Contributor Author

Wodann commented Dec 2, 2020

@petrochenkov sorry for being late to the party. Good catch with the preprocessor order. Did you already fix that issue? It seems like some changes were made to the particular *.toml file.

@petrochenkov
Copy link
Contributor

@Wodann
No, I didn't do anything yet, the changes were done during merge to fix conflicts with #620.

emilio added a commit that referenced this pull request Dec 20, 2020
 * Remove artificial restriction on lifetime parameters on enums (#604)
 * Add an option for converting usize/isize into size_t/ptrdiff_t. (#606)
 * Allow controlling the cargo profile used for expansion. (#607)
 * Support wider range of expressions in enum discriminants (#614)
 * Support generation of Cython bindings (#590)
 * Fixed some issues with style=tag and recursive structs (#615)
 * Default C style to Both (as specified in docs) (#615)
 * Fix resolution of path dependencies from certain modules. (#629)
 * Support inlined definitions for tuple variants with a single field in C (#631)

Thanks to all the awesome contributors that contributed to this release.
bors bot added a commit to crypto-com/thaler that referenced this pull request Dec 21, 2020
2401: Bump cbindgen from 0.15.0 to 0.16.0 r=tomtau a=dependabot-preview[bot]

Bumps [cbindgen](https://github.com/eqrion/cbindgen) from 0.15.0 to 0.16.0.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/eqrion/cbindgen/blob/master/CHANGES">cbindgen's changelog</a>.</em></p>
<blockquote>
<h2>0.16.0</h2>
<pre><code> * Remove artificial restriction on lifetime parameters on enums ([#604](mozilla/cbindgen#604))
 * Add an option for converting usize/isize into size_t/ptrdiff_t. ([#606](mozilla/cbindgen#606))
 * Allow controlling the cargo profile used for expansion. ([#607](mozilla/cbindgen#607))
 * Support wider range of expressions in enum discriminants ([#614](mozilla/cbindgen#614))
 * Support generation of Cython bindings ([#590](mozilla/cbindgen#590))
 * Fixed some issues with style=tag and recursive structs ([#615](mozilla/cbindgen#615))
 * Default C style to Both (as specified in docs) ([#615](mozilla/cbindgen#615))
 * Fix resolution of path dependencies from certain modules. ([#629](mozilla/cbindgen#629))
 * Support inlined definitions for tuple variants with a single field in C ([#631](mozilla/cbindgen#631))
</code></pre>
<p>Thanks to all the awesome contributors that contributed to this release.</p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/eqrion/cbindgen/commit/a00b4215a907601680f6e9acaf93df1cbafa8ded"><code>a00b421</code></a> v0.16.0</li>
<li><a href="https://github.com/eqrion/cbindgen/commit/b82e37525478d7d0bddbea2baf27e2eb9434531f"><code>b82e375</code></a> enum: Support inlined definitions for tuple variants with a single field</li>
<li><a href="https://github.com/eqrion/cbindgen/commit/eaf3e57e743dba7621bfa59d0c5bf0656a79cb71"><code>eaf3e57</code></a> enum: Remove some redundant function parameters</li>
<li><a href="https://github.com/eqrion/cbindgen/commit/0083c43e13c384787023c1fc8c491744d9f41070"><code>0083c43</code></a> Remove <code>Struct::tuple_struct</code></li>
<li><a href="https://github.com/eqrion/cbindgen/commit/8a5db0baebfd45f4c43681151d111cdcb31bc6c5"><code>8a5db0b</code></a> Minor cleanup to <code>fn close_brace</code></li>
<li><a href="https://github.com/eqrion/cbindgen/commit/1963f0c92e93456359713db353aa6276f6200f7b"><code>1963f0c</code></a> Partially support <code>#[cfg]</code>s on fields</li>
<li><a href="https://github.com/eqrion/cbindgen/commit/dfcee869ba536e661a0c972b5407ea3a5579d960"><code>dfcee86</code></a> enum: Do not forget to rename entities in enum discriminants</li>
<li><a href="https://github.com/eqrion/cbindgen/commit/fbc2237b7d7b8ab250ec184c709bc5d4129fceab"><code>fbc2237</code></a> parser: Fix resolution of #[path] dependencies from certain modules.</li>
<li><a href="https://github.com/eqrion/cbindgen/commit/9f558e30f3313f2fe6fcdc172b6f86c619564414"><code>9f558e3</code></a> enum: <code>enum_name</code> -&gt; <code>tag_name</code></li>
<li><a href="https://github.com/eqrion/cbindgen/commit/8997277cb71922b028a003349c59bd87ae0afe4d"><code>8997277</code></a> enum: Break up <code>Enum::write</code> into multiple functions</li>
<li>Additional commits viewable in <a href="https://github.com/eqrion/cbindgen/compare/v0.15.0...v0.16.0">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://api.dependabot.com/badges/compatibility_score?dependency-name=cbindgen&package-manager=cargo&previous-version=0.15.0&new-version=0.16.0)](https://dependabot.com/compatibility-score/?dependency-name=cbindgen&package-manager=cargo&previous-version=0.15.0&new-version=0.16.0)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `@dependabot use these labels` will set the current labels as the default for future PRs for this repo and language
- `@dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- `@dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language
- `@dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language
- `@dependabot badge me` will comment on this PR with code to add a "Dependabot enabled" badge to your readme

Additionally, you can set the following in your Dependabot [dashboard](https://app.dependabot.com):
- Update frequency (including time of day and day of week)
- Pull request limits (per update run and/or open at any time)
- Out-of-range updates (receive only lockfile updates, if desired)
- Security updates (receive only security updates, if desired)



</details>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
bors-servo added a commit to servo/servo that referenced this pull request Apr 6, 2022
Bump cbindgen from 0.14.6 to 0.20.0

Bumps [cbindgen](https://github.com/eqrion/cbindgen) from 0.14.6 to 0.20.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/eqrion/cbindgen/releases">cbindgen's releases</a>.</em></p>
<blockquote>
<h2>v0.20.0</h2>
<ul>
<li>Add Builder::with_using_namespaces. (<a href="https://github-redirect.dependabot.com/eqrion/cbindgen/issues/688">#688</a>)</li>
<li>Ignore PhantomPinned. (<a href="https://github-redirect.dependabot.com/eqrion/cbindgen/issues/695">#695</a>)</li>
<li>Simplify Pin<!-- raw HTML omitted --> to T. (<a href="https://github-redirect.dependabot.com/eqrion/cbindgen/issues/697">#697</a>)</li>
<li>Update --pretty=expanded to -Zunpretty=expanded. (<a href="https://github-redirect.dependabot.com/eqrion/cbindgen/issues/706">#706</a>)</li>
</ul>
<h2>v0.19.0</h2>
<ul>
<li>Simplify types in generics (<a href="https://github-redirect.dependabot.com/eqrion/cbindgen/issues/663">#663</a>)</li>
<li>Use --profile=check for macro expansion (<a href="https://github-redirect.dependabot.com/eqrion/cbindgen/issues/671">#671</a>)</li>
<li>Use exported name to prefix enum variants (<a href="https://github-redirect.dependabot.com/eqrion/cbindgen/issues/672">#672</a>)</li>
<li>Fix path attribute handling in inline submodules (<a href="https://github-redirect.dependabot.com/eqrion/cbindgen/issues/679">#679</a>)</li>
<li>Fix a stack overflow with some recursive typedefs (<a href="https://github-redirect.dependabot.com/eqrion/cbindgen/issues/680">#680</a>)</li>
</ul>
<h2>v0.18.0</h2>
<ul>
<li>Simplify types in nested types such as pointed-to types and function signatures (<a href="https://github-redirect.dependabot.com/eqrion/cbindgen/issues/661">#661</a>)</li>
</ul>
<h2>v0.17.0</h2>
<ul>
<li>Add with_parse_extra_bindings to builder. (<a href="https://github-redirect.dependabot.com/eqrion/cbindgen/issues/645">#645</a>)</li>
<li>Support NonZero and fix incorrect simplification of Option<!-- raw HTML omitted --> into ptr. (<a href="https://github-redirect.dependabot.com/eqrion/cbindgen/issues/647">#647</a>)</li>
<li>Deal with name conflicts correctly in declaration type resolution. (<a href="https://github-redirect.dependabot.com/eqrion/cbindgen/issues/651">#651</a>)</li>
<li>Support pointers to ZSTs. (<a href="https://github-redirect.dependabot.com/eqrion/cbindgen/issues/656">#656</a>)</li>
</ul>
<h2>v0.16.0</h2>
<p>No release notes provided.</p>
<h2>v0.15.0</h2>
<p>No release notes provided.</p>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/eqrion/cbindgen/blob/master/CHANGES">cbindgen's changelog</a>.</em></p>
<blockquote>
<h2>0.20.0</h2>
<pre><code> * Add Builder::with_using_namespaces. ([#688](mozilla/cbindgen#688))
 * Ignore PhantomPinned. ([#695](mozilla/cbindgen#695))
 * Simplify Pin&lt;T&gt; to T. ([#697](mozilla/cbindgen#697))
 * Update --pretty=expanded to -Zunpretty=expanded. ([#706](mozilla/cbindgen#706))
</code></pre>
<h2>0.19.0</h2>
<pre><code> * Simplify types in generics ([#663](mozilla/cbindgen#663))
 * Use --profile=check for macro expansion ([#671](mozilla/cbindgen#671))
 * Use exported name to prefix enum variants ([#672](mozilla/cbindgen#672))
 * Fix path attribute handling in inline submodules ([#679](mozilla/cbindgen#679))
 * Fix a stack overflow with some recursive typedefs ([#680](mozilla/cbindgen#680))
</code></pre>
<h2>0.18.0</h2>
<pre><code> * Simplify types in nested types such as pointed-to types and function signatures ([#661](mozilla/cbindgen#661))
</code></pre>
<h2>0.17.0</h2>
<pre><code> * Add with_parse_extra_bindings to builder. ([#645](mozilla/cbindgen#645))
 * Support NonZero and fix incorrect simplification of Option&lt;ptr&gt; into ptr. ([#647](mozilla/cbindgen#647))
 * Deal with name conflicts correctly in declaration type resolution. ([#651](mozilla/cbindgen#651))
 * Support pointers to ZSTs. ([#656](mozilla/cbindgen#656))
</code></pre>
<h2>0.16.0</h2>
<pre><code> * Remove artificial restriction on lifetime parameters on enums ([#604](mozilla/cbindgen#604))
 * Add an option for converting usize/isize into size_t/ptrdiff_t. ([#606](mozilla/cbindgen#606))
 * Allow controlling the cargo profile used for expansion. ([#607](mozilla/cbindgen#607))
 * Support wider range of expressions in enum discriminants ([#614](mozilla/cbindgen#614))
 * Support generation of Cython bindings ([#590](mozilla/cbindgen#590))
 * Fixed some issues with style=tag and recursive structs ([#615](mozilla/cbindgen#615))
 * Default C style to Both (as specified in docs) ([#615](mozilla/cbindgen#615))
 * Fix resolution of path dependencies from certain modules. ([#629](mozilla/cbindgen#629))
 * Support inlined definitions for tuple variants with a single field in C ([#631](mozilla/cbindgen#631))
</code></pre>
<p>Thanks to all the awesome contributors that contributed to this release.</p>
<h2>0.15.0</h2>
<pre><code> * Allow customizing mangling of generic parameters in C ([#575](mozilla/cbindgen#575))
 * Box&lt;T&gt; simplifies to T* in C (4ce324c)
 * ManuallyDrop&lt;T&gt; and MaybeUninit&lt;T&gt; simplify to T in C, and are opaque in C++ (0076a17)
 * C++ supports a derive-ostream annotation to derive serialization of structs, unions and enums ([#582](mozilla/cbindgen#582))
 * Large character constants have been fixed on Windows ([#586](mozilla/cbindgen#586))
 * Constants are now generated for typedefs, etc ([#589](mozilla/cbindgen#589))
 * The `sort_by` configuration option has been made to work for constants ([#587](mozilla/cbindgen#587))
 * Default sort order is source order now (sort_by = &quot;None&quot;), and can be changed by the above option ([#587](mozilla/cbindgen#587))
</code></pre>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/eqrion/cbindgen/commit/41506d5aeb2be8d200f52d08afb0c243414eb00d"><code>41506d5</code></a> v0.20.0</li>
<li><a href="https://github.com/eqrion/cbindgen/commit/34299aef5610fa82a058374bdfce8d782e0abe29"><code>34299ae</code></a> Don't use <code>check</code> profile when expanding code on a release build</li>
<li><a href="https://github.com/eqrion/cbindgen/commit/6c96c8ab957542eb0bebe576fee3fb1241db0114"><code>6c96c8a</code></a> Update --pretty=expanded to -Zunpretty=expanded</li>
<li><a href="https://github.com/eqrion/cbindgen/commit/57add9c86083b492266c8511fba30fb7c37cce25"><code>57add9c</code></a> Fix some clippy lints.</li>
<li><a href="https://github.com/eqrion/cbindgen/commit/63c1043dfb92fcac0bf3073c2d71e9e4ac69c943"><code>63c1043</code></a> Simplify Pin&lt;T&gt; to T</li>
<li><a href="https://github.com/eqrion/cbindgen/commit/ccd1f0e9ec2369735b9481c85057b9c65b6b0908"><code>ccd1f0e</code></a> add <code>Builder::with_using_namespaces</code></li>
<li><a href="https://github.com/eqrion/cbindgen/commit/4e394493d63c2348a08d486562dc2082cbdfe306"><code>4e39449</code></a> Ignore PhantomPinned</li>
<li><a href="https://github.com/eqrion/cbindgen/commit/2d20c4b15179523b10605bdd95006882dd1c8e4e"><code>2d20c4b</code></a> Move the target-guessing code from <a href="https://github-redirect.dependabot.com/eqrion/cbindgen/issues/676">#676</a> to its own function.</li>
<li><a href="https://github.com/eqrion/cbindgen/commit/93c06c5c9d319f481788c9670700097b4e46d270"><code>93c06c5</code></a> Only fetch dependencies for current platform by default (<a href="https://github-redirect.dependabot.com/eqrion/cbindgen/issues/676">#676</a>)</li>
<li><a href="https://github.com/eqrion/cbindgen/commit/d9e490ce8b836194595bd30611253a7028059da2"><code>d9e490c</code></a> v0.19.0</li>
<li>Additional commits viewable in <a href="https://github.com/eqrion/cbindgen/compare/v0.14.6...v0.20.0">compare view</a></li>
</ul>
</details>
<br />

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=cbindgen&package-manager=cargo&previous-version=0.14.6&new-version=0.20.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

</details>
mhallin added a commit to mhallin/cbindgen that referenced this pull request May 25, 2024
v0.16.0

     * Remove artificial restriction on lifetime parameters on enums (mozilla#604)
     * Add an option for converting usize/isize into size_t/ptrdiff_t. (mozilla#606)
     * Allow controlling the cargo profile used for expansion. (mozilla#607)
     * Support wider range of expressions in enum discriminants (mozilla#614)
     * Support generation of Cython bindings (mozilla#590)
     * Fixed some issues with style=tag and recursive structs (mozilla#615)
     * Default C style to Both (as specified in docs) (mozilla#615)
     * Fix resolution of path dependencies from certain modules. (mozilla#629)
     * Support inlined definitions for tuple variants with a single field in C (mozilla#631)

    Thanks to all the awesome contributors that contributed to this release.

# Conflicts:
#	src/bindgen/ir/enumeration.rs
#	src/bindgen/writer.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Forward declaration of all pointers
3 participants