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

Use the same deprecation macros on the no_std Error as the official Error #425

Closed
NWPlayer123 opened this issue Dec 2, 2023 · 3 comments · Fixed by #430
Closed

Use the same deprecation macros on the no_std Error as the official Error #425

NWPlayer123 opened this issue Dec 2, 2023 · 3 comments · Fixed by #430

Comments

@NWPlayer123
Copy link

While writing up documentation, I noticed several deprecation warnings concerning description and cause, which have been deprecated since March 2020 and February 2019 respectively, which are coming up on 4 and 5 years ago, so I think it's high time to remove them entirely. Any repositories that still rely on it can either fix to a specific older version, or update their code to remove it.

@shepmaster
Copy link
Owner

shepmaster commented Dec 4, 2023

If I create an error type not using SNAFU and check its documentation, it contains those deprecation warnings:

use std::fmt;

#[derive(Debug)]
pub struct Demo;

impl fmt::Display for Demo {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        "Demo".fmt(f)
    }
}

impl std::error::Error for Demo {}
image

I'm sure you've checked something similar, so I'm not sure I understand what your end goal is here. Can you try and restate so I understand better?

@NWPlayer123
Copy link
Author

So it does, interesting. I was mostly bringing this up because I found https://github.com/shepmaster/snafu/blob/main/src/no_std_error.rs#L6 as I was digging around how no_std works, and that's what I was mostly taking issue with.

In that case, you should use the same deprecation macro as the official Error does, as library authors are able to use it.
image

@shepmaster shepmaster changed the title Remove Error::{description, cause} Use the same deprecation macros on the no_std Error as the official Error Dec 22, 2023
@shepmaster
Copy link
Owner

around how no_std works

If possible for your case, I'd recommend that you use the unstable-core-error feature flag to use the version of Error that lives in the core library. Once that is stable enough, SNAFU will no longer have a reason to create its own Error trait.

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

Successfully merging a pull request may close this issue.

2 participants