Skip to content

Commit

Permalink
Rollup merge of rust-lang#81060 - nagisa:nagisa/regression-50041, r=M…
Browse files Browse the repository at this point in the history
…ark-Simulacrum

Add a regression test for rust-lang#50041

AFAICT the test case never landed alongside the fix for the issue.
  • Loading branch information
m-ou-se authored Jan 16, 2021
2 parents 9df8dcb + af0d099 commit b67689b
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/test/ui/mir/ssa-analysis-regression-50041.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// build-pass
// compile-flags: -Z mir-opt-level=3

#![crate_type="lib"]
#![feature(lang_items)]
#![no_std]

#[lang = "owned_box"]
pub struct Box<T: ?Sized>(*mut T);

impl<T: ?Sized> Drop for Box<T> {
fn drop(&mut self) {
}
}

#[lang = "box_free"]
#[inline(always)]
unsafe fn box_free<T: ?Sized>(ptr: *mut T) {
dealloc(ptr)
}

#[inline(never)]
fn dealloc<T: ?Sized>(_: *mut T) {
}

pub struct Foo<T>(T);

pub fn foo(a: Option<Box<Foo<usize>>>) -> usize {
let f = match a {
None => Foo(0),
Some(vec) => *vec,
};
f.0
}

0 comments on commit b67689b

Please sign in to comment.