Closed TimonPost closed 1 year ago
I found the bug, it has to do with features depending on other features. async-std contains the 'std' feature, and the std feature depends on the 'alloc' feature. In my current implementation, I do a look-up into all dependencies of 'std' and add them to the list to remove one by one. Also, I add the std feature itself. But 'std' and 'alloc' are present in the list and will both activate the task namespace. I can remove 'alloc' and see if it compiles and it will since 'std' is still present. However, in fact, we can not remove it as alloc is a required dependency.
So somehow I will have to consider original features and their dependent features separately. One way to fix it is to not collect all sub-enabled features and just keep it at the root level. Then removing "std" will certainly break the compilation as it will disable all sub-features. But there might be sub-features of "std" that could be enabled individually rather than the whole set of sub-features. So we would lose some granularity/detail.
If you're running this library on a binary rather than a library, please make sure to supply '--bin' flag. This might actually solve the issue already. Default the project only compilers libraries.
Flag is made default enabled in https://crates.io/crates/cargo-unused-features/0.1.7
From reddit.
Probably not a minimal example, but this fails for me: