Skip to content

Commit

Permalink
feat: begin nested entry function test
Browse files Browse the repository at this point in the history
  • Loading branch information
BD103 committed Dec 3, 2024
1 parent 00e1ee3 commit b68abfd
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 0 deletions.
22 changes: 22 additions & 0 deletions bevy_lint/tests/ui/unused_appexit/nested_entry_fn.fixed
Original file line number Diff line number Diff line change
@@ -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`
};
}
22 changes: 22 additions & 0 deletions bevy_lint/tests/ui/unused_appexit/nested_entry_fn.rs
Original file line number Diff line number Diff line change
@@ -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`
};
}
52 changes: 52 additions & 0 deletions bevy_lint/tests/ui/unused_appexit/nested_entry_fn.stderr
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit b68abfd

Please sign in to comment.