From ae3c5940b2db6528d53de378bc051b16c638dd69 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Sun, 17 Nov 2024 08:40:22 +0100 Subject: [PATCH] rust: raise a warning if clippy is used instead of rustc clippy-driver is not meant to be a general-purpose compiler front-end. Since Meson can now provide natively the ability to invoke clippy, raise a warning if someone uses it that way. Signed-off-by: Paolo Bonzini --- docs/markdown/snippets/clippy.md | 3 +++ mesonbuild/compilers/detect.py | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/docs/markdown/snippets/clippy.md b/docs/markdown/snippets/clippy.md index 14bcc77428a1..47d02083a0ab 100644 --- a/docs/markdown/snippets/clippy.md +++ b/docs/markdown/snippets/clippy.md @@ -3,3 +3,6 @@ Meson now defines a `clippy` target if the project uses the Rust programming language. The target runs clippy on all Rust sources, using the `clippy-driver` program from the same Rust toolchain as the `rustc` compiler. + +Using `clippy-driver` as the Rust compiler will now emit a warning, as it +is not meant to be a general-purpose compiler front-end. diff --git a/mesonbuild/compilers/detect.py b/mesonbuild/compilers/detect.py index 7542fb6283a2..69dafc413874 100644 --- a/mesonbuild/compilers/detect.py +++ b/mesonbuild/compilers/detect.py @@ -1042,6 +1042,10 @@ def detect_rust_compiler(env: 'Environment', for_machine: MachineChoice) -> Rust version = search_version(out) cls = rust.ClippyRustCompiler + mlog.warning( + 'clippy-driver is not intended as a general purpose compiler. ' + 'You can use "ninja clippy" in order to run clippy on a ' + 'meson project.') if 'rustc' in out: # On Linux and mac rustc will invoke gcc (clang for mac