Skip to content

Reduce confusion of some drop order tests #142113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions tests/ui/drop/issue-2735-2.rs
Original file line number Diff line number Diff line change
@@ -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());
}
11 changes: 4 additions & 7 deletions tests/ui/drop/issue-2735-3.rs
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
12 changes: 5 additions & 7 deletions tests/ui/drop/issue-2735.rs
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
11 changes: 4 additions & 7 deletions tests/ui/drop/issue-979.rs
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
Loading