Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cargo new --edition 2018? #5980

Closed
japaric opened this issue Sep 5, 2018 · 2 comments · Fixed by #5984
Closed

cargo new --edition 2018? #5980

japaric opened this issue Sep 5, 2018 · 2 comments · Fixed by #5984

Comments

@japaric
Copy link
Member

japaric commented Sep 5, 2018

cargo new creates a new project for the 2015 edition. If you want to use the 2018 features like not having to type extern crate foo to be able to import foo::bar then you have to add this to your Cargo.toml:

cargo-features = ["edition"]

[package]
edition = "2018"
# ..

Would it make sense to add an --edition flag to cargo new to indicate which edition the project will use? For example, cargo new --edition 2018 would create a project with a Cargo.toml that includes package.edition = "2018"

Please avoid discussing whether cargo new should default to the 2018 edition. That's a separate issue and should be discussed separately.

alexcrichton added a commit to alexcrichton/cargo that referenced this issue Sep 6, 2018
This commit stabilizes the `edition` key in `Cargo.toml`, both in the
`[package]` section and inside subtargets. Additionally the `cargo new` and
`cargo init` subcommands have been enhanced with a `--edition` flag to allow
explicitly specifying the edition to be generated.

This commit does not yet change the default edition that's generated.

Closes rust-lang#5980
bors added a commit that referenced this issue Sep 6, 2018
Stabilize `edition` key and add `cargo new --edition`

This commit stabilizes the `edition` key in `Cargo.toml`, both in the
`[package]` section and inside subtargets. Additionally the `cargo new` and
`cargo init` subcommands have been enhanced with a `--edition` flag to allow
explicitly specifying the edition to be generated.

This commit does not yet change the default edition that's generated.

Closes #5980
@bors bors closed this as completed in #5984 Sep 6, 2018
bors bot added a commit to rust-embedded/embedonomicon that referenced this issue Sep 14, 2018
19: move code to the 2018 edition r=japaric a=japaric

most code changes are minor

the annoying part of using the 2018 edition right now is that there is no easy
way to create new 2018 project (Cargo still defaults to 2015 projects; see
rust-lang/cargo#5980) and there's no visible documentation on how to move a new
project to the 2018 edition (see rust-lang/edition-guide#102) so I have
included the required changes in the preface -- I hope people won't miss that
part.

r? @rust-embedded/resources (anyone)

closes #1

Co-authored-by: Jorge Aparicio <jorge@japaric.io>
@MggMuggins
Copy link

MggMuggins commented Oct 12, 2018

Does this flag in Cargo.toml change how your crate is used as a dependency? AKA, does specifying edition = "2018" mean that someone using a project with edition = "2015" or no edition cannot use my crate as a dependency?

@ehuss
Copy link
Contributor

ehuss commented Oct 12, 2018

@MggMuggins Dependencies will use the edition that they declare, regardless of the edition in your root package. It should be safe to use 2018 dependencies in a 2015 package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants