-fn contains_ignore_directive(contents: &String, check: &str) -> bool {
- contents.contains(&format!("// ignore-tidy-{}", check)) ||
- contents.contains(&format!("# ignore-tidy-{}", check))
+enum Directive {
+ /// By default, tidy always warns against style issues.
+ Deny,
+
+ /// `Ignore(false)` means that an `ignore-tidy-*` directive
+ /// has been provided, but is unnecessary. `Ignore(true)`
+ /// means that it is necessary (i.e. a warning would be
+ /// produced if `ignore-tidy-*` was not present).
+ Ignore(bool),
+}
+
+fn contains_ignore_directive(contents: &String, check: &str) -> Directive {
+ if contents.contains(&format!("// ignore-tidy-{}", check)) ||
+ contents.contains(&format!("# ignore-tidy-{}", check)) {
+ Directive::Ignore(false)
+ } else {
+ Directive::Deny
+ }
+}
+
+macro_rules! suppressible_tidy_err {
+ ($err:ident, $skip:ident, $msg:expr) => {
+ if let Directive::Deny = $skip {
+ $err($msg);
+ } else {
+ $skip = Directive::Ignore(true);
+ }
+ };