diff options
| author | xFrednet <xFrednet@gmail.com> | 2022-04-01 19:55:51 +0200 |
|---|---|---|
| committer | Noah Lev <camelidcamel@gmail.com> | 2022-04-04 13:16:08 -0700 |
| commit | 86e586bc74a6ada2e33d85be2b8d8975364d6c1b (patch) | |
| tree | 07ac07360fbc67381579e92e68d38811657eeb3f /src/doc/rustc-dev-guide | |
| parent | ab445871d680343164735a9137416d1053c687ec (diff) | |
| download | rust-86e586bc74a6ada2e33d85be2b8d8975364d6c1b.tar.gz rust-86e586bc74a6ada2e33d85be2b8d8975364d6c1b.zip | |
Add example how lints can be feature gated
Diffstat (limited to 'src/doc/rustc-dev-guide')
| -rw-r--r-- | src/doc/rustc-dev-guide/src/diagnostics.md | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/doc/rustc-dev-guide/src/diagnostics.md b/src/doc/rustc-dev-guide/src/diagnostics.md index 3671a0eccff..b6752042852 100644 --- a/src/doc/rustc-dev-guide/src/diagnostics.md +++ b/src/doc/rustc-dev-guide/src/diagnostics.md @@ -594,6 +594,20 @@ declare_lint! { This makes the `ANONYMOUS_PARAMETERS` lint allow-by-default in the 2015 edition but warn-by-default in the 2018 edition. +### Feature-gated lints + +Lints belonging to a feature should only be usable if the feature is enabled in the +crate. To support this, lint declarations can contain a feature gate like so: + +```rust,ignore +declare_lint! { + pub SOME_LINT_NAME, + Warn, + "a new and useful, but feature gated lint", + @feature_gate = sym::feature_name; +} +``` + ### Future-incompatible lints The use of the term `future-incompatible` within the compiler has a slightly |
