]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #52562 - Manishearth:clippyup, r=RalfJung
authorbors <bors@rust-lang.org>
Sat, 21 Jul 2018 12:32:17 +0000 (12:32 +0000)
committerbors <bors@rust-lang.org>
Sat, 21 Jul 2018 12:32:17 +0000 (12:32 +0000)
Update clippy

r? @kennytm @oli-obk

1  2 
src/librustc/lint/mod.rs

diff --combined src/librustc/lint/mod.rs
index c16029d33205e6875ad9902aa2f80b285f03b91a,8161dcf675da704d555506379dbaecce59c4faba..c0f3c351d2627666db1d550f2f112befccb2f2db
@@@ -39,7 -39,7 +39,7 @@@ use hir::intravisit
  use hir;
  use lint::builtin::BuiltinLintDiagnostics;
  use session::{Session, DiagnosticMessageId};
 -use std::hash;
 +use std::{hash, ptr};
  use syntax::ast;
  use syntax::codemap::{MultiSpan, ExpnFormat};
  use syntax::edition::Edition;
@@@ -80,6 -80,9 +80,9 @@@ pub struct Lint 
      /// Starting at the given edition, default to the given lint level. If this is `None`, then use
      /// `default_level`.
      pub edition_lint_opts: Option<(Edition, Level)>,
+     /// Whether this lint is reported even inside expansions of external macros
+     pub report_in_external_macro: bool,
  }
  
  impl Lint {
  #[macro_export]
  macro_rules! declare_lint {
      ($vis: vis $NAME: ident, $Level: ident, $desc: expr) => (
+         declare_lint!{$vis $NAME, $Level, $desc, false}
+     );
+     ($vis: vis $NAME: ident, $Level: ident, $desc: expr, report_in_external_macro: $rep: expr) => (
+         declare_lint!{$vis $NAME, $Level, $desc, $rep}
+     );
+     ($vis: vis $NAME: ident, $Level: ident, $desc: expr, $external: expr) => (
          $vis static $NAME: &$crate::lint::Lint = &$crate::lint::Lint {
              name: stringify!($NAME),
              default_level: $crate::lint::$Level,
              desc: $desc,
              edition_lint_opts: None,
+             report_in_external_macro: $external,
          };
      );
      ($vis: vis $NAME: ident, $Level: ident, $desc: expr,
              default_level: $crate::lint::$Level,
              desc: $desc,
              edition_lint_opts: Some(($lint_edition, $crate::lint::Level::$edition_level)),
+             report_in_external_macro: false,
          };
      );
  }
@@@ -354,7 -365,7 +365,7 @@@ pub struct LintId 
  
  impl PartialEq for LintId {
      fn eq(&self, other: &LintId) -> bool {
 -        (self.lint as *const Lint) == (other.lint as *const Lint)
 +        ptr::eq(self.lint, other.lint)
      }
  }
  
@@@ -583,8 -594,7 +594,7 @@@ pub fn struct_lint_level<'a>(sess: &'a 
      // items to take care of (delete the macro invocation). As a result we have
      // a few lints we whitelist here for allowing a lint even though it's in a
      // foreign macro invocation.
-     } else if lint_id != LintId::of(builtin::UNREACHABLE_CODE) &&
-         lint_id != LintId::of(builtin::DEPRECATED) {
+     } else if !lint.report_in_external_macro {
          if err.span.primary_spans().iter().any(|s| in_external_macro(sess, *s)) {
              err.cancel();
          }