diesel-rs/diesel · error
Only enums are supported as multiconnection type
Error message
Only enums are supported as multiconnection type
What it means
Compile-time error in the #[multi_connection] attribute macro. The macro expects the annotated item to be an enum whose variants are the supported backend connections; it generates the MultiBackend/MultiRow plumbing only from that enum. It fires when the user applies #[diesel::multi_connection] to a struct, union, or other non-enum item, where no backend dispatch can be generated. Fix: annotate an enum listing one variant per backend connection.
Solutions
- Convert the type into an enum with one backend per variant
- Apply the derive only to enum types
- Use a single concrete connection type instead of a struct wrapper
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at diesel_derives/src/multiconnection.rs:65 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of diesel-rs/diesel@6fa6ed01b2 (2026-09-07).
Data as JSON: /api/errors/3d6c055b24859f4b.
Report an issue: GitHub.
Appendix: source
Thrown at diesel_derives/src/multiconnection.rs:65
mod row {
use super::*;
#row
}
mod connection {
use super::*;
#connection
}
pub use self::backend::{MultiBackend, MultiRawValue};
pub use self::row::{MultiRow, MultiField};
}
pub use self::multi_connection_impl::{MultiBackend, MultiRow, MultiRawValue, MultiField};
}
} else {
panic!("Only enums are supported as multiconnection type");
}
}
/// A helper struct containing common tokens used in the sync and async in similar.
struct MultiHelper {
is_async: bool,
/// Type of Connection trait.
conn: TokenStream,
/// Trait with the Backend Type.
conn_backend: TokenStream,
/// Trait implementing the load function.
conn_load: TokenStream,
/// The multi connection helper trait, used to cast to Any.
multi_conn_helper: TokenStream,
/// Type of the SimpleConnection trait.
simple_connection: TokenStream,
/// Type of the TransactionManager trait.
transaction_manager: TokenStream,View on GitHub (pinned to 6fa6ed01b2)