about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-01-05 14:04:31 +0000
committerbors <bors@rust-lang.org>2019-01-05 14:04:31 +0000
commitc63b6349b44019146cc2edcef8141692891b9401 (patch)
treecb1a9c05a0521e08fd462f1a5e046d1f8ca1a6ae
parent05467abd2481a2d2437c77bc988735e8f4f610f9 (diff)
parent8ff4a1f0a82be971ecadfdba0066fd448db2a8b3 (diff)
downloadrust-c63b6349b44019146cc2edcef8141692891b9401.tar.gz
rust-c63b6349b44019146cc2edcef8141692891b9401.zip
Auto merge of #3635 - matthiaskrgr:revert_random_state_3603, r=xfix
Revert the random_state lint.

Remove the random_state lint until it or rustc has been fixed to no longer crash with debug assertions (see #3628)
We can't update clippy in the rustc repo because of this which is blocking nightlies because toolstate is already broken.

fixes #3628
-rw-r--r--CHANGELOG.md1
-rw-r--r--README.md2
-rw-r--r--clippy_lints/src/lib.rs3
-rw-r--r--clippy_lints/src/random_state.rs50
-rw-r--r--clippy_lints/src/utils/paths.rs1
-rw-r--r--tests/run-pass/used_underscore_binding_macro.rs1
-rw-r--r--tests/ui/random_state.rs19
-rw-r--r--tests/ui/random_state.stderr28
8 files changed, 1 insertions, 104 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b5c8feb8ac6..efa637b185c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -814,7 +814,6 @@ All notable changes to this project will be documented in this file.
 [`ptr_offset_with_cast`]: https://rust-lang.github.io/rust-clippy/master/index.html#ptr_offset_with_cast
 [`pub_enum_variant_names`]: https://rust-lang.github.io/rust-clippy/master/index.html#pub_enum_variant_names
 [`question_mark`]: https://rust-lang.github.io/rust-clippy/master/index.html#question_mark
-[`random_state`]: https://rust-lang.github.io/rust-clippy/master/index.html#random_state
 [`range_minus_one`]: https://rust-lang.github.io/rust-clippy/master/index.html#range_minus_one
 [`range_plus_one`]: https://rust-lang.github.io/rust-clippy/master/index.html#range_plus_one
 [`range_step_by_zero`]: https://rust-lang.github.io/rust-clippy/master/index.html#range_step_by_zero
diff --git a/README.md b/README.md
index 8ca10da416d..be54424dc38 100644
--- a/README.md
+++ b/README.md
@@ -7,7 +7,7 @@
 
 A collection of lints to catch common mistakes and improve your [Rust](https://github.com/rust-lang/rust) code.
 
-[There are 291 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)
+[There are 290 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)
 
 We have a bunch of lint categories to allow you to choose how much Clippy is supposed to ~~annoy~~ help you:
 
diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs
index 31cd58d2c78..2e515cc8aea 100644
--- a/clippy_lints/src/lib.rs
+++ b/clippy_lints/src/lib.rs
@@ -180,7 +180,6 @@ pub mod precedence;
 pub mod ptr;
 pub mod ptr_offset_with_cast;
 pub mod question_mark;
-pub mod random_state;
 pub mod ranges;
 pub mod redundant_clone;
 pub mod redundant_field_names;
@@ -487,7 +486,6 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
     reg.register_late_lint_pass(box ptr_offset_with_cast::Pass);
     reg.register_late_lint_pass(box redundant_clone::RedundantClone);
     reg.register_late_lint_pass(box slow_vector_initialization::Pass);
-    reg.register_late_lint_pass(box random_state::Pass);
 
     reg.register_lint_group("clippy::restriction", Some("clippy_restriction"), vec![
         arithmetic::FLOAT_ARITHMETIC,
@@ -1027,7 +1025,6 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
         fallible_impl_from::FALLIBLE_IMPL_FROM,
         mutex_atomic::MUTEX_INTEGER,
         needless_borrow::NEEDLESS_BORROW,
-        random_state::RANDOM_STATE,
         redundant_clone::REDUNDANT_CLONE,
         unwrap::PANICKING_UNWRAP,
         unwrap::UNNECESSARY_UNWRAP,
diff --git a/clippy_lints/src/random_state.rs b/clippy_lints/src/random_state.rs
deleted file mode 100644
index f95116c04b6..00000000000
--- a/clippy_lints/src/random_state.rs
+++ /dev/null
@@ -1,50 +0,0 @@
-use crate::utils::{match_type, paths, span_lint};
-use rustc::hir::Ty;
-use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
-use rustc::ty::subst::UnpackedKind;
-use rustc::ty::TyKind;
-use rustc::{declare_tool_lint, lint_array};
-
-/// **What it does:** Checks for usage of `RandomState`
-///
-/// **Why is this bad?** Some applications don't need collision prevention
-/// which lowers the performance.
-///
-/// **Known problems:** None.
-///
-/// **Example:**
-/// ```rust
-/// fn x() {
-///     let mut map = std::collections::HashMap::new();
-///     map.insert(3, 4);
-/// }
-/// ```
-declare_clippy_lint! {
-    pub RANDOM_STATE,
-    nursery,
-    "use of RandomState"
-}
-
-pub struct Pass;
-
-impl LintPass for Pass {
-    fn get_lints(&self) -> LintArray {
-        lint_array!(RANDOM_STATE)
-    }
-}
-
-impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
-    fn check_ty(&mut self, cx: &LateContext<'a, 'tcx>, ty: &Ty) {
-        if let Some(tys) = cx.tables.node_id_to_type_opt(ty.hir_id) {
-            if let TyKind::Adt(_, substs) = tys.sty {
-                for subst in substs {
-                    if let UnpackedKind::Type(build_hasher) = subst.unpack() {
-                        if match_type(cx, build_hasher, &paths::RANDOM_STATE) {
-                            span_lint(cx, RANDOM_STATE, ty.span, "usage of RandomState");
-                        }
-                    }
-                }
-            }
-        }
-    }
-}
diff --git a/clippy_lints/src/utils/paths.rs b/clippy_lints/src/utils/paths.rs
index 0ec684e36bc..0779d77936f 100644
--- a/clippy_lints/src/utils/paths.rs
+++ b/clippy_lints/src/utils/paths.rs
@@ -73,7 +73,6 @@ pub const PATH_BUF: [&str; 3] = ["std", "path", "PathBuf"];
 pub const PATH_TO_PATH_BUF: [&str; 4] = ["std", "path", "Path", "to_path_buf"];
 pub const PTR_NULL: [&str; 2] = ["ptr", "null"];
 pub const PTR_NULL_MUT: [&str; 2] = ["ptr", "null_mut"];
-pub const RANDOM_STATE: [&str; 5] = ["std", "collections", "hash", "map", "RandomState"];
 pub const RANGE: [&str; 3] = ["core", "ops", "Range"];
 pub const RANGE_ARGUMENT_TRAIT: [&str; 3] = ["core", "ops", "RangeBounds"];
 pub const RANGE_FROM: [&str; 3] = ["core", "ops", "RangeFrom"];
diff --git a/tests/run-pass/used_underscore_binding_macro.rs b/tests/run-pass/used_underscore_binding_macro.rs
index e3af880524c..8b6c6557b49 100644
--- a/tests/run-pass/used_underscore_binding_macro.rs
+++ b/tests/run-pass/used_underscore_binding_macro.rs
@@ -8,7 +8,6 @@
 // except according to those terms.
 
 #![allow(clippy::useless_attribute)] //issue #2910
-#![allow(clippy::random_state)] // issue #3628
 
 #[macro_use]
 extern crate serde_derive;
diff --git a/tests/ui/random_state.rs b/tests/ui/random_state.rs
deleted file mode 100644
index f4fa85997a8..00000000000
--- a/tests/ui/random_state.rs
+++ /dev/null
@@ -1,19 +0,0 @@
-#![warn(clippy::random_state)]
-
-use std::collections::hash_map::RandomState;
-use std::collections::hash_map::{DefaultHasher, HashMap};
-use std::hash::BuildHasherDefault;
-
-fn main() {
-    // Should warn
-    let mut map = HashMap::new();
-    map.insert(3, 4);
-    let mut map = HashMap::with_hasher(RandomState::new());
-    map.insert(true, false);
-    let _map: HashMap<_, _> = vec![(2, 3)].into_iter().collect();
-    let _vec: Vec<HashMap<i32, i32>>;
-    // Shouldn't warn
-    let _map: HashMap<i32, i32, BuildHasherDefault<DefaultHasher>> = HashMap::default();
-    let mut map = HashMap::with_hasher(BuildHasherDefault::<DefaultHasher>::default());
-    map.insert("a", "b");
-}
diff --git a/tests/ui/random_state.stderr b/tests/ui/random_state.stderr
deleted file mode 100644
index df224bf0c29..00000000000
--- a/tests/ui/random_state.stderr
+++ /dev/null
@@ -1,28 +0,0 @@
-error: usage of RandomState
-  --> $DIR/random_state.rs:9:19
-   |
-LL |     let mut map = HashMap::new();
-   |                   ^^^^^^^^^^^^
-   |
-   = note: `-D clippy::random-state` implied by `-D warnings`
-
-error: usage of RandomState
-  --> $DIR/random_state.rs:11:19
-   |
-LL |     let mut map = HashMap::with_hasher(RandomState::new());
-   |                   ^^^^^^^^^^^^^^^^^^^^
-
-error: usage of RandomState
-  --> $DIR/random_state.rs:13:15
-   |
-LL |     let _map: HashMap<_, _> = vec![(2, 3)].into_iter().collect();
-   |               ^^^^^^^^^^^^^
-
-error: usage of RandomState
-  --> $DIR/random_state.rs:14:19
-   |
-LL |     let _vec: Vec<HashMap<i32, i32>>;
-   |                   ^^^^^^^^^^^^^^^^^
-
-error: aborting due to 4 previous errors
-