Skip to content

Commit 3d23917

Browse files
committed
Add an example of the example of an edition migration lint
It was observed that some people were missing the `edition20xx` rustdoc attribute. Although this probably won't solve that problem, I'd still like to highlight it as something to be aware of.
1 parent 1b53c12 commit 3d23917

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/doc/rustc-dev-guide/src/guides/editions.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,23 @@ When a user runs `cargo fix --edition`, cargo will pass the `--force-warn rust-2
193193
flag to force all of these lints to appear during the edition migration.
194194
Cargo also passes `--cap-lints=allow` so that no other lints interfere with the edition migration.
195195

196+
Make sure that the example code sets the correct edition. The example should illustrate the previous edition, and show what the migration warning would look like. For example, this lint for a 2024 migration shows an example in 2021:
197+
198+
```rust,ignore
199+
declare_lint! {
200+
/// The `keyword_idents_2024` lint detects ...
201+
///
202+
/// ### Example
203+
///
204+
/// ```rust,edition2021
205+
/// #![warn(keyword_idents_2024)]
206+
/// fn gen() {}
207+
/// ```
208+
///
209+
/// {{produces}}
210+
}
211+
```
212+
196213
Migration lints can be either `Allow` or `Warn` by default.
197214
If it is `Allow`, users usually won't see this warning unless they are doing an edition migration
198215
manually or there is a problem during the migration.

0 commit comments

Comments
 (0)