Workaround for import diagnostics failing to mention disabled features #19297
+68
−0
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
Users often start a Bevy app by cut and pasting an example. But they can quickly run into errors if the example uses a feature that's disabled by default:
The fix is simple - enable the
bevy_dev_tools
feature. But it's hard for users to get from the compile error to the fix (see #19200 (comment))In some situations the rust compiler will flag up missing features as a possible cause - this might not get users all the way there, but it would be a good start:
But that diagnostic doesn't trigger right now. I suspect it trips over the way the
bevy
module glob importsbevy_internal::*
. I've filed a rustc bug here: rust-lang/rust#141256.Solution
The workaround is to duplicate the
bevy_internal
re-exports and their feature gates. This is ugly but simple.I also considered:
bevy_dev_tools
andbevy_remote
. These are the only features that are disabled by default, so they're likely to cover the majority of cases that users will encounter.cfg
-ed item referenced through glob import rust-lang/rust#141256.The fix could go into 0.16.x if the reference to
bevy_anti_aliasing
is removed.Testing
Simulate a user by editing the
bevy/Cargo.toml
section for examplefps_overlay
to comment out therequired-features = ["bevy_dev_tools"]
. Alternatively, copy and pasteexamples/dev_tools/fps_overlay.rs
into a new crate.