-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
135 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Cargo: Reject unused inherited default-features | ||
|
||
🚧 The 2024 Edition has not yet been released and hence this section is still "under construction". | ||
|
||
## Summary | ||
|
||
- `default-features = false` is no longer allowed in an inherited workspace dependency if the workspace dependency specifies `default-features = true` (or does not specify `default-features`). | ||
|
||
## Details | ||
|
||
[Workspace inheritance] allows you to specify dependencies in one place (the workspace), and then to refer to those workspace dependencies from within a package. | ||
There was an inadvertent interaction with how `default-features` is specified that is no longer allowed in the 2024 Edition. | ||
|
||
Unless the workspace specifies `default-features = false`, it is no longer allowed to specify `default-features = false` in an inherited package dependency. | ||
For example, with a workspace that specifies: | ||
|
||
```toml | ||
[workspace.dependencies] | ||
regex = "1.10.4" | ||
``` | ||
|
||
The following is now an error: | ||
|
||
```toml | ||
[package] | ||
name = "foo" | ||
version = "1.0.0" | ||
edition = "2024" | ||
|
||
[dependencies] | ||
regex = { workspace = true, default-features = false } # ERROR | ||
``` | ||
|
||
The reason for this change is to avoid confusion when specifying `default-features = false` when the default feature is already enabled, since it has no effect. | ||
|
||
If you want the flexibility of deciding whether or not a dependency enables the default-features of a dependency, be sure to set `default-features = false` in the workspace definition. | ||
Just beware that if you build multiple workspace members at the same time, the features will be unified so that if one member sets `default-features = true` (which is the default if not explicitly set), the default-features will be enabled for all members using that dependency. | ||
|
||
## Migration | ||
|
||
When using `cargo fix --edition`, Cargo will automatically update your `Cargo.toml` file to remove `default-features = false` in this situation. | ||
|
||
If you would prefer to update your `Cargo.toml` manually, check for any warnings when running a build and remove the corresponding entries. | ||
Previous editions should display something like: | ||
|
||
```text | ||
warning: /home/project/Cargo.toml: `default-features` is ignored for regex, | ||
since `default-features` was not specified for `workspace.dependencies.regex`, | ||
this could become a hard error in the future | ||
``` | ||
|
||
[workspace inheritance]: ../../cargo/reference/specifying-dependencies.html#inheriting-a-dependency-from-a-workspace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Cargo: Table and key name consistency | ||
|
||
🚧 The 2024 Edition has not yet been released and hence this section is still "under construction". | ||
|
||
## Summary | ||
|
||
- Several table and key names in `Cargo.toml` have been removed where there was previously two ways to specify it. | ||
- Removed `[project]`, use `[package]` instead. | ||
- Removed `default_features`, use `default-features` instead. | ||
- Removed `crate_type`, use `crate-type` instead. | ||
- Removed `proc_macro`, use `proc-macro` instead. | ||
- Removed `dev_dependencies`, use `dev-dependencies` instead. | ||
- Removed `build_dependencies`, use `build-dependencies` instead. | ||
|
||
## Details | ||
|
||
Several table and keys names are no longer allowed in the 2024 Edition. | ||
There were two ways to specify these tables or keys, and this helps ensure there is only one way to specify them. | ||
|
||
Some were due to a change in decisions over time, and some were inadvertent implementation artifacts. | ||
In order to avoid confusion, and to enforce a single style for specifying these tables and keys, only one variant is now allowed. | ||
|
||
For example: | ||
|
||
```toml | ||
[dev_dependencies] | ||
rand = { version = "0.8.5", default_features = false } | ||
``` | ||
|
||
Should be changed to: | ||
|
||
```toml | ||
[dev-dependencies] | ||
rand = { version = "0.8.5", default-features = false } | ||
``` | ||
|
||
Notice that the underscores were changed to dashes for `dev_dependencies` and `default_features`. | ||
|
||
## Migration | ||
|
||
When using `cargo fix --edition`, Cargo will automatically update your `Cargo.toml` file to use the preferred table and key names. | ||
|
||
If you would prefer to update your `Cargo.toml` manually, be sure to go through the list above and make sure only the new forms are used. |