From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f73.google.com (mail-wr1-f73.google.com [209.85.221.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 72B923BB4A for ; Mon, 16 Feb 2026 08:48:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771231727; cv=none; b=g3YZoFvXNY8hIcvmu9rvLINKP5CCWiu/mYa5OtVO+FdjswdnsoKa/KALzOkxY2NGZaHWi5D3QZDr3tfRm4sYrzVL79E0dsskbSa2OD0bVarakxhHNtT7dZFwZCWLm40nZlmdsifx3zJkFhrrBDMQN+jXqrqCRxkfeADBzdL8qAY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771231727; c=relaxed/simple; bh=r9Er4jRBIPtew/bgT7ovEHgwL9mrxO4Zty80eV5vxbQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=seopiKIIurg5qtklsAL9K48l9vDRA87GgRwCcEqp9PAQ90TVaHQ7ufx5UM/wjWEPXfHXdVMYOYvZEPejFDqAtaCGK3h03ZOlQhl1xbE8Usv5x4qYFr05fs04g9ZXOLP1EpDWmO9kMSBetpRnOSz2sJp3XKSyPfdpqr7DIv/qhKA= 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=trRAFSIy; arc=none smtp.client-ip=209.85.221.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="trRAFSIy" Received: by mail-wr1-f73.google.com with SMTP id ffacd0b85a97d-43624564fc9so3038887f8f.2 for ; Mon, 16 Feb 2026 00:48:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1771231725; x=1771836525; 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=giujmDKKRSBKpyYtDZgeWurVeUo8sMxl5dMSo8TDoOA=; b=trRAFSIyVIzNcokPY5V+uU2JBXcyHb4Cm7QjBYRv68Aehx586g/1peLYucxfE3GhXr vESY7F0RoPGilUEDwx1A+ExBBmOKmySqSjID+aLfEyDafqkO4ZUR7+xID/nJhbJ69a79 6q7r2rB2CKGaJK8ibPQqeQuSSIjSEK5sQQauss8tXo2rpHLX1DxSmc/3rHSPi5hzla/T vrKZRTliLe4mNb+sf0/uHuU610kEE4FMUZP0SLDnSvXy6ECvLnuFIvB73vBeo0kMwsem wJ0ul2d+7NowvDyvSfw5vXBygCvcYgb511QPKaVZckvW+5thQqwtKSQfG2RVJKkInRd7 iKXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771231725; x=1771836525; 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=giujmDKKRSBKpyYtDZgeWurVeUo8sMxl5dMSo8TDoOA=; b=oLpddQ9kI59t2UaL3BBSzLG/HRfiJVllxs7Fn7jgvr44eCMtueam/8N+87Lf9zq82o TbxAg6o42ZhkWD7aIi/A33x+FueVWF6JphIRl5flgH86W8/JL/UoxCA3cZ4i+GLyLxyz kiwKxl+lU7OgM2L2StLYgnYjSKaimvxAzK5J4FZ/LnkjFfhN6EE+cMsFNUCUVKMVe07t x6eiqUv0vMMsfxEYgoITOVq+/rmPoTs6SJnZWflsK6nazszgSsS+mgENe3SBDn4hKJak Vx/4M6ugm/7B9PfKn56dxMLaKAYUzPm6TQ3WRhm+rZQGxl0e/2XeSuKM6OcNT4ftWwMY WqoA== X-Forwarded-Encrypted: i=1; AJvYcCXx2arftHN2n23woiejSI9FyLOr+QkSn8cycd/xuryeWg4Jty4JwW8Nfb6cp0H6CZLVLFYLaGCZZFRzpqw=@vger.kernel.org X-Gm-Message-State: AOJu0Yx7AovW9geZcsjJIZUWoAFVlpoHbh+4GEvyeEmNCAbNGGyiVFi+ tEcvk0tYe4nUd/oBnA46pKJyxuNeqRYRSiYml225gseihVcZ5QrZAl/JMzlgGbQRIiL/6NfPkT8 Tod/1Per+lxMC6JgraQ== X-Received: from wmjs4.prod.google.com ([2002:a7b:c384:0:b0:483:fe4:5332]) (user=aliceryhl job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:5308:b0:47e:e946:3a72 with SMTP id 5b1f17b1804b1-48379bf78f1mr113161055e9.27.1771231724550; Mon, 16 Feb 2026 00:48:44 -0800 (PST) Date: Mon, 16 Feb 2026 08:48:43 +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: <20260214-pin-slice-init-v1-1-0b174fbb1844@kernel.org> Message-ID: Subject: Re: [PATCH] rust: alloc: allow different error types in `KBox::pin_slice` From: Alice Ryhl To: Danilo Krummrich Cc: Benno Lossin , Andreas Hindborg , Lorenzo Stoakes , Vlastimil Babka , "Liam R. Howlett" , Uladzislau Rezki , Miguel Ojeda , Boqun Feng , Gary Guo , "=?utf-8?B?QmrDtnJu?= Roy Baron" , Trevor Gross , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" On Sat, Feb 14, 2026 at 03:56:43PM +0100, Danilo Krummrich wrote: > On Sat Feb 14, 2026 at 3:40 PM CET, Benno Lossin wrote: > > On Sat Feb 14, 2026 at 3:17 PM CET, Danilo Krummrich wrote: > >> On Sat Feb 14, 2026 at 2:28 PM CET, Andreas Hindborg wrote: > >>> @@ -333,24 +333,31 @@ pub fn pin(x: T, flags: Flags) -> Result>, AllocError> > >>> /// assert_eq!(s[3].d.lock().a, 20); > >>> /// # Ok::<(), Error>(()) > >>> /// ``` > >>> - pub fn pin_slice( > >>> + pub fn pin_slice( > >>> mut init: Func, > >>> len: usize, > >>> flags: Flags, > >>> ) -> Result>, E> > >>> where > >>> Func: FnMut(usize) -> Item, > >>> - Item: PinInit, > >>> - E: From, > >> > >> I think we should keep this bound and just add: > > > > The `Into` trait bounds are the idiomatic ones for functions consuming > > things. See https://doc.rust-lang.org/std/convert/trait.Into.html: > > > > Prefer using Into over From when specifying trait bounds on a > > generic function to ensure that types that only implement Into can > > be used as well. > > Yeah, but isn't this only because of [1], which does not apply to the kernel > because our minimum compiler version is 1.78 anyways? > > I.e. are there any cases where we can't implement From in the kernel and have to > fall back to Into? Probably not, but it's still best practice to use Into over From when specifying trait bounds. Alice