aboutsummaryrefslogtreecommitdiff
path: root/ctr-std/src/sys_common/backtrace.rs
diff options
context:
space:
mode:
authorFenrir <[email protected]>2018-08-19 17:48:00 -0600
committerFenrir <[email protected]>2018-08-19 17:56:18 -0600
commit5d28bfcfd6086c3328837de9695099ea39048d0d (patch)
treea514fde042ff2a504a03305bfe0894ff8cd8d47e /ctr-std/src/sys_common/backtrace.rs
parentUpdate for latest nightly 2018-06-09 (#70) (diff)
downloadctru-rs-5d28bfcfd6086c3328837de9695099ea39048d0d.tar.xz
ctru-rs-5d28bfcfd6086c3328837de9695099ea39048d0d.zip
Update for nightly-2018-08-18
Diffstat (limited to 'ctr-std/src/sys_common/backtrace.rs')
-rw-r--r--ctr-std/src/sys_common/backtrace.rs21
1 files changed, 10 insertions, 11 deletions
diff --git a/ctr-std/src/sys_common/backtrace.rs b/ctr-std/src/sys_common/backtrace.rs
index 20109d2..7737178 100644
--- a/ctr-std/src/sys_common/backtrace.rs
+++ b/ctr-std/src/sys_common/backtrace.rs
@@ -49,7 +49,7 @@ pub struct Frame {
const MAX_NB_FRAMES: usize = 100;
/// Prints the current backtrace.
-pub fn print(w: &mut Write, format: PrintFormat) -> io::Result<()> {
+pub fn print(w: &mut dyn Write, format: PrintFormat) -> io::Result<()> {
static LOCK: Mutex = Mutex::new();
// Use a lock to prevent mixed output in multithreading context.
@@ -62,7 +62,7 @@ pub fn print(w: &mut Write, format: PrintFormat) -> io::Result<()> {
}
}
-fn _print(w: &mut Write, format: PrintFormat) -> io::Result<()> {
+fn _print(w: &mut dyn Write, format: PrintFormat) -> io::Result<()> {
let mut frames = [Frame {
exact_position: ptr::null(),
symbol_addr: ptr::null(),
@@ -156,16 +156,15 @@ pub fn log_enabled() -> Option<PrintFormat> {
_ => return Some(PrintFormat::Full),
}
- let val = match env::var_os("RUST_BACKTRACE") {
- Some(x) => if &x == "0" {
+ let val = env::var_os("RUST_BACKTRACE").and_then(|x|
+ if &x == "0" {
None
} else if &x == "full" {
Some(PrintFormat::Full)
} else {
Some(PrintFormat::Short)
- },
- None => None,
- };
+ }
+ );
ENABLED.store(match val {
Some(v) => v as isize,
None => 1,
@@ -177,7 +176,7 @@ pub fn log_enabled() -> Option<PrintFormat> {
///
/// These output functions should now be used everywhere to ensure consistency.
/// You may want to also use `output_fileline`.
-fn output(w: &mut Write, idx: usize, frame: Frame,
+fn output(w: &mut dyn Write, idx: usize, frame: Frame,
s: Option<&str>, format: PrintFormat) -> io::Result<()> {
// Remove the `17: 0x0 - <unknown>` line.
if format == PrintFormat::Short && frame.exact_position == ptr::null() {
@@ -202,7 +201,7 @@ fn output(w: &mut Write, idx: usize, frame: Frame,
///
/// See also `output`.
#[allow(dead_code)]
-fn output_fileline(w: &mut Write,
+fn output_fileline(w: &mut dyn Write,
file: &[u8],
line: u32,
format: PrintFormat) -> io::Result<()> {
@@ -254,7 +253,7 @@ fn output_fileline(w: &mut Write,
// Note that this demangler isn't quite as fancy as it could be. We have lots
// of other information in our symbols like hashes, version, type information,
// etc. Additionally, this doesn't handle glue symbols at all.
-pub fn demangle(writer: &mut Write, mut s: &str, format: PrintFormat) -> io::Result<()> {
+pub fn demangle(writer: &mut dyn Write, mut s: &str, format: PrintFormat) -> io::Result<()> {
// During ThinLTO LLVM may import and rename internal symbols, so strip out
// those endings first as they're one of the last manglings applied to
// symbol names.
@@ -263,7 +262,7 @@ pub fn demangle(writer: &mut Write, mut s: &str, format: PrintFormat) -> io::Res
let candidate = &s[i + llvm.len()..];
let all_hex = candidate.chars().all(|c| {
match c {
- 'A' ... 'F' | '0' ... '9' => true,
+ 'A' ..= 'F' | '0' ..= '9' => true,
_ => false,
}
});