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 A2CFD254B18 for ; Thu, 11 Dec 2025 01:21:35 +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=1765416097; cv=none; b=YcvD6oC/HmWRVajNYkGRA8yzn2MjKNjW6tIbbeP7iTEWWCnjhQBtiv5vnfUhLcr273kJyxMI/IDNY8KUoTaphgZFKOi19r9cbHu7zVIJRRpmVQ8GyAx4kZjx7txr+QU1DXdQDJ5csevo6KP/8+UxXJN7pVGpzpfnNxyk3hEjPNg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765416097; c=relaxed/simple; bh=0a7e+oTzNpAw5XpSS3EZgOGDkx9mAsYyfurWVyJHWBE=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=FrUcOpQFpZPaJ8y0d7qCsdPHB5NOk/4WBMdfvTPwwLjtgqWvKMtxYGDl9GsIVkD4jDR3x8wTdfnLlOsKsbTnwKJNTWnEt6JfA2uRuW/q5W692O+hWy7qbgKsJrc2BYNMdGz0g/UvD+f1ATIms/CVi6MNjdnU7UaXmq9y8WZJCNs= 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=fowSkTtg; 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="fowSkTtg" Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-4775d110fabso2325215e9.1 for ; Wed, 10 Dec 2025 17:21:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1765416094; x=1766020894; 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=o7xFGJFC2OPlPtlFX/3YLVgyGi635Qjm2qw++qLP0iw=; b=fowSkTtga9NSE67ARyF9gzn/Vr/VIYyXb/uHsGtjWRodmjztZFmrgUVN1vjsie5HQ5 nLSACRyUSxzVL7Ivjvetb5sKnsx47dZNDAW2LOh/JGRqajEsKCHUZOmbEz+OsD/NM+L0 LnjiNwgfSeaFZUc1sNtFQuNJNkpX3PAjGIjgIMBkaQLBAa3yzstCImRktSUq6isWx+xL kA1iRbE2V4hAcJy6XzfIWsNOo/pP1baGsp5Kd0wxEqPFF7sGfEA0AzH5k3188+sNaqv6 voh1LMDc12cqCeYqZnXZ8nktbwaSsbX6YDwzsVJZgNsE0LlYKUBBDUVfjSSaD+kWa0Yv IT1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765416094; x=1766020894; 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=o7xFGJFC2OPlPtlFX/3YLVgyGi635Qjm2qw++qLP0iw=; b=aiHLJ+qjpMfmZSIfbnHzIyeW5bLy85UJPi//JNVwVCAboQ/U2JetH2Zgm+CaPNdOeK taSWh8yGintFCB1UWL5JMJw1kQRn8eQL1w7B6KcGLpeSiE8Ndb6sG76yIbwI8YjTwLBg 0wXGJl3ruimRuMIkOXAPs4oyBAz96X0Fhaf/WTBTXyDqvDpSdewFIAbv9tBmmcauxsDq XI60iDhBrI6RSNkXatJI8eRerhK9e/3VDOytW8VkcaaDWBnu+1jQo+B69SQnrO7LMRze qxRrCZ1xnWg/rsAPSW7IVYve7K9p3M763c6swg/A6D7JT6E+HnYIoRmDOj2zKv4CCoj7 7pTg== X-Forwarded-Encrypted: i=1; AJvYcCVZU+IniLbx5V2ZjbZceUDk9izEckaAL/lXYvnwVVvhym1Yin/wPAL/Ah0mtdQZazsvR7xzsOTwBi4b6Zw=@vger.kernel.org X-Gm-Message-State: AOJu0YwG0n1OI7L2ZqqpxGquyO91gOHEiyEDAvQUUGSJwtFWB79NASkI Um+iZmHZ3ikpYioLGdB6y+C90qjAHQMwvwH1RHldaiH7bfxxJakkGcIirolaFTjPdDB1xZxXofK M8FawHD+AJCG+FocS1g== X-Google-Smtp-Source: AGHT+IFtFWUUzpkF86P5ETw0RFmegagMnjG4lFL6iORMMelpm8ChDh1ncoMX+kPNRnack1lNVlzOSNNzzRxAG/I= X-Received: from wmxb6-n2.prod.google.com ([2002:a05:600d:8446:20b0:477:100b:1033]) (user=aliceryhl job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:198f:b0:45d:d8d6:7fcc with SMTP id 5b1f17b1804b1-47a8384cf91mr43407335e9.27.1765416094013; Wed, 10 Dec 2025 17:21:34 -0800 (PST) Date: Thu, 11 Dec 2025 01:21:33 +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: <20251209-transmute_unit-v3-0-819fe584ba06@nvidia.com> <20251209-transmute_unit-v3-1-819fe584ba06@nvidia.com> Message-ID: Subject: Re: [PATCH v3 1/2] rust: transmute: implement FromBytes and AsBytes for inhabited ZSTs From: Alice Ryhl To: Benno Lossin Cc: Alexandre Courbot , Miguel Ojeda , Boqun Feng , Gary Guo , "=?utf-8?B?QmrDtnJu?= Roy Baron" , Andreas Hindborg , Trevor Gross , Danilo Krummrich , John Hubbard , Alistair Popple , Joel Fernandes , Timur Tabi , Edwin Peer , Eliot Courtney , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" On Tue, Dec 09, 2025 at 01:14:08PM +0100, Benno Lossin wrote: > On Tue Dec 9, 2025 at 3:57 AM CET, 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. > > > > Reviewed-by: Alistair Popple > > Signed-off-by: Alexandre Courbot > > --- > > rust/kernel/transmute.rs | 8 ++++++++ > > 1 file changed, 8 insertions(+) > > > > diff --git a/rust/kernel/transmute.rs b/rust/kernel/transmute.rs > > index be5dbf3829e2..a888a312e7ff 100644 > > --- a/rust/kernel/transmute.rs > > +++ b/rust/kernel/transmute.rs > > @@ -170,6 +170,10 @@ macro_rules! impl_frombytes { > > } > > > > impl_frombytes! { > > + // SAFETY: Inhabited ZSTs only have one possible bit pattern. > > Even inhabited ZSTs cannot just be conjured out of thin air, since there > might be safety invariants on the creation of such a type. Now these > two concrete ones do not have any, so this is fine, but should still be > mentioned in the comment IMO. I think we can say "it has no invariants". Alice