Skip to content

Compilation error in release mode when using geo_traits::to_geo::ToGeoGeometry #1385

@kylebarron

Description

@kylebarron

If you try to build geoarrow-rs from commit geoarrow/geoarrow-rs@7460d2d in release mode, it fails to compile

> cargo build -p geoarrow-geo --release
error[E0275]: overflow evaluating the requirement `<impl GeoArrowArrayAccessor<'a> as GeoArrowArrayAccessor<'_>>::Item: GeometryTrait`
  |
  = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`geoarrow_geo`)
  = note: required for `<... as GeometryCollectionTrait>::GeometryType<'_>` to implement `ToGeoGeometry<f64>`
  = note: the full name for the type has been written to '/Users/kyle/github/geoarrow/geoarrow-rs/target/release/deps/geoarrow_geo-8bdeb9ef39e43e3f.long-type-1864961926160306549.txt'
  = note: consider using `--verbose` to print the full type name to the console

This is specifically a recursion error with associated types on traits that I expect will occur for any use of geo_traits::to_geo::ToGeoGeometry.

This is an upstream rustc bug: rust-lang/rust#128887. The easiest workaround is to use functional recursion instead of traits. See https://github.com/geoarrow/geoarrow-rs/pull/1241/files#diff-65671f18ff582a277533174c62b8ef053c13120d788084a00b6917dbece31c84

I suppose in #1255 (comment) maybe I should've chosen the functional approach instead of the trait-based approach 😅

This issue is mostly to spread awareness of the problem. I'm not sure there's anything actionable here? Maybe we should just wait for rustc to fix their bug and advise users to vendor a functional workaround?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions