Skip to content

Test for diagnostic applicability #317

@BD103

Description

@BD103

In bevy_lint we're making more and more lints machine applicable in preparation for an integration with cargo fix (TheBevyFlock/bevy_cli#394). It would be really nice to test the Applicability of specific diagnostics to ensure they remain MachineApplicable or MaybeIncorrect for certain situations.

For example, we have a missing_reflect lint that checks whether the Reflect trait can be automatically derived. When it cannot, it emits Applicability::MaybeIncorrect instead of Applicability::MachineApplicable.

Here is a mock syntax for specifying applicability, though I don't know how challenging it would be to implement nor do I have a strong preference:

#[derive(Reflect)]
struct Reflect(u64);

#[derive(Component)]
//~| APPLICABILITY: machine applicable
//~v ERROR: defined a component without a `Reflect` implementation
struct CanAutomaticallyDerive(Reflect);

struct NonReflect(u64);

#[derive(Component)]
//~| APPLICABILITY: maybe incorrect
//~v ERROR: defined a component without a `Reflect` implementation
struct CannotAutomaticallyDerive(NonReflect);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions