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 4FB8828690 for ; Thu, 11 Dec 2025 01:14:17 +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=1765415658; cv=none; b=hTdQK9X1IBABP5tK7zMgZmHhfMccOKq308E9FvKhbo91Svl85vqAr/PNszgR9C5/nCtj7YKJPcB6uFiFJn2Tvmb1ZvTk93zNGl89QELoSS9Rg0e8eor4lAw1k1Ev2sPMQWNq+RRczwcwus6224TV1tQUGyikXXfKbUXruU16m5A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765415658; c=relaxed/simple; bh=HrFNGIOmsdwLnKhuyIL2R8LM6jmjuQf1ZSS52nzwN+4=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=nZoM/hRhSvgXCw+l7kwWo3CWROu3rzFDYzU5DHyYc2o5XiUW11oedLamJyy2Vsq10FSH+Ba84AvhX1WIlkAncnD5kinjoITi3HayhvEHg/yDHJtZZyq4NOlQ30RxesuySHyT+5IFF/WkSdPVtnAxaJZ0nxgheR6xjUaW01CL43o= 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=sd5A85+S; 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="sd5A85+S" Received: by mail-wm1-f74.google.com with SMTP id 5b1f17b1804b1-4775e00b16fso2165015e9.2 for ; Wed, 10 Dec 2025 17:14:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1765415656; x=1766020456; 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=bIGqGGf2vc4lX/k3Vza8UP79uJgvpgWax6YVvgudVcQ=; b=sd5A85+SjBKkgN7lRc2ZL11OdbA1QV25veI4cOwagfWnK39pvF1OlrwzvrvWJBCUMv Gg3mKBEeC7axJj9E1T08WZzekBq9qRLRVurvWcJk7N875J41s1SRPzeeI3erI4tzNkLy ac72WxV2ma444DXA2pOpFFJKr/SzDhZ6E2tYpAfhjbC28baoo0anaIXF4sTT/ZkMagP/ oSRQicr+gxStTC/4pu2XCD195fwVQbuNgda8hkHroznFNLsbpEH208N8oXVQwrVgamSc SQLdSv7bMfdcq9G1Dsy/7/Oe7wlvR5kfuWwJ3py19g9cgMl3zIpZevhuZL7Oqb05vl4Z 3fRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765415656; x=1766020456; 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=bIGqGGf2vc4lX/k3Vza8UP79uJgvpgWax6YVvgudVcQ=; b=jgbWkQmiY9bIBvld9Zy+S88OHcESu+vutQU0tpasrxzrfcBRAZHnQWJbquu2sRZogS rUwEenV75OT9u5TV7cpGiDfi4DghsnRLEdBr0EUTFVJKQ1BpeEmv8qMBTw9r/yxsMBhb 0bkIIU9qqwh5MA/kgVeygFJ7pjPFsLIv+4Miw7hABiq+XQXpOkBgTnc+YafT1rOPqTvd EcU+9+zYG39+BrIu/pWDJP1oNvrv2GL9dgy0i7p5zAAmZQyY4l8iNO4ikPk+LCM7WVMn iPTJN4g483cRbxKbLZAffuyXUKAPDxFEV7zfQtIFZ3VY8S0GbgdHyZ546ejuMA2GwVBk Jpmw== X-Forwarded-Encrypted: i=1; AJvYcCUNBym7AQWIGzkKEe/zJk8Z9nqfIowSDkkKLQuKci5EHzHlqkqLPpMnGmBBqJsiNXM3cRc8vRX25PNUiwo=@vger.kernel.org X-Gm-Message-State: AOJu0Yzqo/jbM+njhjkXPmL5Exzf6n1paU919VFRkcY1FXhKpUKrCIHQ tle6ZgwpeG9FOfUIcUe+Nk1QbmWzkePKWRJ2C8eqZec7dKmqRDAMIbn5b66CDlOBQZYS/rOjcXr g9b102OmVlvKddicb/Q== X-Google-Smtp-Source: AGHT+IFQ57qdbPtZco/Wy4RKQJ1U6jpams82D2ix7Rsdt9tB3zU2O90IV4TKYLc8CFN15oLvEW91qjxu3AhVWno= X-Received: from wmjl3.prod.google.com ([2002:a7b:c343:0:b0:477:a656:6762]) (user=aliceryhl job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:a41:b0:475:de68:3c30 with SMTP id 5b1f17b1804b1-47a8377e5c8mr51960545e9.16.1765415655788; Wed, 10 Dec 2025 17:14:15 -0800 (PST) Date: Thu, 11 Dec 2025 01:14:14 +0000 In-Reply-To: <20251208-transmute_unit-v1-1-680c7386b5d9@nvidia.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251208-transmute_unit-v1-1-680c7386b5d9@nvidia.com> Message-ID: Subject: Re: [PATCH] rust: transmute: implement FromBytes and AsBytes for () From: Alice Ryhl To: Alexandre Courbot Cc: Miguel Ojeda , Boqun Feng , Gary Guo , "=?utf-8?B?QmrDtnJu?= Roy Baron" , Benno Lossin , Andreas Hindborg , Trevor Gross , Danilo Krummrich , John Hubbard , Alistair Popple , Joel Fernandes , Timur Tabi , Edwin Peer , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" On Mon, Dec 08, 2025 at 01:15:13PM +0900, Alexandre Courbot wrote: > This is useful when using types that may or may not be empty in generic > code relying on these traits. It is also safe because technically a > no-op. > > Signed-off-by: Alexandre Courbot > --- > This is going to be useful in Nova's GSP message handling, as some > messages are empty and we need to explicitly use an empty structure for > them. > > If accepted, I would like to merge it through `drm-rust-next` so Nova > code can start using this feature quickly. > --- > rust/kernel/transmute.rs | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/rust/kernel/transmute.rs b/rust/kernel/transmute.rs > index be5dbf3829e2..8d78c81e3749 100644 > --- a/rust/kernel/transmute.rs > +++ b/rust/kernel/transmute.rs > @@ -170,6 +170,9 @@ macro_rules! impl_frombytes { > } > > impl_frombytes! { > + // SAFETY: This type is empty and thus does not consume any data. > + (), This should mention that the type has no invariants. > impl_asbytes! { > + // SAFETY: This type is empty and thus returns an empty slice. > + (), Ok. Alice