From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BE63E264612; Thu, 23 Jul 2026 02:11:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784772682; cv=none; b=TcHKZMzA2m2qwgVruNIRZ6+Z9ckjZ3Ao2NupHc+ACj/sG1P8LmtztsmA2g1eAbph0UqrnWy9jL6F/sxNMZUEITf9XCSJibX0+0js4MQ7EZ/zjOk9gn3CHXRcfRduoDDVkeWwha6xaZ0FBs2q7Hiqdr8SMalJaLUqYW1nrQlXTfQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784772682; c=relaxed/simple; bh=ESjStQdmlknQnDN11JwGEzcIvjttoeIr5V6aNECIncg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=He9k0Weiag5mGt62K4197QTTW/QLmxln4LYus1kvwmUTh+a/1SglbOIHiEIdSil8RPz3DZWrquE9+1eIGtQKLHSpgmDKFyQN7wnlBbpFGB+CeMzADMPbDwTy6NJBFVGiYwp1nusWR5YmAqLC912u1/33LpWJwL/4KrrSNGYHSLg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=GVxSjdK1; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="GVxSjdK1" Received: by smtp.kernel.org (Postfix) with ESMTPS id 7AC92C2BD04; Thu, 23 Jul 2026 02:11:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1784772682; bh=ESjStQdmlknQnDN11JwGEzcIvjttoeIr5V6aNECIncg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=GVxSjdK1R6Fb+4koUBEku6vQO1kXwg/tiXE/Z5740kMqwF4qLruKbUUQlNE+XE171 +x2ZqxZnChaELKEW6PXtb0nZnNtMT62hfYzn81vnxelrvy/36BQ4svZ6BhvcaUi4wJ DmC4ye13HHKHVrW2LkP54VxaWBSq1Nv7NO9xRlVs= Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63AD7C531C7; Thu, 23 Jul 2026 02:11:22 +0000 (UTC) From: Alvin Sun Date: Thu, 23 Jul 2026 10:10:26 +0800 Subject: [PATCH v9 03/10] rust: doctest: add LocalModule fallback for #[vtable] ThisModule Precedence: bulk X-Mailing-List: linux-modules@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260723-fix-fops-owner-v9-3-c1c3af7f7bcb@linux.dev> References: <20260723-fix-fops-owner-v9-0-c1c3af7f7bcb@linux.dev> In-Reply-To: <20260723-fix-fops-owner-v9-0-c1c3af7f7bcb@linux.dev> To: Miguel Ojeda , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen , Aaron Tomlin , Greg Kroah-Hartman , "Rafael J. Wysocki" , David Airlie , Simona Vetter , Daniel Almeida , Arnd Bergmann , Brendan Higgins , David Gow , Rae Moar , Breno Leitao , Jens Axboe , Dave Ertman , Leon Romanovsky , Igor Korotin , FUJITA Tomonori , Bjorn Helgaas , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , =?utf-8?q?Arve_Hj=C3=B8nnev=C3=A5g?= , Todd Kjos , Christian Brauner , Carlos Llamas Cc: rust-for-linux@vger.kernel.org, linux-modules@vger.kernel.org, driver-core@lists.linux.dev, dri-devel@lists.freedesktop.org, nova-gpu@lists.linux.dev, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-pci@vger.kernel.org, Alvin Sun X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1784772679; l=1377; i=alvin.sun@linux.dev; s=20260317; h=from:subject:message-id; bh=ESjStQdmlknQnDN11JwGEzcIvjttoeIr5V6aNECIncg=; b=0V1lvzkTeSKzwK4603cLNWuoSLrUbyq2/uGNBBZl/R228cq0Sz06kESuqjlzFq3qsaCTCUwh8 Aq9oQWxzNxyBC0gQK1UfXpX3cxs1txivtdXRqX8rs+lynQbFj5Nr1UW X-Developer-Key: i=alvin.sun@linux.dev; a=ed25519; pk=CHcwQp8GSoj25V/L1ZWNSQjWp9eSIb0s9LKr0Nm3WuE= X-Endpoint-Received: by B4 Relay for alvin.sun@linux.dev/20260317 with auth_id=684 Add a `LocalModule` struct with a null-pointer `ModuleMetadata` impl in the doctest harness, so that `crate::LocalModule` (auto-inserted by `#[vtable]`) resolves correctly when there is no `module!` macro. Assisted-by: opencode:glm-5.2 Reviewed-by: Andreas Hindborg Reviewed-by: Gary Guo Acked-by: Danilo Krummrich Reviewed-by: Alice Ryhl Signed-off-by: Alvin Sun --- scripts/rustdoc_test_gen.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/scripts/rustdoc_test_gen.rs b/scripts/rustdoc_test_gen.rs index ee76e96b41eea..198af4e446c8c 100644 --- a/scripts/rustdoc_test_gen.rs +++ b/scripts/rustdoc_test_gen.rs @@ -239,6 +239,22 @@ macro_rules! assert_eq {{ const __LOG_PREFIX: &[u8] = b"rust_doctests_kernel\0"; +/// Dummy module type for doctest context. +struct LocalModule; + +use kernel::{{ + str::CStr, + ModuleMetadata, + ThisModule, // +}}; +use core::ptr::null_mut; + +impl ModuleMetadata for LocalModule {{ + const NAME: &'static CStr = c"rust_doctests_kernel"; + // SAFETY: `try_module_get`/`module_put` handle null module pointers gracefully. + const THIS_MODULE: ThisModule = unsafe {{ ThisModule::from_ptr(null_mut()) }}; +}} + {rust_tests} "# ) -- 2.43.0