rust/tests/ui/drop/issue-979.rs
Jake Goulding 8fc1bed0c8 Reduce confusion of some drop order tests
In addition to adhering to normal Rust casing idioms, I ran `rustfmt`.
2025-06-06 08:30:47 -04:00

27 lines
339 B
Rust

//@ run-pass
use std::cell::Cell;
struct R<'a> {
b: &'a Cell<isize>,
}
impl<'a> Drop for R<'a> {
fn drop(&mut self) {
self.b.set(self.b.get() + 1);
}
}
fn r(b: &Cell<isize>) -> R<'_> {
R { b }
}
pub fn main() {
let b = &Cell::new(0);
{
let _p = Some(r(b));
}
assert_eq!(b.get(), 1);
}