derive macro broke if you `use anyhow::Ok`
Opened this issue · 0 comments
LuckyTurtleDev commented
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`.