diff options
| author | Eric Huss <eric@huss.org> | 2025-04-28 11:29:42 -0700 |
|---|---|---|
| committer | Eric Huss <eric@huss.org> | 2025-04-28 11:29:42 -0700 |
| commit | 3d23917b2d331b92e59b73a50098f9f3b2bf5a9c (patch) | |
| tree | 4b7ffb344d6e49c20127b84d7021ba726013d523 | |
| parent | 1b53c12753a9ecead0e9728e01dcc2a7c07c18f9 (diff) | |
| download | rust-3d23917b2d331b92e59b73a50098f9f3b2bf5a9c.tar.gz rust-3d23917b2d331b92e59b73a50098f9f3b2bf5a9c.zip | |
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.
| -rw-r--r-- | src/doc/rustc-dev-guide/src/guides/editions.md | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/doc/rustc-dev-guide/src/guides/editions.md b/src/doc/rustc-dev-guide/src/guides/editions.md index ea207167791..750631dfe56 100644 --- a/src/doc/rustc-dev-guide/src/guides/editions.md +++ b/src/doc/rustc-dev-guide/src/guides/editions.md @@ -193,6 +193,23 @@ When a user runs `cargo fix --edition`, cargo will pass the `--force-warn rust-2 flag to force all of these lints to appear during the edition migration. Cargo also passes `--cap-lints=allow` so that no other lints interfere with the edition migration. +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: + +```rust,ignore +declare_lint! { + /// The `keyword_idents_2024` lint detects ... + /// + /// ### Example + /// + /// ```rust,edition2021 + /// #![warn(keyword_idents_2024)] + /// fn gen() {} + /// ``` + /// + /// {{produces}} +} +``` + Migration lints can be either `Allow` or `Warn` by default. If it is `Allow`, users usually won't see this warning unless they are doing an edition migration manually or there is a problem during the migration. |
