stdweb icon indicating copy to clipboard operation
stdweb copied to clipboard

#[js_export] causes error message locations to be wrong

Open phiresky opened this issue 7 years ago • 3 comments

With js_export, all errors in a function are reduced to be located at the #[js_export] annotation:

without js_export:

error[E0308]: mismatched types
  --> src/lib.rs:27:71
   |
27 |         let mut writer = brotli::DecompressorWriter::new(&mut output, buffer_size);
   |                                                                       ^^^^^^^^^^^ expected usize, found u32

with js_export:

22 | #[js_export]
   | ^^^^^^^^^^^^ expected usize, found u32

Any way to fix this?

phiresky avatar Jul 06 '18 17:07 phiresky

This is due to the fact that the js_export uses the older string-based procedular macros APIs; newer proc_macro2-based APIs do preserve those properly, however they're not as stable. (They break from time to time while the string based APIs are, while not stabilized, very stable.)

Once the newer APIs are stabilized I'll switch to them. As a workaround you can probably just comment out the #[js_export] temporarily.

koute avatar Jul 06 '18 19:07 koute

I ran into this problem after building it successfully a few weeks back. commenting out '#[js_export]' allows successful build but failed in execution (does not generate the hash code). Any idea idea the time frame this thing can be fixed and js_export can be used again?

godadada avatar Jul 24 '18 00:07 godadada

Latest version is working. Thanks.

godadada avatar Jul 24 '18 01:07 godadada