about summary refs log tree commit diff
path: root/clippy_utils/src
diff options
context:
space:
mode:
authorxFrednet <xFrednet@gmail.com>2022-06-25 14:16:34 +0200
committerxFrednet <xFrednet@gmail.com>2022-06-25 14:37:52 +0200
commit4d41a97735c0f9c8d33fab6d7710c9383e063d83 (patch)
tree2daee905163d19768c63b403e28af8688bd435f4 /clippy_utils/src
parent6427ba4855702e14b8a8d668e37bf984d08a52bd (diff)
downloadrust-4d41a97735c0f9c8d33fab6d7710c9383e063d83.tar.gz
rust-4d41a97735c0f9c8d33fab6d7710c9383e063d83.zip
Add note to `is_lint_allowed` about lint emission
Diffstat (limited to 'clippy_utils/src')
-rw-r--r--clippy_utils/src/lib.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/clippy_utils/src/lib.rs b/clippy_utils/src/lib.rs
index 73c1bdd0e3f..ebe1b52df9e 100644
--- a/clippy_utils/src/lib.rs
+++ b/clippy_utils/src/lib.rs
@@ -1539,9 +1539,13 @@ pub fn is_try<'tcx>(cx: &LateContext<'_>, expr: &'tcx Expr<'tcx>) -> Option<&'tc
     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
 }