#Allow

#Allow("rule") switches off one rux lint rule for the declaration below it, and nowhere else. It is for a declaration with a deliberate reason to break a convention — most often a name that must match an outside contract, such as a C struct or a C macro.

allow-attribute = "#Allow" "(" string-literal ")"

Rules

Rulerux lint reports#Allow applies to
"naming.type"a struct, enum, variant, union or type alias name that is not PascalCasetype declarations
"naming.const"a constant name that is not PascalCaseconstant declarations
"docs.missing"a public declaration without a /// or /** … */ commentany declaration
// Mirrors the C struct, so it keeps C's spelling.
#Allow("naming.type")
struct timespec {
    seconds: int64;
    nanoseconds: int64;
}

// A C macro's own name, which a reader porting code will look for.
#Allow("naming.const")
const SEEK_SET: int32 = 0;

Without the attributes, rux lint reports:

warning: struct name 'timespec' should be PascalCase
  help: rename it to 'Timespec'
warning: constant name 'SEEK_SET' should be PascalCase
  help: rename it to 'SeekSet'

One #Allow names one rule; stack several for several rules. The rule names are checked when the source is compiled, not only when it is linted, so a typo cannot silence nothing:

MistakeError
an unknown ruleunknown lint rule 'naming.konst'; valid rules are: naming.type, naming.const, docs.missing
naming.type on a function'#Allow("naming.type")' can only be applied to a type declaration
naming.const on a struct'#Allow("naming.const")' can only be applied to a constant declaration
the same rule twiceduplicate '#Allow("naming.const")' attribute
two rules in one attribute'#Allow' accepts exactly one argument

See also