-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
71 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
//! This test tracks the bug reported in [#174]. When this starts failing, the bug has been fixed. | ||
//! | ||
//! [#174]: https://github.com/TheBevyFlock/bevy_cli/issues/174 | ||
|
||
//@check-pass | ||
|
||
#![feature(register_tool)] | ||
#![register_tool(bevy)] | ||
#![deny(bevy::borrowed_reborrowable)] | ||
|
||
use bevy::prelude::*; | ||
|
||
fn main() { | ||
let mut world = World::new(); | ||
|
||
closure_wrapper(world.commands(), |commands| commands.spawn_empty().id()); | ||
closure_wrapper2(world.commands(), |commands| commands.spawn_empty().id()); | ||
} | ||
|
||
fn closure_wrapper(mut commands: Commands, f: impl FnOnce(&mut Commands) -> Entity) { | ||
f(&mut commands); | ||
} | ||
|
||
fn closure_wrapper2(mut commands: Commands, f: fn(&mut Commands) -> Entity) { | ||
f(&mut commands); | ||
} |
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,20 @@ | ||
//! This tests the `borrowed_reborrowable` lint, specifically when triggered on closure types. | ||
|
||
#![feature(register_tool)] | ||
#![register_tool(bevy)] | ||
#![deny(bevy::borrowed_reborrowable)] | ||
|
||
use bevy::prelude::*; | ||
|
||
fn main() { | ||
let mut world = World::new(); | ||
let mut commands = world.commands(); | ||
|
||
//~| HELP: use `Commands` instead | ||
//~v ERROR: parameter takes `&mut Commands` instead of a re-borrowed `Commands` | ||
let closure = |commands: &mut Commands| { | ||
commands.spawn_empty(); | ||
}; | ||
|
||
closure(&mut commands); | ||
} |
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,14 @@ | ||
error: parameter takes `&mut Commands` instead of a re-borrowed `Commands` | ||
--> tests/ui/borrowed_reborrowable/closures.rs:15:20 | ||
| | ||
15 | let closure = |commands: &mut Commands| { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^ help: use `Commands` instead: `mut commands: bevy::prelude::Commands<'_, '_>` | ||
| | ||
note: the lint level is defined here | ||
--> tests/ui/borrowed_reborrowable/closures.rs:5:9 | ||
| | ||
5 | #![deny(bevy::borrowed_reborrowable)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 1 previous error | ||
|