]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #51149 - zackmdavis:․․․_to_․․=, r=nikomatsakis
authorbors <bors@rust-lang.org>
Tue, 26 Jun 2018 23:15:30 +0000 (23:15 +0000)
committerbors <bors@rust-lang.org>
Tue, 26 Jun 2018 23:15:30 +0000 (23:15 +0000)
lint to favor `..=` over `...` range patterns; migrate to `..=` throughout codebase

We probably need an RFC to actually deprecate the `...` syntax, but here's a candidate implementation for the lint considered in #51043. (My local build is super flaky, but hopefully I got all of the test revisions.)

1  2 
src/librustc_lint/lib.rs

diff --combined src/librustc_lint/lib.rs
index 11bca9b4a2d0b00d0c073612ab5f5900ab020075,ba373b5c0e89dc4f106efb8fa5b03f811900cc5e..13e97a9d3e5914b3d36fce41ccbdb01da6bdc8f0
@@@ -41,14 -41,9 +41,14 @@@ extern crate rustc_target
  extern crate syntax_pos;
  
  use rustc::lint;
 +use rustc::lint::{LateContext, LateLintPass, LintPass, LintArray};
  use rustc::lint::builtin::{BARE_TRAIT_OBJECTS, ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE};
  use rustc::session;
  use rustc::util;
 +use rustc::hir;
 +
 +use syntax::ast;
 +use syntax_pos::Span;
  
  use session::Session;
  use syntax::edition::Edition;
@@@ -72,6 -67,14 +72,6 @@@ pub use builtin::SoftLints
  /// defined in this crate and the ones defined in
  /// `rustc::lint::builtin`).
  pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
 -    macro_rules! add_builtin {
 -        ($sess:ident, $($name:ident),*,) => (
 -            {$(
 -                store.register_late_pass($sess, false, box $name);
 -                )*}
 -            )
 -    }
 -
      macro_rules! add_early_builtin {
          ($sess:ident, $($name:ident),*,) => (
              {$(
              )
      }
  
 -    macro_rules! add_builtin_with_new {
 -        ($sess:ident, $($name:ident),*,) => (
 -            {$(
 -                store.register_late_pass($sess, false, box $name::new());
 -                )*}
 -            )
 -    }
 -
      macro_rules! add_early_builtin_with_new {
          ($sess:ident, $($name:ident),*,) => (
              {$(
                         AnonymousParameters,
                         UnusedDocComment,
                         BadRepr,
+                        EllipsisInclusiveRangePatterns,
                         );
  
      add_early_builtin_with_new!(sess,
                                  DeprecatedAttr,
                                  );
  
 -    add_builtin!(sess,
 -                 HardwiredLints,
 -                 WhileTrue,
 -                 ImproperCTypes,
 -                 VariantSizeDifferences,
 -                 BoxPointers,
 -                 UnusedAttributes,
 -                 PathStatements,
 -                 UnusedResults,
 -                 NonCamelCaseTypes,
 -                 NonSnakeCase,
 -                 NonUpperCaseGlobals,
 -                 NonShorthandFieldPatterns,
 -                 UnsafeCode,
 -                 UnusedAllocation,
 -                 MissingCopyImplementations,
 -                 UnstableFeatures,
 -                 UnconditionalRecursion,
 -                 InvalidNoMangleItems,
 -                 PluginAsLibrary,
 -                 MutableTransmutes,
 -                 UnionsWithDropFields,
 -                 UnreachablePub,
 -                 TypeAliasBounds,
 -                 UnusedBrokenConst,
 -                 TrivialConstraints,
 -                 );
 -
 -    add_builtin_with_new!(sess,
 -                          TypeLimits,
 -                          MissingDoc,
 -                          MissingDebugImplementations,
 -                          );
 +    late_lint_methods!(declare_combined_late_lint_pass, [BuiltinCombinedLateLintPass, [
 +        HardwiredLints: HardwiredLints,
 +        WhileTrue: WhileTrue,
 +        ImproperCTypes: ImproperCTypes,
 +        VariantSizeDifferences: VariantSizeDifferences,
 +        BoxPointers: BoxPointers,
 +        UnusedAttributes: UnusedAttributes,
 +        PathStatements: PathStatements,
 +        UnusedResults: UnusedResults,
 +        NonCamelCaseTypes: NonCamelCaseTypes,
 +        NonSnakeCase: NonSnakeCase,
 +        NonUpperCaseGlobals: NonUpperCaseGlobals,
 +        NonShorthandFieldPatterns: NonShorthandFieldPatterns,
 +        UnsafeCode: UnsafeCode,
 +        UnusedAllocation: UnusedAllocation,
 +        MissingCopyImplementations: MissingCopyImplementations,
 +        UnstableFeatures: UnstableFeatures,
 +        UnconditionalRecursion: UnconditionalRecursion,
 +        InvalidNoMangleItems: InvalidNoMangleItems,
 +        PluginAsLibrary: PluginAsLibrary,
 +        MutableTransmutes: MutableTransmutes,
 +        UnionsWithDropFields: UnionsWithDropFields,
 +        UnreachablePub: UnreachablePub,
 +        TypeAliasBounds: TypeAliasBounds,
 +        UnusedBrokenConst: UnusedBrokenConst,
 +        TrivialConstraints: TrivialConstraints,
 +        TypeLimits: TypeLimits::new(),
 +        MissingDoc: MissingDoc::new(),
 +        MissingDebugImplementations: MissingDebugImplementations::new(),
 +    ]], ['tcx]);
 +
 +    store.register_late_pass(sess, false, box BuiltinCombinedLateLintPass::new());
  
      add_lint_group!(sess,
                      "bad_style",
                      "rust_2018_idioms",
                      BARE_TRAIT_OBJECTS,
                      UNREACHABLE_PUB,
-                     UNUSED_EXTERN_CRATES);
+                     UNUSED_EXTERN_CRATES,
+                     ELLIPSIS_INCLUSIVE_RANGE_PATTERNS);
  
      // Guidelines for creating a future incompatibility lint:
      //