Skip to content

Commit f717d24

Browse files
committed
fix: adapt to the breaking api change in facet-macro-parse v0.31.8
We now use the Deref implementation to get at the data in DelimitedVec through its api methods instead of direct field access. Boxed our use of its error types as well. Updated the changelog.
1 parent a107fde commit f717d24

3 files changed

Lines changed: 23 additions & 15 deletions

File tree

.justfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ version BUMP:
2828
#!/usr/bin/env bash
2929
set -e
3030
current=$(tomato get package.version Cargo.toml)
31-
version=$(echo "$current" | semver-bump {{BUMP}})
31+
version=$(semver-bump {{BUMP}} "$current")
3232
tomato set package.version "$version" Cargo.toml &> /dev/null
3333
cargo generate-lockfile
34-
git commit Cargo.toml Cargo.lock -m "v${version}"
34+
git commit Cargo.toml -m "v${version}"
3535
git tag "v${version}"
3636
echo "Release tagged for version v${version}"
3737

CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.1.1] - 2025-11-28
11+
12+
### Fixed
13+
14+
- Fixed compatibility with `facet-macros-parse` 0.31.8 breaking API changes where `DelimitedVec` field `.0` became private
15+
- Fixed broken documentation link to `facet::Facet` (facet is a dev-dependency)
16+
- Fixed clippy warnings about large error variants in Result types
17+
1018
## [0.1.0] - 2025-01-20
1119

1220
### Added
@@ -38,5 +46,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3846
- Conservative fallback: fails safe by hiding data when metadata is unavailable
3947
- No data leakage in debug output for HIPAA-compliant and other sensitive applications
4048

41-
[Unreleased]: https://github.com/ceejbot/safe-debug/compare/v0.1.0...HEAD
49+
[Unreleased]: https://github.com/ceejbot/safe-debug/compare/v0.1.1...HEAD
50+
[0.1.1]: https://github.com/ceejbot/safe-debug/compare/v0.1.0...v0.1.1
4251
[0.1.0]: https://github.com/ceejbot/safe-debug/releases/tag/v0.1.0

src/lib.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//!
1212
//! ## Requirements
1313
//!
14-
//! - Must also derive or implement [`facet::Facet`]
14+
//! - Must also derive or implement `facet::Facet`
1515
//! - Sensitive fields marked with `#[facet(sensitive)]`
1616
//!
1717
//! ## Performance
@@ -54,6 +54,9 @@
5454
use facet_macros_parse::*;
5555
use quote::quote;
5656

57+
/// Type alias for Results with boxed errors to avoid large error variants
58+
type BoxedResult<T> = std::result::Result<T, Box<facet_macros_parse::Error>>;
59+
5760
/// Derives `std::fmt::Debug` with automatic redaction for sensitive fields.
5861
///
5962
/// # Supported Types
@@ -161,11 +164,11 @@ pub fn derive_safe_debug(input: proc_macro::TokenStream) -> proc_macro::TokenStr
161164
}
162165
}
163166

164-
fn derive_facet_debug_impl(input: &TokenStream) -> Result<TokenStream> {
167+
fn derive_facet_debug_impl(input: &TokenStream) -> BoxedResult<TokenStream> {
165168
let mut iter = input.to_token_iter();
166169

167170
// Parse the input as an ADT (struct or enum)
168-
let adt: AdtDecl = iter.parse()?;
171+
let adt: AdtDecl = iter.parse().map_err(Box::new)?;
169172

170173
match adt {
171174
AdtDecl::Struct(s) => derive_for_struct(s),
@@ -244,7 +247,7 @@ macro_rules! extract_type_param_bounds {
244247
///
245248
/// This takes a fail-safe approach: if reflection fails, ALL fields are
246249
/// redacted to prevent accidental data leakage.
247-
fn derive_for_struct(parsed: Struct) -> Result<TokenStream> {
250+
fn derive_for_struct(parsed: Struct) -> BoxedResult<TokenStream> {
248251
let struct_name = &parsed.name;
249252

250253
// Extract generics - convert to TokenStream
@@ -297,7 +300,6 @@ fn derive_for_struct(parsed: Struct) -> Result<TokenStream> {
297300
// Generate field checks (when metadata is available)
298301
let field_checks: Vec<_> = fields
299302
.content
300-
.0
301303
.iter()
302304
.enumerate()
303305
.map(|(idx, field)| {
@@ -317,7 +319,6 @@ fn derive_for_struct(parsed: Struct) -> Result<TokenStream> {
317319
// Generate fallback (when metadata is unavailable) - redact for safety
318320
let fallback_fields: Vec<_> = fields
319321
.content
320-
.0
321322
.iter()
322323
.map(|field| {
323324
let field_name = &field.value.name;
@@ -352,7 +353,6 @@ fn derive_for_struct(parsed: Struct) -> Result<TokenStream> {
352353
// Generate field checks (when metadata is available)
353354
let field_checks: Vec<_> = fields
354355
.content
355-
.0
356356
.iter()
357357
.enumerate()
358358
.map(|(idx, _field)| {
@@ -370,7 +370,7 @@ fn derive_for_struct(parsed: Struct) -> Result<TokenStream> {
370370
.collect();
371371

372372
// Generate fallback (when metadata is unavailable) - redact for safety
373-
let fallback_fields: Vec<_> = (0..fields.content.0.len())
373+
let fallback_fields: Vec<_> = (0..fields.content.len())
374374
.map(|_| {
375375
quote! {
376376
debug_tuple.field(&"[REDACTED:NO_METADATA]");
@@ -428,7 +428,7 @@ fn derive_for_struct(parsed: Struct) -> Result<TokenStream> {
428428
/// The generated code takes a fail-conservative approach: if reflection
429429
/// fails, ONLY the enum type name is written with no variant or field data,
430430
/// preventing any potential data leakage.
431-
fn derive_for_enum(parsed: Enum) -> Result<TokenStream> {
431+
fn derive_for_enum(parsed: Enum) -> BoxedResult<TokenStream> {
432432
let enum_name = &parsed.name;
433433

434434
// Extract generics - same as structs
@@ -467,7 +467,6 @@ fn derive_for_enum(parsed: Enum) -> Result<TokenStream> {
467467
let match_arms: Vec<_> = parsed
468468
.body
469469
.content
470-
.0
471470
.iter()
472471
.enumerate()
473472
.map(|(variant_idx, variant_like)| {
@@ -485,7 +484,7 @@ fn derive_for_enum(parsed: Enum) -> Result<TokenStream> {
485484
}
486485
EnumVariantData::Tuple(tuple_variant) => {
487486
let variant_name = &tuple_variant.name;
488-
let field_count = tuple_variant.fields.content.0.len();
487+
let field_count = tuple_variant.fields.content.len();
489488

490489
// Generate field bindings: _field_0, _field_1, _field_2, ...
491490
let bindings: Vec<_> = (0..field_count).map(|i| quote::format_ident!("_field_{}", i)).collect();
@@ -517,7 +516,7 @@ fn derive_for_enum(parsed: Enum) -> Result<TokenStream> {
517516
}
518517
EnumVariantData::Struct(struct_variant) => {
519518
let variant_name = &struct_variant.name;
520-
let fields = &struct_variant.fields.content.0;
519+
let fields = &struct_variant.fields.content;
521520

522521
// Generate field bindings: ref field1, ref field2, ...
523522
let field_names: Vec<_> = fields.iter().map(|field| &field.value.name).collect();

0 commit comments

Comments
 (0)