summaryrefslogtreecommitdiff
path: root/mesonbuild/modules/rust.py
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2025-07-19 10:44:40 +0200
committerDylan Baker <dylan@pnwbakers.com>2025-07-21 09:20:44 -0700
commit9530af6d657d1a393ef511c5ee13d12c10f81ae1 (patch)
tree0624700c712c7e31fef8ad3fe1d4e7effd6d5b23 /mesonbuild/modules/rust.py
parent6b217e690f2e475363985bc0d074d4e644300d32 (diff)
downloadmeson-9530af6d657d1a393ef511c5ee13d12c10f81ae1.tar.gz
rust: only allow rust.doctests if the target is a crate
Rust doctests implicitly use the base target as a crate. This is not possible unless the target uses the Rust ABI. If someone uses a C-ABI target with rust.doctest(), you get an unresolved module error and it is not clear what's really going on, so add a more specific error. Cargo does the same, though it only reports a warning. Fixes: #14813 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'mesonbuild/modules/rust.py')
-rw-r--r--mesonbuild/modules/rust.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/mesonbuild/modules/rust.py b/mesonbuild/modules/rust.py
index c5f18e8e5..d0e809181 100644
--- a/mesonbuild/modules/rust.py
+++ b/mesonbuild/modules/rust.py
@@ -242,6 +242,10 @@ class RustModule(ExtensionModule):
def doctest(self, state: ModuleState, args: T.Tuple[str, T.Union[SharedLibrary, StaticLibrary]], kwargs: FuncDoctest) -> ModuleReturnValue:
name, base_target = args
+ if not base_target.uses_rust():
+ raise MesonException('doc tests are only supported for Rust targets')
+ if not base_target.uses_rust_abi():
+ raise MesonException("doc tests are not supported for rust_abi: 'c'")
if state.environment.is_cross_build() and state.environment.need_exe_wrapper(base_target.for_machine):
mlog.notice('skipping Rust doctests due to cross compilation', once=True)
return ModuleReturnValue(None, [])