Skip to content

Commit 8fc1bed

Browse files
committed
Reduce confusion of some drop order tests
In addition to adhering to normal Rust casing idioms, I ran `rustfmt`.
1 parent d00435f commit 8fc1bed

File tree

4 files changed

+18
-29
lines changed

4 files changed

+18
-29
lines changed

tests/ui/drop/issue-2735-2.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,24 @@
11
//@ run-pass
2-
#![allow(non_camel_case_types)]
32

43
use std::cell::Cell;
54

65
// This test should behave exactly like issue-2735-3
7-
struct defer<'a> {
6+
struct Defer<'a> {
87
b: &'a Cell<bool>,
98
}
109

11-
impl<'a> Drop for defer<'a> {
10+
impl<'a> Drop for Defer<'a> {
1211
fn drop(&mut self) {
1312
self.b.set(true);
1413
}
1514
}
1615

17-
fn defer(b: &Cell<bool>) -> defer<'_> {
18-
defer {
19-
b: b
20-
}
16+
fn defer(b: &Cell<bool>) -> Defer<'_> {
17+
Defer { b }
2118
}
2219

2320
pub fn main() {
2421
let dtor_ran = &Cell::new(false);
25-
let _ = defer(dtor_ran);
22+
let _ = defer(dtor_ran);
2623
assert!(dtor_ran.get());
2724
}

tests/ui/drop/issue-2735-3.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
11
//@ run-pass
2-
#![allow(non_camel_case_types)]
32

43
use std::cell::Cell;
54

65
// This test should behave exactly like issue-2735-2
7-
struct defer<'a> {
6+
struct Defer<'a> {
87
b: &'a Cell<bool>,
98
}
109

11-
impl<'a> Drop for defer<'a> {
10+
impl<'a> Drop for Defer<'a> {
1211
fn drop(&mut self) {
1312
self.b.set(true);
1413
}
1514
}
1615

17-
fn defer(b: &Cell<bool>) -> defer<'_> {
18-
defer {
19-
b: b
20-
}
16+
fn defer(b: &Cell<bool>) -> Defer<'_> {
17+
Defer { b }
2118
}
2219

2320
pub fn main() {

tests/ui/drop/issue-2735.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
//@ run-pass
22
#![allow(dead_code)]
3-
#![allow(non_camel_case_types)]
43

5-
6-
trait hax {
7-
fn dummy(&self) { }
4+
trait Hax {
5+
fn dummy(&self) {}
86
}
9-
impl<A> hax for A { }
7+
impl<A> Hax for A {}
108

11-
fn perform_hax<T: 'static>(x: Box<T>) -> Box<dyn hax+'static> {
12-
Box::new(x) as Box<dyn hax+'static>
9+
fn perform_hax<T: 'static>(x: Box<T>) -> Box<dyn Hax + 'static> {
10+
Box::new(x) as Box<dyn Hax + 'static>
1311
}
1412

1513
fn deadcode() {

tests/ui/drop/issue-979.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
11
//@ run-pass
2-
#![allow(non_camel_case_types)]
32

43
use std::cell::Cell;
54

6-
struct r<'a> {
5+
struct R<'a> {
76
b: &'a Cell<isize>,
87
}
98

10-
impl<'a> Drop for r<'a> {
9+
impl<'a> Drop for R<'a> {
1110
fn drop(&mut self) {
1211
self.b.set(self.b.get() + 1);
1312
}
1413
}
1514

16-
fn r(b: &Cell<isize>) -> r<'_> {
17-
r {
18-
b: b
19-
}
15+
fn r(b: &Cell<isize>) -> R<'_> {
16+
R { b }
2017
}
2118

2219
pub fn main() {

0 commit comments

Comments
 (0)