diff options
| author | Kivooeo <Kivooeo123@gmail.com> | 2025-07-24 18:29:09 +0500 |
|---|---|---|
| committer | Kivooeo <Kivooeo123@gmail.com> | 2025-07-25 15:34:28 +0500 |
| commit | 90bb5cacb5c1a5fe20ba821d28e7eb7a21e35d09 (patch) | |
| tree | fa18c4e8fc12592084b8d16f71a8838e44a116ac /tests/ui/drop/vec-replace-skip-while-drop.rs | |
| parent | 3c30dbbe31bfbf6029f4534170165ba573ff0fd1 (diff) | |
| download | rust-90bb5cacb5c1a5fe20ba821d28e7eb7a21e35d09.tar.gz rust-90bb5cacb5c1a5fe20ba821d28e7eb7a21e35d09.zip | |
moved 34 tests to organized locations
Diffstat (limited to 'tests/ui/drop/vec-replace-skip-while-drop.rs')
| -rw-r--r-- | tests/ui/drop/vec-replace-skip-while-drop.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/ui/drop/vec-replace-skip-while-drop.rs b/tests/ui/drop/vec-replace-skip-while-drop.rs new file mode 100644 index 00000000000..b18108e0a8a --- /dev/null +++ b/tests/ui/drop/vec-replace-skip-while-drop.rs @@ -0,0 +1,32 @@ +//@ run-pass + +// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +#![allow(static_mut_refs)] + +use std::mem; + +static mut DROP_COUNT: usize = 0; + +struct Fragment; + +impl Drop for Fragment { + fn drop(&mut self) { + unsafe { + DROP_COUNT += 1; + } + } +} + +fn main() { + { + let mut fragments = vec![Fragment, Fragment, Fragment]; + let _new_fragments: Vec<Fragment> = mem::replace(&mut fragments, vec![]) + .into_iter() + .skip_while(|_fragment| { + true + }).collect(); + } + unsafe { + assert_eq!(DROP_COUNT, 3); + } +} |
