You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/editions/advanced-migrations.md
+23Lines changed: 23 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -126,6 +126,23 @@ For example, you can use the [`edition2018` annotation][rustdoc-annotation] on t
126
126
Another area where the automated fixes cannot apply is if you have a build script which generates Rust code at compile time (see [Code generation] for an example).
127
127
In this situation, if you end up with code that doesn't work in the next edition, you will need to manually change the build script to generate code that is compatible.
128
128
129
+
## Migrating non-Cargo projects
130
+
131
+
If your project is not using Cargo as a build system, it may still be possible to make use of the automated lints to assist migrating to the next build system.
132
+
You can enable the migration lints as described above by enabling the appropriate [lint group].
133
+
For example, you can use the `#![warn(rust_2021_compatibility)]` attribute or the `-Wrust-2021-compatibility`[CLI flag].
134
+
135
+
The next step is to apply those lints to your code.
136
+
There are several options here:
137
+
138
+
* Manually read the warnings and apply the suggestions recommended by the compiler.
139
+
* Use an editor or IDE that supports automatically applying suggestions.
140
+
For example, [Visual Studio Code] with the [Rust Analyzer extension] has the ability to use the "Quick Fix" links to automatically apply suggestions.
141
+
Many other editors and IDEs have similar functionality.
142
+
* Write a migration tool using the [`rustfix`] library.
143
+
This is the library that Cargo uses internally to take the [JSON messages] from the compiler and modify the source code.
144
+
Check the [`examples` directory][rustfix-examples] for examples of how to use the library.
145
+
129
146
## Writing idiomatic code in a new edition
130
147
131
148
Editions are not only about new features and removing old ones.
@@ -168,15 +185,21 @@ We're now more idiomatic, and we didn't have to fix our code manually!
0 commit comments