Reduce confusion of some drop order tests

In addition to adhering to normal Rust casing idioms, I ran `rustfmt`.
This commit is contained in:
Jake Goulding
2025-05-29 09:38:44 -04:00
parent d00435f223
commit 8fc1bed0c8
4 changed files with 18 additions and 29 deletions
+5 -8
View File
@@ -1,27 +1,24 @@
//@ run-pass
#![allow(non_camel_case_types)]
use std::cell::Cell;
// This test should behave exactly like issue-2735-3
struct defer<'a> {
struct Defer<'a> {
b: &'a Cell<bool>,
}
impl<'a> Drop for defer<'a> {
impl<'a> Drop for Defer<'a> {
fn drop(&mut self) {
self.b.set(true);
}
}
fn defer(b: &Cell<bool>) -> defer<'_> {
defer {
b: b
}
fn defer(b: &Cell<bool>) -> Defer<'_> {
Defer { b }
}
pub fn main() {
let dtor_ran = &Cell::new(false);
let _ = defer(dtor_ran);
let _ = defer(dtor_ran);
assert!(dtor_ran.get());
}
+4 -7
View File
@@ -1,23 +1,20 @@
//@ run-pass
#![allow(non_camel_case_types)]
use std::cell::Cell;
// This test should behave exactly like issue-2735-2
struct defer<'a> {
struct Defer<'a> {
b: &'a Cell<bool>,
}
impl<'a> Drop for defer<'a> {
impl<'a> Drop for Defer<'a> {
fn drop(&mut self) {
self.b.set(true);
}
}
fn defer(b: &Cell<bool>) -> defer<'_> {
defer {
b: b
}
fn defer(b: &Cell<bool>) -> Defer<'_> {
Defer { b }
}
pub fn main() {
+5 -7
View File
@@ -1,15 +1,13 @@
//@ run-pass
#![allow(dead_code)]
#![allow(non_camel_case_types)]
trait hax {
fn dummy(&self) { }
trait Hax {
fn dummy(&self) {}
}
impl<A> hax for A { }
impl<A> Hax for A {}
fn perform_hax<T: 'static>(x: Box<T>) -> Box<dyn hax+'static> {
Box::new(x) as Box<dyn hax+'static>
fn perform_hax<T: 'static>(x: Box<T>) -> Box<dyn Hax + 'static> {
Box::new(x) as Box<dyn Hax + 'static>
}
fn deadcode() {
+4 -7
View File
@@ -1,22 +1,19 @@
//@ run-pass
#![allow(non_camel_case_types)]
use std::cell::Cell;
struct r<'a> {
struct R<'a> {
b: &'a Cell<isize>,
}
impl<'a> Drop for r<'a> {
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: b
}
fn r(b: &Cell<isize>) -> R<'_> {
R { b }
}
pub fn main() {