Add compiler_error!() description for error when multi_threaded feature is enabled but async_executor is not #19334
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Objective
Fixes #19051.
Solution
The
compile_error!()
is added tobevy_tasks/src/lib.rs
. It triggers specifically when themulti_threaded
feature is active, butasync_executor
is not.The error message is user-friendly, detailing:
Cargo.toml
snippet for a fix.DefaultPlugins
usually handles this automatically.Testing
These changes were tested using a minimal, external project designed to specifically trigger the new
compile_error!()
.How it was tested:
compile_fail_tasks
binary project was set up in an external directory.Cargo.toml
was configured to depend on the localbevy_tasks
, explicitly disabling default features and enabling onlymulti_threaded
.src/main.rs
referenced abevy_tasks
component (bevy_tasks::ComputeTaskPool::new();
) to ensure compilation paths were hit.cargo build -p compile_fail_tasks
from the Bevy root.Results:
The build failed as expected, prominently displaying the custom
compile_error!()
message. While otherSend
/Sync
errors also appeared (confirming the underlying problem this fix addresses), the primary goal of providing a clear compile-time error was achieved.How to test:
Reviewers can easily verify this by:
tests/compile_fail_tasks/Cargo.toml
with:cargo build -p compile_fail_tasks
or simplycargo build
within the current directory.Platforms tested:
macOS (aarch64). As a
#[cfg]
based compile-time check, behavior should be consistent across platforms.Tagging @bushrat011899 for review.