Skip to content

Commit

Permalink
T: disable check if feature state for stdlib dependencies for now
Browse files Browse the repository at this point in the history
  • Loading branch information
Undin committed Mar 24, 2021
1 parent e5e7e29 commit 965d53e
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions src/main/kotlin/org/rust/cargo/project/workspace/CargoWorkspace.kt
Expand Up @@ -430,20 +430,28 @@ private class WorkspaceImpl(
pkg.cargoEnabledFeatures.map { PackageFeature(pkg, it) }
}
for ((feature, state) in inferFeatureState(UserDisabledFeatures.EMPTY)) {
if (feature.pkg.origin == STDLIB) {
// All features of stdlib package should be considered as enabled by default.
// If `RsExperiments.FETCH_ACTUAL_STDLIB_METADATA` is enabled,
// the plugin invokes `cargo metadata` for `test` crate of stdlib to get actual info.
// And since stdlib packages are not a single workspace,
// `cargo` considers that all stdlib crates except test one are dependencies and
// as a result, enabled only features required by `test` package (i.e. `pkg.cargoEnabledFeatures` are not expected)
// It doesn't make sense to fix `pkg.cargoEnabledFeatures` so let's just adjust this check
if (!state.isEnabled) {
error("Feature `${feature.name}` in package `${feature.pkg.name}` should be ${!state}, but it is $state")
when (feature.pkg.origin) {
STDLIB -> {
// All features of stdlib package should be considered as enabled by default.
// If `RsExperiments.FETCH_ACTUAL_STDLIB_METADATA` is enabled,
// the plugin invokes `cargo metadata` for `test` crate of stdlib to get actual info.
// And since stdlib packages are not a single workspace,
// `cargo` considers that all stdlib crates except test one are dependencies and
// as a result, enabled only features required by `test` package (i.e. `pkg.cargoEnabledFeatures` are not expected)
// It doesn't make sense to fix `pkg.cargoEnabledFeatures` so let's just adjust this check
if (!state.isEnabled) {
error("Feature `${feature.name}` in package `${feature.pkg.name}` should be ${!state}, but it is $state")
}
}
} else {
if (feature in enabledByCargo != state.isEnabled) {
error("Feature `${feature.name}` in package `${feature.pkg.name}` should be ${!state}, but it is $state")
// `cargoEnabledFeatures` are not source of truth here when `RsExperiments.FETCH_ACTUAL_STDLIB_METADATA` is enabled
// because only `test` crate is considered as part of workspace where all features are enabled by default (see comment above).
// As a result, state of stdlib dependencies can differ from `cargoEnabledFeatures`.
// Skip check here for now
STDLIB_DEPENDENCY -> Unit
else -> {
if (feature in enabledByCargo != state.isEnabled) {
error("Feature `${feature.name}` in package `${feature.pkg.name}` should be ${!state}, but it is $state")
}
}
}
}
Expand Down

0 comments on commit 965d53e

Please sign in to comment.