Skip to content

feat: add allow_deprecated option to stack_error - #52

Open
Frando wants to merge 2 commits into
mainfrom
Frando/allow-deprecated
Open

feat: add allow_deprecated option to stack_error#52
Frando wants to merge 2 commits into
mainfrom
Frando/allow-deprecated

Conversation

@Frando

@Frando Frando commented Jul 14, 2026

Copy link
Copy Markdown
Member

Description

The stack_error macro expands to impls that match on and construct every enum variant, including deprecated ones. Under #[deny(deprecated)] (or with the lint enabled), an enum with #[deprecated] variants therefore triggers deprecated warnings/errors at the #[stack_error(..)] call site.

This PR adds an allow_deprecated option to stack_error (enums only) that wraps the generated impls in #[allow(deprecated)], so deprecated variants no longer trigger warnings in the expansion. The added test would fail to compile without the change.

Breaking Changes

Notes & open questions

Change checklist

  • Self-review.
  • Documentation updates following the style guide, if relevant.
  • Tests if relevant.
  • All breaking changes documented.

Suppresses the deprecated lint in the generated impls, so enums can have
#[deprecated] variants without the expansion triggering warnings at the
#[stack_error(..)] call site.
@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown

Documentation for this PR has been generated and is available at: https://n0-computer.github.io/n0-error/pr/52/docs/n0_error/

Last updated: 2026-07-14T10:38:44Z

@Frando
Frando requested review from a team and dignifiedquire July 15, 2026 11:29

@flub flub left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I've done this by hand I only apply the #[allow(deprecated)] on branch that is deprecated instead of the entire enum block. Is that worth doing here as well or is there no downside to allowing it on all branches?

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 this pull request may close these issues.

3 participants