rust-bindgen
rust-bindgen copied to clipboard
Fix source order sorting.
Fixes https://github.com/rust-lang/rust-bindgen/issues/2556.
Previously, headers included with -include
were not added to the includes
map since they don't have a source file. This is now fixed.
Also, some wrong match arms were removed/fixed.
cc @glandium @emilio
Please have a look.
:umbrella: The latest upstream changes (presumably ee980e1afeedc2afadafa6d8bdface54b5027e2d) made this pull request unmergeable. Please resolve the merge conflicts.
I refactored SourceLocation
to be an enum
and the sorting is now split between SourceLocation
and IncludeLocation
. In my opinion it is a bit easier to follow that way.
@pvdrz, I fixed the edge case you gave and added a test for it.
I changed all file names from String
to PathBuf
since we need to absolutize them before comparing them, e.g. running your example with cargo run -- a.h
would actually try to compare the strings "a.h"
and "./a.h"
before.
@emilio, do you have an alternative? The status quo is simply incorrect in some cases.
The only alternative I can see is to never generate constants for variable-like macros and only ever generate Rust macros instead. That way there is never a naming or ordering conflict.
Note that this is also needed for the same reason for function-like macros and functions in https://github.com/rust-lang/rust-bindgen/pull/2369.
@reitermarkus I'm confused, my understanding is that this sorting fixes some cases but breaks others, is that not the case?
No, it only broke some cases due to the sorting being wrong/incomplete previously. Otherwise nothing should break, except for some auto-generated names having a different index.
Confirmed that this works for one of my projects.
Thanks for testing, @alex.
@emilio, @pvdrz, can you have another look at this?
@pvdrz, @emilio, please have another look here, thank you.
@pvdrz, @emilio, another ping here.
:umbrella: The latest upstream changes (presumably 5ff913ab3349db1905cfbbf44a9121cbc223249d) made this pull request unmergeable. Please resolve the merge conflicts.
@pvdrz, @emilio, can you have another look at this?
turn it off by default
This is a prerequisite for supporting complex macros (https://github.com/rust-lang/rust-bindgen/pull/2369), so it can't be optional.
:umbrella: The latest upstream changes (presumably 46c06e5ef11c01680edd9ca250ed0c32b6cdc9e9) made this pull request unmergeable. Please resolve the merge conflicts.
:umbrella: The latest upstream changes (presumably 285eb56cf5a02ee778880b8e1b7bb2e8118a5a88) made this pull request unmergeable. Please resolve the merge conflicts.
@pvdrz, @emilio please have another look.
I'd rather keep the
CXFile
rather than reading the path and doing IO to absolutize it eagerly for most callers that don't need that...
I have re-added the File
struct as SourceFile
now to avoid eagerly absolutizing every path.
:umbrella: The latest upstream changes (presumably 3b5ce9c5861cd2e97e9789f5b686238656abd2d6) made this pull request unmergeable. Please resolve the merge conflicts.