Skip to content

Commit

Permalink
Add a regression test for rust-lang#50041
Browse files Browse the repository at this point in the history
AFAICT the test case never landed alongside the fix for the issue.
  • Loading branch information
nagisa committed Jan 15, 2021
1 parent d03fe84 commit af0d099
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 af0d099

Please sign in to comment.