From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) (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 EA66013AD1C for ; Mon, 11 Aug 2025 09:19:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754903949; cv=none; b=VEbeWlwf+8K4pLjo5++hjwNQFFJZ1CGOVYi4g7DCHFDwMyKfEViabzVGywi00aDHa7ZHVbWZKviWfbI0Uos6n39agJWAjy72kwjWhGYvTOp0IAjKbwvi8mkqOJO184yp8NeDO9yvdfEHIcdlwURQmrw/zPk8S/uSxY3kmI4/zXk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754903949; c=relaxed/simple; bh=nuRMRugXR4lnu9XV/vJZknQh7XkLZ7RgDbwK9GxUeP0=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=bakO/3BDNtM+/FmiE2m7yBsP4hBe94OFgW0JhJRnvP5tMdk0xY/bAZ4nY77kz/O/dv5/UQXwPSlzuu8OBSwXURBlA9HsE/g1q/WTXUVzoMrHHj1A5ilrdwe99S/Xv1HdoGKyxKEdoolo4cXhLr75IqEYDqYSYY4Dz0299o8PQNo= 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=sehjWJ7d; arc=none smtp.client-ip=209.85.128.73 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="sehjWJ7d" Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-459d3abb2b5so15368745e9.3 for ; Mon, 11 Aug 2025 02:19:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1754903946; x=1755508746; 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=y5Kol7Ja1D7vtEkDoq2cssqguuGYYATqFKYbReC67Fw=; b=sehjWJ7d5QUfQiKpWx+CAL6wk6mjJbN/8HQ5TiFfrWAduNY8GJdAmda0tiYbgT4nxo +M+imsu03TwCIKtgRKvLEwagobmAl8ZyzS+egyIZJ1fjo4Ef9GP02BR0SdkvNPhxguLt wyExj4WBLpfK14kqeL+7OzPek8D6hKlt6n1irz3UcIVrrNOSaqdqJSxSg5pLHzd7acI7 0zLDG72qq8/CsG8ragbnEa+9/PLp0jmvFfmyKsdegXpqoqcLsBxr1aqZMkjnt0IWb5CM eTicP+D+cmEMlLo5I02hLWHxEGrBFE6a2JfOo2EczM5WQX3npjj7rRus5+Zbmdvsksb0 kq7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754903946; x=1755508746; 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=y5Kol7Ja1D7vtEkDoq2cssqguuGYYATqFKYbReC67Fw=; b=Xx1H+WsQpP59It4OJvhC2rbk8zZjEXcWUZjzs8HUetAyOafNs2Ca0PaQG9+jgAW1lC CgJqd+oNK7XJ2Cv4Vu9Rtzl+0v/fE09cJ9b45mX3Nuzy6Pe9qRyC184P6Mb9C2M0UyK2 CRkzrbaMBKxqzkyqpvk1vNw4BdZ802Vv4Vjkr6pVompd0KlrFRxdEYobM5/F/yn3Toer 9ZF7P8YRBKgprTu1PlF70zslCYOWa4YR+rCbAl+fTGdUO9jhNoZq95ejUBHaJ/qOAh4o dHf75L63x51YEl4N/xERYTd78BevC/zKgJEXMNzScUER1aDahX0n4gzYu+QqykKB0JPQ Jxnw== X-Forwarded-Encrypted: i=1; AJvYcCXtFgRrefoG3XY/AQDflonNYhJ9EpFL6KcBCadAcBFvDweJlzyVmjXM8yXsSJXVnMnQwREvnIaUL5nySbQ5+Q==@vger.kernel.org X-Gm-Message-State: AOJu0Yxt4EC1DQ3O2XVIG3kBdyIuOE5Zz0GCmlEruwBfAMey9zkB+iS8 dVG0vdVs2O5tWnrkox2AVuxFMenoO6VBNb6mW34tXNQBZJe4LEeBrnlc5c6BJSi6TwG37S8mTuB 72sunz5mqTH49SBaa8g== X-Google-Smtp-Source: AGHT+IHHOZJPfypw7CKlkWXBejdNHY8129ucWhHjmuSizxfAXx9R+2Px01HW4RJjv0kjWM7A6pFRVoT5hERdOmo= X-Received: from wmbes9.prod.google.com ([2002:a05:600c:8109:b0:458:be13:ea6d]) (user=aliceryhl job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:45c7:b0:458:c002:6888 with SMTP id 5b1f17b1804b1-459f4fc0ee2mr85079135e9.32.1754903946262; Mon, 11 Aug 2025 02:19:06 -0700 (PDT) Date: Mon, 11 Aug 2025 09:19:05 +0000 In-Reply-To: <20250808192005.209188-1-ritvikfoss@gmail.com> Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250808192005.209188-1-ritvikfoss@gmail.com> Message-ID: Subject: Re: [PATCH v4] rust: kernel: introduce `unsafe_precondition_assert!` macro From: Alice Ryhl To: Ritvik Gupta , Tamir Duberstein Cc: Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , "=?utf-8?B?QmrDtnJu?= Roy Baron" , Benno Lossin , Andreas Hindborg , Trevor Gross , Danilo Krummrich , linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org Content-Type: text/plain; charset="utf-8" On Sat, Aug 09, 2025 at 12:47:49AM +0530, Ritvik Gupta wrote: > Introduce a new `safety` module containing `unsafe_precondition_assert!` > macro. It is a wrapper around `debug_assert!`, intended for validating > pre-conditions of unsafe function. > > When `CONFIG_RUST_DEBUG_ASSERTIONS` flag is enabled, this macro performs > runtime checks to ensure that the preconditions for unsafe function hold. > Otherwise, the macro is a no-op. > > Suggested-by: Miguel Ojeda > Link: https://github.com/Rust-for-Linux/linux/issues/1162 > Link: https://rust-for-linux.zulipchat.com/#narrow/channel/291566-Library/topic/.60unsafe_precondition_assert.60.20macro/with/528457452 > Signed-off-by: Ritvik Gupta > + ($cond:expr, $($arg:tt)+) => { > + $crate::unsafe_precondition_assert!(@inner $cond, ::core::format_args!($($arg)+)) Tamir, taking your fmt series into account, what's the correct replacement for ::core::format_args! here? Alice