Skip to content

Commit 127abaa

Browse files
xFrednetcamelid
authored andcommitted
Add example how lints can be feature gated
1 parent 155126b commit 127abaa

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/diagnostics.md

+14
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,20 @@ declare_lint! {
594594
This makes the `ANONYMOUS_PARAMETERS` lint allow-by-default in the 2015 edition
595595
but warn-by-default in the 2018 edition.
596596

597+
### Feature-gated lints
598+
599+
Lints belonging to a feature should only be usable if the feature is enabled in the
600+
crate. To support this, lint declarations can contain a feature gate like so:
601+
602+
```rust,ignore
603+
declare_lint! {
604+
pub SOME_LINT_NAME,
605+
Warn,
606+
"a new and useful, but feature gated lint",
607+
@feature_gate = sym::feature_name;
608+
}
609+
```
610+
597611
### Future-incompatible lints
598612

599613
The use of the term `future-incompatible` within the compiler has a slightly

0 commit comments

Comments
 (0)