Sitelet https://github.com/starkware-libs/cairo/pull/10096
Skip to content

feat(plugins): deprecate #[panic_with] - #10096

Merged
orizi merged 1 commit into
mainfrom
orizi/06-14-feat_plugins_deprecate_panic_with_
Jun 16, 2026
Merged

orizi merged 1 commit into
mainfrom
orizi/06-14-feat_plugins_deprecate_panic_with_

Conversation

@orizi

@orizi orizi commented Jun 14, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Deprecates the #[panic_with] macro by emitting a warning diagnostic when it is used without an explicit #[feature("deprecated-panic-with")] opt-in attribute. The warning message directs users to use simple calculations instead, noting that these are supported in const context.


Type of change

Please check one:

  • Bug fix (fixes incorrect behavior)
  • New feature
  • Performance improvement
  • Documentation change with concrete technical impact
  • Style, wording, formatting, or typo-only change

Why is this change needed?

The #[panic_with] macro is being deprecated in favor of simple calculations, which are now supported in const context. Without a deprecation warning, users have no signal to migrate away from this macro.


What was the behavior or documentation before?

Using #[panic_with] produced no deprecation warning. The macro expanded silently regardless of whether the user acknowledged its deprecated status.


What is the behavior or documentation after?

Using #[panic_with] without #[feature("deprecated-panic-with")] on the same item now emits a warning:

Usage of deprecated macro `panic_with` with no `#[feature("deprecated-panic-with")]` attribute.
Use simple calculations instead, as these are supported in const context.

Users who need to continue using the macro can suppress the warning by adding #[feature("deprecated-panic-with")] to the item.


Related issue or discussion (if any)


Additional context

The feature gate string "deprecated-panic-with" is stored with surrounding quotes because allowed_features holds raw string-literal text.

@reviewable-StarkWare

Copy link
Copy Markdown

This change is Reviewable

orizi commented Jun 14, 2026 •

Copy link
Copy Markdown
Collaborator Author

@cursor

cursor Bot commented Jun 14, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
Compiler-plugin diagnostic and feature-gating only; no change to generated code paths when the feature is present or absent beyond new warnings.

Overview
The PanicablePlugin now consults MacroPluginMetadata::allowed_features and emits a warning on each #[panic_with] use when "deprecated-panic-with" is not opted in via #[feature("deprecated-panic-with")] on the item (or inherited module features). The message steers users toward simple calculations in const context; macro expansion behavior is unchanged.

Plugin tests that expect clean expansion add the feature attribute on annotated items. Diagnostic tests now also expect this deprecation signal alongside existing panic_with errors.

Reviewed by Cursor Bugbot for commit 26f0bf0. Bugbot is set up for automated code reviews on this repo. Configure here.

@eytan-starkware eytan-starkware left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

:lgtm:

@eytan-starkware reviewed 2 files and all commit messages, and made 1 comment.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on TomerStarkware).

@TomerStarkware TomerStarkware left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

:lgtm:

@TomerStarkware made 1 comment.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on orizi).

@orizi
orizi force-pushed the orizi/06-14-feat_plugins_deprecate_panic_with_ branch from f4957f3 to 302f09c Compare June 15, 2026 16:18
@orizi
orizi force-pushed the orizi/06-14-chore_corelib_drop_internal_panic_with_usages branch from ccf3121 to 063248d Compare June 15, 2026 16:18
@orizi
orizi force-pushed the orizi/06-14-feat_plugins_deprecate_panic_with_ branch from 302f09c to e64c09f Compare June 16, 2026 07:00
@orizi
orizi force-pushed the orizi/06-14-chore_corelib_drop_internal_panic_with_usages branch from 063248d to 6cbbfb3 Compare June 16, 2026 07:00
@orizi
orizi force-pushed the orizi/06-14-feat_plugins_deprecate_panic_with_ branch from e64c09f to 9593fd5 Compare June 16, 2026 10:46
@orizi
orizi force-pushed the orizi/06-14-chore_corelib_drop_internal_panic_with_usages branch from 6cbbfb3 to 0335928 Compare June 16, 2026 10:46
Emit a warning when `#[panic_with]` is used, unless the item or an enclosing
  module grants `#[feature("deprecated-panic-with")]`. Prefer explicit calculations,
  which are now supported in const context.

  The wrapper is still generated — this only warns. Relies on
  `MacroPluginMetadata::allowed_features` being populated at the defs layer.
@orizi
orizi changed the base branch from orizi/06-14-chore_corelib_drop_internal_panic_with_usages to graphite-base/10096 June 16, 2026 10:56
@orizi
orizi force-pushed the graphite-base/10096 branch from 0335928 to 6e4bec5 Compare June 16, 2026 10:56
@orizi
orizi force-pushed the orizi/06-14-feat_plugins_deprecate_panic_with_ branch from 9593fd5 to 26f0bf0 Compare June 16, 2026 10:56
@orizi
orizi changed the base branch from graphite-base/10096 to main June 16, 2026 10:56
@orizi
orizi enabled auto-merge June 16, 2026 10:57
@orizi
orizi added this pull request to the merge queue Jun 16, 2026
Merged via the queue into main with commit b86539a Jun 16, 2026
106 checks passed
@orizi
orizi deleted the orizi/06-14-feat_plugins_deprecate_panic_with_ branch June 16, 2026 11:08
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.

4 participants