Repository navigation
Keep the semicolon inside #if for cfg'd struct and union fields - #1193
Open
thelastbackspace wants to merge 1 commit into
Open
thelastbackspace wants to merge 1 commit into
thelastbackspace wants to merge 1 commit into
Conversation
A field with a #[cfg] that maps to a define was written as
#if defined(XYZ)
uint32_t b
#endif
;
because the list writer appended the ';' after write_field had already
closed the condition. Write the terminator for struct and union members
before the #endif instead. The C++ constructor argument list still uses
the old path since it joins with ','.
Fixes mozilla#1058
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1058
When a struct or union field has a
#[cfg]that maps to a define, the;ended up after the#endif:That gives
-Wextra-semiwarnings when the define isn't set. As ogoffart pointed out in the issue, the cause iswrite_vertical_source_listwithListType::Cap(";"): it adds the;only afterwrite_fieldhas already closed the condition.I split
write_fieldso that struct and union members write their;beforecondition.write_after(). The list now usesJoin(""), so it doesn't add a second one. Uncfg'd fields come out the same as before. The C++ constructor argument list still useswrite_fieldwithJoin(","), so it keeps the existing newline workaround from #634.Now it's generated as:
The
cfg,cfg_bothandcfg_tagexpectations already contained the stray;line. I regenerated them, and they're the only expectation files that change. If I keep the new expectations and revert the source change,test_cfgfails.Testing:
CBINDGEN_TEST_VERIFY=1 cargo +nightly test(161 passed, so all expectations compile with gcc, g++ and Cython 3.0.2), pluscargo fmt --checkandcargo clippy --all-targets(no new warnings).