diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2025-06-06 23:53:19 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-06 23:53:19 +0200 |
| commit | b6ace054b813a700a34b97af00b21c61ce61f8aa (patch) | |
| tree | f8b61faf05c5b8dcda2816f7f984e8a828d413c4 | |
| parent | c1e67ad3d54dd9a1da197f3cd77b8a79576838ba (diff) | |
| parent | 8fc1bed0c8b6aab76d07e7576b0c1c1f29b934bf (diff) | |
| download | rust-b6ace054b813a700a34b97af00b21c61ce61f8aa.tar.gz rust-b6ace054b813a700a34b97af00b21c61ce61f8aa.zip | |
Rollup merge of #142113 - shepmaster:drop-order-test-confusion, r=jieyouxu
Reduce confusion of some drop order tests In addition to adhering to normal Rust casing idioms, I ran `rustfmt`. Closes rust-lang/rust#141604 r? `@jieyouxu`
| -rw-r--r-- | tests/ui/drop/issue-2735-2.rs | 13 | ||||
| -rw-r--r-- | tests/ui/drop/issue-2735-3.rs | 11 | ||||
| -rw-r--r-- | tests/ui/drop/issue-2735.rs | 12 | ||||
| -rw-r--r-- | tests/ui/drop/issue-979.rs | 11 |
4 files changed, 18 insertions, 29 deletions
diff --git a/tests/ui/drop/issue-2735-2.rs b/tests/ui/drop/issue-2735-2.rs index 66025956e08..43fbafe7a0e 100644 --- a/tests/ui/drop/issue-2735-2.rs +++ b/tests/ui/drop/issue-2735-2.rs @@ -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()); } diff --git a/tests/ui/drop/issue-2735-3.rs b/tests/ui/drop/issue-2735-3.rs index c9535168653..cc28f96d2b0 100644 --- a/tests/ui/drop/issue-2735-3.rs +++ b/tests/ui/drop/issue-2735-3.rs @@ -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() { diff --git a/tests/ui/drop/issue-2735.rs b/tests/ui/drop/issue-2735.rs index cd7e0b8f461..838b9da109b 100644 --- a/tests/ui/drop/issue-2735.rs +++ b/tests/ui/drop/issue-2735.rs @@ -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() { diff --git a/tests/ui/drop/issue-979.rs b/tests/ui/drop/issue-979.rs index 70052708be6..abbcc71de18 100644 --- a/tests/ui/drop/issue-979.rs +++ b/tests/ui/drop/issue-979.rs @@ -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() { |
