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

Reduce collision potential for macros #27

Merged
merged 2 commits into from
Jun 24, 2022
Merged

Conversation

OpenByteDev
Copy link
Contributor

I encountered a name collision when using thie macros from this crate together with iced-x86:

use iced_x86::code_asm::registers::gpr8::ch;
fn main() {
    widestring::u16cstr!("test");
}

which results in the following errors

error[E0308]: mismatched types
  --> src\lib.rs:37:5
   |
37 |     widestring::u16cstr!("test");
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |     |
   |     expected `u32`, found struct `AsmRegister8`
   |     this expression has type `std::option::Option<(u32, &[u8])>`
   |
   = note: this error originates in the macro `widestring::u16cstr` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0369]: no implementation for `AsmRegister8 & {integer}`  --> src\lib.rs:37:5
   |
37 |     widestring::u16cstr!("test");
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |     |
   |     AsmRegister8
   |     {integer}
   |
   = note: this error originates in the macro `widestring::u16cstr` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0369]: cannot subtract `{integer}` from `AsmRegister8` 
  --> src\lib.rs:37:5
   |
37 |     widestring::u16cstr!("test");
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |     |
   |     AsmRegister8
   |     {integer}
   |
   = note: this error originates in the macro `widestring::u16cstr` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0605]: non-primitive cast: `AsmRegister8` as `u16`     
  --> src\lib.rs:37:5
   |
37 |     widestring::u16cstr!("test");
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object
   |
   = note: this error originates in the macro `widestring::u16cstr` (in Nightly builds, run with -Z macro-backtrace for more info)

This pull request adds the prefix _widestring_ to all locals declared in the macros and also uses fully qualified names for one occurance of u16/u32 and Some.

@starkat99 starkat99 merged commit 21aef68 into starkat99:main Jun 24, 2022
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.

2 participants