Open
Description
Im still getting a recursion error even after #89576.
Maybe related: #77291, #89576, #75397.
I tried this code:
pub async fn products( params: Query<QueryParams>, Extension(pool): Extension<Pool<Postgres>>)
-> impl IntoResponse {
async move {
let mut connection=pool.acquire().await.unwrap();
connection.transaction(|conn| async move {
let products: Pin<Box<dyn futures::Stream<Item=Result<Bytes, sqlx::Error>> + Send>> = query_as!(
Product,
"select * from products order by product_name")
.map(|p| {
let json = format!("{}\n", serde_json::to_string(&p).unwrap());
Bytes::from(json)
})
.fetch(&mut connection);
Ok(StreamBody::new(products))
})
}.await
}
#[derive(Debug,Serialize, Deserialize, ormx::Table, sqlx::FromRow)]
#[ormx(table = "Products", id = product_id, insertable, deletable)]
struct Product {
product_id: i16,
product_name: String,
supplier_id: i16,
category_id: i16,
quantity_per_unit: String,
unit_price: f32,
units_in_stock: i16,
units_on_order: i16,
reorder_level: i16,
discontinued: i32,
}
I know there is an error in the code I meant to put conn
where it is presently .fetch(&mut connection)
.
I expected to see this happen: A non-recursive compiler error.
Instead, this happened (cargo +nightly build
):
error[E0275]: overflow evaluating the requirement `&HashSet<_, _>: std::ops::Sub`
--> src/northwind.rs:92:39
|
92 | connection.transaction(|conn| async move {
| _______________________________________^
93 | | let products: Pin<Box<dyn futures::Stream<Item=Result<Bytes, sqlx::Error>> + Send>> = query_as!(
94 | | Product,
95 | | "select * from products order by product_name")
... |
101 | | Ok(StreamBody::new(products))
102 | | })
| |_________^
|
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`server`)
= note: required because of the requirements on the impl of `std::ops::Sub` for `&ordered_float::OrderedFloat<HashSet<_, _>>`
= note: 126 redundant requirements hidden
= note: required because of the requirements on the impl of `std::ops::Sub<&ordered_float::OrderedFloat<ordered_float::OrderedFloat<ordered_float::OrderedFloat<ordered_float::OrderedFloat<ordered_float::OrderedFloat<ordered_float::OrderedFloat<ordered_float::OrderedFloat<ordered_float::OrderedFloat<ordered_float::OrderedFloat<ordered_float::OrderedFloat<ordered_float::OrderedFloat<ordered_float::OrderedFloat<ordered_float::OrderedFloat<ordered_float::OrderedFloat<ordered_float::OrderedFloat<ordered_float::OrderedFloat<ordered_float::OrderedFloat<ordered_float::OrderedFloat<ordered_float::....etc
rustc --version --verbose
:
rustc 1.58.0-nightly (547a6ffee 2021-10-21)
binary: rustc
commit-hash: 547a6ffee0cf4da9929a9e3d49546dc87d607735
commit-date: 2021-10-21
host: x86_64-unknown-linux-gnu
release: 1.58.0-nightly
LLVM version: 13.0.0
cargo --version --verbose
cargo 1.57.0-nightly (7fbbf4e8f 2021-10-19)
release: 1.57.0
commit-hash: 7fbbf4e8f23e3c24b8afff541dcb17e53eb5ff88
commit-date: 2021-10-19
host: x86_64-unknown-linux-gnu
libgit2: 1.3.0 (sys:0.13.23 vendored)
libcurl: 7.79.1-DEV (sys:0.4.49+curl-7.79.1 vendored ssl:OpenSSL/1.1.1l)
os: Ubuntu 20.04 (focal) [64-bit]
Another version of the code compiles and works fine
pub async fn products_via_vec( params: Query<QueryParams>, Extension(pool): Extension<Pool<Postgres>>)
-> impl IntoResponse {
let products:Vec<Result<_, std::io::Error>>=query_as!(
Product,
"select * from products order by product_name")
.map(|p| {
let json=format!("{}\n",serde_json::to_string(&p).unwrap());
Ok(Bytes::from(json)) })
.fetch_all(&pool).await.unwrap();
let stream = stream::iter(products);
StreamBody::new(stream)
}
Im not sure how to create a minimal test case of what is occurring.
I can provide the cargo toml if required