Skip to content

Commit bf85988

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 bf85988

File tree

4 files changed

+79
-20
lines changed

4 files changed

+79
-20
lines changed

src/doc/man/cargo-fix.md

+16-5
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,22 @@ 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 during migration, instead of fixing everything
56+
in a single `cargo fix` invocation, try fixing only a subset of packages for
57+
specific features and Cargo targets. Fixing each combination separately can
58+
help identify the root cause of failures more easily and avoid unintended
59+
feature unification between packages. For example:
60+
61+
* Use the `--package` flag to fix only some packages, e.g., `cargo fix --package foo`.
62+
* Instead of `--all-features`, use the `--features` flag to activate a specific
63+
set of features, e.g., `cargo fix --package foo --features myfeat`.
64+
* `cargo fix` implies `--all-targets` by default. Use target selection flags to
65+
fix only a subset of Cargo targets, e.g., `cargo fix --bin mybin`.
66+
67+
Also keep in mind of the caveats mentioned above that `cargo fix` cannot update
68+
code for inactive features or `cfg` expressions. Also, in some rare cases the
69+
compiler is unable to automatically migrate all code to the new edition,
70+
and this may require manual changes after building with the new edition.
6071

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

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

+23-5
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,29 @@ 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 during migration, instead of fixing
57+
everything in a single cargo fix invocation, try fixing only a subset of
58+
packages for specific features and Cargo targets. Fixing each
59+
combination separately can help identify the root cause of failures more
60+
easily and avoid unintended feature unification between packages. For
61+
example:
62+
63+
o Use the --package flag to fix only some packages, e.g., cargo fix
64+
--package foo.
65+
66+
o Instead of --all-features, use the --features flag to activate a
67+
specific set of features, e.g., cargo fix --package foo --features
68+
myfeat.
69+
70+
o cargo fix implies --all-targets by default. Use target selection
71+
flags to fix only a subset of Cargo targets, e.g., cargo fix --bin
72+
mybin.
73+
74+
Also keep in mind of the caveats mentioned above that cargo fix cannot
75+
update code for inactive features or cfg expressions. Also, in some rare
76+
cases the compiler is unable to automatically migrate all code to the
77+
new edition, and this may require manual changes after building with the
78+
new edition.
6179

6280
OPTIONS
6381
Fix options

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

+16-5
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,22 @@ 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 during migration, instead of fixing everything
52+
in a single `cargo fix` invocation, try fixing only a subset of packages for
53+
specific features and Cargo targets. Fixing each combination separately can
54+
help identify the root cause of failures more easily and avoid unintended
55+
feature unification between packages. For example:
56+
57+
* Use the `--package` flag to fix only some packages, e.g., `cargo fix --package foo`.
58+
* Instead of `--all-features`, use the `--features` flag to activate a specific
59+
set of features, e.g., `cargo fix --package foo --features myfeat`.
60+
* `cargo fix` implies `--all-targets` by default. Use target selection flags to
61+
fix only a subset of Cargo targets, e.g., `cargo fix --bin mybin`.
62+
63+
Also keep in mind of the caveats mentioned above that `cargo fix` cannot update
64+
code for inactive features or `cfg` expressions. Also, in some rare cases the
65+
compiler is unable to automatically migrate all code to the new edition,
66+
and this may require manual changes after building with the new edition.
5667

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

src/etc/man/cargo-fix.1

+24-5
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,30 @@ 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 during migration, instead of fixing everything
68+
in a single \fBcargo fix\fR invocation, try fixing only a subset of packages for
69+
specific features and Cargo targets. Fixing each combination separately can
70+
help identify the root cause of failures more easily and avoid unintended
71+
feature unification between packages. For example:
72+
.sp
73+
.RS 4
74+
\h'-04'\(bu\h'+02'Use the \fB\-\-package\fR flag to fix only some packages, e.g., \fBcargo fix \-\-package foo\fR\&.
75+
.RE
76+
.sp
77+
.RS 4
78+
\h'-04'\(bu\h'+02'Instead of \fB\-\-all\-features\fR, use the \fB\-\-features\fR flag to activate a specific
79+
set of features, e.g., \fBcargo fix \-\-package foo \-\-features myfeat\fR\&.
80+
.RE
81+
.sp
82+
.RS 4
83+
\h'-04'\(bu\h'+02'\fBcargo fix\fR implies \fB\-\-all\-targets\fR by default. Use target selection flags to
84+
fix only a subset of Cargo targets, e.g., \fBcargo fix \-\-bin mybin\fR\&.
85+
.RE
86+
.sp
87+
Also keep in mind of the caveats mentioned above that \fBcargo fix\fR cannot update
88+
code for inactive features or \fBcfg\fR expressions. Also, in some rare cases the
89+
compiler is unable to automatically migrate all code to the new edition,
90+
and this may require manual changes after building with the new edition.
7291
.SH "OPTIONS"
7392
.SS "Fix options"
7493
.sp

0 commit comments

Comments
 (0)