From b68abfd91f2f6fb631228d1f44e930df1947b06b Mon Sep 17 00:00:00 2001 From: BD103 <59022059+BD103@users.noreply.github.com> Date: Tue, 3 Dec 2024 14:30:38 -0500 Subject: [PATCH] feat: begin nested entry function test --- .../ui/unused_appexit/nested_entry_fn.fixed | 22 ++++++++ .../ui/unused_appexit/nested_entry_fn.rs | 22 ++++++++ .../ui/unused_appexit/nested_entry_fn.stderr | 52 +++++++++++++++++++ 3 files changed, 96 insertions(+) create mode 100644 bevy_lint/tests/ui/unused_appexit/nested_entry_fn.fixed create mode 100644 bevy_lint/tests/ui/unused_appexit/nested_entry_fn.rs create mode 100644 bevy_lint/tests/ui/unused_appexit/nested_entry_fn.stderr diff --git a/bevy_lint/tests/ui/unused_appexit/nested_entry_fn.fixed b/bevy_lint/tests/ui/unused_appexit/nested_entry_fn.fixed new file mode 100644 index 0000000..1a6ad4c --- /dev/null +++ b/bevy_lint/tests/ui/unused_appexit/nested_entry_fn.fixed @@ -0,0 +1,22 @@ +#![feature(register_tool)] +#![register_tool(bevy)] +#![deny(bevy::unused_appexit)] + +use bevy::prelude::*; + +fn main() { + let _closure = || { + App::new().run(); + //~^ ERROR: called `App::run()` without handling the returned `AppExit` + }; + + fn _nested_function() { + let _app_exit = App::new().run(); + //~^ ERROR: called `App::run()` without handling the returned `AppExit` + } + + let _async_block = async { + App::new().run(); + //~^ ERROR: called `App::run()` without handling the returned `AppExit` + }; +} diff --git a/bevy_lint/tests/ui/unused_appexit/nested_entry_fn.rs b/bevy_lint/tests/ui/unused_appexit/nested_entry_fn.rs new file mode 100644 index 0000000..8e8efea --- /dev/null +++ b/bevy_lint/tests/ui/unused_appexit/nested_entry_fn.rs @@ -0,0 +1,22 @@ +#![feature(register_tool)] +#![register_tool(bevy)] +#![deny(bevy::unused_appexit)] + +use bevy::prelude::*; + +fn main() { + let _closure = || { + App::new().run(); + //~^ ERROR: called `App::run()` without handling the returned `AppExit` + }; + + fn _nested_function() { + App::new().run(); + //~^ ERROR: called `App::run()` without handling the returned `AppExit` + } + + let _async_block = async { + App::new().run(); + //~^ ERROR: called `App::run()` without handling the returned `AppExit` + }; +} diff --git a/bevy_lint/tests/ui/unused_appexit/nested_entry_fn.stderr b/bevy_lint/tests/ui/unused_appexit/nested_entry_fn.stderr new file mode 100644 index 0000000..a690f36 --- /dev/null +++ b/bevy_lint/tests/ui/unused_appexit/nested_entry_fn.stderr @@ -0,0 +1,52 @@ +error: called `App::run()` without handling the returned `AppExit` + --> tests/ui/unused_appexit/nested_entry_fn.rs:9:20 + | +9 | App::new().run(); + | ^^^^^ + | + = note: `App::run()` returns `AppExit`, which is used to determine whether the app exited successfully or not + = help: `AppExit` implements `Termination`, so it can be returned directly from `fn main()` +note: the lint level is defined here + --> tests/ui/unused_appexit/nested_entry_fn.rs:3:9 + | +3 | #![deny(bevy::unused_appexit)] + | ^^^^^^^^^^^^^^^^^^^^ +help: return the result of `App::run()` + | +9 | return App::new().run(); + | ~~~~~~~~~~~~~~~~~~~~~~~ +help: set the return type of `fn main()` + | +7 | fn main() -> AppExit { + | ++++++++++ + +error: called `App::run()` without handling the returned `AppExit` + --> tests/ui/unused_appexit/nested_entry_fn.rs:14:20 + | +14 | App::new().run(); + | -----------^^^^^ + | | + | help: handle the returned `AppExit`: `let _app_exit = App::new().run()` + | + = note: `App::run()` returns `AppExit`, which is used to determine whether the app exited successfully or not + = help: consider logging a warning if the returned `AppExit` is an error + +error: called `App::run()` without handling the returned `AppExit` + --> tests/ui/unused_appexit/nested_entry_fn.rs:19:20 + | +19 | App::new().run(); + | ^^^^^ + | + = note: `App::run()` returns `AppExit`, which is used to determine whether the app exited successfully or not + = help: `AppExit` implements `Termination`, so it can be returned directly from `fn main()` +help: return the result of `App::run()` + | +19 | return App::new().run(); + | ~~~~~~~~~~~~~~~~~~~~~~~ +help: set the return type of `fn main()` + | +7 | fn main() -> AppExit { + | ++++++++++ + +error: aborting due to 3 previous errors +