Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
1825810
Vec::dedup optimization
Soveu Feb 16, 2021
c114894
Vec::dedup optimization - panic gracefully
Soveu Feb 17, 2021
e292e6e
Stabilize `peekable_peek_mut`
lukaslueg Feb 9, 2021
2abab1f
Vec::dedup optimization - add tests
Soveu Mar 15, 2021
afdbc9e
Vec::dedup optimization - finishing polishes
Soveu Mar 15, 2021
d6a7c1d
Extend `proc_macro_back_compat` lint to `procedural-masquerade`
Aaron1011 Mar 15, 2021
2285f11
Vec::dedup optimization - add test for panic
Soveu Mar 15, 2021
96d6f22
Merge branch 'master' into dedup
Soveu Mar 15, 2021
1796cc0
Make source-based code coverage compatible with MIR inlining
tmiasko Mar 13, 2021
5a9538a
Functions inlined into reachable functions are reachable
tmiasko Mar 13, 2021
ad8f9af
Remove inline-instrument-coverage-fail.rs test case
tmiasko Mar 13, 2021
4b6cc0c
Add support for compile-flags in coverage tests
tmiasko Mar 15, 2021
0d84e0b
Add test case for -Zinline-mir & -Zinstrument-coverage
tmiasko Mar 16, 2021
bd2737f
ci/docker: Add SDK/NDK level 21 to android docker for 32bit platforms
kinnison Mar 16, 2021
b0092bc
Vec::dedup optimization - add benches
Soveu Mar 16, 2021
5bd50ef
Simplify C compilation for Fortanix-SGX target
Mar 16, 2021
e3031fe
Allow registering tool lints with `register_tool`
jyn514 Mar 16, 2021
f414c33
Display error details when a `mmap` call fails
JohnTitor Mar 17, 2021
7dc654c
Update library/core/src/iter/traits/iterator.rs
lukaslueg Mar 17, 2021
8af15db
Update library/core/src/iter/traits/iterator.rs
lukaslueg Mar 17, 2021
ee98c6f
Don't show HTML diff if tidy isn't installed for rustdoc tests
GuillaumeGomez Mar 17, 2021
03abd47
Rollup merge of #81938 - lukaslueg:stab_peek_mut, r=KodrAus,JohnTitor
Dylan-DPC Mar 17, 2021
af0424e
Rollup merge of #82191 - Soveu:dedup, r=nagisa
Dylan-DPC Mar 17, 2021
9a852f9
Rollup merge of #83080 - tmiasko:inline-coverage, r=wesleywiser
Dylan-DPC Mar 17, 2021
243b275
Rollup merge of #83168 - Aaron1011:lint-procedural-masquerade, r=petr…
Dylan-DPC Mar 17, 2021
2472e15
Rollup merge of #83192 - kinnison:add-android-21, r=Mark-Simulacrum
Dylan-DPC Mar 17, 2021
dbd1df1
Rollup merge of #83204 - jethrogb:jb/sgx-c-build, r=joshtriplett,raou…
Dylan-DPC Mar 17, 2021
86faabe
Rollup merge of #83216 - jyn514:register-tool, r=petrochenkov
Dylan-DPC Mar 17, 2021
af9ed1d
Rollup merge of #83223 - JohnTitor:display-err-from-mmap, r=joshtriplett
Dylan-DPC Mar 17, 2021
423fc34
Rollup merge of #83228 - GuillaumeGomez:no-diff-if-no-tidy, r=jyn514
Dylan-DPC Mar 17, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Vec::dedup optimization - add test for panic
  • Loading branch information
Soveu committed Mar 15, 2021
commit 2285f11724e2fa3251c94c9ab7672544099600e2
54 changes: 54 additions & 0 deletions library/alloc/tests/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use std::mem::{size_of, swap};
use std::ops::Bound::*;
use std::panic::{catch_unwind, AssertUnwindSafe};
use std::rc::Rc;
use std::sync::atomic::{AtomicU32, Ordering};
use std::vec::{Drain, IntoIter};

struct DropCounter<'a> {
Expand Down Expand Up @@ -2169,3 +2170,56 @@ fn test_vec_dedup() {
assert_eq!(vec, dedup);
}
}

#[test]
fn test_vec_dedup_panicking() {
#[derive(Debug)]
struct Panic {
drop_counter: &'static AtomicU32,
value: bool,
index: usize,
}

impl PartialEq for Panic {
fn eq(&self, other: &Self) -> bool {
self.value == other.value
}
}

impl Drop for Panic {
fn drop(&mut self) {
let x = self.drop_counter.fetch_add(1, Ordering::SeqCst);
assert!(x != 4);
}
}

static DROP_COUNTER: AtomicU32 = AtomicU32::new(0);
let expected = [
Panic { drop_counter: &DROP_COUNTER, value: false, index: 0 },
Panic { drop_counter: &DROP_COUNTER, value: false, index: 5 },
Panic { drop_counter: &DROP_COUNTER, value: true, index: 6 },
Panic { drop_counter: &DROP_COUNTER, value: true, index: 7 },
];
let mut vec = vec![
Panic { drop_counter: &DROP_COUNTER, value: false, index: 0 },
// these elements get deduplicated
Panic { drop_counter: &DROP_COUNTER, value: false, index: 1 },
Panic { drop_counter: &DROP_COUNTER, value: false, index: 2 },
Panic { drop_counter: &DROP_COUNTER, value: false, index: 3 },
Panic { drop_counter: &DROP_COUNTER, value: false, index: 4 },
// here it panics
Panic { drop_counter: &DROP_COUNTER, value: false, index: 5 },
Panic { drop_counter: &DROP_COUNTER, value: true, index: 6 },
Panic { drop_counter: &DROP_COUNTER, value: true, index: 7 },
];

let _ = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
vec.dedup();
}));

let ok = vec.iter().zip(expected.iter()).all(|(x, y)| x.index == y.index);

if !ok {
panic!("expected: {:?}\ngot: {:?}\n", expected, vec);
}
}