From nobody Mon Jun 15 07:33:52 2026 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C18F5342519 for ; Wed, 8 Apr 2026 20:10:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775679005; cv=none; b=ATupKiP2N/D3hD29ZYY5cm+9MUk0gea1LFglAqiqjIUjXNpIomm/U8YkvONM0jAcSrand9MLAl7ZQKSOlH+Y8lqDAfOhd3cVkgDDj6pn/ed/+n+pXajW9uUhlubbTCKd9Id9ST2yyde4Rj7AbRAOxdW0Q+x9muhl6LB0oakzqaw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775679005; c=relaxed/simple; bh=9ZayO0Os6B3uVdwtFtK43Rcp2eSqPW9ZaMNoyrY+gKs=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=D7fpPeubyw7xZCkTEnLeVZa8ZB6f3JCyOOL5/SJ+qZl6kWkib8rJowxEIA6Len5HgCuNfNi4NH09t+hiqBjeGS51rRzIaRCljYxlG8OsArxWOK1gzZ24PzSkD7I3O4IQ+efjQc/nn+gkh2Ctk21khPIsX7u57gl9wdmTvFQik7A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=NSIdUrWU; arc=none smtp.client-ip=209.85.128.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NSIdUrWU" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-4852b81c73aso1024425e9.3 for ; Wed, 08 Apr 2026 13:10:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775679001; x=1776283801; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=A10jT5nFIVtQZOyY/swyTbMMXrCD8+pLyIvSjBDicJg=; b=NSIdUrWU29vYnk98PfpyrraClyFrwAYy0ZhaBUpxAQDAQsGE2YvgzSTa03JVOTMFaa IcRKK19RYQrdfNahloN3kzdKBNYES+Q8KiGiumECuYo87j7vXMe1CZ9X1H5E5nFXEpDU 1f2t1V/x8g1i1/+aZ5WImgTqaHeZED/rCa0Ketpr1IGomAeOpAdTGrIG7l1fkI7UUQCo VLwlA/LfG6bSElQfU/iiQlWB8dLVtkxVTvs7EAZNnGy4FKHL3SiOaAnN4pJ0jVqnvAJx fOiFYt3sGWwvWQmDaxi1pvzCYesBpSm4EKTK2v8t9Vx6qKWBfL599gpfj4+DAy2Zkhfv UNIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775679001; x=1776283801; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=A10jT5nFIVtQZOyY/swyTbMMXrCD8+pLyIvSjBDicJg=; b=cJmSlx75r/ypX7TERjChu6oe1tb+61Dq8MguAjZnqBVzeioxcwFI1nyrsgkuBeexc8 pNvkapFBhK8WkmeD1Ey39wn3CnPJj7ANWapBPKbqI/jy0jMq8a5RGY3YiUZ7oJiuKPcd l/5e8jg7O3jK1yWtnkGWfJyie05rpV0dOd9rwFGteAMXDzD2eFiabddv9SCh3ya77bsp jLDtN8YILYZ9Vuyz/qTSj1aDq7Shhh+JG4qGAbgY0nCghFQWTM/IaaT/3tpOZ5Sgutwz aFXGq21zsFR3YYVfbw37NESpZ5KEbHBs7uUvmZLHBJ9tQAz+ktixmBrm72zgIwcXalSF FfGg== X-Forwarded-Encrypted: i=1; AJvYcCXXsKhjbIrBaKTNf0XO0rxIGR1t32psv1EPyKvfUOaH7pAi0k1fM3XcDaECyqebipF8ypUy5ekzUBjy7FM=@vger.kernel.org X-Gm-Message-State: AOJu0YzUeS2OEZeo/eGsudI14g9RarqxbLxEVn5nBfgdiw4Lzk8dUNl6 Mx6xtiXrkS1LsEdwf+w8LI2BnCLaebDTnZIfWyYyLhg9xFE7Z8ZO51F1 X-Gm-Gg: AeBDietpcX0RowZiAPCXy+eT29pQxwGyyki3OBUHuomMWffWleOmU6rxpazUEPmUGT8 HKYEdokCeC7DaraSaHCJx4U18MdQVVFag4jkx5RHYCMQ06E5KmcIX4WO4fF5sV62X5VXnJJU/Ft xGPZEY9G7ZHsQTYn3IjzAlSCrEhjDHEYGL4g4PMHKfjsy4CIIuXj45CZjFg82W/Fbk7stljmhSP zNwKuzbKq1PIXMHKWnK59aFMhhl3Z68FcqLIpzBvlbhJLRGw0SPxs2EB1Jg+bcDqupnR4uaV0U2 0bEh3vJfbPT4voB0vpYDpgyOjnDWyqKOGJIqbUaug/wj7WjpDgIeWVWj6ozbJHT4wEZykHPHQyi H3E5NYSEUzHxFwQoPvkwpQ4FSYqTHK+6du6rKeFdjeJultiGFmY2axYcfkGjHr0Sw+hpmNY8GUv GLkMpWxm6P4gYY/0yP7NZ8uG0Oz2Mqky+63RudoGId X-Received: by 2002:a05:600c:8591:b0:488:ab5b:d711 with SMTP id 5b1f17b1804b1-488ccfe6a5amr11030235e9.23.1775679000962; Wed, 08 Apr 2026 13:10:00 -0700 (PDT) Received: from archito ([2a01:e0a:acc:bb60:756b:64e3:20ef:1d08]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-488cd1bb778sm15940165e9.7.2026.04.08.13.10.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 13:10:00 -0700 (PDT) From: CastilloDel 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 Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, CastilloDel Subject: [PATCH] rust: macros: Replace match + panic in const context with const expect Date: Wed, 8 Apr 2026 22:09:39 +0200 Message-ID: <20260408200949.99059-1-delcastillodelarosadaniel@gmail.com> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This patch replaces an instance of match + panic with const expect, which is now usable in const contexts after the MSRV was was updated to 1.85.0 (it was available since Rust 1.83.0). Signed-off-by: Daniel del Castillo Suggested-by: Gary Guo Link: https://github.com/Rust-for-Linux/linux/issues/1229 Reviewed-by: Alice Ryhl --- I searched for other appearances, but couldn't find any. There is a similar one in the `c_str!` macro in `rust/kernel/str.rs`, but it would need `Result::expect` (or `Result::ok`) to be const. The original issue will probably have to wait for those to be fully resolved. --- rust/kernel/error.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/rust/kernel/error.rs b/rust/kernel/error.rs index decceb6ae855..2ef5226f3913 100644 --- a/rust/kernel/error.rs +++ b/rust/kernel/error.rs @@ -25,10 +25,8 @@ macro_rules! declare_err { #[doc =3D $doc] )* pub const $err: super::Error =3D - match super::Error::try_from_errno(-(crate::bindings::$err= as i32)) { - Some(err) =3D> err, - None =3D> panic!("Invalid errno in `declare_err!`"), - }; + super::Error::try_from_errno(-(crate::bindings::$err as i3= 2)) + .expect("Invalid errno in `declare_err!`"); }; } =20 --=20 2.53.0