Compiler can't find Diesel's "table!" macro

First, a link to the repository I'm having trouble with.
The file that causes the issue is schema.rs.

Diesel, one of the libraries I'm working with, relies on the "table!" macro to abstract database tables in Rust. The problem is that the compiler keeps telling that it can´t find that macro and I should consider importing "diesel::table". I tried this and the error persists, although with a different macro missing.

I also tried adding "#[macro_use] extern crate diesel;" to the main file, but this doesn't change the errror. The closet I got to solving the issue is by adding "use diesel::*;" to shchema.rs, but there still are macros that Rust can't find.

I suspect this is a compiler bug, but maybe I just messed something up :sweat_smile:. If someone would help me I would really appreciate.

PS.: There's a similar issue on Github that, apparently, has been solved (Issue #78333)

That indeed is the correct thing to do. What error do you get when you do that?

"cannot find macro __diesel_parse_table in this scope".

By the way, when I glob-import diesel in schema.rs. The compiler tells it can´t find find a bunch of other macros. For all of them it suggests to import "schema::". One of the macros missing , "static_cond!" is from a private Diesel module with the same name.

#[macro_use] extern crate diesel; should be in the library crate (lib.rs), not the binary crate (main.rs). You should also not have mod lib; anywhere. The library can be accessed as rust_server_v2, such as rust_server_v2::schema. You can read more about main.rs and lib.rs at Packages and Crates - The Rust Programming Language

1 Like

This solved the issue. Thank you very much! :smile: