Description
Hi! I'm trying to compile my Rocket/Diesel/R2d2 task management project, which has previously successfully compiled, and when I add the newest piece which relies on macros in some new/different way (sorry for vague, I'm new to rust) it starts failing to compile.
Looking at the backtrace, the error seems to be in MacroExpander::expand_invoc.
new code that causes the bug
#[post("ctl"), format="application/json", data=nt]
fn append_ctl_struct(conn: DbConn, nt: NewTask) -> &'static str {
use schema::ctl::dsl::*;
diesel::insert_into(ctl)
.values(&nt)
.get_result::<Task>(&*conn);
return "Struckt Bites."
}
expected behavior:
I expect it to have the same behavior as the simpler version of the route:
#[post("/ctl/<tsk>/<disc>")]
fn append_ctl(conn: DbConn, tsk: String, disc: bool) -> &'static str {
use schema::ctl::dsl::*;
let nt = NewTask{
name: &tsk,
discrete: disc
};
diesel::insert_into(ctl)
.values(&nt)
.get_result::<Task>(&*conn);
// .expect("failed to insert task to CTL")
return "Bagel Bites."
}
which warns about unused query result on compile but successfully runs, builds the NewTask struct from url components, and inserts it into the database.
result behavior
it fails to compile during cargo run, and the same exact error shows during cargo check. I've pasted the whole command with outputs here:
https://gist.github.com/haniawni/d333080a91c0370de6a245713f803c84
replication
Check out my project's "uhoh" branch for the exact code where I get the bug.
Check out my project's master branch at commit 5ec317 to see the functional version (requires a local postgresql instance and a DATABASE_URL env variable in a env file).