shekohex / flutterust

Flutter + Rust = :heart:

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Data type return by macro cstr! show as '()' in IDE of Idea

yiv opened this issue · comments

commented
#[no_mangle]
pub extern "C" fn load_page(port: i64, url: *const raw::c_char) -> i32 {
    let rt = runtime!();
    let url = cstr!(url);
    let t = Isolate::new(port).task(scrap::load_page(url));
    rt.spawn(t);
    1
}

I am using IDE of Idea with Rust plugin to develop, it shows the returned data type of macro cstr! is '()'

mismatched types [E0308] expected `&str`, found `()` 

But the returned data type of other micros shows correctly, like runtime!

Does the code compile? Try runbcargo check and see if there is any errors.
Because sometimes IDE is wrong and gives a false-postive error.

commented

Yes it does, just because of seeing runtime! give the right type, cstr! make me a little anoying, so I am wondering whether any ingnored implement need to be improved in macro cstr!

Thanks for replying, if nothing need to be done, then this issue could be closed

I'm currently not using IDEA from Jetbrains, but as far as I remember, there was an option in the Rust Plugin Settings to enable something called "experimental macro engine" , or something like that.

I guess if that is enabled you should get better types support.

Also check (run cargo check on Save) option should give you the right feedback.

I hope that will help you with that issue.

PS: I'm using rust-analyzer right now, and it doesn't give any errors related to the macros, and gives the correct types too.