DiagnosticDirectives
Lowers one diagnostic selector to the allow level in lexical scope.
Module std.compiler.prelude
import std.compiler.prelude;Public declaration contracts and authored examples. A page can document several related symbols. Implementation bodies are excluded.
allow
pub directive allow(Selector: str);Lowers one diagnostic selector to the allow level in lexical scope. Selector: Stable diagnostic code, hierarchical category, or warnings.
Example
module example.diagnostic_directives;
@allow("numeric.float-comparison")
fn AllowedComparison() -> bool { return 1.0 == 1.0; }
@warn("api.deprecated")
fn WarnOnDeprecatedUse() -> i32 { return 0; }
@deny("correctness.discarded-result")
fn RejectDiscardedResults() -> i32 { return 0; }
@forbid("warnings")
fn LockedWarningPolicy() -> i32 { return 0; }
fn Main() -> i32 {
if !AllowedComparison() { return 1; }
return WarnOnDeprecatedUse() + RejectDiscardedResults() +
LockedWarningPolicy();
}warn
pub directive warn(Selector: str);Sets one diagnostic selector to warning level in lexical scope. Selector: Stable diagnostic code, hierarchical category, or warnings.
deny
pub directive deny(Selector: str);Promotes one diagnostic selector to error level in lexical scope. Selector: Stable diagnostic code, hierarchical category, or warnings.
forbid
pub directive forbid(Selector: str);Locks one diagnostic selector against lowering in nested scopes. Selector: Stable diagnostic code, hierarchical category, or warnings.