about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-04-04 02:31:46 +0000
committerbors <bors@rust-lang.org>2019-04-04 02:31:46 +0000
commita5dfdc589a1b44f01cb640cd0244372dcbbd6f37 (patch)
tree2e64cd0111d47ed14ffdfbde912e5a746ac8b454 /src/test
parent314a79cd80ed905f80d24b79fd7acb4c8c72789b (diff)
parent231bd482c6d2f2aae463f2d5b57ed3c8f5a0803e (diff)
downloadrust-a5dfdc589a1b44f01cb640cd0244372dcbbd6f37.tar.gz
rust-a5dfdc589a1b44f01cb640cd0244372dcbbd6f37.zip
Auto merge of #59684 - Centril:rollup-n7pnare, r=Centril
Rollup of 6 pull requests

Successful merges:

 - #59316 (Internal lints take 2)
 - #59663 (Be more direct about borrow contract)
 - #59664 (Updated the documentation of spin_loop and spin_loop_hint)
 - #59666 (Updated the environment description in rustc.)
 - #59669 (Reduce repetition in librustc(_lint) wrt. impl LintPass by using macros)
 - #59677 (rustfix coverage: Skip UI tests with non-json error-format)

Failed merges:

r? @ghost
Diffstat (limited to 'src/test')
-rw-r--r--src/test/run-pass-fulldeps/auxiliary/issue-40001-plugin.rs19
-rw-r--r--src/test/ui-fulldeps/auxiliary/lint-for-crate.rs18
-rw-r--r--src/test/ui-fulldeps/auxiliary/lint-group-plugin-test.rs12
-rw-r--r--src/test/ui-fulldeps/auxiliary/lint-plugin-test.rs12
-rw-r--r--src/test/ui-fulldeps/auxiliary/lint-tool-test.rs12
-rw-r--r--src/test/ui-fulldeps/internal-lints/default_hash_types.rs22
-rw-r--r--src/test/ui-fulldeps/internal-lints/default_hash_types.stderr39
-rw-r--r--src/test/ui-fulldeps/internal-lints/ty_tykind_usage.rs49
-rw-r--r--src/test/ui-fulldeps/internal-lints/ty_tykind_usage.stderr196
9 files changed, 321 insertions, 58 deletions
diff --git a/src/test/run-pass-fulldeps/auxiliary/issue-40001-plugin.rs b/src/test/run-pass-fulldeps/auxiliary/issue-40001-plugin.rs
index 09aa106ebbd..76d0906f97c 100644
--- a/src/test/run-pass-fulldeps/auxiliary/issue-40001-plugin.rs
+++ b/src/test/run-pass-fulldeps/auxiliary/issue-40001-plugin.rs
@@ -26,21 +26,14 @@ pub fn plugin_registrar(reg: &mut Registry) {
     reg.register_attribute("whitelisted_attr".to_string(), Whitelisted);
 }
 
-declare_lint!(MISSING_WHITELISTED_ATTR, Deny,
-              "Checks for missing `whitelisted_attr` attribute");
-
-struct MissingWhitelistedAttrPass;
-
-impl LintPass for MissingWhitelistedAttrPass {
-    fn name(&self) -> &'static str {
-        "MissingWhitelistedAttrPass"
-    }
-
-    fn get_lints(&self) -> LintArray {
-        lint_array!(MISSING_WHITELISTED_ATTR)
-    }
+declare_lint! {
+    MISSING_WHITELISTED_ATTR,
+    Deny,
+    "Checks for missing `whitelisted_attr` attribute"
 }
 
+declare_lint_pass!(MissingWhitelistedAttrPass => [MISSING_WHITELISTED_ATTR]);
+
 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingWhitelistedAttrPass {
     fn check_fn(&mut self,
                 cx: &LateContext<'a, 'tcx>,
diff --git a/src/test/ui-fulldeps/auxiliary/lint-for-crate.rs b/src/test/ui-fulldeps/auxiliary/lint-for-crate.rs
index 82aa28b26b6..e8f1d2eedf5 100644
--- a/src/test/ui-fulldeps/auxiliary/lint-for-crate.rs
+++ b/src/test/ui-fulldeps/auxiliary/lint-for-crate.rs
@@ -12,20 +12,14 @@ use rustc_plugin::Registry;
 use rustc::hir;
 use syntax::attr;
 
-declare_lint!(CRATE_NOT_OKAY, Warn, "crate not marked with #![crate_okay]");
-
-struct Pass;
-
-impl LintPass for Pass {
-    fn name(&self) -> &'static str {
-        "Pass"
-    }
-
-    fn get_lints(&self) -> LintArray {
-        lint_array!(CRATE_NOT_OKAY)
-    }
+declare_lint! {
+    CRATE_NOT_OKAY,
+    Warn,
+    "crate not marked with #![crate_okay]"
 }
 
+declare_lint_pass!(Pass => [CRATE_NOT_OKAY]);
+
 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
     fn check_crate(&mut self, cx: &LateContext, krate: &hir::Crate) {
         if !attr::contains_name(&krate.attrs, "crate_okay") {
diff --git a/src/test/ui-fulldeps/auxiliary/lint-group-plugin-test.rs b/src/test/ui-fulldeps/auxiliary/lint-group-plugin-test.rs
index 16630e2b312..941fe25b14c 100644
--- a/src/test/ui-fulldeps/auxiliary/lint-group-plugin-test.rs
+++ b/src/test/ui-fulldeps/auxiliary/lint-group-plugin-test.rs
@@ -16,17 +16,7 @@ declare_lint!(TEST_LINT, Warn, "Warn about items named 'lintme'");
 
 declare_lint!(PLEASE_LINT, Warn, "Warn about items named 'pleaselintme'");
 
-struct Pass;
-
-impl LintPass for Pass {
-    fn name(&self) -> &'static str {
-        "Pass"
-    }
-
-    fn get_lints(&self) -> LintArray {
-        lint_array!(TEST_LINT, PLEASE_LINT)
-    }
-}
+declare_lint_pass!(Pass => [TEST_LINT, PLEASE_LINT]);
 
 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
     fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
diff --git a/src/test/ui-fulldeps/auxiliary/lint-plugin-test.rs b/src/test/ui-fulldeps/auxiliary/lint-plugin-test.rs
index 4e45189b424..1d204e7bfcf 100644
--- a/src/test/ui-fulldeps/auxiliary/lint-plugin-test.rs
+++ b/src/test/ui-fulldeps/auxiliary/lint-plugin-test.rs
@@ -16,17 +16,7 @@ use rustc_plugin::Registry;
 use syntax::ast;
 declare_lint!(TEST_LINT, Warn, "Warn about items named 'lintme'");
 
-struct Pass;
-
-impl LintPass for Pass {
-    fn name(&self) -> &'static str {
-        "Pass"
-    }
-
-    fn get_lints(&self) -> LintArray {
-        lint_array!(TEST_LINT)
-    }
-}
+declare_lint_pass!(Pass => [TEST_LINT]);
 
 impl EarlyLintPass for Pass {
     fn check_item(&mut self, cx: &EarlyContext, it: &ast::Item) {
diff --git a/src/test/ui-fulldeps/auxiliary/lint-tool-test.rs b/src/test/ui-fulldeps/auxiliary/lint-tool-test.rs
index d25a5ea3746..182d2899da1 100644
--- a/src/test/ui-fulldeps/auxiliary/lint-tool-test.rs
+++ b/src/test/ui-fulldeps/auxiliary/lint-tool-test.rs
@@ -19,17 +19,7 @@ declare_tool_lint!(
     Warn, "Warn about other stuff"
 );
 
-struct Pass;
-
-impl LintPass for Pass {
-    fn name(&self) -> &'static str {
-        "Pass"
-    }
-
-    fn get_lints(&self) -> LintArray {
-        lint_array!(TEST_LINT, TEST_GROUP)
-    }
-}
+declare_lint_pass!(Pass => [TEST_LINT, TEST_GROUP]);
 
 impl EarlyLintPass for Pass {
     fn check_item(&mut self, cx: &EarlyContext, it: &ast::Item) {
diff --git a/src/test/ui-fulldeps/internal-lints/default_hash_types.rs b/src/test/ui-fulldeps/internal-lints/default_hash_types.rs
new file mode 100644
index 00000000000..3264099c876
--- /dev/null
+++ b/src/test/ui-fulldeps/internal-lints/default_hash_types.rs
@@ -0,0 +1,22 @@
+// compile-flags: -Z unstable-options
+
+#![feature(rustc_private)]
+
+extern crate rustc_data_structures;
+
+use rustc_data_structures::fx::{FxHashMap, FxHashSet};
+use std::collections::{HashMap, HashSet};
+
+#[deny(default_hash_types)]
+fn main() {
+    let _map: HashMap<String, String> = HashMap::default();
+    //~^ ERROR Prefer FxHashMap over HashMap, it has better performance
+    //~^^ ERROR Prefer FxHashMap over HashMap, it has better performance
+    let _set: HashSet<String> = HashSet::default();
+    //~^ ERROR Prefer FxHashSet over HashSet, it has better performance
+    //~^^ ERROR Prefer FxHashSet over HashSet, it has better performance
+
+    // test that the lint doesn't also match the Fx variants themselves
+    let _fx_map: FxHashMap<String, String> = FxHashMap::default();
+    let _fx_set: FxHashSet<String> = FxHashSet::default();
+}
diff --git a/src/test/ui-fulldeps/internal-lints/default_hash_types.stderr b/src/test/ui-fulldeps/internal-lints/default_hash_types.stderr
new file mode 100644
index 00000000000..64f322cb0c1
--- /dev/null
+++ b/src/test/ui-fulldeps/internal-lints/default_hash_types.stderr
@@ -0,0 +1,39 @@
+error: Prefer FxHashMap over HashMap, it has better performance
+  --> $DIR/default_hash_types.rs:12:15
+   |
+LL |     let _map: HashMap<String, String> = HashMap::default();
+   |               ^^^^^^^ help: use: `FxHashMap`
+   |
+note: lint level defined here
+  --> $DIR/default_hash_types.rs:10:8
+   |
+LL | #[deny(default_hash_types)]
+   |        ^^^^^^^^^^^^^^^^^^
+   = note: a `use rustc_data_structures::fx::FxHashMap` may be necessary
+
+error: Prefer FxHashMap over HashMap, it has better performance
+  --> $DIR/default_hash_types.rs:12:41
+   |
+LL |     let _map: HashMap<String, String> = HashMap::default();
+   |                                         ^^^^^^^ help: use: `FxHashMap`
+   |
+   = note: a `use rustc_data_structures::fx::FxHashMap` may be necessary
+
+error: Prefer FxHashSet over HashSet, it has better performance
+  --> $DIR/default_hash_types.rs:15:15
+   |
+LL |     let _set: HashSet<String> = HashSet::default();
+   |               ^^^^^^^ help: use: `FxHashSet`
+   |
+   = note: a `use rustc_data_structures::fx::FxHashSet` may be necessary
+
+error: Prefer FxHashSet over HashSet, it has better performance
+  --> $DIR/default_hash_types.rs:15:33
+   |
+LL |     let _set: HashSet<String> = HashSet::default();
+   |                                 ^^^^^^^ help: use: `FxHashSet`
+   |
+   = note: a `use rustc_data_structures::fx::FxHashSet` may be necessary
+
+error: aborting due to 4 previous errors
+
diff --git a/src/test/ui-fulldeps/internal-lints/ty_tykind_usage.rs b/src/test/ui-fulldeps/internal-lints/ty_tykind_usage.rs
new file mode 100644
index 00000000000..dba0db69b7f
--- /dev/null
+++ b/src/test/ui-fulldeps/internal-lints/ty_tykind_usage.rs
@@ -0,0 +1,49 @@
+// compile-flags: -Z unstable-options
+
+#![feature(rustc_private)]
+
+extern crate rustc;
+
+use rustc::ty::{self, Ty, TyKind};
+
+#[deny(usage_of_ty_tykind)]
+fn main() {
+    let sty = TyKind::Bool; //~ ERROR usage of `ty::TyKind::<kind>`
+
+    match sty {
+        TyKind::Bool => (), //~ ERROR usage of `ty::TyKind::<kind>`
+        TyKind::Char => (), //~ ERROR usage of `ty::TyKind::<kind>`
+        TyKind::Int(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
+        TyKind::Uint(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
+        TyKind::Float(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
+        TyKind::Adt(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
+        TyKind::Foreign(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
+        TyKind::Str => (), //~ ERROR usage of `ty::TyKind::<kind>`
+        TyKind::Array(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
+        TyKind::Slice(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
+        TyKind::RawPtr(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
+        TyKind::Ref(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
+        TyKind::FnDef(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
+        TyKind::FnPtr(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
+        TyKind::Dynamic(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
+        TyKind::Closure(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
+        TyKind::Generator(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
+        TyKind::GeneratorWitness(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
+        TyKind::Never => (), //~ ERROR usage of `ty::TyKind::<kind>`
+        TyKind::Tuple(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
+        TyKind::Projection(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
+        TyKind::UnnormalizedProjection(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
+        TyKind::Opaque(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
+        TyKind::Param(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
+        TyKind::Bound(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
+        TyKind::Placeholder(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
+        TyKind::Infer(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
+        TyKind::Error => (), //~ ERROR usage of `ty::TyKind::<kind>`
+    }
+
+    if let ty::Int(int_ty) = sty {}
+
+    if let TyKind::Int(int_ty) = sty {} //~ ERROR usage of `ty::TyKind::<kind>`
+
+    fn ty_kind(ty_bad: TyKind<'_>, ty_good: Ty<'_>) {} //~ ERROR usage of `ty::TyKind`
+}
diff --git a/src/test/ui-fulldeps/internal-lints/ty_tykind_usage.stderr b/src/test/ui-fulldeps/internal-lints/ty_tykind_usage.stderr
new file mode 100644
index 00000000000..4e94af12453
--- /dev/null
+++ b/src/test/ui-fulldeps/internal-lints/ty_tykind_usage.stderr
@@ -0,0 +1,196 @@
+error: usage of `ty::TyKind::<kind>`
+  --> $DIR/ty_tykind_usage.rs:11:15
+   |
+LL |     let sty = TyKind::Bool;
+   |               ^^^^^^ help: try using ty::<kind> directly: `ty`
+   |
+note: lint level defined here
+  --> $DIR/ty_tykind_usage.rs:9:8
+   |
+LL | #[deny(usage_of_ty_tykind)]
+   |        ^^^^^^^^^^^^^^^^^^
+
+error: usage of `ty::TyKind::<kind>`
+  --> $DIR/ty_tykind_usage.rs:14:9
+   |
+LL |         TyKind::Bool => (),
+   |         ^^^^^^ help: try using ty::<kind> directly: `ty`
+
+error: usage of `ty::TyKind::<kind>`
+  --> $DIR/ty_tykind_usage.rs:15:9
+   |
+LL |         TyKind::Char => (),
+   |         ^^^^^^ help: try using ty::<kind> directly: `ty`
+
+error: usage of `ty::TyKind::<kind>`
+  --> $DIR/ty_tykind_usage.rs:16:9
+   |
+LL |         TyKind::Int(..) => (),
+   |         ^^^^^^ help: try using ty::<kind> directly: `ty`
+
+error: usage of `ty::TyKind::<kind>`
+  --> $DIR/ty_tykind_usage.rs:17:9
+   |
+LL |         TyKind::Uint(..) => (),
+   |         ^^^^^^ help: try using ty::<kind> directly: `ty`
+
+error: usage of `ty::TyKind::<kind>`
+  --> $DIR/ty_tykind_usage.rs:18:9
+   |
+LL |         TyKind::Float(..) => (),
+   |         ^^^^^^ help: try using ty::<kind> directly: `ty`
+
+error: usage of `ty::TyKind::<kind>`
+  --> $DIR/ty_tykind_usage.rs:19:9
+   |
+LL |         TyKind::Adt(..) => (),
+   |         ^^^^^^ help: try using ty::<kind> directly: `ty`
+
+error: usage of `ty::TyKind::<kind>`
+  --> $DIR/ty_tykind_usage.rs:20:9
+   |
+LL |         TyKind::Foreign(..) => (),
+   |         ^^^^^^ help: try using ty::<kind> directly: `ty`
+
+error: usage of `ty::TyKind::<kind>`
+  --> $DIR/ty_tykind_usage.rs:21:9
+   |
+LL |         TyKind::Str => (),
+   |         ^^^^^^ help: try using ty::<kind> directly: `ty`
+
+error: usage of `ty::TyKind::<kind>`
+  --> $DIR/ty_tykind_usage.rs:22:9
+   |
+LL |         TyKind::Array(..) => (),
+   |         ^^^^^^ help: try using ty::<kind> directly: `ty`
+
+error: usage of `ty::TyKind::<kind>`
+  --> $DIR/ty_tykind_usage.rs:23:9
+   |
+LL |         TyKind::Slice(..) => (),
+   |         ^^^^^^ help: try using ty::<kind> directly: `ty`
+
+error: usage of `ty::TyKind::<kind>`
+  --> $DIR/ty_tykind_usage.rs:24:9
+   |
+LL |         TyKind::RawPtr(..) => (),
+   |         ^^^^^^ help: try using ty::<kind> directly: `ty`
+
+error: usage of `ty::TyKind::<kind>`
+  --> $DIR/ty_tykind_usage.rs:25:9
+   |
+LL |         TyKind::Ref(..) => (),
+   |         ^^^^^^ help: try using ty::<kind> directly: `ty`
+
+error: usage of `ty::TyKind::<kind>`
+  --> $DIR/ty_tykind_usage.rs:26:9
+   |
+LL |         TyKind::FnDef(..) => (),
+   |         ^^^^^^ help: try using ty::<kind> directly: `ty`
+
+error: usage of `ty::TyKind::<kind>`
+  --> $DIR/ty_tykind_usage.rs:27:9
+   |
+LL |         TyKind::FnPtr(..) => (),
+   |         ^^^^^^ help: try using ty::<kind> directly: `ty`
+
+error: usage of `ty::TyKind::<kind>`
+  --> $DIR/ty_tykind_usage.rs:28:9
+   |
+LL |         TyKind::Dynamic(..) => (),
+   |         ^^^^^^ help: try using ty::<kind> directly: `ty`
+
+error: usage of `ty::TyKind::<kind>`
+  --> $DIR/ty_tykind_usage.rs:29:9
+   |
+LL |         TyKind::Closure(..) => (),
+   |         ^^^^^^ help: try using ty::<kind> directly: `ty`
+
+error: usage of `ty::TyKind::<kind>`
+  --> $DIR/ty_tykind_usage.rs:30:9
+   |
+LL |         TyKind::Generator(..) => (),
+   |         ^^^^^^ help: try using ty::<kind> directly: `ty`
+
+error: usage of `ty::TyKind::<kind>`
+  --> $DIR/ty_tykind_usage.rs:31:9
+   |
+LL |         TyKind::GeneratorWitness(..) => (),
+   |         ^^^^^^ help: try using ty::<kind> directly: `ty`
+
+error: usage of `ty::TyKind::<kind>`
+  --> $DIR/ty_tykind_usage.rs:32:9
+   |
+LL |         TyKind::Never => (),
+   |         ^^^^^^ help: try using ty::<kind> directly: `ty`
+
+error: usage of `ty::TyKind::<kind>`
+  --> $DIR/ty_tykind_usage.rs:33:9
+   |
+LL |         TyKind::Tuple(..) => (),
+   |         ^^^^^^ help: try using ty::<kind> directly: `ty`
+
+error: usage of `ty::TyKind::<kind>`
+  --> $DIR/ty_tykind_usage.rs:34:9
+   |
+LL |         TyKind::Projection(..) => (),
+   |         ^^^^^^ help: try using ty::<kind> directly: `ty`
+
+error: usage of `ty::TyKind::<kind>`
+  --> $DIR/ty_tykind_usage.rs:35:9
+   |
+LL |         TyKind::UnnormalizedProjection(..) => (),
+   |         ^^^^^^ help: try using ty::<kind> directly: `ty`
+
+error: usage of `ty::TyKind::<kind>`
+  --> $DIR/ty_tykind_usage.rs:36:9
+   |
+LL |         TyKind::Opaque(..) => (),
+   |         ^^^^^^ help: try using ty::<kind> directly: `ty`
+
+error: usage of `ty::TyKind::<kind>`
+  --> $DIR/ty_tykind_usage.rs:37:9
+   |
+LL |         TyKind::Param(..) => (),
+   |         ^^^^^^ help: try using ty::<kind> directly: `ty`
+
+error: usage of `ty::TyKind::<kind>`
+  --> $DIR/ty_tykind_usage.rs:38:9
+   |
+LL |         TyKind::Bound(..) => (),
+   |         ^^^^^^ help: try using ty::<kind> directly: `ty`
+
+error: usage of `ty::TyKind::<kind>`
+  --> $DIR/ty_tykind_usage.rs:39:9
+   |
+LL |         TyKind::Placeholder(..) => (),
+   |         ^^^^^^ help: try using ty::<kind> directly: `ty`
+
+error: usage of `ty::TyKind::<kind>`
+  --> $DIR/ty_tykind_usage.rs:40:9
+   |
+LL |         TyKind::Infer(..) => (),
+   |         ^^^^^^ help: try using ty::<kind> directly: `ty`
+
+error: usage of `ty::TyKind::<kind>`
+  --> $DIR/ty_tykind_usage.rs:41:9
+   |
+LL |         TyKind::Error => (),
+   |         ^^^^^^ help: try using ty::<kind> directly: `ty`
+
+error: usage of `ty::TyKind::<kind>`
+  --> $DIR/ty_tykind_usage.rs:46:12
+   |
+LL |     if let TyKind::Int(int_ty) = sty {}
+   |            ^^^^^^ help: try using ty::<kind> directly: `ty`
+
+error: usage of `ty::TyKind`
+  --> $DIR/ty_tykind_usage.rs:48:24
+   |
+LL |     fn ty_kind(ty_bad: TyKind<'_>, ty_good: Ty<'_>) {}
+   |                        ^^^^^^^^^^
+   |
+   = help: try using `ty::Ty` instead
+
+error: aborting due to 31 previous errors
+