fix: 'core' module conflict in Bindgen::emit#568
Merged
alexcrichton merged 2 commits intobytecodealliance:mainfrom May 4, 2023
Merged
fix: 'core' module conflict in Bindgen::emit#568alexcrichton merged 2 commits intobytecodealliance:mainfrom
alexcrichton merged 2 commits intobytecodealliance:mainfrom
Conversation
Contributor
Author
|
Sorry about the ci failures, I only ran |
4017278 to
f46d628
Compare
pchickey
reviewed
May 3, 2023
Contributor
pchickey
left a comment
There was a problem hiding this comment.
Can we instead use a leading ::, i.e. ::core::mem::forget?
Contributor
Author
Ah, that would be much better! I'll update shortly, thanks! |
This commit is an attempt to avoid module name conflicts where a user
library may have a module defined as follows:
```rust
mod core;
wit_bindgen::generate!("component");
```
This would currently clash with the 'core' module used in the
`Bindgen::emit` function and result in a compilation error:
```console
31 | wit_bindgen::generate!("component");
|^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ could not find `mem` in `core`
```
Signed-off-by: Daniel Bevenius <daniel.bevenius@gmail.com>
f46d628 to
9720678
Compare
alexcrichton
approved these changes
May 3, 2023
Member
|
Oh also, could you add a test for this? Probably somewhere around |
Contributor
Author
Absolutely, I'll take a look at adding one tomorrow. |
This commit adds additional external crate prefixes (::) to 'core' modules used in code generated from macros. It also adds a "test" in that an empty module named 'core' has been added to catch any future additions or modifications. Signed-off-by: Daniel Bevenius <daniel.bevenius@gmail.com>
alexcrichton
approved these changes
May 4, 2023
Member
|
Thanks! |
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.
This commit is an attempt to avoid module name conflicts where a user library may have a module defined as follows:
This would currently clash with the 'core' module used in the
Bindgen::emitfunction and result in a compilation error: