-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
C-bugCategory: This is a bug.Category: This is a bug.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.Performance or correctness regression from stable to beta.
Milestone
Description
Caught while fleshing out a much beefier test suite for SliceIndex, which I plan to submit as a PR. (this Issue is here just in case that PR never happens).
Lines 2107 to 2115 in 1ef1563
fn index_mut(self, slice: &mut str) -> &mut Self::Output { | |
assert!(self.end != usize::max_value(), | |
"attempted to index str up to maximum usize"); | |
if slice.is_char_boundary(self.end) { | |
unsafe { self.get_unchecked_mut(slice) } | |
} else { | |
super::slice_error_fail(slice, 0, self.end + 1) | |
} | |
} |
The unicode character boundary check here should be looking at self.end + 1
. Better yet, the method could just delegate to RangeTo
instead. (note: it can't delegate to get_mut
here without NLL, which seems to be a leading factor as to how this function ended up this way)
kennytm
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.Performance or correctness regression from stable to beta.