From b9c9b3e7a28b187f06395e91235bdc560f3d0807 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 2 Dec 2023 14:54:14 +0100 Subject: [PATCH] remove a cranelift test that doesn't make sense any more --- .../build_system/tests.rs | 5 -- .../example/issue-91827-extern-types.rs | 55 ------------------- 2 files changed, 60 deletions(-) delete mode 100644 compiler/rustc_codegen_cranelift/example/issue-91827-extern-types.rs diff --git a/compiler/rustc_codegen_cranelift/build_system/tests.rs b/compiler/rustc_codegen_cranelift/build_system/tests.rs index 3309a0a6abd1f..1a38d5967f4b1 100644 --- a/compiler/rustc_codegen_cranelift/build_system/tests.rs +++ b/compiler/rustc_codegen_cranelift/build_system/tests.rs @@ -75,11 +75,6 @@ const BASE_SYSROOT_SUITE: &[TestCase] = &[ "example/arbitrary_self_types_pointers_and_wrappers.rs", &[], ), - TestCase::build_bin_and_run( - "aot.issue_91827_extern_types", - "example/issue-91827-extern-types.rs", - &[], - ), TestCase::build_lib("build.alloc_system", "example/alloc_system.rs", "lib"), TestCase::build_bin_and_run("aot.alloc_example", "example/alloc_example.rs", &[]), TestCase::jit_bin("jit.std_example", "example/std_example.rs", ""), diff --git a/compiler/rustc_codegen_cranelift/example/issue-91827-extern-types.rs b/compiler/rustc_codegen_cranelift/example/issue-91827-extern-types.rs deleted file mode 100644 index 6f39c5edcad20..0000000000000 --- a/compiler/rustc_codegen_cranelift/example/issue-91827-extern-types.rs +++ /dev/null @@ -1,55 +0,0 @@ -// Copied from rustc ui test suite - -// run-pass -// -// Test that we can handle unsized types with an extern type tail part. -// Regression test for issue #91827. - -#![feature(extern_types)] - -use std::ptr::addr_of; - -extern "C" { - type Opaque; -} - -unsafe impl Sync for Opaque {} - -#[repr(C)] -pub struct List { - len: usize, - data: [T; 0], - tail: Opaque, -} - -#[repr(C)] -pub struct ListImpl { - len: usize, - data: [T; N], -} - -impl List { - const fn as_slice(&self) -> &[T] { - unsafe { std::slice::from_raw_parts(self.data.as_ptr(), self.len) } - } -} - -impl ListImpl { - const fn as_list(&self) -> &List { - unsafe { std::mem::transmute(self) } - } -} - -pub static A: ListImpl = ListImpl { len: 3, data: [5, 6, 7] }; -pub static A_REF: &'static List = A.as_list(); -pub static A_TAIL_OFFSET: isize = tail_offset(A.as_list()); - -const fn tail_offset(list: &List) -> isize { - unsafe { (addr_of!(list.tail) as *const u8).offset_from(list as *const List as *const u8) } -} - -fn main() { - assert_eq!(A_REF.as_slice(), &[5, 6, 7]); - // Check that interpreter and code generation agree about the position of the tail field. - assert_eq!(A_TAIL_OFFSET, tail_offset(A_REF)); -}