-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make lint silence locations more intuitive (#162)
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: ```rust // 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.
- Loading branch information
Showing
12 changed files
with
81 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
bevy_lint/tests/ui/main_return_without_appexit/bug_132.stderr
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
//! A version of `main.rs` where the lint is muted on the expression that called `App::run()`. This | ||
//! should pass without any errors. | ||
//@check-pass | ||
|
||
#![feature(register_tool)] | ||
#![register_tool(bevy)] | ||
#![deny(bevy::main_return_without_appexit)] | ||
|
||
use bevy::prelude::*; | ||
|
||
fn main() { | ||
#[allow(bevy::main_return_without_appexit)] | ||
App::new().run(); | ||
} |
15 changes: 0 additions & 15 deletions
15
bevy_lint/tests/ui/main_return_without_appexit/muted_function.rs
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
19 changes: 0 additions & 19 deletions
19
bevy_lint/tests/ui/plugin_not_ending_in_plugin/bug_132.stderr
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 10 additions & 8 deletions
18
bevy_lint/tests/ui/plugin_not_ending_in_plugin/main.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 10 additions & 8 deletions
18
bevy_lint/tests/ui/plugin_not_ending_in_plugin/spoofed_name.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters