rust/tests/ui/unsafe/issue-45107-unnecessary-unsafe-in-closure.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

29 lines
674 B
Rust
Raw Normal View History

// revisions: mir thir
// [thir]compile-flags: -Zthir-unsafeck
#[deny(unused_unsafe)]
fn main() {
let mut v = Vec::<i32>::with_capacity(24);
unsafe {
let f = |v: &mut Vec<_>| {
2017-11-20 06:13:27 -06:00
unsafe { //~ ERROR unnecessary `unsafe`
v.set_len(24);
2017-11-20 06:13:27 -06:00
|w: &mut Vec<u32>| { unsafe { //~ ERROR unnecessary `unsafe`
w.set_len(32);
} };
}
2017-11-20 06:13:27 -06:00
|x: &mut Vec<u32>| { unsafe { //~ ERROR unnecessary `unsafe`
x.set_len(40);
} };
};
v.set_len(0);
f(&mut v);
}
|y: &mut Vec<u32>| { unsafe {
y.set_len(48);
} };
}