- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
Closed
Labels
A-collectionsArea: `std::collections`Area: `std::collections`C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.
Description
Today, set_len has a debug_assert! on the length being legal:
rust/library/alloc/src/vec/mod.rs
Lines 1950 to 1956 in 855e0fe
| #[inline] | |
| #[stable(feature = "rust1", since = "1.0.0")] | |
| pub unsafe fn set_len(&mut self, new_len: usize) { | |
| debug_assert!(new_len <= self.capacity()); | |
| self.len = new_len; | |
| } | 
It would be nice, assuming the compilation time hit is tolerable, to upgrade that to a UB-check in order to better catch people making over-long vectors.
paolobarbolini, denboba and vcfxb
Metadata
Metadata
Assignees
Labels
A-collectionsArea: `std::collections`Area: `std::collections`C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.