Comments (5)
Here's minimized code that causes a different but similarly confusing error message. Unsure if this still preserves the essence of the original code.
async fn listen() {
let things: Vec<Vec<i32>> = vec![];
for _ in things.iter().map(|n| n.iter()).flatten() {
// comment this line and everything compiles
async {}.await;
}
}
fn require_send<T: Send>(_x: T) {}
fn foo() {
let future = listen();
require_send(future);
}
Error message:
Compiling playground v0.0.1 (/playground)
error: implementation of `FnOnce` is not general enough
--> src/lib.rs:13:5
|
13 | require_send(future);
| ^^^^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough
|
= note: closure with signature `fn(&'0 Vec<i32>) -> std::slice::Iter<'_, i32>` must implement `FnOnce<(&'1 Vec<i32>,)>`, for any two lifetimes `'0` and `'1`...
= note: ...but it actually implements `FnOnce<(&Vec<i32>,)>`
error: could not compile `playground` (lib) due to 1 previous error
from rust.
Both fn iter<T>(v: &Vec<T>) -> Iter<'_, T> { v.iter() }
replacing closure and .flat_map(|n| n.iter())
make the code compile. The difference between FlatMap
and Flatten
is that the first one unifies lifetimes of returned U: IntoIterator
s, and the other tries to unify Map::<I, F: Fn(_) -> _>::Item
s, but F isn't higher ranked closure, and as such it fails to do so. Feel free to correct me if I'm wrong.
from rust.
@rustbot label -needs-triage +A-diagnostics +A-Async-Await +A-auto-traits +A-traits +D-confusing
from rust.
This doesn't use closures and has the same issue.
async fn listen() {
let things: Vec<Vec<i32>> = vec![];
for _ in things.iter().map(id).flatten() {
// comment this line and everything compiles
async {}.await;
}
}
fn id<T>(x: T) -> T { x }
fn require_send<T: Send>(_x: T) {}
fn foo() {
let future = listen();
require_send(future);
}
Compiling playground v0.0.1 (/playground)
error: implementation of `FnOnce` is not general enough
--> src/lib.rs:15:5
|
15 | require_send(future);
| ^^^^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough
|
= note: `fn(&'0 Vec<i32>) -> &'0 Vec<i32> {id::<&'0 Vec<i32>>}` must implement `FnOnce<(&'1 Vec<i32>,)>`, for any two lifetimes `'0` and `'1`...
= note: ...but it actually implements `FnOnce<(&Vec<i32>,)>`
error: could not compile `playground` (lib) due to 1 previous error
from rust.
@rustbot labels +AsyncAwait-Triaged
We discussed this in the async meeting today. We think this is probably related to:
from rust.
Related Issues (20)
- ICE `index out of bounds: the len is 0 but the index is 0` HOT 1
- `binary_asm_labels` should suggest a change HOT 5
- ICE: `bpos.to_u32() >= mbc.pos.to_u32() + mbc.bytes as u32` HOT 4
- ICE: `failed to resolve instance for ErrorGuaranteed()` HOT 1
- aarch64-pointer-auth test failing on LLVM 19 HOT 1
- Poorly-documented safety assumptions in `unix::stack_overflow::init` HOT 6
- Bootstrap using `set_times` on a read-only file
- Compiler marks import as unnecessary when it isn't (panic_handler) HOT 4
- Corrupted data trashes the output HOT 8
- Confusing CI error when compiler build fails HOT 8
- unreachable pattern lint should report some (or all) of the earlier match arms that subsume the unreachable one HOT 6
- Compiler unexpectedly panicked - async HOT 4
- ICE: `unexpected value of coverage attribute` HOT 1
- ICE: `typeid_for_instance: couldn't get fn_abi of instance`
- High failure rate on Windows MSVC CI with filesystem errors HOT 3
- `#[expect(unused_imports)]` does not work correctly on grouped imports HOT 8
- Solve the pinned memchr problem
- `doctest` line number is incorrect if used with #![doc = include_str!()] HOT 6
- `tests/run-make/print-target-list` `--print=sysroot` check fails for experimental llvm targets HOT 3
- Missing implied bound raises misleading error message HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust.