TheBevyFlock / bevy_cli

A Bevy CLI tool and linter.
https://thebevyflock.github.io/bevy_cli/
Apache License 2.0
44 stars 7 forks source link

Make lint silence locations more intuitive #162

Closed BD103 closed 1 month ago

BD103 commented 1 month ago

Fixes #132.

plugin_not_ending_in_plugin and main_return_without_appexit check for impl blocks, but emit the lint on the original structure definition. This results in confusing locations for #[allow(...)] attributes:

// This doesn't actually silence the lint.
#[allow(bevy::plugin_not_ending_in_plugin)]
struct Foo;

// But this does.
#[allow(bevy::plugin_not_ending_in_plugin)]
impl Plugin for Foo {
    fn build(&self, _app: &mut App) {}
}

This can be fixed by calling span_lint_hir(), which lets you specify the HirId of the item that the lint is attached to.

This PR switches main_return_without_appexit and plugin_not_ending_in_plugin to specify the HirId of the structure definition, not the impl block, making the #[allow(...)] location more intuitive.

BD103 commented 1 month ago

A lot of the files changed are simply just UI tests. The actual important changes are within src/lints :)