The `database` feature doesn't compile without a database driver feature

Open
#846 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
55/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
rust
Domain
database

Research direction

Start with the reported dispatch matches in laravel-rust-database-0.2.0/src/db/neutral/transaction.rs:91 and src/db/neutral.rs:247, then check the type inference error at src/db/neutral.rs:293. Reproduce with database enabled and no driver feature. Done when that configuration compiles or produces a clear compile-time error explaining the driver requirement.

Written by the indexing model from the issue text.

Description

Enabling laravel-rust's database feature without one of database-sqlite, database-postgres or database-mysql fails to compile. This hits packages that forward a plain database feature (so apps can pick their own driver), and any cargo doc --all-features or MSRV check that doesn't pull in a driver.

Reproduction

[package]
name = "repro"
version = "0.1.0"
edition = "2024"

[dependencies]
laravel-rust = { version = "=0.2.0", default-features = false, features = ["database"] }
fn main() {}

cargo check (rustc 1.100.0):

error[E0004]: non-exhaustive patterns: type `&mut AnyTransaction<'_>` is non-empty
  --> laravel-rust-database-0.2.0/src/db/neutral/transaction.rs:91:19
   |
91 |         dispatch!(self, AnyTransaction, tx => tx.begin().await.map(Into::into))
   |                   ^^^^
   = note: references are always considered inhabited

error[E0004]: non-exhaustive patterns: type `&AnyConnection` is non-empty
   --> laravel-rust-database-0.2.0/src/db/neutral.rs:247:19

error[E0283]: type annotations needed for `(u32, _)`
   --> laravel-rust-database-0.2.0/src/db/neutral.rs:293:13

With no driver enabled, AnyConnection and AnyTransaction have no variants, so the dispatch! matches are non-exhaustive.

Expected

Either database compiles on its own (for example, with an uninhabited fallback arm or a compile_error! that names the missing driver feature), or the docs say that database needs a driver feature.

Seen on 0.2.0; the same code is on 0.x at 6156f0e.

Dominant language
Rust
Stars
847
Forks
174
Avg merge
5h 40m
Merged PRs (30d)
167

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from laravel/rust-framework

All issues in laravel/rust-framework

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.