Cargoのresolverに対する警告を修正する
cargoコマンドを実行すると、以下のような警告が発生する。
warning: virtual workspace defaulting to `resolver = "1"` despite one or more workspace members being on edition 2021 which implies `resolver = "2"`
note: to keep the current resolver, specify `workspace.resolver = "1"` in the workspace root's manifest
note: to use the edition 2021 resolver, specify `workspace.resolver = "2"` in the workspace root's manifest
note: for more details see https://doc.rust-lang.org/cargo/reference/resolver.html#resolver-versions
まず、"virtual workspace"とは、
https://doc.rust-lang.org/cargo/reference/workspaces.html#virtual-workspace
によると、複数ディレクトリに分けれて、各ディレクトリでCargo.tomlを管理する場合に親ディレクトリで使用される概念。
親ディレクトリのCargo.tomlには[package]セクションが存在せず、代わりに[workspace]セクションが存在する。
各ディレクトリにおけるライブラリの依存バージョンを管理するときや、共通のversionを設定する際に有用。
resolverとは
https://doc.rust-lang.org/cargo/reference/features.html#feature-resolver-version-2
によると、unifying-featuresの観点で1と2は異なるらしい。異なるターゲット向けにビルドする際に、それぞれのターゲットに適した機能のみを有効にできるため、クロスコンパイルやテスト時に有利に働く場合があるらしい。
新規プロジェクトを構築する際は一旦2を指定する方針にしてみようと思うが、余分にビルドが走り直す可能性があるためその点だけケアしてあげたほうが良いかもしれない。
docには以下のような記載もあり、明示的な指定が必要であることがわかる。
resolver must be set explicitly in virtual workspaces as they have no package.edition to infer it from resolver version.
今回の自分のプロジェクトに関しては"2"の方を指定して様子を見てみることとした。