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

Outdated documentation for manifest edition field #8951

Closed
hkennyv opened this issue Dec 6, 2020 · 4 comments
Closed

Outdated documentation for manifest edition field #8951

hkennyv opened this issue Dec 6, 2020 · 4 comments
Labels
C-bug Category: bug

Comments

@hkennyv
Copy link
Contributor

hkennyv commented Dec 6, 2020

Problem

The current documentation specifies that the default value for the edition is 2015. I believe it should be 2018 (after doing a quick search for "rust edition" in this repository).

Steps

  1. view the current docs here (at the time of this issue)

Possible Solution(s)

Update the docs to reflect the new default value, 2018

(i have a PR on the way!)

Notes

Output of cargo version:

cargo 1.50.0-nightly (bfca1cd22 2020-11-24)
@Eh2406
Copy link
Contributor

Eh2406 commented Dec 6, 2020

If you don't have an addition specified in your Cargo.toml then we use edition 2015. @ehuss pointed it out to me the last time I tried to "fix" this documentation. It is clearly confusing, as we keep getting PRs to change it. Is there a clearer way to explain what is ment?

@hkennyv
Copy link
Contributor Author

hkennyv commented Dec 6, 2020

@Eh2406 Glad to hear I'm not the only person who got confused when reading this. After reading @ehuss 's comment and re-reading the section, it makes sense.

I think the confusing part is that it is an optional key but running cargo new automatically writes it. For someone whose not well-versed in Cargo, you wouldn't think it's optional.

I reworded the edition section below. That makes sense to me, anyone else have any thoughts?


The edition field

The edition key is an optional key that affects which edition your package is compiled with. Cargo
will always generate packages via [cargo new] with the edition key set to the
latest edition. Setting the edition key in [package] will affect all
targets/crates in the package, including test suites, benchmarks, binaries,
examples, etc.

If the edition key is not set to a specific [Rust Edition] in your Cargo.toml, Cargo will
default to 2015.

[package]
# ...
edition = '2018'

@Eh2406
Copy link
Contributor

Eh2406 commented Dec 6, 2020

Sounds reasonable. Want to make a PR with that clarification and we can wordsmith there?

@hkennyv
Copy link
Contributor Author

hkennyv commented Dec 6, 2020

done, let's discuss here #8953

bors added a commit that referenced this issue Dec 7, 2020
Clarify cargo manifest edition field docs

addresses #8951

This PR aims to clarify the documentation for the `edition` field in the Cargo manifest.

The confusion (IME) stems from the behavior of `cargo new` (defaults to writing edition = "2018") being confused for the default behavior of how Cargo interprets the manifest (`edition` is an optional key, defaults to 2015).

would love to get some other thoughts on how we can clarify this since it seems like I'm not the only one who got confused `@Eh2406`
@hkennyv hkennyv closed this as completed Dec 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants