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 51B6733B6CC for ; Tue, 3 Mar 2026 11:39:10 +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=1772537951; cv=none; b=r0kgKgVGTfcuia4bnldwsg6DeCJVmxW6EYBQ0jTZd3GTglclgan4xXrdHA8i4W4LAIgx/Gdq+TDdRkkVP0uLFBswfWyaH2/nu3cIPdOIehC77bEtwR2RbJlEHLFbOjxc/sKOREky0Vooa+loc43EHkINaXpSdV8DFKDfIfBe2BA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772537951; c=relaxed/simple; bh=SOkN8YVRNPjTfsz/PejMeq0iowgdTuG0HqfQGfFGgEs=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=qhlA6aEZ0Q7e36hEgzNRJ473RMwJz8J8hFuDCvU5Z2FIfiCRtj+Zuak6ea4NhQ20ox3vtwsHKFHr0Mu18BRdyFmCSbC4djd4tx2EFHIdYMFttU4VZXNOCs0MuxZ4paelqiwxxF6VKc/YOCTu3yE4TR0xjVywVFZnZsT/ZbgTk18= 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=Cvqh1bpC; 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="Cvqh1bpC" Received: by mail-wm1-f74.google.com with SMTP id 5b1f17b1804b1-48071615686so45313775e9.1 for ; Tue, 03 Mar 2026 03:39:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1772537949; x=1773142749; 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=Kh33YTVJdNdb4rfed7VKp0A1E6qzkpd9sZhD0bYZ4Vs=; b=Cvqh1bpC6d1xy/LrYmXaCBkxgKpotSkzc2Yl8ic9wYiv7bxTXsS6PXwpyA9m9zBuC+ Oc7YsKkODvTSsE3T14CM6N5fOFFUj/5YjtAjgfmUwew+/6LpYeE5vrEFxiKXfFrKmpv/ oXZ2lvR7qYbeOzCV9+M7DjSDKrzPJO0f1YkJnl/JDG8M7f+mvMoKlZz3kvRYK+DW6a70 1Oy+8bkIwRB7F/hI2Dsusg1TbY8pPE8th2Ne6u7e9c1qTiwpgxH/BB4mIrl+7BfbfGCq x6uYtoaS2+ctcQFg3nG1RVlqjQ2UYUsTXYS1pbIppd57cKqO0dxdRqBvlAuaTWDZcsL2 WMnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772537949; x=1773142749; 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=Kh33YTVJdNdb4rfed7VKp0A1E6qzkpd9sZhD0bYZ4Vs=; b=w6lvBjKBccqlBQUw/N3T+z5oFdINaZlgUwmGWrrFHjE0f8uU5B4aHFTRp18bz5hNUf kAwK21VHXYESJTqGV0k5WbIX1NAY4KDYRJKnQaHeaSsySpP1PZ4cZfU2MtRlQ6DeqAoD 01gtlAesm/2nn9rJxKnW+XYEWYp5AruPf1cMypDIMNSRX7nBHat2E+OVMlVZC06qMSDo RKKQgFN0tnVLDtVUNOBf0xpTwvuiXh+CP9wIBWsO6rUUe18YgQodgC1rvWroHzpFeq2X 0ZAE6QPmN0N0AqfcIAvhT2wxUJEIMDBNUBIUubToWvSywy/PtRzusU1qDsjHip/5CIlM e3rQ== X-Forwarded-Encrypted: i=1; AJvYcCWqSeFyao8JG0+WeW+VVLcb69sKHPwrEBSdcrpjh3sIftgTZFSpYoTJTtkErw6mivMlJWg3xLuj6BpvZiM=@vger.kernel.org X-Gm-Message-State: AOJu0YyJRr77mqHjCl2lobneKxjp9vDA0Qa3rSnwVzO9k5eDaZs0M+ZH kFi2vYRt2132C477bwgjbPSh+sd6VNJLSLYPAqQq/gVeUGwsbyiXEKlLGqSrFmK23Hq0nC6pvmu eS26tHlhJC5yPETtZDA== X-Received: from wmbjv25.prod.google.com ([2002:a05:600c:5719:b0:480:6a27:9ec2]) (user=aliceryhl job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:3106:b0:47a:7fd0:9eea with SMTP id 5b1f17b1804b1-483c9ba610fmr259196275e9.3.1772537948481; Tue, 03 Mar 2026 03:39:08 -0800 (PST) Date: Tue, 3 Mar 2026 11:39:07 +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: <20260302130223.134058-1-gary@kernel.org> <20260302130223.134058-2-gary@kernel.org> Message-ID: Subject: Re: [PATCH v3 1/2] rust: add projection infrastructure From: Alice Ryhl To: Gary Guo Cc: Benno Lossin , Miguel Ojeda , Boqun Feng , "=?utf-8?B?QmrDtnJu?= Roy Baron" , Andreas Hindborg , Trevor Gross , Danilo Krummrich , Nathan Chancellor , Nicolas Schier , rust-for-linux@vger.kernel.org, Aditya Rajan , linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org Content-Type: text/plain; charset="utf-8" On Tue, Mar 03, 2026 at 10:17:01AM +0000, Gary Guo wrote: > On Tue Mar 3, 2026 at 9:14 AM GMT, Benno Lossin wrote: > > On Mon Mar 2, 2026 at 11:19 PM CET, Gary Guo wrote: > >> I am basically just having `size_of_val_raw` in mind when writing this. So the > >> current `KnownSize` comment in v4 is something that I am happy about. > > > > Well size_of_val_raw is `unsafe` and only valid to call in certain > > conditions. It asks in the case of slices that the length is an > > initialized integer and that the entire value must fit into `isize`. > > This to me just further indicates that `*mut T` has safety > > requirements to obtaining the size of an arbitrary pointer. > > > > In the special cases of `T: Sized` and `T == [U]`, we have safe ways of > > getting their size. > > Hmm, the `isize` fitting requirement is problematic indeed. It's broken code if > pointer projection is used with an allocation that exceeds the limit, but I want > the API to be safe, so it'll be good if the API is defined to just be wrapping > and safe (it may return values that doesn't make sense, but that'll be on the > user). > > Anyhow this is moot as we're going the `KnownSize` route. It sounds like that's no different from dyn trait vtable case. Fat pointer must have valid metadata, even if raw pointer. Alice