Remove allowing static_mut_refs lint
This commit is contained in:
parent
883f9a2c8f
commit
1e10e503fe
2 changed files with 11 additions and 11 deletions
|
@ -2,7 +2,7 @@
|
||||||
//! Primarily used to extract a backtrace from stack overflow
|
//! Primarily used to extract a backtrace from stack overflow
|
||||||
|
|
||||||
use std::alloc::{Layout, alloc};
|
use std::alloc::{Layout, alloc};
|
||||||
use std::{fmt, mem, ptr};
|
use std::{fmt, mem, ptr, slice};
|
||||||
|
|
||||||
use rustc_interface::util::{DEFAULT_STACK_SIZE, STACK_SIZE};
|
use rustc_interface::util::{DEFAULT_STACK_SIZE, STACK_SIZE};
|
||||||
|
|
||||||
|
@ -35,20 +35,22 @@ macro raw_errln($tokens:tt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Signal handler installed for SIGSEGV
|
/// Signal handler installed for SIGSEGV
|
||||||
// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint
|
///
|
||||||
#[allow(static_mut_refs)]
|
/// # Safety
|
||||||
extern "C" fn print_stack_trace(_: libc::c_int) {
|
///
|
||||||
|
/// Caller must ensure that this function is not re-entered.
|
||||||
|
unsafe extern "C" fn print_stack_trace(_: libc::c_int) {
|
||||||
const MAX_FRAMES: usize = 256;
|
const MAX_FRAMES: usize = 256;
|
||||||
|
let stack = unsafe {
|
||||||
// Reserve data segment so we don't have to malloc in a signal handler, which might fail
|
// Reserve data segment so we don't have to malloc in a signal handler, which might fail
|
||||||
// in incredibly undesirable and unexpected ways due to e.g. the allocator deadlocking
|
// in incredibly undesirable and unexpected ways due to e.g. the allocator deadlocking
|
||||||
static mut STACK_TRACE: [*mut libc::c_void; MAX_FRAMES] = [ptr::null_mut(); MAX_FRAMES];
|
static mut STACK_TRACE: [*mut libc::c_void; MAX_FRAMES] = [ptr::null_mut(); MAX_FRAMES];
|
||||||
let stack = unsafe {
|
|
||||||
// Collect return addresses
|
// Collect return addresses
|
||||||
let depth = libc::backtrace(STACK_TRACE.as_mut_ptr(), MAX_FRAMES as i32);
|
let depth = libc::backtrace(&raw mut STACK_TRACE as _, MAX_FRAMES as i32);
|
||||||
if depth == 0 {
|
if depth == 0 {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
&STACK_TRACE.as_slice()[0..(depth as _)]
|
slice::from_raw_parts(&raw const STACK_TRACE as _, depth as _)
|
||||||
};
|
};
|
||||||
|
|
||||||
// Just a stack trace is cryptic. Explain what we're doing.
|
// Just a stack trace is cryptic. Explain what we're doing.
|
||||||
|
|
|
@ -288,8 +288,6 @@ cfg_if::cfg_if! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint
|
|
||||||
#[allow(static_mut_refs)]
|
|
||||||
pub unsafe fn panic(data: Box<dyn Any + Send>) -> u32 {
|
pub unsafe fn panic(data: Box<dyn Any + Send>) -> u32 {
|
||||||
use core::intrinsics::atomic_store_seqcst;
|
use core::intrinsics::atomic_store_seqcst;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue