Skip to content

Commit

Permalink
Move vec-slice-drop test
Browse files Browse the repository at this point in the history
  • Loading branch information
poliorcetics committed Sep 21, 2020
1 parent 8904921 commit 275eed7
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 31 deletions.
29 changes: 29 additions & 0 deletions library/core/tests/slice.rs
Expand Up @@ -1980,3 +1980,32 @@ fn test_is_sorted() {
assert!(!["c", "bb", "aaa"].is_sorted());
assert!(["c", "bb", "aaa"].is_sorted_by_key(|s| s.len()));
}

#[test]
fn test_slice_run_destructors() {
use core::cell::Cell;

// Make sure that destructors get run on slice literals
struct Foo<'a> {
x: &'a Cell<isize>,
}

impl<'a> Drop for Foo<'a> {
fn drop(&mut self) {
self.x.set(self.x.get() + 1);
}
}

fn foo(x: &Cell<isize>) -> Foo<'_> {
Foo { x }
}

let x = &Cell::new(0);

{
let l = &[foo(x)];
assert_eq!(l[0].x.get(), 0);
}

assert_eq!(x.get(), 1);
}
31 changes: 0 additions & 31 deletions src/test/ui/array-slice-vec/vec-slice-drop.rs

This file was deleted.

0 comments on commit 275eed7

Please sign in to comment.