about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/ui-toml/disallowed_macros/auxiliary/macros.rs32
-rw-r--r--tests/ui-toml/disallowed_macros/clippy.toml11
-rw-r--r--tests/ui-toml/disallowed_macros/disallowed_macros.rs39
-rw-r--r--tests/ui-toml/disallowed_macros/disallowed_macros.stderr84
-rw-r--r--tests/ui-toml/toml_disallowed_methods/clippy.toml1
-rw-r--r--tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs6
-rw-r--r--tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.stderr24
-rw-r--r--tests/ui-toml/toml_unknown_key/conf_unknown_key.stderr1
8 files changed, 189 insertions, 9 deletions
diff --git a/tests/ui-toml/disallowed_macros/auxiliary/macros.rs b/tests/ui-toml/disallowed_macros/auxiliary/macros.rs
new file mode 100644
index 00000000000..fcaeace0e98
--- /dev/null
+++ b/tests/ui-toml/disallowed_macros/auxiliary/macros.rs
@@ -0,0 +1,32 @@
+#[macro_export]
+macro_rules! expr {
+    () => {
+        1
+    };
+}
+
+#[macro_export]
+macro_rules! stmt {
+    () => {
+        let _x = ();
+    };
+}
+
+#[macro_export]
+macro_rules! ty {
+    () => { &'static str };
+}
+
+#[macro_export]
+macro_rules! pat {
+    () => {
+        _
+    };
+}
+
+#[macro_export]
+macro_rules! item {
+    () => {
+        const ITEM: usize = 1;
+    };
+}
diff --git a/tests/ui-toml/disallowed_macros/clippy.toml b/tests/ui-toml/disallowed_macros/clippy.toml
new file mode 100644
index 00000000000..c8fe8be9a77
--- /dev/null
+++ b/tests/ui-toml/disallowed_macros/clippy.toml
@@ -0,0 +1,11 @@
+disallowed-macros = [
+    "std::println",
+    "std::vec",
+    { path = "std::cfg" },
+    { path = "serde::Serialize", reason = "no serializing" },
+    "macros::expr",
+    "macros::stmt",
+    "macros::ty",
+    "macros::pat",
+    "macros::item",
+]
diff --git a/tests/ui-toml/disallowed_macros/disallowed_macros.rs b/tests/ui-toml/disallowed_macros/disallowed_macros.rs
new file mode 100644
index 00000000000..2bb5376076e
--- /dev/null
+++ b/tests/ui-toml/disallowed_macros/disallowed_macros.rs
@@ -0,0 +1,39 @@
+// aux-build:macros.rs
+
+#![allow(unused)]
+
+extern crate macros;
+
+use serde::Serialize;
+
+fn main() {
+    println!("one");
+    println!("two");
+    cfg!(unix);
+    vec![1, 2, 3];
+
+    #[derive(Serialize)]
+    struct Derive;
+
+    let _ = macros::expr!();
+    macros::stmt!();
+    let macros::pat!() = 1;
+    let _: macros::ty!() = "";
+    macros::item!();
+
+    eprintln!("allowed");
+}
+
+struct S;
+
+impl S {
+    macros::item!();
+}
+
+trait Y {
+    macros::item!();
+}
+
+impl Y for S {
+    macros::item!();
+}
diff --git a/tests/ui-toml/disallowed_macros/disallowed_macros.stderr b/tests/ui-toml/disallowed_macros/disallowed_macros.stderr
new file mode 100644
index 00000000000..aed9feb6f79
--- /dev/null
+++ b/tests/ui-toml/disallowed_macros/disallowed_macros.stderr
@@ -0,0 +1,84 @@
+error: use of a disallowed macro `std::println`
+  --> $DIR/disallowed_macros.rs:10:5
+   |
+LL |     println!("one");
+   |     ^^^^^^^^^^^^^^^
+   |
+   = note: `-D clippy::disallowed-macros` implied by `-D warnings`
+
+error: use of a disallowed macro `std::println`
+  --> $DIR/disallowed_macros.rs:11:5
+   |
+LL |     println!("two");
+   |     ^^^^^^^^^^^^^^^
+
+error: use of a disallowed macro `std::cfg`
+  --> $DIR/disallowed_macros.rs:12:5
+   |
+LL |     cfg!(unix);
+   |     ^^^^^^^^^^
+
+error: use of a disallowed macro `std::vec`
+  --> $DIR/disallowed_macros.rs:13:5
+   |
+LL |     vec![1, 2, 3];
+   |     ^^^^^^^^^^^^^
+
+error: use of a disallowed macro `serde::Serialize`
+  --> $DIR/disallowed_macros.rs:15:14
+   |
+LL |     #[derive(Serialize)]
+   |              ^^^^^^^^^
+   |
+   = note: no serializing (from clippy.toml)
+
+error: use of a disallowed macro `macros::expr`
+  --> $DIR/disallowed_macros.rs:18:13
+   |
+LL |     let _ = macros::expr!();
+   |             ^^^^^^^^^^^^^^^
+
+error: use of a disallowed macro `macros::stmt`
+  --> $DIR/disallowed_macros.rs:19:5
+   |
+LL |     macros::stmt!();
+   |     ^^^^^^^^^^^^^^^
+
+error: use of a disallowed macro `macros::pat`
+  --> $DIR/disallowed_macros.rs:20:9
+   |
+LL |     let macros::pat!() = 1;
+   |         ^^^^^^^^^^^^^^
+
+error: use of a disallowed macro `macros::ty`
+  --> $DIR/disallowed_macros.rs:21:12
+   |
+LL |     let _: macros::ty!() = "";
+   |            ^^^^^^^^^^^^^
+
+error: use of a disallowed macro `macros::item`
+  --> $DIR/disallowed_macros.rs:22:5
+   |
+LL |     macros::item!();
+   |     ^^^^^^^^^^^^^^^
+
+error: use of a disallowed macro `macros::item`
+  --> $DIR/disallowed_macros.rs:30:5
+   |
+LL |     macros::item!();
+   |     ^^^^^^^^^^^^^^^
+
+error: use of a disallowed macro `macros::item`
+  --> $DIR/disallowed_macros.rs:34:5
+   |
+LL |     macros::item!();
+   |     ^^^^^^^^^^^^^^^
+
+error: use of a disallowed macro `macros::item`
+  --> $DIR/disallowed_macros.rs:38:5
+   |
+LL |     macros::item!();
+   |     ^^^^^^^^^^^^^^^
+
+error: aborting due to 13 previous errors
+
diff --git a/tests/ui-toml/toml_disallowed_methods/clippy.toml b/tests/ui-toml/toml_disallowed_methods/clippy.toml
index c902d21123d..28774db625b 100644
--- a/tests/ui-toml/toml_disallowed_methods/clippy.toml
+++ b/tests/ui-toml/toml_disallowed_methods/clippy.toml
@@ -3,6 +3,7 @@ disallowed-methods = [
     "std::iter::Iterator::sum",
     "f32::clamp",
     "slice::sort_unstable",
+    "futures::stream::select_all",
     # can give path and reason with an inline table
     { path = "regex::Regex::is_match", reason = "no matching allowed" },
     # can use an inline table but omit reason
diff --git a/tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs b/tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs
index 3397fa1ec69..b483f160028 100644
--- a/tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs
+++ b/tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs
@@ -1,6 +1,9 @@
 #![warn(clippy::disallowed_methods)]
 
+extern crate futures;
 extern crate regex;
+
+use futures::stream::{empty, select_all};
 use regex::Regex;
 
 fn main() {
@@ -20,4 +23,7 @@ fn main() {
 
     let in_call = Box::new(f32::clamp);
     let in_method_call = ["^", "$"].into_iter().map(Regex::new);
+
+    // resolve ambiguity between `futures::stream::select_all` the module and the function
+    let same_name_as_module = select_all(vec![empty::<()>()]);
 }
diff --git a/tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.stderr b/tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.stderr
index 5cbb567546c..6d78c32e127 100644
--- a/tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.stderr
+++ b/tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.stderr
@@ -1,5 +1,5 @@
 error: use of a disallowed method `regex::Regex::new`
-  --> $DIR/conf_disallowed_methods.rs:7:14
+  --> $DIR/conf_disallowed_methods.rs:10:14
    |
 LL |     let re = Regex::new(r"ab.*c").unwrap();
    |              ^^^^^^^^^^^^^^^^^^^^
@@ -7,7 +7,7 @@ LL |     let re = Regex::new(r"ab.*c").unwrap();
    = note: `-D clippy::disallowed-methods` implied by `-D warnings`
 
 error: use of a disallowed method `regex::Regex::is_match`
-  --> $DIR/conf_disallowed_methods.rs:8:5
+  --> $DIR/conf_disallowed_methods.rs:11:5
    |
 LL |     re.is_match("abc");
    |     ^^^^^^^^^^^^^^^^^^
@@ -15,40 +15,46 @@ LL |     re.is_match("abc");
    = note: no matching allowed (from clippy.toml)
 
 error: use of a disallowed method `std::iter::Iterator::sum`
-  --> $DIR/conf_disallowed_methods.rs:11:5
+  --> $DIR/conf_disallowed_methods.rs:14:5
    |
 LL |     a.iter().sum::<i32>();
    |     ^^^^^^^^^^^^^^^^^^^^^
 
 error: use of a disallowed method `slice::sort_unstable`
-  --> $DIR/conf_disallowed_methods.rs:13:5
+  --> $DIR/conf_disallowed_methods.rs:16:5
    |
 LL |     a.sort_unstable();
    |     ^^^^^^^^^^^^^^^^^
 
 error: use of a disallowed method `f32::clamp`
-  --> $DIR/conf_disallowed_methods.rs:15:13
+  --> $DIR/conf_disallowed_methods.rs:18:13
    |
 LL |     let _ = 2.0f32.clamp(3.0f32, 4.0f32);
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: use of a disallowed method `regex::Regex::new`
-  --> $DIR/conf_disallowed_methods.rs:18:61
+  --> $DIR/conf_disallowed_methods.rs:21:61
    |
 LL |     let indirect: fn(&str) -> Result<Regex, regex::Error> = Regex::new;
    |                                                             ^^^^^^^^^^
 
 error: use of a disallowed method `f32::clamp`
-  --> $DIR/conf_disallowed_methods.rs:21:28
+  --> $DIR/conf_disallowed_methods.rs:24:28
    |
 LL |     let in_call = Box::new(f32::clamp);
    |                            ^^^^^^^^^^
 
 error: use of a disallowed method `regex::Regex::new`
-  --> $DIR/conf_disallowed_methods.rs:22:53
+  --> $DIR/conf_disallowed_methods.rs:25:53
    |
 LL |     let in_method_call = ["^", "$"].into_iter().map(Regex::new);
    |                                                     ^^^^^^^^^^
 
-error: aborting due to 8 previous errors
+error: use of a disallowed method `futures::stream::select_all`
+  --> $DIR/conf_disallowed_methods.rs:28:31
+   |
+LL |     let same_name_as_module = select_all(vec![empty::<()>()]);
+   |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 9 previous errors
 
diff --git a/tests/ui-toml/toml_unknown_key/conf_unknown_key.stderr b/tests/ui-toml/toml_unknown_key/conf_unknown_key.stderr
index f27f78d15d3..82ee8054132 100644
--- a/tests/ui-toml/toml_unknown_key/conf_unknown_key.stderr
+++ b/tests/ui-toml/toml_unknown_key/conf_unknown_key.stderr
@@ -11,6 +11,7 @@ error: error reading Clippy's configuration file `$DIR/clippy.toml`: unknown fie
            cargo-ignore-publish
            cognitive-complexity-threshold
            cyclomatic-complexity-threshold
+           disallowed-macros
            disallowed-methods
            disallowed-names
            disallowed-types