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 892D635C1B6 for ; Wed, 29 Apr 2026 08:03:49 +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=1777449830; cv=none; b=lLFXWXotiZPyUEk5YEIttTPuqfjS9eoJY5AUMDjmRZfq41dzVQ0NIYUbR04bhcvHyFpGOgbLG2Qg0pVS42Jqh511WavkPjeeVaDI/7Kmrc5fj7kXVZofpjtGFXQ/mOFCz1Lws5xvMlQNxs9rjlz/E2oUZPTX6v0c654ukTkkqUM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777449830; c=relaxed/simple; bh=s3VWFF0kRj6XD8MBAzFelHmtl5zPo2hrgmsQrQICp+I=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Dr3Fj01bVgYBeJIaZWzcI06MhFOCgiMtwFqFO/NDoT32IzNi7s+otuf+ZMa0OgO1K/SOivLBm/1FfyPr+ohfssYEISKKUoU3n4fQsOsgJzOmS0tHabsB7XsznDiDqXoSGDE3CCXuxMSOwdOBLQDitgEEipYjlfjzP44RppmETv0= 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=UyGim/3a; 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="UyGim/3a" Received: by mail-wm1-f74.google.com with SMTP id 5b1f17b1804b1-488c768a9a9so79429335e9.1 for ; Wed, 29 Apr 2026 01:03:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1777449828; x=1778054628; 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=byhdwSUP4Jou7A9vRHhYS4n9uJdEyD37hisZJJAeOpI=; b=UyGim/3aL3gxkQjlzVLdT3Zw9SwQyn62s6h+8btbyWHi/713oEzYWqTBNVFG55CwAV WRC58eyihzD/i2HrdBQNyts7QYyiqbgdUmrs2jfmHpD8PY0Nse1Iy6H10Tj1I4aEpIaE dJLlsVOtqq9gK9LbM4BCSgnSueySgcVdb+wLbMA2c5p8WbhrnB+D1AOy4pB4N/nv3o34 AMWqx0muH3A4UuNlRKUn4GkcdPLLYmWMhXBdvf5XXlV/1N8FJu6Wi64k9RnLxBeAgn89 DrqeTVBV5Yn484sELkQ9i9JjulsAWM5QI3B/cukamRtwK9tZjxORklIMABK/WzYZrbzO QxnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777449828; x=1778054628; 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=byhdwSUP4Jou7A9vRHhYS4n9uJdEyD37hisZJJAeOpI=; b=sLlNgGm/ELFgMMZebwah532O4aCDQ0hyhg+6/WwCytROdWZ/6P+XC9ZGnAFg2OfBxj DQaIv+bpE6klSB+XQqByju9ZLhKropqtIiTYFGayrrJiXRjSfhgGc6mOjNKumXz1Xj9f 0GnsQwzIqYGb0tszUPZGeS92jlksHiP87BBNI3P/53hRqYK7HI0BuRvPLUbdNnv9J4by SCTIzhjRiJZ0edofmvKmkXYzICl8ram4iOoiZH0thDws8vLlIQVlU7ghTUJfiGydhRPW oVmGSwrc6QjK0dxUPAhgfnNqWDchK0Djx79z8G+utubVUdU9EFGt5eWgioVsBWYKvBJH ynkw== X-Forwarded-Encrypted: i=1; AFNElJ/Jr/P1NIEe22QB540zNWdWbgYdBPN0lelBi4H84Mw1zuW+5ftD58pd2X2BOXX1NlztYuXl7YOrEgq3hZE=@vger.kernel.org X-Gm-Message-State: AOJu0Yx8xaOtBsxRVHvD1j4toZ503/PVQohtcGqMR4rSbTbzKso3MA9V cPql1p1vPbjAxnaQe1X/BHGP6hlg4uCvcjwJr2mTa76cZAufNMdVLhcLVGytKQ3pO3Jy0smA1q6 u96P9my7Tz8Zy0Y9LEg== X-Received: from wmrc4.prod.google.com ([2002:a05:600c:ac4:b0:488:994f:2c27]) (user=aliceryhl job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:c177:b0:48a:5301:bb5c with SMTP id 5b1f17b1804b1-48a77b12a49mr88679275e9.16.1777449827714; Wed, 29 Apr 2026 01:03:47 -0700 (PDT) Date: Wed, 29 Apr 2026 08:03:46 +0000 In-Reply-To: <20260427-doctest-kvec-reserve-v1-1-0623abcd9c2e@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260427-doctest-kvec-reserve-v1-1-0623abcd9c2e@gmail.com> Message-ID: Subject: Re: [PATCH] rust: alloc: fix assert in `Vec::reserve` doc test From: Alice Ryhl To: Hsiu Che Yu Cc: Danilo Krummrich , Lorenzo Stoakes , Vlastimil Babka , "Liam R. Howlett" , Uladzislau Rezki , Miguel Ojeda , Boqun Feng , Gary Guo , "=?utf-8?B?QmrDtnJu?= Roy Baron" , Benno Lossin , Andreas Hindborg , Trevor Gross , Alexandre Courbot , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" On Mon, Apr 27, 2026 at 10:15:49PM +0800, Hsiu Che Yu wrote: > The assert in the doctest used `>= 10`, which only checks that the > capacity can hold `additional` elements, ignoring the existing length > of `v`. The correct check should ensure there is room for `additional` > *extra* elements on top of what is already in the vector. > > Fix the assert to use `>= v.len() + 10` so the example accurately > reflects the actual semantics of the function. > > Reported-by: Miguel Ojeda > Closes: https://lore.kernel.org/rust-for-linux/CANiq72nkXWhjK9iFRrhGtkMZGsvNE_zVsu4JnxaFRfxWL7RRdg@mail.gmail.com/ > Fixes: 2aac4cd7dae3d ("rust: alloc: implement kernel `Vec` type") > Signed-off-by: Hsiu Che Yu Reviewed-by: Alice Ryhl