Skip to content

Commit 4d41a97

Browse files
committed
Add note to is_lint_allowed about lint emission
1 parent 6427ba4 commit 4d41a97

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

clippy_utils/src/lib.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1539,9 +1539,13 @@ pub fn is_try<'tcx>(cx: &LateContext<'_>, expr: &'tcx Expr<'tcx>) -> Option<&'tc
15391539
None
15401540
}
15411541

1542-
/// Returns `true` if the lint is allowed in the current context
1542+
/// Returns `true` if the lint is allowed in the current context. This is useful for
1543+
/// skipping long running code when it's unnecessary
15431544
///
1544-
/// Useful for skipping long running code when it's unnecessary
1545+
/// This function should check the lint level for the same node, that the lint will
1546+
/// be emitted at. If the information is buffered to be emitted at a later point, please
1547+
/// make sure to use `span_lint_hir` functions to emit the lint. This ensures that
1548+
/// expectations at the checked nodes will be fulfilled.
15451549
pub fn is_lint_allowed(cx: &LateContext<'_>, lint: &'static Lint, id: HirId) -> bool {
15461550
cx.tcx.lint_level_at_node(lint, id).0 == Level::Allow
15471551
}

0 commit comments

Comments
 (0)