summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui-toml/toml_disallowed_methods
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:32 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:32 +0000
commit4547b622d8d29df964fa2914213088b148c498fc (patch)
tree9fc6b25f3c3add6b745be9a2400a6e96140046e9 /src/tools/clippy/tests/ui-toml/toml_disallowed_methods
parentReleasing progress-linux version 1.66.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-4547b622d8d29df964fa2914213088b148c498fc.tar.xz
rustc-4547b622d8d29df964fa2914213088b148c498fc.zip
Merging upstream version 1.67.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools/clippy/tests/ui-toml/toml_disallowed_methods')
-rw-r--r--src/tools/clippy/tests/ui-toml/toml_disallowed_methods/clippy.toml6
-rw-r--r--src/tools/clippy/tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs30
-rw-r--r--src/tools/clippy/tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.stderr50
3 files changed, 76 insertions, 10 deletions
diff --git a/src/tools/clippy/tests/ui-toml/toml_disallowed_methods/clippy.toml b/src/tools/clippy/tests/ui-toml/toml_disallowed_methods/clippy.toml
index 28774db62..41dbd5068 100644
--- a/src/tools/clippy/tests/ui-toml/toml_disallowed_methods/clippy.toml
+++ b/src/tools/clippy/tests/ui-toml/toml_disallowed_methods/clippy.toml
@@ -8,4 +8,10 @@ disallowed-methods = [
{ path = "regex::Regex::is_match", reason = "no matching allowed" },
# can use an inline table but omit reason
{ path = "regex::Regex::new" },
+ # local paths
+ "conf_disallowed_methods::local_fn",
+ "conf_disallowed_methods::local_mod::f",
+ "conf_disallowed_methods::Struct::method",
+ "conf_disallowed_methods::Trait::provided_method",
+ "conf_disallowed_methods::Trait::implemented_method",
]
diff --git a/src/tools/clippy/tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs b/src/tools/clippy/tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs
index b483f1600..2f3160c83 100644
--- a/src/tools/clippy/tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs
+++ b/src/tools/clippy/tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs
@@ -1,3 +1,5 @@
+// compile-flags: --crate-name conf_disallowed_methods
+
#![warn(clippy::disallowed_methods)]
extern crate futures;
@@ -6,6 +8,27 @@ extern crate regex;
use futures::stream::{empty, select_all};
use regex::Regex;
+fn local_fn() {}
+
+struct Struct;
+
+impl Struct {
+ fn method(&self) {}
+}
+
+trait Trait {
+ fn provided_method(&self) {}
+ fn implemented_method(&self);
+}
+
+impl Trait for Struct {
+ fn implemented_method(&self) {}
+}
+
+mod local_mod {
+ pub fn f() {}
+}
+
fn main() {
let re = Regex::new(r"ab.*c").unwrap();
re.is_match("abc");
@@ -26,4 +49,11 @@ fn main() {
// resolve ambiguity between `futures::stream::select_all` the module and the function
let same_name_as_module = select_all(vec![empty::<()>()]);
+
+ local_fn();
+ local_mod::f();
+ let s = Struct;
+ s.method();
+ s.provided_method();
+ s.implemented_method();
}
diff --git a/src/tools/clippy/tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.stderr b/src/tools/clippy/tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.stderr
index 6d78c32e1..148d1cae5 100644
--- a/src/tools/clippy/tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.stderr
+++ b/src/tools/clippy/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:10:14
+ --> $DIR/conf_disallowed_methods.rs:33: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:11:5
+ --> $DIR/conf_disallowed_methods.rs:34:5
|
LL | re.is_match("abc");
| ^^^^^^^^^^^^^^^^^^
@@ -15,46 +15,76 @@ 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:14:5
+ --> $DIR/conf_disallowed_methods.rs:37:5
|
LL | a.iter().sum::<i32>();
| ^^^^^^^^^^^^^^^^^^^^^
error: use of a disallowed method `slice::sort_unstable`
- --> $DIR/conf_disallowed_methods.rs:16:5
+ --> $DIR/conf_disallowed_methods.rs:39:5
|
LL | a.sort_unstable();
| ^^^^^^^^^^^^^^^^^
error: use of a disallowed method `f32::clamp`
- --> $DIR/conf_disallowed_methods.rs:18:13
+ --> $DIR/conf_disallowed_methods.rs:41:13
|
LL | let _ = 2.0f32.clamp(3.0f32, 4.0f32);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: use of a disallowed method `regex::Regex::new`
- --> $DIR/conf_disallowed_methods.rs:21:61
+ --> $DIR/conf_disallowed_methods.rs:44: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:24:28
+ --> $DIR/conf_disallowed_methods.rs:47:28
|
LL | let in_call = Box::new(f32::clamp);
| ^^^^^^^^^^
error: use of a disallowed method `regex::Regex::new`
- --> $DIR/conf_disallowed_methods.rs:25:53
+ --> $DIR/conf_disallowed_methods.rs:48:53
|
LL | let in_method_call = ["^", "$"].into_iter().map(Regex::new);
| ^^^^^^^^^^
error: use of a disallowed method `futures::stream::select_all`
- --> $DIR/conf_disallowed_methods.rs:28:31
+ --> $DIR/conf_disallowed_methods.rs:51:31
|
LL | let same_name_as_module = select_all(vec![empty::<()>()]);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-error: aborting due to 9 previous errors
+error: use of a disallowed method `conf_disallowed_methods::local_fn`
+ --> $DIR/conf_disallowed_methods.rs:53:5
+ |
+LL | local_fn();
+ | ^^^^^^^^^^
+
+error: use of a disallowed method `conf_disallowed_methods::local_mod::f`
+ --> $DIR/conf_disallowed_methods.rs:54:5
+ |
+LL | local_mod::f();
+ | ^^^^^^^^^^^^^^
+
+error: use of a disallowed method `conf_disallowed_methods::Struct::method`
+ --> $DIR/conf_disallowed_methods.rs:56:5
+ |
+LL | s.method();
+ | ^^^^^^^^^^
+
+error: use of a disallowed method `conf_disallowed_methods::Trait::provided_method`
+ --> $DIR/conf_disallowed_methods.rs:57:5
+ |
+LL | s.provided_method();
+ | ^^^^^^^^^^^^^^^^^^^
+
+error: use of a disallowed method `conf_disallowed_methods::Trait::implemented_method`
+ --> $DIR/conf_disallowed_methods.rs:58:5
+ |
+LL | s.implemented_method();
+ | ^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 14 previous errors