I'm trying to use some of the macros from the diesel crate but they say they have not been imported, even when explicitly imported.
I Think the problem is coming from the use the feature decl_macro. This feature is required by rocket in order to use some of the unsafe macros "[rustc E0658] [E] macro
is experimental" but I am not sure.
The way the rocket-rs documentation says to use diesel is by using rocket_contrib::databases::diesel
.
The thing I want to use is at rocket_contrib::databases::diesel::prelude::Insertable
or just diesel::prelude::Insertable
, and table_name in the same location.
Here is the code I have for the imports
#![feature(proc_macro_hygiene, decl_macro)]
use rocket::request::{Form, FromForm};
use rocket::Request;
use rocket::*;
#[macro_use] extern crate rocket_contrib;
use rocket_contrib::databases::diesel;
use rocket_contrib::databases::diesel::prelude::*;
// --snip--
Here is the code that says Insertable and the macro table_name are missing
// --snip--
#[derive(Insertable, Debug)]
#[table_name="redirects"]
pub struct Redirect<'a> {
pub alias: &'a String,
pub url: &'a String,
pub count: &'a i64,
}
The errors I get are these
error: cannot find derive macro `Insertable` in this scope
--> src/main.rs:20:10
|
20 | #[derive(Insertable, Debug)]
| ^^^^^^^^^^
error: cannot find attribute `table_name` in this scope
--> src/main.rs:21:3
|
21 | #[table_name="redirects"]
| ^^^^^^^^^^
What I have tried:
- removing the decl_macro
- adding proc_macro_hygiene as a feature
- using the diesel::prelude::* instead of rocket_contrib::databases::diesel::prelude::*
- using #[macro_use] extern crate diesel
The goal is to use the rocket_contrib, while keeping decl_macro enabled for rocket, and still having things like table_name and Insertable imported from diesel.