From 0d88411edd92814279dfe909db52700b4ca8e81d Mon Sep 17 00:00:00 2001 From: Alex Huszagh Date: Sat, 21 Sep 2024 14:50:51 -0500 Subject: [PATCH] Disallow I/O methods via clippy. Use clippy lints to disallow macros like `println!`, etc., and other diagnostic macros and/or tools, or those that use general I/O. --- clippy.toml | 17 +++++++++++++++++ lexical-asm/clippy.toml | 2 +- lexical-benchmark/clippy.toml | 2 +- lexical-size/clippy.toml | 2 +- 4 files changed, 20 insertions(+), 3 deletions(-) mode change 120000 => 100644 lexical-asm/clippy.toml mode change 120000 => 100644 lexical-benchmark/clippy.toml mode change 120000 => 100644 lexical-size/clippy.toml diff --git a/clippy.toml b/clippy.toml index cda8d17e..fac585ae 100644 --- a/clippy.toml +++ b/clippy.toml @@ -1 +1,18 @@ avoid-breaking-exported-api = false +disallowed-macros = [ + # Can also use an inline table with a `path` key. + { path = "std::print", reason = "no IO allowed" }, + { path = "std::println", reason = "no IO allowed" }, + { path = "std::format", reason = "no string allocation allowed" }, + { path = "std::debug", reason = "debugging macros should not be present in any release" }, +] +disallowed-methods = [ + { path = "std::io::stdout", reason = "no IO allowed" }, + { path = "std::io::stdin", reason = "no IO allowed" }, + { path = "std::io::stderr", reason = "no IO allowed" }, +] +disallowed-types = [ + { path = "std::io::File", reason = "no IO allowed" }, + { path = "std::io::BufReader", reason = "need our own abstractions for reading/writing" }, + { path = "std::io::BufWriter", reason = "need our own abstractions for reading/writing" }, +] diff --git a/lexical-asm/clippy.toml b/lexical-asm/clippy.toml deleted file mode 120000 index 85f6167c..00000000 --- a/lexical-asm/clippy.toml +++ /dev/null @@ -1 +0,0 @@ -../clippy.toml \ No newline at end of file diff --git a/lexical-asm/clippy.toml b/lexical-asm/clippy.toml new file mode 100644 index 00000000..cda8d17e --- /dev/null +++ b/lexical-asm/clippy.toml @@ -0,0 +1 @@ +avoid-breaking-exported-api = false diff --git a/lexical-benchmark/clippy.toml b/lexical-benchmark/clippy.toml deleted file mode 120000 index 85f6167c..00000000 --- a/lexical-benchmark/clippy.toml +++ /dev/null @@ -1 +0,0 @@ -../clippy.toml \ No newline at end of file diff --git a/lexical-benchmark/clippy.toml b/lexical-benchmark/clippy.toml new file mode 100644 index 00000000..cda8d17e --- /dev/null +++ b/lexical-benchmark/clippy.toml @@ -0,0 +1 @@ +avoid-breaking-exported-api = false diff --git a/lexical-size/clippy.toml b/lexical-size/clippy.toml deleted file mode 120000 index 85f6167c..00000000 --- a/lexical-size/clippy.toml +++ /dev/null @@ -1 +0,0 @@ -../clippy.toml \ No newline at end of file diff --git a/lexical-size/clippy.toml b/lexical-size/clippy.toml new file mode 100644 index 00000000..cda8d17e --- /dev/null +++ b/lexical-size/clippy.toml @@ -0,0 +1 @@ +avoid-breaking-exported-api = false