mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Reduce confusion of some drop order tests
In addition to adhering to normal Rust casing idioms, I ran `rustfmt`.
This commit is contained in:
@@ -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());
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user