rustsym
rustsym copied to clipboard
rustsym can give wrong results because it doesn't run macros
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:

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

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


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.