Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recursive rustc error not solved by #89576 - error[E0275]: overflow evaluating the requirement &HashSet<_, _>: std::ops::Sub #90212

Open
apps4uco opened this issue Oct 23, 2021 · 0 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-traits Area: Trait system D-confusing Diagnostics: Confusing error or lint that should be reworked. D-newcomer-roadblock Diagnostics: Confusing error or lint; hard to understand for new users. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@apps4uco
Copy link

apps4uco commented Oct 23, 2021

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

@apps4uco apps4uco added the C-bug Category: This is a bug. label Oct 23, 2021
@ChrisDenton ChrisDenton added the needs-triage-legacy Old issue that were never triaged. Remove this label once the issue has been sufficiently triaged. label Jul 16, 2023
@fmease fmease added A-diagnostics Area: Messages for errors, warnings, and lints A-traits Area: Trait system T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. D-confusing Diagnostics: Confusing error or lint that should be reworked. D-newcomer-roadblock Diagnostics: Confusing error or lint; hard to understand for new users. and removed C-bug Category: This is a bug. needs-triage-legacy Old issue that were never triaged. Remove this label once the issue has been sufficiently triaged. labels Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-traits Area: Trait system D-confusing Diagnostics: Confusing error or lint that should be reworked. D-newcomer-roadblock Diagnostics: Confusing error or lint; hard to understand for new users. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants