Skip to content

Units are not UnwindSafe #227

@DusterTheFirst

Description

@DusterTheFirst

When trying to pass the units into a closure passed to panic::catch_unwind I get this mess of an error:

Error
error[E0277]: the type `(dyn preflight_impl::uom::si::Dimension<I = Z0, N = Z0, Kind = (dyn Kind + 'static), L = PInt<UInt<UTerm, B1>>, J = Z0, T = Z0, M = Z0, Th = Z0> + 'static)` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary
   --> crates/preflight/src/bin/cargo-preflight.rs:63:38
    |
63  |                         let result = panic::catch_unwind(|| dbg!(api.avionics_guide(&input)));
    |                                      ^^^^^^^^^^^^^^^^^^^ `(dyn preflight_impl::uom::si::Dimension<I = Z0, N = Z0, Kind = (dyn Kind + 'static), L = PInt<UInt<UTerm, B1>>, J = Z0, T = Z0, M = Z0, Th = Z0> + 'static)` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary
    | 
   ::: /home/dusterthefirst/.local/share/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:381:40
    |
381 | pub fn catch_unwind<F: FnOnce() -> R + UnwindSafe, R>(f: F) -> Result<R> {
    |                                        ---------- required by this bound in `catch_unwind`
    |
    = help: within `Sensors`, the trait `RefUnwindSafe` is not implemented for `(dyn preflight_impl::uom::si::Dimension<I = Z0, N = Z0, Kind = (dyn Kind + 'static), L = PInt<UInt<UTerm, B1>>, J = Z0, T = Z0, M = Z0, Th = Z0> + 'static)`
    = note: required because it appears within the type `PhantomData<(dyn preflight_impl::uom::si::Dimension<I = Z0, N = Z0, Kind = (dyn Kind + 'static), L = PInt<UInt<UTerm, B1>>, J = Z0, T = Z0, M = Z0, Th = Z0> + 'static)>`
    = note: required because it appears within the type `Quantity<(dyn preflight_impl::uom::si::Dimension<I = Z0, N = Z0, Kind = (dyn Kind + 'static), L = PInt<UInt<UTerm, B1>>, J = Z0, T = Z0, M = Z0, Th = Z0> + 'static), (dyn Units<f64, thermodynamic_temperature = preflight_impl::uom::si::thermodynamic_temperature::kelvin, mass = kilogram, electric_current = ampere, time = preflight_impl::uom::si::time::second, amount_of_substance = mole, luminous_intensity = candela, length = meter> + 'static), f64>`
    = note: required because it appears within the type `Sensors`
    = note: required because of the requirements on the impl of `UnwindSafe` for `&Sensors`
    = note: required because it appears within the type `[closure@crates/preflight/src/bin/cargo-preflight.rs:63:58: 63:93]`

error[E0277]: the type `(dyn Units<f64, thermodynamic_temperature = preflight_impl::uom::si::thermodynamic_temperature::kelvin, mass = kilogram, electric_current = ampere, time = preflight_impl::uom::si::time::second, amount_of_substance = mole, luminous_intensity = candela, length = meter> + 'static)` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary
   --> crates/preflight/src/bin/cargo-preflight.rs:63:38
    |
63  |                         let result = panic::catch_unwind(|| dbg!(api.avionics_guide(&input)));
    |                                      ^^^^^^^^^^^^^^^^^^^ `(dyn Units<f64, thermodynamic_temperature = preflight_impl::uom::si::thermodynamic_temperature::kelvin, mass = kilogram, electric_current = ampere, time = preflight_impl::uom::si::time::second, amount_of_substance = mole, luminous_intensity = candela, length = meter> + 'static)` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary
    | 
   ::: /home/dusterthefirst/.local/share/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:381:40
    |
381 | pub fn catch_unwind<F: FnOnce() -> R + UnwindSafe, R>(f: F) -> Result<R> {
    |                                        ---------- required by this bound in `catch_unwind`
    |
    = help: within `Sensors`, the trait `RefUnwindSafe` is not implemented for `(dyn Units<f64, thermodynamic_temperature = preflight_impl::uom::si::thermodynamic_temperature::kelvin, mass = kilogram, electric_current = ampere, time = preflight_impl::uom::si::time::second, amount_of_substance = mole, luminous_intensity = candela, length = meter> + 'static)`
    = note: required because it appears within the type `PhantomData<(dyn Units<f64, thermodynamic_temperature = preflight_impl::uom::si::thermodynamic_temperature::kelvin, mass = kilogram, electric_current = ampere, time = preflight_impl::uom::si::time::second, amount_of_substance = mole, luminous_intensity = candela, length = meter> + 'static)>`
    = note: required because it appears within the type `Quantity<(dyn preflight_impl::uom::si::Dimension<I = Z0, N = Z0, Kind = (dyn Kind + 'static), L = PInt<UInt<UTerm, B1>>, J = Z0, T = Z0, M = Z0, Th = Z0> + 'static), (dyn Units<f64, thermodynamic_temperature = preflight_impl::uom::si::thermodynamic_temperature::kelvin, mass = kilogram, electric_current = ampere, time = preflight_impl::uom::si::time::second, amount_of_substance = mole, luminous_intensity = candela, length = meter> + 'static), f64>`
    = note: required because it appears within the type `Sensors`
    = note: required because of the requirements on the impl of `UnwindSafe` for `&Sensors`
    = note: required because it appears within the type `[closure@crates/preflight/src/bin/cargo-preflight.rs:63:58: 63:93]`

which seems to stem from the fact that uom::si::f64::Length does not implement RefUnwindSafe or UnwindSafe.
I thought it might have been since I had omitted the std feature from the dependency, but the issue persists with and without the std feature

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions