Skip to content

Commit 92a788a

Browse files
committed
add compile file test
1 parent 88331ca commit 92a788a

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

crates/bevy_tasks/src/task_pool.rs

+15-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ impl TaskPool {
177177
///
178178
/// ```compile_fail
179179
/// use bevy_tasks::TaskPool;
180-
/// fn compile_fail() {
180+
/// fn scope_escapes_closure() {
181181
/// let pool = TaskPool::new();
182182
/// let foo = Box::new(42);
183183
/// pool.scope(|scope| {
@@ -190,6 +190,20 @@ impl TaskPool {
190190
/// });
191191
/// }
192192
/// ```
193+
///
194+
/// ```compile_fail
195+
/// use bevy_tasks::TaskPool;
196+
/// fn cannot_borrow_from_closure() {
197+
/// let pool = TaskPool::new();
198+
/// pool.scope(|scope| {
199+
/// let x = 1;
200+
/// let y = &x;
201+
/// scope.spawn(async move {
202+
/// assert_eq!(*y, 1);
203+
/// });
204+
/// });
205+
/// }
206+
///
193207
pub fn scope<'env, F, T>(&self, f: F) -> Vec<T>
194208
where
195209
F: for<'scope> FnOnce(&'env Scope<'scope, 'env, T>),

0 commit comments

Comments
 (0)