mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-06 04:08:40 +00:00
Reduce the number of unstable features in tests
This commit is contained in:
parent
f5e0b760d0
commit
e66220f747
@ -7,9 +7,10 @@
|
|||||||
// compile-flags:-C panic=abort
|
// compile-flags:-C panic=abort
|
||||||
// aux-build:helper.rs
|
// aux-build:helper.rs
|
||||||
|
|
||||||
#![feature(start, rustc_private, new_uninit, panic_info_message, lang_items)]
|
#![feature(rustc_private, lang_items)]
|
||||||
#![feature(alloc_error_handler)]
|
#![feature(alloc_error_handler)]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
#![no_main]
|
||||||
|
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
extern crate libc;
|
extern crate libc;
|
||||||
@ -21,35 +22,30 @@ pub fn __aeabi_unwind_cpp_pr0() {}
|
|||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub fn __aeabi_unwind_cpp_pr1() {}
|
pub fn __aeabi_unwind_cpp_pr1() {}
|
||||||
|
|
||||||
use core::ptr::null_mut;
|
|
||||||
use core::alloc::{GlobalAlloc, Layout};
|
|
||||||
use alloc::boxed::Box;
|
use alloc::boxed::Box;
|
||||||
|
use alloc::string::ToString;
|
||||||
|
use core::alloc::{GlobalAlloc, Layout};
|
||||||
|
use core::ptr::null_mut;
|
||||||
|
|
||||||
extern crate helper;
|
extern crate helper;
|
||||||
|
|
||||||
struct MyAllocator;
|
struct MyAllocator;
|
||||||
|
|
||||||
#[alloc_error_handler]
|
#[alloc_error_handler]
|
||||||
fn my_oom(layout: Layout) -> !
|
fn my_oom(layout: Layout) -> ! {
|
||||||
{
|
|
||||||
use alloc::fmt::write;
|
use alloc::fmt::write;
|
||||||
unsafe {
|
unsafe {
|
||||||
let size = layout.size();
|
let size = layout.size();
|
||||||
let mut s = alloc::string::String::new();
|
let mut s = alloc::string::String::new();
|
||||||
write(&mut s, format_args!("My OOM: failed to allocate {} bytes!\n", size)).unwrap();
|
write(&mut s, format_args!("My OOM: failed to allocate {} bytes!\n", size)).unwrap();
|
||||||
let s = s.as_str();
|
libc::write(libc::STDERR_FILENO, s.as_ptr() as *const _, s.len());
|
||||||
libc::write(libc::STDERR_FILENO, s as *const _ as _, s.len());
|
|
||||||
libc::exit(0)
|
libc::exit(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl GlobalAlloc for MyAllocator {
|
unsafe impl GlobalAlloc for MyAllocator {
|
||||||
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
|
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
|
||||||
if layout.size() < 4096 {
|
if layout.size() < 4096 { libc::malloc(layout.size()) as _ } else { null_mut() }
|
||||||
libc::malloc(layout.size()) as _
|
|
||||||
} else {
|
|
||||||
null_mut()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
unsafe fn dealloc(&self, _ptr: *mut u8, _layout: Layout) {}
|
unsafe fn dealloc(&self, _ptr: *mut u8, _layout: Layout) {}
|
||||||
}
|
}
|
||||||
@ -60,26 +56,12 @@ static A: MyAllocator = MyAllocator;
|
|||||||
#[panic_handler]
|
#[panic_handler]
|
||||||
fn panic(panic_info: &core::panic::PanicInfo) -> ! {
|
fn panic(panic_info: &core::panic::PanicInfo) -> ! {
|
||||||
unsafe {
|
unsafe {
|
||||||
if let Some(s) = panic_info.payload().downcast_ref::<&str>() {
|
let s = panic_info.to_string();
|
||||||
const PSTR: &str = "panic occurred: ";
|
const PSTR: &str = "panic occurred: ";
|
||||||
const CR: &str = "\n";
|
const CR: &str = "\n";
|
||||||
libc::write(libc::STDERR_FILENO, PSTR as *const _ as _, PSTR.len());
|
libc::write(libc::STDERR_FILENO, PSTR.as_ptr() as *const _, PSTR.len());
|
||||||
libc::write(libc::STDERR_FILENO, s as *const _ as _, s.len());
|
libc::write(libc::STDERR_FILENO, s.as_ptr() as *const _, s.len());
|
||||||
libc::write(libc::STDERR_FILENO, CR as *const _ as _, CR.len());
|
libc::write(libc::STDERR_FILENO, CR.as_ptr() as *const _, CR.len());
|
||||||
}
|
|
||||||
if let Some(args) = panic_info.message() {
|
|
||||||
let mut s = alloc::string::String::new();
|
|
||||||
alloc::fmt::write(&mut s, *args).unwrap();
|
|
||||||
let s = s.as_str();
|
|
||||||
const PSTR: &str = "panic occurred: ";
|
|
||||||
const CR: &str = "\n";
|
|
||||||
libc::write(libc::STDERR_FILENO, PSTR as *const _ as _, PSTR.len());
|
|
||||||
libc::write(libc::STDERR_FILENO, s as *const _ as _, s.len());
|
|
||||||
libc::write(libc::STDERR_FILENO, CR as *const _ as _, CR.len());
|
|
||||||
} else {
|
|
||||||
const PSTR: &str = "panic occurred\n";
|
|
||||||
libc::write(libc::STDERR_FILENO, PSTR as *const _ as _, PSTR.len());
|
|
||||||
}
|
|
||||||
libc::exit(1)
|
libc::exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -89,15 +71,14 @@ fn panic(panic_info: &core::panic::PanicInfo) -> ! {
|
|||||||
// in these libraries will refer to `rust_eh_personality` if LLVM can not *prove* the contents won't
|
// in these libraries will refer to `rust_eh_personality` if LLVM can not *prove* the contents won't
|
||||||
// unwind. So, for this test case we will define the symbol.
|
// unwind. So, for this test case we will define the symbol.
|
||||||
#[lang = "eh_personality"]
|
#[lang = "eh_personality"]
|
||||||
extern fn rust_eh_personality() {}
|
extern "C" fn rust_eh_personality() {}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Default, Debug)]
|
||||||
struct Page(#[allow(unused_tuple_struct_fields)] [[u64; 32]; 16]);
|
struct Page(#[allow(unused_tuple_struct_fields)] [[u64; 32]; 16]);
|
||||||
|
|
||||||
#[start]
|
#[no_mangle]
|
||||||
pub fn main(_argc: isize, _argv: *const *const u8) -> isize {
|
fn main(_argc: i32, _argv: *const *const u8) -> isize {
|
||||||
let zero = Box::<Page>::new_zeroed();
|
let zero = Box::<Page>::new(Default::default());
|
||||||
let zero = unsafe { zero.assume_init() };
|
|
||||||
helper::work_with(&zero);
|
helper::work_with(&zero);
|
||||||
1
|
1
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,9 @@
|
|||||||
// compile-flags:-C panic=abort
|
// compile-flags:-C panic=abort
|
||||||
// aux-build:helper.rs
|
// aux-build:helper.rs
|
||||||
|
|
||||||
#![feature(start, rustc_private, new_uninit, panic_info_message, lang_items)]
|
#![feature(rustc_private, lang_items)]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
#![no_main]
|
||||||
|
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
extern crate libc;
|
extern crate libc;
|
||||||
@ -21,6 +22,7 @@ pub fn __aeabi_unwind_cpp_pr0() {}
|
|||||||
pub fn __aeabi_unwind_cpp_pr1() {}
|
pub fn __aeabi_unwind_cpp_pr1() {}
|
||||||
|
|
||||||
use alloc::boxed::Box;
|
use alloc::boxed::Box;
|
||||||
|
use alloc::string::ToString;
|
||||||
use core::alloc::{GlobalAlloc, Layout};
|
use core::alloc::{GlobalAlloc, Layout};
|
||||||
use core::ptr::null_mut;
|
use core::ptr::null_mut;
|
||||||
|
|
||||||
@ -30,11 +32,7 @@ struct MyAllocator;
|
|||||||
|
|
||||||
unsafe impl GlobalAlloc for MyAllocator {
|
unsafe impl GlobalAlloc for MyAllocator {
|
||||||
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
|
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
|
||||||
if layout.size() < 4096 {
|
if layout.size() < 4096 { libc::malloc(layout.size()) as _ } else { null_mut() }
|
||||||
libc::malloc(layout.size()) as _
|
|
||||||
} else {
|
|
||||||
null_mut()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
unsafe fn dealloc(&self, _ptr: *mut u8, _layout: Layout) {}
|
unsafe fn dealloc(&self, _ptr: *mut u8, _layout: Layout) {}
|
||||||
}
|
}
|
||||||
@ -45,26 +43,12 @@ static A: MyAllocator = MyAllocator;
|
|||||||
#[panic_handler]
|
#[panic_handler]
|
||||||
fn panic(panic_info: &core::panic::PanicInfo) -> ! {
|
fn panic(panic_info: &core::panic::PanicInfo) -> ! {
|
||||||
unsafe {
|
unsafe {
|
||||||
if let Some(s) = panic_info.payload().downcast_ref::<&str>() {
|
let s = panic_info.to_string();
|
||||||
const PSTR: &str = "panic occurred: ";
|
const PSTR: &str = "panic occurred: ";
|
||||||
const CR: &str = "\n";
|
const CR: &str = "\n";
|
||||||
libc::write(libc::STDERR_FILENO, PSTR as *const _ as _, PSTR.len());
|
libc::write(libc::STDERR_FILENO, PSTR.as_ptr() as *const _, PSTR.len());
|
||||||
libc::write(libc::STDERR_FILENO, s as *const _ as _, s.len());
|
libc::write(libc::STDERR_FILENO, s.as_ptr() as *const _, s.len());
|
||||||
libc::write(libc::STDERR_FILENO, CR as *const _ as _, CR.len());
|
libc::write(libc::STDERR_FILENO, CR.as_ptr() as *const _, CR.len());
|
||||||
}
|
|
||||||
if let Some(args) = panic_info.message() {
|
|
||||||
let mut s = alloc::string::String::new();
|
|
||||||
alloc::fmt::write(&mut s, *args).unwrap();
|
|
||||||
let s = s.as_str();
|
|
||||||
const PSTR: &str = "panic occurred: ";
|
|
||||||
const CR: &str = "\n";
|
|
||||||
libc::write(libc::STDERR_FILENO, PSTR as *const _ as _, PSTR.len());
|
|
||||||
libc::write(libc::STDERR_FILENO, s as *const _ as _, s.len());
|
|
||||||
libc::write(libc::STDERR_FILENO, CR as *const _ as _, CR.len());
|
|
||||||
} else {
|
|
||||||
const PSTR: &str = "panic occurred\n";
|
|
||||||
libc::write(libc::STDERR_FILENO, PSTR as *const _ as _, PSTR.len());
|
|
||||||
}
|
|
||||||
libc::exit(0)
|
libc::exit(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -74,15 +58,14 @@ fn panic(panic_info: &core::panic::PanicInfo) -> ! {
|
|||||||
// in these libraries will refer to `rust_eh_personality` if LLVM can not *prove* the contents won't
|
// in these libraries will refer to `rust_eh_personality` if LLVM can not *prove* the contents won't
|
||||||
// unwind. So, for this test case we will define the symbol.
|
// unwind. So, for this test case we will define the symbol.
|
||||||
#[lang = "eh_personality"]
|
#[lang = "eh_personality"]
|
||||||
extern fn rust_eh_personality() {}
|
extern "C" fn rust_eh_personality() {}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Default, Debug)]
|
||||||
struct Page(#[allow(unused_tuple_struct_fields)] [[u64; 32]; 16]);
|
struct Page(#[allow(unused_tuple_struct_fields)] [[u64; 32]; 16]);
|
||||||
|
|
||||||
#[start]
|
#[no_mangle]
|
||||||
pub fn main(_argc: isize, _argv: *const *const u8) -> isize {
|
fn main(_argc: i32, _argv: *const *const u8) -> isize {
|
||||||
let zero = Box::<Page>::new_zeroed();
|
let zero = Box::<Page>::new(Default::default());
|
||||||
let zero = unsafe { zero.assume_init() };
|
|
||||||
helper::work_with(&zero);
|
helper::work_with(&zero);
|
||||||
1
|
1
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user