Skip to content
This repository was archived by the owner on Jan 11, 2026. It is now read-only.

Labeling a function in a trait pub gives misleading "Non-productive state" diagnostic #34

@Dessix

Description

@Dessix

I just tripped myself up on this one for a little while by porting an impl block to trait signatures.

The error message is misleading for syntax that would otherwise be flat-out invalid.

#[typestate]
mod traffic_light {
    #[automaton]
    pub struct TrafficLight;

    #[state]
    pub struct Green; // Errors with "Non-productive state. For a state to be productive..."
    #[state]
    pub struct Red;

    pub trait Green {
        fn turn_on() -> Green;
        pub fn to_red(self) -> Red;
    }
    pub trait Red {
        fn turn_off(self);
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions