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

subtle documentation ambiguity #12112

Closed
mcandre opened this issue May 9, 2023 · 2 comments · Fixed by #12679
Closed

subtle documentation ambiguity #12112

mcandre opened this issue May 9, 2023 · 2 comments · Fixed by #12679
Labels
A-documenting-cargo-itself Area: Cargo's documentation A-semver Area: semver specifications, version matching, etc. C-bug Category: bug E-easy Experience: Easy S-accepted Status: Issue or feature is accepted, and has a team member available to help mentor or review

Comments

@mcandre
Copy link

mcandre commented May 9, 2023

Problem

The Cargo Book says:

Caret requirements are an alternative syntax for the default strategy, ^1.2.3 is exactly equivalent to 1.2.3.

This phrasing has an unfortunate interpretation for Rust newbies, who may take the statement to mean that caret means the exact version identifier.

A very careful reading reveals that caret is merely the default semantic, but is not exactly equivalent to any fixed version. Some users may get tripped up by this ambiguity.

Possible Solution(s)

We can help the reader to disambiguate Cargo syntax and semantics. For example, adjust the section to say something like:

The caret prefix is also the default version resolution strategy; it may be omitted. Both ^1.2.3 and 1.2.3 match the latest available, Cargo SemVer compatible release that Cargo can find.

@mcandre mcandre added C-bug Category: bug S-triage Status: This issue is waiting on initial triage. labels May 9, 2023
@weihanglo
Copy link
Member

weihanglo commented May 9, 2023

Thanks for the report. If I recall correctly, caret ^ is really only an alternative syntax for “SemVer compatible” version requirements. We encourage people to use “1.2.3” instead of “^1.2.3” at syntax level. See #10158.

That being said, I feel like we missed a clear mention of “default strategy” in the paragraph above, as well as encourage people to avoid prefixes unless really needed. We can perhaps disambiguate the sentence with something like

Caret requirements are an alternative syntax for the default strategy. For instance, log = "^1.2.3" is exactly equivalent to log = "1.2.3", which allows SemVer compatible updates.

@weihanglo weihanglo added A-documenting-cargo-itself Area: Cargo's documentation A-semver Area: semver specifications, version matching, etc. S-needs-mentor Status: Issue or feature is accepted, but needs a team member to commit to helping and reviewing. and removed S-triage Status: This issue is waiting on initial triage. labels May 9, 2023
@ehuss
Copy link
Contributor

ehuss commented May 9, 2023

I'm wondering if the confusion is also rooted with the use of the word "exactly"? Maybe phrasing it as: `log = "^1.2.3"` means the same thing as `log = "1.2.3", which allows …` could help?

@weihanglo weihanglo added E-easy Experience: Easy S-accepted Status: Issue or feature is accepted, and has a team member available to help mentor or review and removed S-needs-mentor Status: Issue or feature is accepted, but needs a team member to commit to helping and reviewing. labels May 27, 2023
@bors bors closed this as completed in 4c10811 Sep 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-documenting-cargo-itself Area: Cargo's documentation A-semver Area: semver specifications, version matching, etc. C-bug Category: bug E-easy Experience: Easy S-accepted Status: Issue or feature is accepted, and has a team member available to help mentor or review
Projects
None yet
3 participants