Skip to content

Fix #[cgp_type] when associated types contain self-referential bounds#208

Merged
soareschen merged 5 commits intomainfrom
fix-cgp-type-local
Feb 27, 2026
Merged

Fix #[cgp_type] when associated types contain self-referential bounds#208
soareschen merged 5 commits intomainfrom
fix-cgp-type-local

Conversation

@soareschen
Copy link
Collaborator

This PR fixes a bug in #[cgp_type] where the associated type contains trait bounds that refer back to the associated type. For example:

#[cgp_type]
pub trait HasScalarType {
    type Scalar: Mul<Output = Self::Scalar> + Clone;
}

Before this, the Self::Scalar inside Mul<Output = Self::Scalar> is not transformed when the UseType and WithProvider providers are generated. The PR fixes the issue by binding it to a local associated type.

The same bug is also fixed for #[cgp_auto_getter] and #[cgp_getter] that contains an associated type. For example:

#[cgp_getter]
pub trait HasScalar {
    type Scalar: Mul<Output = Self::Scalar> + Clone;

    fn scalar(&self) -> &Self::Scalar;
}

@soareschen soareschen merged commit 408c760 into main Feb 27, 2026
5 checks passed
@soareschen soareschen deleted the fix-cgp-type-local branch February 27, 2026 21:17
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.

1 participant