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

rustsym can give wrong results because it doesn't run macros #13

Open
mcclure opened this issue Feb 21, 2021 · 0 comments
Open

rustsym can give wrong results because it doesn't run macros #13

mcclure opened this issue Feb 21, 2021 · 0 comments

Comments

@mcclure
Copy link

mcclure commented Feb 21, 2021

The problem

So I've got this small project (can provide you a git repo if it helps) that uses the "mlua" crate. I have a file with this code:

use mlua::Lua;
use mlua::prelude::{LuaResult, LuaTable};

fn func1(_: &Lua, _: ()) -> LuaResult<()> {
    Ok(())
}

fn func2(_: &Lua, _: ()) -> LuaResult<()> {
    Ok(())
}

#[mlua::lua_module]
pub fn module(lua: &Lua) -> LuaResult<LuaTable> {
    lua.create_table_from(vec![
        ("func1", lua.create_function(func1)?),
        ("func2", lua.create_function(func2)?),
    ])
}

Now, I have a problem: I want to use this "module" function in another file. But see that #[mlua::lua_module]? That's a macro the mlua crate publishes, and it actually changes the name (and visibility) of the function it is attached to. It turns out it changes it to luaopen_module. But I didn't know that, so I installed rustsym.

So I run rustsym and:

Screen Shot 2021-02-21 at 12 59 26 AM

Cool, so there's an exported function named "module".

Except no:

Screen Shot 2021-02-20 at 7 59 13 PM

Eventually I figure out I can also use cargo doc --open for this purpose. Here's what it says exists:

Screen Shot 2021-02-21 at 12 42 34 AM

Screen Shot 2021-02-21 at 12 42 38 AM

Expected behavior

I think rustsym gave the incorrect name for luaopen_module because it doesn't run macros, whereas cargo doc --open gave the correct name because it did. Ideally rustsym should run macros.

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

No branches or pull requests

1 participant