withoutboats / fehler

Rust doesn't have exceptions
Other
629 stars 24 forks source link

could not find `fehler` in `{{root}}` when reexporting the lib #56

Closed artemshein closed 4 years ago

artemshein commented 4 years ago
use other_lib::fehler::{self, *}

#[throws]
fn main() {
}
error[E0433]: failed to resolve: could not find `fehler` in `{{root}}`
   --> super_app/src/main.rs:5:5
    |
5 |     #[throws]
    |     ^^^^^^^^^ could not find `fehler` in `{{root}}`
    |
    = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)

when it's exported from another crate other_lib like:

pub use fehler;

Is it a bug or a feature?

withoutboats commented 4 years ago

It's neither, its a necessary limitation. The throws macro generates code, which uses paths from the fehler crate, so if you don't have a direct dependency on the fehler crate, the macro will not work.

artemshein commented 4 years ago

If it's not something we're able to change probably no need to keep the issue open.

blueforesticarus commented 1 year ago

This is supported in crates like serde and strum with an attribute.

https://serde.rs/container-attrs.html#crate