mirror of https://github.com/zkat/miette.git
Use Borrow::borrow instead of AsRef
AsRef is not reflexive, meaning that it is not implemented as &T for all T. Borrow is though, so we use that to make sure that we always get a reference that is correct, even in the presence of smart pointers.
This commit is contained in:
parent
8ba24da443
commit
3914726ddb
|
|
@ -59,7 +59,8 @@ impl DiagnosticSource {
|
||||||
};
|
};
|
||||||
quote! {
|
quote! {
|
||||||
Self::#ident #display_pat => {
|
Self::#ident #display_pat => {
|
||||||
std::option::Option::Some(#rel.as_ref())
|
use std::borrow::Borrow;
|
||||||
|
std::option::Option::Some(#rel.borrow())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -71,7 +72,8 @@ impl DiagnosticSource {
|
||||||
let rel = &self.0;
|
let rel = &self.0;
|
||||||
Some(quote! {
|
Some(quote! {
|
||||||
fn diagnostic_source<'a>(&'a self) -> std::option::Option<&'a dyn miette::Diagnostic> {
|
fn diagnostic_source<'a>(&'a self) -> std::option::Option<&'a dyn miette::Diagnostic> {
|
||||||
std::option::Option::Some(&self.#rel)
|
use std::borrow::Borrow;
|
||||||
|
std::option::Option::Some(self.#rel.borrow())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue