failed Send inference resulting in "one type is more general than the other" E0308
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
this might be related to #90656 but since that is open since 2021 I document my case.
I'm running into E0308's when trying to compile an async fn that uses
- rust 1.98.1 (48a229cea 2026-09-01)
- uom v0.38
- ndarray v0.17.2 (NOTE - v0.16 seems to work)
The problem can be isolated into the following minimal code, which I would expect to compile. Please note it works with ndarray v0.16 so I will also report it there but at least the error message is not helpful
use uom::si::f64::Length;
use uom::ConstZero;
use ndarray::Array2;
fn assert_send<T: Send>(_t: T) {}
fn main() {
assert_send(check());
}
async fn check() {
let lengths: Array2<Length> = Array2::from_elem((2, 3), Length::ZERO);
std::future::pending::<()>().await;
println!("{}", lengths[(0, 0)].get::<uom::si::length::meter>());
}
The compiler error message is:
error[E0308]: mismatched types
--> src/main.rs:8:5
|
8 | assert_send(check());
| ^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
|
= note: expected struct `Quantity<..., ..., f64>`
found struct `Quantity<..., ..., f64>`
note: the lifetime requirement is introduced here
--> src/main.rs:5:19
|
5 | fn assert_send<T: Send>(_t: T) {}
| ^^^^
If you are interested I have a workaround wrapping the Array2 into a newtype with a at(&self,usize,usize)->Length fn and using that to obtain Length quantities inside the async fn. This comes from a bigger project though (https://github.com/ODIN-fire/odin-rs) where such workarounds are clearly suboptimal since it is highly async.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the minimal reproducer in src/main.rs and compile it using Rust 1.98.1, comparing ndarray v0.17.2 with v0.16. Read the related issue #90656 and investigate the E0308 diagnostic around the async Send requirement. Done means the cause is identified and the compiler either accepts the valid case or reports a more useful, accurate error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100