-
-
Notifications
You must be signed in to change notification settings - Fork 169
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
Error: use of unstable library feature 'error_generic_member_access #387
Comments
Using Backtrace in errors requires a nightly compiler. This is mentioned in the readme. |
I can use Backtraces fine with the this stable compiler. Compilation works fine if I remove -#[derive(Debug, thiserror::Error)]
+#[derive(Debug)]
pub struct Error {
kind: ErrorKind,
source: Option<Box<dyn std::error::Error + Send + Sync>>,
backtrace: Backtrace,
}
+impl std::error::Error for Error {} Does |
@WhyNotHugo You can disable this behavior by creating a type alias. |
Is there a fundamental reason for that? What doesn't work with 1.82.0? Unfortunately using nightly compiler to ship production code is not the best approach for us. Would be great to have backtraces without |
@mhnap could you provide more details which type alias is needed to use Backtrace with stable compiler? |
Here's a workaround: use std::backtrace::Backtrace as MacrosCannotSeeTypes;
#[derive(Debug, thiserror::Error)]
pub struct Error {
backtrace: MacrosCannotSeeTypes,
} |
@kornelski that doesn't work:
gives me:
|
@mikea You can write impl From <nix::errno::Errno> for SetupError {
fn from(value: nix::errno::Errno) -> Self {
todo!()
}
} |
@mhnap I could, but what's preventing thiserror from generating the same code? It doesn't involve nightly or any obscure feature. Also, your suggestion more or less means not to use thiserror when Backtrace is needed and to write everything manually. |
@mikea Because |
@mhnap maybe I am missing something, but this issue is precisely about that: generate From for two fields: source and backtrace. I am not asking to handle unknown fields: the original reporter (and me) would like to use Backtraces with stable rust. It is not clear to me from these explanations why it is not possible to generate such code if I can write it manually. I completely understand if the situation was "we agree, it would be better, but we don't have time. PRs are welcome". Or "we think this is wrong to do because X". The answer instead was "it is documented". Or "do not use thiserror". Which is a little bit hostile for such a simple feature request, don't you think? Especially since Backtraces were stabilizing long long ago. |
@mikea In such a case this makes sense. If you find this usefull, I think it would be better to create a new issue (if there are no existing or closed ones with explanations) and explicitly write about a feature request to support the generation of the (I'm not a contributor, I just noticed a couple of unanswered questions and decided to answer) By the way, I bumped into this some time ago, but I also needed to use |
The following fails to compile:
Error output:
#204 seems to be related. That was due to features not supported by Rust 1.65. I'm using 1.82.0.
It's not entirely clear to me what requires
error_generic_member_access
here. Usingimpl std::error::Error for Error {}
instead ofthiserror
for the same type does work.The text was updated successfully, but these errors were encountered: