Add note to is_lint_allowed about lint emission

This commit is contained in:
xFrednet 2022-06-25 14:16:34 +02:00
parent 6427ba4855
commit 4d41a97735
No known key found for this signature in database
GPG Key ID: F5C59D0E669E5302

View File

@ -1539,9 +1539,13 @@ fn is_err(cx: &LateContext<'_>, arm: &Arm<'_>) -> bool {
None 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 { pub fn is_lint_allowed(cx: &LateContext<'_>, lint: &'static Lint, id: HirId) -> bool {
cx.tcx.lint_level_at_node(lint, id).0 == Level::Allow cx.tcx.lint_level_at_node(lint, id).0 == Level::Allow
} }