Skip to content

Conversation

@sffc
Copy link
Member

@sffc sffc commented Jan 17, 2026

Follow-up from #7411

@sffc sffc requested review from a team and younies as code owners January 17, 2026 10:17
@sffc sffc requested review from robertbastian and removed request for younies January 17, 2026 10:18
#[cfg(not(feature = "zerovec"))]
type Store: ?Sized + PartialEq + core::fmt::Debug;
#[cfg(feature = "zerovec")]
type Store: ?Sized + PartialEq + core::fmt::Debug + zerovec::ule::VarULE;
Copy link
Member

Choose a reason for hiding this comment

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

observation: making a bound tighter based on a feature is not generally ok, but this trait is sealed


#[cfg(feature = "datagen")]
impl<'data, P: PatternBackend> serde::Serialize for CompactPatterns<'data, P>
impl<'data, P: PatternBackend<Store = str>> serde::Serialize for CompactPatterns<'data, P>
Copy link
Member

Choose a reason for hiding this comment

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

serde should only need P::Store: Serialize/Deserialize

Copy link
Member Author

Choose a reason for hiding this comment

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

For Serialize, it looks like it works to write where Pattern<P>: Serialize.

For Deserialize, on this code:

impl<'de, 'data, P: PatternBackend> serde::Deserialize<'de>
    for CompactPatterns<'data, P>
where
    'de: 'data,
    Pattern<P>: serde::Deserialize<'de>,

I'm getting this error:

error[E0275]: overflow evaluating the requirement `&icu_pattern::Pattern<_>: displaynames::provider::_::_serde::Deserialize<'_>`
  |
  = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`icu_experimental`)
  = note: required for `&icu_pattern::Pattern<_>` to implement `displaynames::provider::_::_serde::Deserialize<'_>`
  = note: 125 redundant requirements hidden
  = note: required for `&icu_pattern::Pattern<_>` to implement `displaynames::provider::_::_serde::Deserialize<'_>`

For more information about this error, try `rustc --explain E0275`.

Copy link
Member Author

Choose a reason for hiding this comment

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

It works if the bound is on Box<Pattern<P>>.

@sffc
Copy link
Member Author

sffc commented Jan 18, 2026

I could alternatively remove the requirement that Store always implement VarULE and instead ask clients to write where Pattern<P>: VarULE.

@sffc
Copy link
Member Author

sffc commented Jan 18, 2026

I could alternatively remove the requirement that Store always implement VarULE and instead ask clients to write where Pattern<P>: VarULE.

I tried doing this but then where Pattern<P>: zerovec::ule::VarULE is required everywhere that CompactPatterns is referenced, including in derives, which don't currently carry these where clauses.

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.

2 participants