{"id":1221,"hash":"3bda04fb27cfebc469497fa9f54462ee0d3a44144140969d0d0b6531dcaa6e32","pattern":"How can I resolve &quot;use of undeclared crate or module&quot; error when using #[diesel(table_name = ...)]?","full_message":"I have a Rust project using Rocket and Diesel 1.4. I am using MariaDB as my database. My model and schema is generated this way:\n\ndiesel print-schema --database-url mysql://root:password@127.0.0.1:3306/mydb > src/schema.rs\ndiesel_ext -I \"diesel::sql_types::*\" -I \"crate::schema::*\" -d \"Insertable, Queryable, Debug\" -s .\\src\\schema.rs -m > .\\src\\model.rs\n\nFrom what I can tell those tools reads Rocket.toml and generates the code from there.\n\n//! schema.rs:\ntable! {\n    auth_guest (id) {\n        id -> Unsigned<Integer>,\n        device_id -> Varchar,\n    }\n}\n\n//! model.rs\n// Generated by diesel_ext\n\n#![allow(unused)]\n#![allow(clippy::all)]\n\nuse diesel::sql_types::*;\nuse crate::schema::auth_guest;\n\n#[derive(Insertable, Queryable, Debug)]\n#[diesel(table_name = auth_guest)]\npub struct AuthGuest {\n    pub id: u32,\n    pub device_id: String,\n}\n\n//! main.rs:\n#![feature(decl_macro)]\n#[macro_use] extern crate diesel;\n#[macro_use] extern crate rocket;\n#[macro_use] extern crate rocket_contrib;\n\nmod schema;\nmod model;\n\nuse std::borrow::BorrowMut;\nuse diesel::prelude::*;\nuse crate::schema::auth_guest::*;\n\n#[database(\"mydb\")]\nstruct Db(diesel::MysqlConnection);\n\n#[get(\"/\")]\nfn read(conn: Db) -> String {\n    let guest_user = model::AuthGuest {\n        id: 0,\n        device_id: String::from(\"Hello\")\n    };\n\n    diesel::insert_into(schema::auth_guests::table)\n        .values(guest_user)\n        .execute(&conn)\n        .expect(\"Error creating user\");\n}\n\nfn main() {\n    rocket::ignite()\n        .attach(Db::fairing())\n        .launch();\n}\n\nThe error I am getting is:\n\nerror[E0433]: failed to resolve: use of undeclared crate or module `auth_guests`\n  --> src\\model.rs:11:12\n   |\n11 | pub struct AuthGuest {\n   |            ^^^^^^^^^ use of undeclared crate or module `auth_guests`\n\nI cant seem to figure out what I am doing wrong or missing regarding the compilation error.","ecosystem":"cargo","package_name":"rust-diesel","package_version":null,"solution":"The code generated by diesel_ext does not match the code your diesel version is expecting. The #[diesel(table_name = …)] attribute is only available for the upcoming 2.0 release. Based on your usage of rocket and the error message I would assume that you use diesel 1.4, which does not use this attribute. You need to use #[table_name = \"…\"] there instead or update to a newer diesel version (there are release candidates on crates.io, but I'm not sure if that's supported by rocket yet)","confidence":0.7000000000000001,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/73488465/how-can-i-resolve-use-of-undeclared-crate-or-module-error-when-using-diesel","votes":5,"created_at":"2026-04-19T04:52:37.218532+00:00","updated_at":"2026-04-19T04:52:37.218532+00:00"}