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

derive macro broke if you use anyhow::Ok #47

Open
LuckyTurtleDev opened this issue Oct 11, 2024 · 0 comments
Open

derive macro broke if you use anyhow::Ok #47

LuckyTurtleDev opened this issue Oct 11, 2024 · 0 comments

Comments

@LuckyTurtleDev
Copy link

The derive macro broke if you use anyhow::Ok.
I had accidentally import anyhow::Ok and notify that it broke the marcro.

use anyhow::Ok;

#[derive(Debug, Envconfig)]
pub struct MatrixConfig {
    #[envconfig(from = "MATRIX_HOMESERVER_URL")]
	homeserver_url: String,
    #[envconfig(from = "MATRIX_USERNAME")]
	username: String,
    #[envconfig(from = "MATRIX_PASSWORD")]
	password: String,
}

Error message:

error[E0308]: mismatched types
   --> src/server/matrix/mod.rs:8:17
    |
8   | #[derive(Debug, Envconfig)]
    |                 ^^^^^^^^^
    |                 |
    |                 expected `envconfig::Error`, found `anyhow::Error`
    |                 expected `Result<MatrixConfig, envconfig::Error>` because of return type
    |
    = note: `anyhow::Error` and `envconfig::Error` have similar names, but are actually distinct types
note: `anyhow::Error` is defined in crate `anyhow`
   --> /home/lukas/.cargo/registry/src/index.crates.io-6f17d22bba15001f/anyhow-1.0.89/src/lib.rs:389:1
    |
389 | pub struct Error {
    | ^^^^^^^^^^^^^^^^
note: `envconfig::Error` is defined in crate `envconfig`
   --> /home/lukas/.cargo/registry/src/index.crates.io-6f17d22bba15001f/envconfig-0.11.0/src/error.rs:7:1
    |
7   | pub enum Error {
    | ^^^^^^^^^^^^^^
    = note: this error originates in the derive macro `Envconfig` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E0308`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant