Skip to content

refactor(core): derive Display and Error via thiserror in DecodeErrorKind and EncodeErrorKind#1261

Closed
Greg Lamberson (glamberson) wants to merge 1 commit into
Devolutions:masterfrom
lamco-admin:feat/thiserror-derive-core
Closed

refactor(core): derive Display and Error via thiserror in DecodeErrorKind and EncodeErrorKind#1261
Greg Lamberson (glamberson) wants to merge 1 commit into
Devolutions:masterfrom
lamco-admin:feat/thiserror-derive-core

Conversation

@glamberson
Copy link
Copy Markdown
Contributor

Refs #1257. Companion to #1260.

Companion to the std-only thiserror migration in #1260. ironrdp-core is split off because it is no_std-aware and the change requires Cargo.toml feature wiring that the other crates do not need.

Changes

  • Adds thiserror = { version = "2", default-features = false } to dependencies.
  • Wires thiserror/std into the existing std feature: std = ["alloc", "ironrdp-error/std", "thiserror/std"].
  • Derives thiserror::Error on DecodeErrorKind and EncodeErrorKind with per-variant #[error("...")] attributes that match the prior write!(f, "...") format strings exactly.
  • Each cfg-gated UnsupportedValue variant (with/without alloc) receives its own #[error("...")] attribute.
  • Removes the #[cfg(feature = "std")] impl core::error::Error for *ErrorKind {} gates. core::error::Error lives in core (stabilized Rust 1.81, well below MSRV 1.89), and thiserror's derive emits an unconditional impl. The behaviour change is from "Error impl available only with std" to "Error impl always available", which is a strict superset.

Public API impact

None. The pub type DecodeError = ironrdp_error::Error<DecodeErrorKind> and pub type EncodeError = ironrdp_error::Error<EncodeErrorKind> aliases are unchanged. Consumers see no source-level break.

no_std verification

All three feature combinations build cleanly:

  • cargo check -p ironrdp-core --no-default-features (no_std, no alloc)
  • cargo check -p ironrdp-core --no-default-features --features alloc (no_std + alloc)
  • cargo check -p ironrdp-core --features std

xtask verification

Diff size

5 files changed, +20 −73 (net −53 lines of code removed).

…Kind and EncodeErrorKind

Refs Devolutions#1257.

Companion to the std-only thiserror migration in the prior PR. ironrdp-core
is split off because it is no_std-aware and the change requires Cargo.toml
feature wiring that the other crates do not need.

### Changes

- Adds `thiserror = { version = "2", default-features = false }` to dependencies.
- Wires `thiserror/std` into the existing `std` feature: `std = ["alloc", "ironrdp-error/std", "thiserror/std"]`.
- Derives `thiserror::Error` on `DecodeErrorKind` and `EncodeErrorKind` with per-variant `#[error("...")]` attributes that match the prior `write!(f, "...")` format strings exactly.
- Each cfg-gated `UnsupportedValue` variant (with/without `alloc`) receives its own `#[error("...")]` attribute.
- Removes the `#[cfg(feature = "std")] impl core::error::Error for *ErrorKind {}` gates. `core::error::Error` lives in `core` (stabilized Rust 1.81, well below MSRV 1.89), and `thiserror`'s derive emits an unconditional `impl`. The behaviour change is from "Error impl available only with std" to "Error impl always available", which is a strict superset.

### Public API impact

None. The `pub type DecodeError = ironrdp_error::Error<DecodeErrorKind>` and `pub type EncodeError = ironrdp_error::Error<EncodeErrorKind>` aliases are unchanged. Consumers see no source-level break.

### no_std verification

All three feature combinations build cleanly:

- `cargo check -p ironrdp-core --no-default-features` (no_std, no alloc)
- `cargo check -p ironrdp-core --no-default-features --features alloc` (no_std + alloc)
- `cargo check -p ironrdp-core --features std`

### xtask verification

- `cargo xtask check fmt`: clean
- `cargo xtask check lints`: clean
- `cargo xtask check locks`: clean (root and fuzz Cargo.lock both updated and included; the missing fuzz lock was the failure mode of the earlier Devolutions#1259 attempt)
- `cargo xtask check typos`: clean
- `cargo xtask check tests`: clean
@glamberson
Copy link
Copy Markdown
Contributor Author

Closing per #1257 (#1257 (comment)). Change 1's premise is withdrawn after the Core Tier proc-macro invariant correction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant