about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorSamuel Moelius <sam@moeli.us>2024-11-08 19:40:55 -0500
committerSamuel Moelius <sam@moeli.us>2024-11-15 17:37:08 -0500
commitf159a3eb1dfc3b81088fce364a09e8a79968adda (patch)
tree3881f83e15ebb5af52233dff91c700ac79d33fe4 /tests
parent10e29413bc92c2b4d17ab497353604a9015cd705 (diff)
downloadrust-f159a3eb1dfc3b81088fce364a09e8a79968adda.tar.gz
rust-f159a3eb1dfc3b81088fce364a09e8a79968adda.zip
Support replacements in `disallowed_methods`
Diffstat (limited to 'tests')
-rw-r--r--tests/ui-toml/toml_replaceable_disallowed_methods/clippy.toml4
-rw-r--r--tests/ui-toml/toml_replaceable_disallowed_methods/replaceable_disallowed_methods.fixed8
-rw-r--r--tests/ui-toml/toml_replaceable_disallowed_methods/replaceable_disallowed_methods.rs8
-rw-r--r--tests/ui-toml/toml_replaceable_disallowed_methods/replaceable_disallowed_methods.stderr17
4 files changed, 37 insertions, 0 deletions
diff --git a/tests/ui-toml/toml_replaceable_disallowed_methods/clippy.toml b/tests/ui-toml/toml_replaceable_disallowed_methods/clippy.toml
new file mode 100644
index 00000000000..dc393f1355b
--- /dev/null
+++ b/tests/ui-toml/toml_replaceable_disallowed_methods/clippy.toml
@@ -0,0 +1,4 @@
+disallowed-methods = [
+    { path = "replaceable_disallowed_methods::bad", replacement = "good" },
+    { path = "replaceable_disallowed_methods::questionable", replacement = "good", reason = "a better function exists" },
+]
diff --git a/tests/ui-toml/toml_replaceable_disallowed_methods/replaceable_disallowed_methods.fixed b/tests/ui-toml/toml_replaceable_disallowed_methods/replaceable_disallowed_methods.fixed
new file mode 100644
index 00000000000..dae7ce76ba2
--- /dev/null
+++ b/tests/ui-toml/toml_replaceable_disallowed_methods/replaceable_disallowed_methods.fixed
@@ -0,0 +1,8 @@
+fn bad() {}
+fn questionable() {}
+fn good() {}
+
+fn main() {
+    good();
+    good();
+}
diff --git a/tests/ui-toml/toml_replaceable_disallowed_methods/replaceable_disallowed_methods.rs b/tests/ui-toml/toml_replaceable_disallowed_methods/replaceable_disallowed_methods.rs
new file mode 100644
index 00000000000..53678ffdf1c
--- /dev/null
+++ b/tests/ui-toml/toml_replaceable_disallowed_methods/replaceable_disallowed_methods.rs
@@ -0,0 +1,8 @@
+fn bad() {}
+fn questionable() {}
+fn good() {}
+
+fn main() {
+    bad();
+    questionable();
+}
diff --git a/tests/ui-toml/toml_replaceable_disallowed_methods/replaceable_disallowed_methods.stderr b/tests/ui-toml/toml_replaceable_disallowed_methods/replaceable_disallowed_methods.stderr
new file mode 100644
index 00000000000..b8559202942
--- /dev/null
+++ b/tests/ui-toml/toml_replaceable_disallowed_methods/replaceable_disallowed_methods.stderr
@@ -0,0 +1,17 @@
+error: use of a disallowed method `replaceable_disallowed_methods::bad`
+  --> tests/ui-toml/toml_replaceable_disallowed_methods/replaceable_disallowed_methods.rs:6:5
+   |
+LL |     bad();
+   |     ^^^ help: use: `good`
+   |
+   = note: `-D clippy::disallowed-methods` implied by `-D warnings`
+   = help: to override `-D warnings` add `#[allow(clippy::disallowed_methods)]`
+
+error: use of a disallowed method `replaceable_disallowed_methods::questionable`
+  --> tests/ui-toml/toml_replaceable_disallowed_methods/replaceable_disallowed_methods.rs:7:5
+   |
+LL |     questionable();
+   |     ^^^^^^^^^^^^ help: a better function exists: `good`
+
+error: aborting due to 2 previous errors
+