Auto merge of #87488 - kornelski:track-remove, r=dtolnay

Track caller of Vec::remove()

`vec.remove(invalid)` doesn't print a helpful source position:

> thread 'main' panicked at 'removal index (is 99) should be < len (is 1)', **library/alloc/src/vec/mod.rs:1379:13**
This commit is contained in:
bors 2021-07-31 03:00:20 +00:00
commit b289bb7fdf

View file

@ -1372,9 +1372,11 @@ impl<T, A: Allocator> Vec<T, A> {
/// assert_eq!(v, [1, 3]);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[track_caller]
pub fn remove(&mut self, index: usize) -> T {
#[cold]
#[inline(never)]
#[track_caller]
fn assert_failed(index: usize, len: usize) -> ! {
panic!("removal index (is {}) should be < len (is {})", index, len);
}