]> git.lizzy.rs Git - rust.git/commitdiff
Add note to `is_lint_allowed` about lint emission
authorxFrednet <xFrednet@gmail.com>
Sat, 25 Jun 2022 12:16:34 +0000 (14:16 +0200)
committerxFrednet <xFrednet@gmail.com>
Sat, 25 Jun 2022 12:37:52 +0000 (14:37 +0200)
clippy_utils/src/lib.rs

index 73c1bdd0e3f4e3ccaf344f7b0f7252594a125163..ebe1b52df9e2290066d210ec2942155e6c97278d 100644 (file)
@@ -1539,9 +1539,13 @@ fn is_err(cx: &LateContext<'_>, arm: &Arm<'_>) -> bool {
     None
 }
 
-/// Returns `true` if the lint is allowed in the current context
+/// Returns `true` if the lint is allowed in the current context. This is useful for
+/// skipping long running code when it's unnecessary
 ///
-/// Useful for skipping long running code when it's unnecessary
+/// This function should check the lint level for the same node, that the lint will
+/// be emitted at. If the information is buffered to be emitted at a later point, please
+/// make sure to use `span_lint_hir` functions to emit the lint. This ensures that
+/// expectations at the checked nodes will be fulfilled.
 pub fn is_lint_allowed(cx: &LateContext<'_>, lint: &'static Lint, id: HirId) -> bool {
     cx.tcx.lint_level_at_node(lint, id).0 == Level::Allow
 }