Skip to content

Commit

Permalink
Avoid warnings from bare trait objects
Browse files Browse the repository at this point in the history
Since we support Rust 1.18 but modern Rust versions have a warning
about bare trait objects, we go ahead and allow them in the code of
`src/lib.rs` & `snafu-derive/src/lib.rs`. We also have to allow
unknown lints because Rust 1.18 doesn't know about the lint we are
allowing.

We can use `dyn` in the documentation and tests because those are
only executed in modern Rust versions.
  • Loading branch information
Atul9 authored and shepmaster committed Jul 13, 2019
1 parent d311b5b commit fe2f81b
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions snafu-derive/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(unknown_lints, bare_trait_objects)]
#![recursion_limit = "128"] // https://github.com/rust-lang/rust/issues/62059

extern crate proc_macro;
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(unknown_lints, bare_trait_objects)]
#![deny(missing_docs)]

//! # SNAFU
Expand Down
2 changes: 1 addition & 1 deletion tests/backtrace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ extern crate snafu;

use snafu::{ensure, Backtrace, ErrorCompat, ResultExt, Snafu};

type AnotherError = Box<std::error::Error>;
type AnotherError = Box<dyn std::error::Error>;

#[derive(Debug, Snafu)]
enum Error {
Expand Down
2 changes: 1 addition & 1 deletion tests/generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ extern crate snafu;

use snafu::{Backtrace, ResultExt, Snafu};

type BoxError = Box<std::error::Error>;
type BoxError = Box<dyn std::error::Error>;

#[derive(Debug, Snafu)]
enum Error<'a, 'x, A, Y> {
Expand Down
2 changes: 1 addition & 1 deletion tests/source_attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ mod transformation {

TransformationToTraitObject {
#[snafu(source(from(InnerError, Box::new)))]
source: Box<std::error::Error>,
source: Box<dyn std::error::Error>,
},
}

Expand Down

0 comments on commit fe2f81b

Please sign in to comment.