Skip to content

Conversation

@luketpeterson
Copy link
Collaborator

Adds spec attributes for traits and trait impl blocks. Addresses #41

@mkovaxx
Copy link
Owner

mkovaxx commented Jan 13, 2026

This is looking pretty good, thanks for working on it!
Added a few initial comments.

luketpeterson and others added 2 commits January 12, 2026 21:00
Tweaks from code review (mostly format and renames)

Co-authored-by: Máté Kovács <481354+mkovaxx@users.noreply.github.com>
Comment on lines 28 to 31
#[spec(
maintains: self.0 == 3,
ensures: *output > self.0,
)]
Copy link
Owner

Choose a reason for hiding this comment

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

On a second thought, I'm conflicted about the idea of allowing per-method specs inside a trait impl. It feels strange as an idea, but I have a difficult time unpacking why.

Copy link
Collaborator Author

@luketpeterson luketpeterson Jan 13, 2026

Choose a reason for hiding this comment

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

I'm pretty convinced we want both.

Specs on the trait items in the declaration enforce the interface is being upheld, but can't see into the implementation. Specs on the implementation can enforce invariants that must be maintained to ensure the implementation is correct.

Copy link
Owner

Choose a reason for hiding this comment

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

I think we've hit an important question here, so let's move this discussion to the feature's design:
#41 (comment)

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