Skip to content

Commit 01e1ff0

Browse files
committed
Squash:
* Explain how `version` works for `git` dependencies * Link to multiple-locations, since this is already explained there * more extensive rewrite
1 parent 2a6f7f6 commit 01e1ff0

File tree

1 file changed

+32
-12
lines changed

1 file changed

+32
-12
lines changed

src/doc/src/reference/specifying-dependencies.md

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,14 @@ and `x > 0`.
5353
It is possible to further tweak the logic for selecting compatible versions
5454
using special operators, though it shouldn't be necessary most of the time.
5555

56-
### Caret requirements
56+
### Version requirement syntax
57+
58+
#### Caret requirements
5759

5860
**Caret requirements** are an alternative syntax for the default strategy,
5961
`^1.2.3` is exactly equivalent to `1.2.3`.
6062

61-
### Tilde requirements
63+
#### Tilde requirements
6264

6365
**Tilde requirements** specify a minimal version with some ability to update.
6466
If you specify a major, minor, and patch version or only a major and minor
@@ -73,7 +75,7 @@ version, then minor- and patch-level changes are allowed.
7375
~1 := >=1.0.0, <2.0.0
7476
```
7577

76-
### Wildcard requirements
78+
#### Wildcard requirements
7779

7880
**Wildcard requirements** allow for any version where the wildcard is
7981
positioned.
@@ -88,7 +90,7 @@ positioned.
8890

8991
> **Note**: [crates.io] does not allow bare `*` versions.
9092
91-
### Comparison requirements
93+
#### Comparison requirements
9294

9395
**Comparison requirements** allow manually specifying a version range or an
9496
exact version to depend on.
@@ -102,7 +104,7 @@ Here are some examples of comparison requirements:
102104
= 1.2.3
103105
```
104106

105-
### Multiple requirements
107+
#### Multiple version requirements
106108

107109
As shown in the examples above, multiple version requirements can be
108110
separated with a comma, e.g., `>= 1.2, < 1.5`.
@@ -157,7 +159,7 @@ some-crate = { version = "1.0", registry = "my-registry" }
157159
```
158160

159161
> **Note**: [crates.io] does not allow packages to be published with
160-
> dependencies on other registries.
162+
> dependencies on code published outside of [crates.io].
161163
162164
[registries documentation]: registries.md
163165

@@ -195,16 +197,27 @@ varies by where the repo is hosted; GitHub in particular exposes a reference to
195197
the most recent commit of every pull request as shown, but other git hosts often
196198
provide something equivalent, possibly under a different naming scheme.
197199

200+
> **Note**: Neither the `git` key nor the `path` key changes the meaning of the
201+
> `version` key: the `version` key always implies that the package is available
202+
> in a registry. `version`, `git`, and `path` keys are considered [separate
203+
> locations](#multiple-locations) for resolving the dependency.
204+
>
205+
> When the dependency is retrieved from `git`, the `version` key will _not_
206+
> affect which commit is used, but the version information in the dependency's
207+
> `Cargo.toml` file will still be validated against the `version` requirement.
208+
198209
Once a `git` dependency has been added, Cargo will lock that dependency to the
199210
latest commit at the time. New commits will not be pulled down automatically
200211
once the lock is in place. However, they can be pulled down manually with
201212
`cargo update`.
202213

203214
See [Git Authentication] for help with git authentication for private repos.
204215

205-
> **Note**: [crates.io] does not allow packages to be published with `git`
206-
> dependencies (`git` [dev-dependencies] are ignored). See the [Multiple
207-
> locations](#multiple-locations) section for a fallback alternative.
216+
> **Note**: [crates.io] does not allow packages to be published with
217+
> dependencies on code published outside of [crates.io] itself
218+
> ([dev-dependencies] are ignored). See the [Multiple
219+
> locations](#multiple-locations) section for a fallback alternative for `git`
220+
> and `path` dependencies.
208221
209222
[Git Authentication]: ../appendix/git-authentication.md
210223

@@ -245,9 +258,16 @@ and specify its version in the dependencies line as well:
245258
hello_utils = { path = "hello_utils", version = "0.1.0" }
246259
```
247260

248-
> **Note**: [crates.io] does not allow packages to be published with `path`
249-
> dependencies (`path` [dev-dependencies] are ignored). See the [Multiple
250-
> locations](#multiple-locations) section for a fallback alternative.
261+
> **Note**: Neither the `git` key nor the `path` key changes the meaning of the
262+
> `version` key: the `version` key always implies that the package is available
263+
> in a registry. `version`, `git`, and `path` keys are considered [separate
264+
> locations](#multiple-locations) for resolving the dependency.
265+
266+
> **Note**: [crates.io] does not allow packages to be published with
267+
> dependencies on code published outside of [crates.io] itself
268+
> ([dev-dependencies] are ignored). See the [Multiple
269+
> locations](#multiple-locations) section for a fallback alternative for `git`
270+
> and `path` dependencies.
251271
252272
### Multiple locations
253273

0 commit comments

Comments
 (0)