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 7A2B7335BB4; Mon, 22 Jun 2026 02:45:02 +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=1782096302; cv=none; b=A7BUQnS9od4HGlmEg4puVfylTBxzbsh2bPCaFeqN3oXsAJqxcK+YI+VTJBO1PcZ+A2qIzhisZDfQzrOD/eHnZBs6tsSzcA9iruz1h1aj4AAA+HqwFE+eMA1/48Qb8cliSVCw5lbmpliemKhf4WbR814d5whrWhGUnSi93kjeDmY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782096302; c=relaxed/simple; bh=NCKNYPa1eYcitZUfD0OiFCu4ehXyOiLLsU3Tp7Qt5Po=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Zgu195nRS7P/xM7tMTMy7FThOoQutmJS1oL9befb7eUNc6H67cx+TEpvNHT0XOKeV3FAFa7i6I9ucm+DSUUnuQ902yyI5l1mU+FoHAisXBRd8eT2sAkBhxoh/W1oP6PBpBAK9cdhFfzJokAwpbqrgS483n99qU5U/j7wiBBVaAE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=kh3vPJcO; 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="kh3vPJcO" Received: by smtp.kernel.org (Postfix) with ESMTPS id 24C40C2BCF5; Mon, 22 Jun 2026 02:45:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1782096302; bh=NCKNYPa1eYcitZUfD0OiFCu4ehXyOiLLsU3Tp7Qt5Po=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=kh3vPJcOJpVVAyc4fRoF96Hms/bQtsreXs0Nb5ymEXT3k49U4TZSpJAjO8lNlOJcT lGDQ7SuxbukZD9nApYUPc0NCooItKyX9DkAupAWknHfjAkbvFJNgCuawDQyVtuFCLF 9NF+V+LeM+4BJQCmyHk4i1jcu0LX9ZbCS0DqX/2c= 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 0A3E6CD98F0; Mon, 22 Jun 2026 02:45:02 +0000 (UTC) From: Alvin Sun Date: Mon, 22 Jun 2026 10:44:56 +0800 Subject: [PATCH v3 2/6] rust: doctest: add LocalModule fallback for #[vtable] ThisModule Precedence: bulk X-Mailing-List: linux-block@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: <20260622-fix-fops-owner-v3-2-49d45cb37032@linux.dev> References: <20260622-fix-fops-owner-v3-0-49d45cb37032@linux.dev> In-Reply-To: <20260622-fix-fops-owner-v3-0-49d45cb37032@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 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, Alvin Sun X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1782096299; l=1210; i=alvin.sun@linux.dev; s=20260317; h=from:subject:message-id; bh=NCKNYPa1eYcitZUfD0OiFCu4ehXyOiLLsU3Tp7Qt5Po=; b=H9jaPxzJ2Tk9+CTb0D8lMG4t8EfKH4+2wPWcNIugqj0uXYTf2KN5ObtWCeY/kZP81vThj/m4/ kxUcfOH9ev9DZOD5YtzrCiXYm8m0j94Ib8FDb6HtuYQCa9WSxD72ajY 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. Reviewed-by: Andreas Hindborg 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