Skip to content

feat(codegen/rust): add deprecated attribute for enum variants and types#175

Open
akozlev wants to merge 3 commits into
thepartly:mainfrom
akozlev:feature/deprecation-in-rust-enum-variant
Open

feat(codegen/rust): add deprecated attribute for enum variants and types#175
akozlev wants to merge 3 commits into
thepartly:mainfrom
akozlev:feature/deprecation-in-rust-enum-variant

Conversation

@akozlev

@akozlev akozlev commented Jun 16, 2026

Copy link
Copy Markdown

No description provided.

@akozlev akozlev requested a review from hardbyte June 16, 2026 19:58
@hardbyte

Copy link
Copy Markdown
Contributor
  1. reflectapi/src/codegen/rust.rs:398 and reflectapi/src/codegen/rust.rs:857: generated clients can fail under -D warnings after adding #[deprecated] to generated types. The generated interface methods still reference those deprecated types in their own signatures, so compiling the generated client itself emits deprecated warnings before any downstream caller has used the deprecated API. A crate with #![deny(warnings)] will fail just by compiling the generated code. The generated module likely needs internal #[allow(deprecated)] around generated references while still exposing #[deprecated] on the public items so downstream users get warnings when they use them.
  2. reflectapi/src/codegen/rust.rs:402, reflectapi/src/codegen/rust.rs:620, reflectapi/src/codegen/rust.rs:732: deprecation notes are interpolated directly into Rust string literals. Notes containing quotes, backslashes, or newlines generate invalid Rust. Example source #[deprecated(note = "use "New"")] becomes #[deprecated(note = "use "New"")]. This should use a Rust string literal escaping helper rather than raw interpolation.
  3. reflectapi/src/codegen/schema/semantic.rs:82 and reflectapi/src/codegen/schema/semantic.rs:145: type/variant deprecation metadata is added to raw schema but not to SemanticStruct, SemanticEnum, or SemanticVariant. In the context of Architecture: move codegen backends toward SemanticSchema as the common backend contract #129, this puts new backend-relevant meaning outside the semantic contract and guarantees drift as backends move toward SemanticSchema. The current snapshots already show the drift: Rust renders deprecated type/variant attributes, but TypeScript/Python/OpenAPI snapshots for the same deprecated types/variants do not surface the metadata.

@avkonst

avkonst commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

regarding 1, is not the point of deprecation to issue a warning and let a user to decide if they want to fail on this, leave a warning or fix? I think they can steer the warning to error or nothing on their side?

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