Skip to content

Commit 25050d9

Browse files
committed
Auto merge of #12270 - BatmanAoD:patch-1, r=weihanglo
Explain how `version` works for `git` dependencies
2 parents 97e73c7 + 6bdbe0a commit 25050d9

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

@@ -202,9 +204,20 @@ once the lock is in place. However, they can be pulled down manually with
202204

203205
See [Git Authentication] for help with git authentication for private repos.
204206

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.
207+
> **Note**: Neither the `git` key nor the `path` key changes the meaning of the
208+
> `version` key: the `version` key always implies that the package is available
209+
> in a registry. `version`, `git`, and `path` keys are considered [separate
210+
> locations](#multiple-locations) for resolving the dependency.
211+
>
212+
> When the dependency is retrieved from `git`, the `version` key will _not_
213+
> affect which commit is used, but the version information in the dependency's
214+
> `Cargo.toml` file will still be validated against the `version` requirement.
215+
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)