Skip to content

Commit

Permalink
Remove experimental failure support
Browse files Browse the repository at this point in the history
Resolves #34
  • Loading branch information
athre0z committed Oct 13, 2020
1 parent c68832a commit a7240e7
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 139 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
@@ -1,6 +1,11 @@
# Changelog
All notable changes to this project will be documented in this file.

## Unreleased

- Add `__rust_begin_short_backtrace` filter
- Remove experimental failure support

## [v0.4.2] (2020-05-19)

#### Added
Expand Down
6 changes: 0 additions & 6 deletions Cargo.toml
Expand Up @@ -16,17 +16,11 @@ keywords = [
"pretty",
]

[[example]]
name = "failure"
required-features = ["failure-bt"]

[features]
default = ["gimli-symbolize"]
failure-bt = ["failure"]
gimli-symbolize = ["backtrace/gimli-symbolize"]

[dependencies]
termcolor = "1.0"
atty = "0.2"
failure = { version = "0.1", optional = true }
backtrace = "0.3"
23 changes: 0 additions & 23 deletions README.md
Expand Up @@ -41,29 +41,6 @@ BacktracePrinter::new().message("Custom message!").install(default_output_stream
- Hide all the frames after the panic was already initiated
- Hide language runtime initialization frames

### Optional Features

- **`failure-bt`** — Experimental support for printing `failure::Backtrace` backtraces.

### **Experimental** Failure backtrace integration

`failure` backtraces are opaque and so this feature uses unsafe code to
transmute the struct into a non private struct to allow access to the internal
`backtrace::Backtrace` object.

The code is dependent on and only tested against failure version `0.1.5` and is
considered a temporary hack while we work on getting backtraces from errors
exposed properly. This feature is marked as unsafe, it relies on UB to work,
and there is no guarantee that rust will pick this layout on a different crate
type. User discretion is advised.

To enable, include the following in your Cargo.toml

```toml
[dependencies]
color-backtrace = { version = "0.4", features = ["failure-bt"] }
```

### Reducing transitive dependencies

In order to reduce transitive dependencies, you can disable the default
Expand Down
22 changes: 0 additions & 22 deletions examples/failure.rs

This file was deleted.

65 changes: 0 additions & 65 deletions src/failure.rs

This file was deleted.

23 changes: 0 additions & 23 deletions src/lib.rs
Expand Up @@ -44,9 +44,6 @@ use std::path::PathBuf;
use std::sync::{Arc, Mutex};
use termcolor::{Ansi, Color, ColorChoice, ColorSpec, StandardStream, WriteColor};

#[cfg(feature = "failure-bt")]
pub mod failure;

// Re-export termcolor so users don't have to depend on it themselves.
pub use termcolor;

Expand Down Expand Up @@ -230,10 +227,7 @@ impl Frame {
"color_backtrace::create_panic_handler",
"std::panicking::begin_panic",
"begin_panic_fmt",
"failure::backtrace::Backtrace::new",
"backtrace::capture",
"failure::error_message::err_msg",
"<failure::error::Error as core::convert::From<F>>::from",
];

match self.name.as_ref() {
Expand Down Expand Up @@ -651,23 +645,6 @@ impl BacktracePrinter {
Ok(())
}

/// Extracts the internal `backtrace::Backtrace` from a `failure::Backtrace` and prints it, if
/// one exists. Prints that a backtrace was not capture if one is not found.
#[cfg(feature = "failure-bt")]
pub unsafe fn print_failure_trace(
&self,
trace: &::failure::Backtrace,
out: &mut impl WriteColor,
) -> IOResult {
let internal = failure::backdoortrace(trace);

if let Some(internal) = internal {
self.print_trace(internal, out)
} else {
writeln!(out, "<failure backtrace not captured>")
}
}

/// Pretty-print a backtrace to a `String`, using VT100 color codes.
pub fn format_trace_to_string(&self, trace: &backtrace::Backtrace) -> IOResult<String> {
// TODO: should we implicitly enable VT100 support on Windows here?
Expand Down

0 comments on commit a7240e7

Please sign in to comment.