[−][src]Macro rustc_ap_rustc_session::declare_lint
Declares a static item of type &'static Lint
.
See https://rustc-dev-guide.rust-lang.org/diagnostics.html for documentation and guidelines on writing lints.
The macro call should start with a doc comment explaining the lint which will be embedded in the rustc user documentation book. It should be written in markdown and have a format that looks like this:
ⓘThis example is not tested
/// The `my_lint_name` lint detects [short explanation here]. /// /// ### Example /// /// ```rust /// [insert a concise example that triggers the lint] /// ``` /// /// {{produces}} /// /// ### Explanation /// /// This should be a detailed explanation of *why* the lint exists, /// and also include suggestions on how the user should fix the problem. /// Try to keep the text simple enough that a beginner can understand, /// and include links to other documentation for terminology that a /// beginner may not be familiar with. If this is "allow" by default, /// it should explain why (are there false positives or other issues?). If /// this is a future-incompatible lint, it should say so, with text that /// looks roughly like this: /// /// This is a [future-incompatible] lint to transition this to a hard /// error in the future. See [issue #xxxxx] for more details. /// /// [issue #xxxxx]: https://github.com/rust-lang/rust/issues/xxxxx
The {{produces}}
tag will be automatically replaced with the output from
the example by the build system. You can build and view the rustc book
with x.py doc --stage=1 src/doc/rustc --open
. If the lint example is too
complex to run as a simple example (for example, it needs an extern
crate), mark it with ignore
and manually paste the expected output below
the example.