From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f74.google.com (mail-wm1-f74.google.com [209.85.128.74]) (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 0A6193D3D1F for ; Thu, 19 Mar 2026 14:34:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773930882; cv=none; b=jtIuQrcxBkTQ62QNDgdZ2Eb0cBk2+gaPP6ThcCRxMfCI/T7m5xgea1G2ZfeWdzziyUKVdcanSv8xg4oxCfJ+voONMvcyEa0M0aATa+awj3jMKLXxmZDfeUq1Ry0to5pE6Uzbi1EFVHSLHWYKuFKknoOpeNVps/RZWP/KWDPGNVs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773930882; c=relaxed/simple; bh=WyMtJOHNgptF+RUudbAi9e6jN+p610GxNdbm0q5d+PU=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=cGixnn9y3zRZmxWKQATBcoO2d36W00fORNgCLV0ozazqjpWQxIAHuOk1r48/cgm+g2/V/43Yd6/zUWofJjNTA4dBTAmw/+k2B4x4kfq8UH0xZ1EeVhNXQ3JVoA6ptxtwaAejeXNd4gw2niwbiU+GoZ+pL4N9zihnIU3jVpClmRk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=NZPCClfJ; arc=none smtp.client-ip=209.85.128.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="NZPCClfJ" Received: by mail-wm1-f74.google.com with SMTP id 5b1f17b1804b1-4853b5b0fafso7497685e9.3 for ; Thu, 19 Mar 2026 07:34:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1773930879; x=1774535679; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=QPovHfZvdIEmxMLcWggNVk241OlOV9iUo7irlye/sV8=; b=NZPCClfJ4MNq50SDaVKf9fLB9I6F6xzcuIqwy2Dp7IlznXJlGImq5q5gfWq4PNXGCX nzhmuEAjWgOypaq1cohLrJcw1G2cEq1nDOFCUgEbhtTXySQwRxOJqctmFumZIxDlkMQP 271zSh7oqP/nUj/R7ZDyi2ae0c7mPbV37c4EvtnkUJk3/WeVAhLsgtqVIihL3KlZ2GI/ kML3whRLqYuTYVQPTQzxKupu/kgUd57dA1K/hmyA1zNLTPc7nHiBIeQKfH/WDO5C8/P1 T9Yy6v57keJOs7C2QVLzf8MYsYBnLwsaYywvrsplc7/xb/nc5Wv3OM5MLvugOyZ45YZS vNxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773930879; x=1774535679; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=QPovHfZvdIEmxMLcWggNVk241OlOV9iUo7irlye/sV8=; b=bd1FY+sRu/WqeCWGxPjgQ/xUVwJik/iBbeniRXCn4ChQ13GJedAh585ld91Gd8+VcP Cgp9vRvqP51DNnl7uRyGFJi9kbt8FbjhTBpDGRMN/2b46vG+INkOZB1y9MKD6hmWfB9t GpgJTvd1IC7ZY9MVjiPDMcvjXxdv10Knf9NYEJFAIZoMfSiGwsfzT52RHcyaC5bPRR9J bacPhGp0Muu9jPeifQ3gyHS06JjcPDtCY+wZH3kYPwJIa9dWwiJS+KhEu5xtgKNwJCEg 6tHATgMr7bp5IMY0sGUg32k7DR4/AB3+KkqsFSaRFBdZGIxAIRUEVtS5wmMug4kF0wqz Lt0Q== X-Forwarded-Encrypted: i=1; AJvYcCVRvEJ+Ei0YjEzamkzjyWKzwBzYq7CMGd+02O1hQ1yh9C39ubyvPAW+jKRE921RCffkpGBiWGAFnhmHm1w=@vger.kernel.org X-Gm-Message-State: AOJu0YxtUDzVRjirKH4TmENFD1Q3dErHzYzIuIkEenKekB2ng1PKx0qt gNRisx5ShGEjEveCSk4AuufashYPY+4hHAQ6LtgeczPOfhMwsZjWT4FKJ+8cKx1nwX9LKKDKgQv gMoXVl0yPLqQfLTdcFw== X-Received: from wmbeq13.prod.google.com ([2002:a05:600c:848d:b0:477:a181:1922]) (user=aliceryhl job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:198f:b0:485:5981:1411 with SMTP id 5b1f17b1804b1-486f4472ee8mr129992255e9.23.1773930879123; Thu, 19 Mar 2026 07:34:39 -0700 (PDT) Date: Thu, 19 Mar 2026 14:34:38 +0000 In-Reply-To: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260319121653.2975748-1-gary@kernel.org> <20260319121653.2975748-3-gary@kernel.org> Message-ID: Subject: Re: [PATCH v3 2/4] rust: add `const_assert!` macro From: Alice Ryhl To: Gary Guo Cc: Miguel Ojeda , Boqun Feng , "=?utf-8?B?QmrDtnJu?= Roy Baron" , Benno Lossin , Andreas Hindborg , Trevor Gross , Danilo Krummrich , Alexandre Courbot , Yury Norov , Nathan Chancellor , Nicolas Schier , Yury Norov , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org Content-Type: text/plain; charset="utf-8" On Thu, Mar 19, 2026 at 02:26:06PM +0000, Gary Guo wrote: > On Thu Mar 19, 2026 at 2:12 PM GMT, Alice Ryhl wrote: > > On Thu, Mar 19, 2026 at 12:16:46PM +0000, Gary Guo wrote: > >> From: Gary Guo > >> > >> The macro is a more powerful version of `static_assert!` for use inside > >> function contexts. This is powered by inline consts, so enable the feature > >> for old compiler versions that does not have it stably. > >> > >> While it is possible already to write `const { assert!(...) }`, this > >> provides a short hand that is more uniform with other assertions. It also > >> formats nicer with rustfmt where it will not be formatted into multiple > >> lines. > >> > >> Two users that would route via the Rust tree are converted. > >> > >> Reviewed-by: Yury Norov > >> Signed-off-by: Gary Guo > > > > Reviewed-by: Alice Ryhl > > > > It may be worth to mention in docs that const_assert! may only be > > checked if the function it appears in has a caller. Whereas > > static_assert! is always checked no matter what. > > > > Alice > > I explained this in patch 3 on why `static_assert!` is preferred over > `const_assert!`. Given that we recommend `const_assert!` only when it refers to > generics, the check is inherently tied to a specific instance anyway, so I don't > think it needs to be mentioned in the item doc. Ok.