Skip to content

feat: #[pavex::methods] must return an error if applied to an impl block that doesn't contain #[pavex::*]-annotated methods #537

@LukeMathWalker

Description

@LukeMathWalker

#[pavex::methods] exists to give other macros (e.g. #[pavex::get]) the required context when they are applied to a method.

There is no reason to apply #[pavex::methods] to an impl block that doesn't contain annotated methods. Such an occurrence may be a symptom of the user not having fully internalized the way Pavex's machinery works: we should emit an error with a proper explanation to nudge them in the right direction.

Example

This code snippet should be rejected at compile-time:

pub struct A;

#[pavex::methods]
impl A {
    pub fn new() -> Self {
        A
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    diagnosticsImprovement or issue with Pavex's CLI diagnostics.good first issueGood for newcomers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions