From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 F059632B99E; Tue, 16 Jun 2026 13:27:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781616422; cv=none; b=BSPh77EKV/WjBq49ReFa5ZyYiwrHRwldqnI3aJDRYRp7Xu2kQcziJ6kki/i2DX6H5RW5BPjgUTKtg8TZ8EjtOXmz1dJI8Pz7ygwZx0v0Md3cEmTMtBzoqG5H60E1pDz8V9LW6c7LW/6F7hjmsBwiRIJ/jt7OcsY+TpkG0/X9oOc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781616422; c=relaxed/simple; bh=SuDxPGY/2+jHL+j5Nt4MuJnp0g232wazxZqGMIkSIPg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=gCRXqVrzZmRb+LYAxTVmA2yOxO5thYQKNUBjcYgtoOEfbg2pq63QpE+i53KT2c0FiuT9LRa6xEZqAmDIBmxjOcmY6sgFld95QYbIhiGY8vdIPXLLiiVy2QDBGsGSS+2pzbCV6v6/Vu3FZIsGn8/ac3rETWxuKMx4nq53KS3RNko= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=aGWBzp1k; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="aGWBzp1k" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C07DC1F000E9; Tue, 16 Jun 2026 13:26:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1781616420; bh=KqZT1Q+H3H4cPiuJ6SilO4+ocoDlYm62hI+tLu8miH0=; h=From:To:Cc:Subject:Date:Reply-To; b=aGWBzp1k93uXl+hYsPTaHEyr3c0YRBoqoeeHt+1NkleSNQ6jjAMKN4xqHxqO0vYK8 zj1IEMcX14eeRwz6aVQswkYGwh6Q8Q28Cf1PJ0g4UEf2iSFktwA3O8ZQ6EJIdTY200 hc967lrd+Oj01nK+L9fLLuqEbpl1pSWy2JkA1MCvM7GOun0j84yjEGqZrRZUhOqjxR QKtfdZTPiMMhFfDUAcIq4paCqMARsEie8JL0tKOLaIipKARKxsRkJc56ckHLgL5DRo luQ7kUbWJaRU11Bq3fYWoDiYWLHPHolFDAP2F4KsslnMQDt4Wk85vebqFtKHfn4ADz NPmeWmRVgCyfQ== From: Gary Guo To: Miguel Ojeda , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , Daniel Almeida , Tamir Duberstein , Alexandre Courbot , =?UTF-8?q?Onur=20=C3=96zkan?= , Brendan Higgins , David Gow , Rae Moar , Igor Korotin , Greg Kroah-Hartman Cc: rust-for-linux@vger.kernel.org, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] rust: doctest: fix incorrect pattern in replacement Date: Tue, 16 Jun 2026 14:25:56 +0100 Message-ID: <20260616132559.2245814-1-gary@kernel.org> X-Mailer: git-send-email 2.54.0 Reply-To: Gary Guo Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Gary Guo The `-> Result<(), impl core::fmt::Debug>` string is generated by rustdoc and by adding "::" into the string it no longer finds anything, and making the line useless. Remove the "::" in the pattern. Omit it in the replacement too, for consistency with upstream rustdoc. Fixes: de7cd3e4d638 ("rust: use absolute paths in macros referencing core and kernel") Signed-off-by: Gary Guo -- Changes in v2: - Update comments too - Stops using :: in the replacement too to be consistent with upstream rustdoc --- scripts/rustdoc_test_builder.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/scripts/rustdoc_test_builder.rs b/scripts/rustdoc_test_builder.rs index f7540bcf595a..5457679c12f9 100644 --- a/scripts/rustdoc_test_builder.rs +++ b/scripts/rustdoc_test_builder.rs @@ -28,7 +28,7 @@ fn main() { // // ``` // fn main() { #[allow(non_snake_case)] fn _doctest_main_rust_kernel_file_rs_28_0() { - // fn main() { #[allow(non_snake_case)] fn _doctest_main_rust_kernel_file_rs_37_0() -> Result<(), impl ::core::fmt::Debug> { + // fn main() { #[allow(non_snake_case)] fn _doctest_main_rust_kernel_file_rs_37_0() -> Result<(), impl core::fmt::Debug> { // ``` // // It should be unlikely that doctest code matches such lines (when code is formatted properly). @@ -47,12 +47,14 @@ fn main() { }) .expect("No test function found in `rustdoc`'s output."); - // Qualify `Result` to avoid the collision with our own `Result` coming from the prelude. + // Replicate rustdoc 1.87+ behaviour by fully qualify `Result` (to avoid the collision with our + // own `Result` coming from the prelude). + // + // TODO: Remove this when MSRV is bumped above 1.87. let body = body.replace( - &format!("{rustdoc_function_name}() -> Result<(), impl ::core::fmt::Debug> {{"), - &format!( - "{rustdoc_function_name}() -> ::core::result::Result<(), impl ::core::fmt::Debug> {{" - ), + &format!("{rustdoc_function_name}() -> Result<(), impl core::fmt::Debug> {{"), + // This intentionally does not use absolute paths to match rustdoc 1.87 behaviour. + &format!("{rustdoc_function_name}() -> core::result::Result<(), impl core::fmt::Debug> {{"), ); // For tests that get generated with `Result`, like above, `rustdoc` generates an `unwrap()` on base-commit: c425609d6ac4012c8bbf01ec2e10e801b1923a7b prerequisite-patch-id: 0000000000000000000000000000000000000000 -- 2.54.0