Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2515608rwb; Fri, 2 Dec 2022 10:49:56 -0800 (PST) X-Google-Smtp-Source: AA0mqf7Ej9fHGTPgF23OvLi/uO1wuz9nR4OkwwEi/9VfdIx3PgPwEZ9FufDezK92CdLl7SjOp4AA X-Received: by 2002:a17:90a:77cc:b0:219:1747:f19c with SMTP id e12-20020a17090a77cc00b002191747f19cmr35517470pjs.222.1670006996209; Fri, 02 Dec 2022 10:49:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670006996; cv=none; d=google.com; s=arc-20160816; b=BucpOVqW7Vbn18uiGh+jE3ceYdz/YyORP5Nerane+sSopyK3bAY36bmf3iNgzu3lNr DXLXC2vzpNqEp2+EhLrzqPRtpNQKSv7kkTyFBL3U8dNCcslcgszWc1PhLtWo4Xz9QTGu /LlpuIaa6AOnvqahKPoHTph09Xkzv8iwKTemtGJa68jSdl+sPTFsyQNalaczVKqYZzN6 alu3c1/RdDdONMUAQA8bHuWHhGvxkZd3sY2k19VtpICSzsSXnt5PvWv2iC09FAVVq7/p t7B7O+men3XvNav8bCOYpboaQ/zEC+9zszK0gZOfFImalTzWqDAcG02pHn+/tjfSV6pk fSTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=dPMI3+zK71UDugRLfvvjNZoXPuW3L0kj2lPu6Tc7ooM=; b=ZGBOC5ZcVy4Uejx5PiYPmBC9WtjINSjQ2Gumxns5o0sjyJEJ2QHgtZbKWdJzsmqIZm TgQU8TozqfRQcf1UwAsPlr0VizHa++q3AQ1kUcaygNNuV1AnTYikEWrh0kPP3P8c+3GK cDHYozhoHoDuOVJGlXdsKDm7ixeFOWn/qAhZS/eX5PiJASXM8GbsDBhOaTPRCs5pyeLS QRK6ZvVbzZ7sMNE4/6uZFWBh4QOH3ArQU/ccFJGhq0n0dmXWY8CTiHVb8YE+eM2AI1bK ZP6INVEk+1M3iAftUxHdfqBB3iGJOH4km9I/jJIUK5U7EeTWBXvJs9Y2KKA8PS+1jgTd eY9g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d9-20020a655889000000b00476c8632d24si8176151pgu.686.2022.12.02.10.49.43; Fri, 02 Dec 2022 10:49:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233848AbiLBSc5 (ORCPT + 83 others); Fri, 2 Dec 2022 13:32:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234297AbiLBScx (ORCPT ); Fri, 2 Dec 2022 13:32:53 -0500 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BF6A37F8E; Fri, 2 Dec 2022 10:32:50 -0800 (PST) Received: by mail-wr1-f47.google.com with SMTP id w15so9069102wrl.9; Fri, 02 Dec 2022 10:32:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=dPMI3+zK71UDugRLfvvjNZoXPuW3L0kj2lPu6Tc7ooM=; b=PZ2SBb35YHOXylVqc7daqMUbAJ0UbVHRnpYdm1IFb0CEFehrWf1LCIvNfZTPE0Wv88 6ker0qcXTdsUgoJwGBapF6au4CY1G5/htzo2T1vFJZfkjYH6QOQ5Ocf3NIaRjywmq3fK zMzXcqMomEeoLCFJTYh74l/8LnISBKmTiCg/mehoXmxC0+2ReDOEO/6v7ocXDwgbidOT w2nfudOx8vrqIUs96gAKJn++DHs4wj78iDXTgy1r0Dbq5glHfGixbhpaaVmxZmxYADHQ twnMYPbFminhMFINCGMuJIxH8518WOyjy8RAuRbtUhX80/N9GMrHSXs5OCTK9mfQzb8G 2R/A== X-Gm-Message-State: ANoB5pmVsWfQhFMXf2b+pAOgxQjQshWKVRpJ59bOKFyzUf/cnfwAGIiV ADYs+CbxxC71dEv/5b879sU= X-Received: by 2002:a05:6000:18cd:b0:242:26ed:2d69 with SMTP id w13-20020a05600018cd00b0024226ed2d69mr10428691wrq.3.1670005969130; Fri, 02 Dec 2022 10:32:49 -0800 (PST) Received: from liuwe-devbox-debian-v2 ([51.145.34.42]) by smtp.gmail.com with ESMTPSA id n12-20020a1c720c000000b003c64c186206sm8950653wmc.16.2022.12.02.10.32.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Dec 2022 10:32:48 -0800 (PST) Date: Fri, 2 Dec 2022 18:32:47 +0000 From: Wei Liu To: ojeda@kernel.org Cc: Wedson Almeida Filho , Alex Gaynor , Boqun Feng , Gary Guo , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Wei Liu Subject: Re: [PATCH v2 26/28] rust: build_assert: add `build_{error,assert}!` macros Message-ID: References: <20221202161502.385525-1-ojeda@kernel.org> <20221202161502.385525-27-ojeda@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221202161502.385525-27-ojeda@kernel.org> X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Dec 02, 2022 at 05:14:57PM +0100, ojeda@kernel.org wrote: > From: Gary Guo > > Add the `build_error!` and `build_assert!` macros which leverage > the previously introduced `build_error` crate. Do so in a new > module, called `build_assert`. > > The former fails the build if the code path calling it can possibly > be executed. The latter asserts that a boolean expression is `true` > at compile time. > > In particular, `build_assert!` can be used in some contexts where > `static_assert!` cannot: > > fn f1() { > static_assert!(N > 1);` // Error. > build_assert!(N > 1); // Build-time check. > assert!(N > 1); // Run-time check. > } > > #[inline] > fn f2(n: usize) { > static_assert!(n > 1); // Error. > build_assert!(n > 1); // Build-time check. > assert!(n > 1); // Run-time check. > } > > Signed-off-by: Gary Guo > [Reworded, adapted for upstream and applied latest changes] > Signed-off-by: Miguel Ojeda Reviewed-by: Wei Liu