Skip to content

Commit 755ec6d

Browse files
committed
docs(cargo-fix): troubleshooting failing fixes
There are a couple of reasons taht `cargo fix` fails. This doc update lists some approaches to narrow the scope to help users deal with those failures one by one.
1 parent 5cea8f1 commit 755ec6d

File tree

4 files changed

+111
-20
lines changed

4 files changed

+111
-20
lines changed

src/doc/man/cargo-fix.md

+27-5
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,37 @@ The `cargo fix` subcommand can also be used to migrate a package from one
5252
(without the `--edition` flag) to apply any suggestions given by the
5353
compiler.
5454

55-
And hopefully that's it! Just keep in mind of the caveats mentioned above that
56-
`cargo fix` cannot update code for inactive features or `cfg` expressions.
57-
Also, in some rare cases the compiler is unable to automatically migrate all
58-
code to the new edition, and this may require manual changes after building
59-
with the new edition.
55+
If you encounter failing fixes, read the troubleshooting section.
6056

6157
[edition]: https://doc.rust-lang.org/edition-guide/editions/transitioning-an-existing-project-to-a-new-edition.html
6258
[edition field]: ../reference/manifest.html#the-edition-field
6359

60+
### Troubleshooting failing fixes
61+
62+
While `cargo fix` strives to automatically apply fixes, it can still fail for
63+
various reasons. Here are some suggestions for troubleshooting fix failures:
64+
65+
* Unlike other commands, `cargo fix` implies `--all-targets` by default.
66+
Try fixing one Cargo target at a time instead of everything in one run.
67+
For instance, narrow the scope to a single binary target:
68+
69+
```sh
70+
cargo fix --bin mybin
71+
```
72+
73+
* If you have a Cargo workspace containing multiple packages,
74+
fix them one by one to avoid unwanted feature unification between packages.
75+
For instance, fix only the `bar` package :
76+
77+
```sh
78+
cargo fix --package bar
79+
```
80+
81+
Keep in mind of the caveats mentioned above that `cargo fix` cannot update code
82+
for inactive features or `cfg` expressions. Also, in some rare cases the
83+
compiler is unable to automatically migrate all code to the new edition,
84+
and this may require manual changes after building with the new edition.
85+
6486
## OPTIONS
6587

6688
### Fix options

src/doc/man/generated_txt/cargo-fix.txt

+24-5
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,30 @@ DESCRIPTION
5353
(without the --edition flag) to apply any suggestions given by the
5454
compiler.
5555

56-
And hopefully that’s it! Just keep in mind of the caveats mentioned
57-
above that cargo fix cannot update code for inactive features or cfg
58-
expressions. Also, in some rare cases the compiler is unable to
59-
automatically migrate all code to the new edition, and this may require
60-
manual changes after building with the new edition.
56+
If you encounter failing fixes, read the troubleshooting section.
57+
58+
Troubleshooting failing fixes
59+
While cargo fix strives to automatically apply fixes, it can still fail
60+
for various reasons. Here are some suggestions for troubleshooting fix
61+
failures:
62+
63+
o Unlike other commands, cargo fix implies --all-targets by default.
64+
Try fixing one Cargo target at a time instead of everything in one
65+
run. For instance, narrow the scope to a single binary target:
66+
67+
cargo fix --bin mybin
68+
69+
o If you have a Cargo workspace containing multiple packages, fix them
70+
one by one to avoid unwanted feature unification between packages.
71+
For instance, fix only the bar package :
72+
73+
cargo fix --package bar
74+
75+
Keep in mind of the caveats mentioned above that cargo fix cannot update
76+
code for inactive features or cfg expressions. Also, in some rare cases
77+
the compiler is unable to automatically migrate all code to the new
78+
edition, and this may require manual changes after building with the new
79+
edition.
6180

6281
OPTIONS
6382
Fix options

src/doc/src/commands/cargo-fix.md

+27-5
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,37 @@ The `cargo fix` subcommand can also be used to migrate a package from one
4848
(without the `--edition` flag) to apply any suggestions given by the
4949
compiler.
5050

51-
And hopefully that's it! Just keep in mind of the caveats mentioned above that
52-
`cargo fix` cannot update code for inactive features or `cfg` expressions.
53-
Also, in some rare cases the compiler is unable to automatically migrate all
54-
code to the new edition, and this may require manual changes after building
55-
with the new edition.
51+
If you encounter failing fixes, read the troubleshooting section.
5652

5753
[edition]: https://doc.rust-lang.org/edition-guide/editions/transitioning-an-existing-project-to-a-new-edition.html
5854
[edition field]: ../reference/manifest.html#the-edition-field
5955

56+
### Troubleshooting failing fixes
57+
58+
While `cargo fix` strives to automatically apply fixes, it can still fail for
59+
various reasons. Here are some suggestions for troubleshooting fix failures:
60+
61+
* Unlike other commands, `cargo fix` implies `--all-targets` by default.
62+
Try fixing one Cargo target at a time instead of everything in one run.
63+
For instance, narrow the scope to a single binary target:
64+
65+
```sh
66+
cargo fix --bin mybin
67+
```
68+
69+
* If you have a Cargo workspace containing multiple packages,
70+
fix them one by one to avoid unwanted feature unification between packages.
71+
For instance, fix only the `bar` package :
72+
73+
```sh
74+
cargo fix --package bar
75+
```
76+
77+
Keep in mind of the caveats mentioned above that `cargo fix` cannot update code
78+
for inactive features or `cfg` expressions. Also, in some rare cases the
79+
compiler is unable to automatically migrate all code to the new edition,
80+
and this may require manual changes after building with the new edition.
81+
6082
## OPTIONS
6183

6284
### Fix options

src/etc/man/cargo-fix.1

+33-5
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,39 @@ warnings are issued, you may want to consider running \fBcargo fix\fR again
6464
compiler.
6565
.RE
6666
.sp
67-
And hopefully that\[cq]s it! Just keep in mind of the caveats mentioned above that
68-
\fBcargo fix\fR cannot update code for inactive features or \fBcfg\fR expressions.
69-
Also, in some rare cases the compiler is unable to automatically migrate all
70-
code to the new edition, and this may require manual changes after building
71-
with the new edition.
67+
If you encounter failing fixes, read the troubleshooting section.
68+
.SS "Troubleshooting failing fixes"
69+
While \fBcargo fix\fR strives to automatically apply fixes, it can still fail for
70+
various reasons. Here are some suggestions for troubleshooting fix failures:
71+
.sp
72+
.RS 4
73+
\h'-04'\(bu\h'+02'Unlike other commands, \fBcargo fix\fR implies \fB\-\-all\-targets\fR by default.
74+
Try fixing one Cargo target at a time instead of everything in one run.
75+
For instance, narrow the scope to a single binary target:
76+
.sp
77+
.RS 4
78+
.nf
79+
cargo fix \-\-bin mybin
80+
.fi
81+
.RE
82+
.RE
83+
.sp
84+
.RS 4
85+
\h'-04'\(bu\h'+02'If you have a Cargo workspace containing multiple packages,
86+
fix them one by one to avoid unwanted feature unification between packages.
87+
For instance, fix only the \fBbar\fR package :
88+
.sp
89+
.RS 4
90+
.nf
91+
cargo fix \-\-package bar
92+
.fi
93+
.RE
94+
.RE
95+
.sp
96+
Keep in mind of the caveats mentioned above that \fBcargo fix\fR cannot update code
97+
for inactive features or \fBcfg\fR expressions. Also, in some rare cases the
98+
compiler is unable to automatically migrate all code to the new edition,
99+
and this may require manual changes after building with the new edition.
72100
.SH "OPTIONS"
73101
.SS "Fix options"
74102
.sp

0 commit comments

Comments
 (0)