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 F2AE11F5842; Fri, 6 Feb 2026 21:30:50 +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=1770413451; cv=none; b=DadaaW+MkUeaxm0nhtPYG4pq6Qh73wS1galw4Sde/RMoL/YKtcoCjixHqReWcxrGqzEkQT+Dd++uUDVSi+yUxoCt9VUZInjmllztSprkUHQEqmvZo3Xsg3X0SAMhGvla6Zk2y1KF58H0BZZtPZp16BzRGjX8SAzXLYYN5m0sjO8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770413451; c=relaxed/simple; bh=UZ7BN+nVDIIBisJquvlyLN3E457oHPK0JvY6/3d2KaE=; h=Mime-Version:Content-Type:Date:Message-Id:To:Cc:Subject:From: References:In-Reply-To; b=YzIrOvKYH387LURZXzdr5bT3VD2JNVwuV8OyIQTWzbsYim77AQDMAv0EzD3VD9LRKiSwMLhUQxSyXBvfCWiVAC6QKgaGumfN2BsgSuciFKIN0eD+t4otrDtmvRBahld7+06FFR+GRZrsxDUXKwZgHnofWScWwIx7EG30M9fSWbk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=vMNfM0ZH; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="vMNfM0ZH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 97E82C116C6; Fri, 6 Feb 2026 21:30:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1770413450; bh=UZ7BN+nVDIIBisJquvlyLN3E457oHPK0JvY6/3d2KaE=; h=Date:To:Cc:Subject:From:References:In-Reply-To:From; b=vMNfM0ZHxTk8nIbRp6CSo8CW8ZVrDt1WMODe7VlqMyF1XIZdJNvF64uaZexgaYbb9 LiMm+PC0n8N/qzWjJLeQndz+nOKjKV0pKRO4l1ki5BbV9injJSlrFq0Ftqg9qw5Xmw F9RNAWcROK2yE/sC2jdt+zoMHLIzu7mA41ItK/M5Ya2H/H3H6ND6o44YHolYkrXswa KrkjzVG37U8WLJcaW7N7M3sw+bLJS+cAFnuKlCp1WapR16d2J0mbbSFH0QQRui3q4Z NCamFZhQ9Cp9rnmJqphGWk5WHENyoVh0ARiYF4mbrF3LwcE6GZoVens3osl+IJFYbp RMXKNH1ysx8eQ== Precedence: bulk X-Mailing-List: rust-for-linux@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 Date: Fri, 06 Feb 2026 22:30:45 +0100 Message-Id: To: "Gary Guo" , "Miguel Ojeda" , "Boqun Feng" , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , "Andreas Hindborg" , "Alice Ryhl" , "Trevor Gross" , "Danilo Krummrich" , "Alexandre Courbot" , "Yury Norov" , "Nathan Chancellor" , "Nicolas Schier" Cc: , , Subject: Re: [PATCH 2/2] rust: add `const_assert!` macro From: "Benno Lossin" X-Mailer: aerc 0.21.0 References: <20260206171253.2704684-1-gary@kernel.org> <20260206171253.2704684-2-gary@kernel.org> In-Reply-To: <20260206171253.2704684-2-gary@kernel.org> On Fri Feb 6, 2026 at 6:12 PM CET, Gary Guo wrote: > +/// Assertion during constant evaluation. > +/// > +/// This is a more powerful version of `static_assert` that can refer to= generics inside functions > +/// or implementation blocks. However, it also have a limitation where i= t can only appear in places > +/// where statements can appear; for example, you cannot use it as an it= em in the module. > +/// > +/// [`static_assert!`] should be preferred where possible. > +/// > +/// # Examples > +/// > +/// When the condition refers to generic parameters [`static_assert!`] c= annot be used. > +/// Use `const_assert!` in this scenario. > +/// ``` > +/// fn foo() { > +/// // `static_assert!(N > 1);` is not allowed > +/// const_assert!(N > 1); // Compile-time check > +/// build_assert!(N > 1); // Build-time check I think having "Build-time check" here is a bit confusing, how about we change it to "Link-time check"? Since a "Compile-time check" also is done at "Build-time" Cheers, Benno