-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into bevy_ptr_align_const
- Loading branch information
Showing
46 changed files
with
1,000 additions
and
355 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 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
19 changes: 19 additions & 0 deletions
19
crates/bevy_ecs/compile_fail/tests/ui/system_query_iter_sort_lifetime_safety.rs
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,19 @@ | ||
use bevy_ecs::prelude::*; | ||
use std::cmp::Ordering; | ||
|
||
#[derive(Component)] | ||
struct A(usize); | ||
|
||
fn system(mut query: Query<&mut A>) { | ||
let iter = query.iter_mut(); | ||
let mut stored: Option<&A> = None; | ||
let mut sorted = iter.sort_by::<&A>(|left, _right| { | ||
// Try to smuggle the lens item out of the closure. | ||
stored = Some(left); | ||
//~^ E0521 | ||
Ordering::Equal | ||
}); | ||
let r: &A = stored.unwrap(); | ||
let m: &mut A = &mut sorted.next().unwrap(); | ||
assert!(std::ptr::eq(r, m)); | ||
} |
10 changes: 10 additions & 0 deletions
10
crates/bevy_ecs/compile_fail/tests/ui/system_query_iter_sort_lifetime_safety.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
error[E0521]: borrowed data escapes outside of closure | ||
--> tests/ui\system_query_iter_sort_lifetime_safety.rs:12:9 | ||
| | ||
9 | let mut stored: Option<&A> = None; | ||
| ---------- `stored` declared here, outside of the closure body | ||
10 | let mut sorted = iter.sort_by::<&A>(|left, _right| { | ||
| ---- `left` is a reference that is only valid in the closure body | ||
11 | // Try to smuggle the lens item out of the closure. | ||
12 | stored = Some(left); | ||
| ^^^^^^^^^^^^^^^^^^^ `left` escapes the closure body here |
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
Oops, something went wrong.