tanakh / cargo-atcoder

Cargo subcommand for AtCoder
BSD 3-Clause "New" or "Revised" License
397 stars 36 forks source link

`cargo atcoder new` で edition が指定できない #63

Open nebocco opened 2 years ago

nebocco commented 2 years ago

私は rustup でデフォルトの toolchain を stable-x86_64-unknown-linux-gnu としているのですが、AtCoder の Rust は 1.42.0 であるため、~/.config/cargo-atcoder.toml 内で rust-toolchain を生成するように指定しています。

[project]
# to create `rust-toolchain` file, uncomment this line.
rustc_version = "1.42.0"

先日 Rust 1.56.0 が stable としてリリースされ、 2021 edition が始まりました。これを反映させるため rustup の update を行いましたが、その影響で cargo new によって生成されるクレートは edition="2021" の指定が入るようになりました。 以上の理由から、cargo atcoder new ... で生成されるプロジェクトを動かすためには Cargo.toml を手で書き換えなければなりません。

プロジェクト生成部

https://github.com/tanakh/cargo-atcoder/blob/8382265062093652bc6bd50963dbe76db45c2ab1/src/main.rs#L101

でオプションとして --edition 2018 を指定すればこれを解決できると思うのですが、

といった解決策が考えられると思います。

この点について PR を送りたいと思っているのですが、どのようにするべきかご意見いただけると幸いです。

mizar commented 2 years ago

cargo atcoder new に毎回editionの指定が必要なのは煩雑になるので、editioncargo-atcoder.toml で指定できるようにした方がいい気がします。

以下は https://github.com/tanakh/cargo-atcoder/pull/65 を元にして rustc_editioncargo-atcoder.toml で指定できるように試みたものです。