Rust E0308: mismatched types
Expression type differs from expected return type, parameter type, or match arm type.
Runs locally in browser
Free · No login
Independently Verified 2026-11-25
v4.0.0
Identifier: Rust E0308: mismatched types
Platform: Rust
Interactive Diagnostic Checklist
Safe Diagnostic Command:
rustc --explain E0308
Technical Explanation
Expression type differs from expected return type, parameter type, or match arm type. Verified resolution path: Check trailing semicolons (which turn expressions into `()`) and explicit numeric conversions.
Worked Examples
- Read-only diagnostic command: rustc --explain E0308
Limitations & Assumptions
- Always verify which infrastructure layer (CDN, Nginx, runtime, OS, or database) emitted the error before modifying production config.
Source References & Verification
Resource ID: err-rust-e0308-mismatched-types · Independently verified: 2026-11-25