Commit Graph

285 Commits

Author SHA1 Message Date
David Tolnay 2e2c126342
Merge pull request #146 from dtolnay/backtrace
Fix up PR 137 for merge
2021-08-28 14:16:40 -07:00
David Tolnay 71c7ebec0e
Update documentation of source-backtrace behavior 2021-08-28 14:12:47 -07:00
David Tolnay 799bb53b10
Extract combined backtrace-source case to separate match arm 2021-08-28 13:44:42 -07:00
David Tolnay d49c5af10f
Handle backtrace coming from Option source field 2021-08-28 13:42:03 -07:00
David Tolnay 2b37b9ed62
Handle enum containing #[source] #[backtrace] field 2021-08-28 13:40:17 -07:00
David Tolnay ed396c2074
Factor out distinct backtrace logic 2021-08-28 13:29:34 -07:00
David Tolnay 9b542cef8f
Adjust how distinct backtrace field is accessed 2021-08-28 13:29:34 -07:00
David Tolnay ca33ed9bc7
Touch up PR 137 2021-08-28 13:29:34 -07:00
David Tolnay c45d7e4de8
Merge pull request 137 from astraw/combined-from-and-backtrace-field 2021-08-28 12:56:45 -07:00
David Tolnay 031fea6f3b
Release 1.0.26 2021-07-02 21:11:05 -07:00
David Tolnay 245e7cfd14
Suppress nonstandard_macro_braces in generated code 2021-07-02 21:10:09 -07:00
David Tolnay 4bbe3ece51
Ignore buggy nonstandard_macro_braces clippy lint
Clippy bug: https://github.com/rust-lang/rust-clippy/issues/7422

    error: use of irregular braces for `write!` macro
     --> tests/test_backtrace.rs:5:10
      |
    5 | #[derive(Error, Debug)]
      |          ^^^^^
      |
      = note: `-D clippy::nonstandard-macro-braces` implied by `-D clippy::all`
    help: consider writing `Error`
     --> tests/test_backtrace.rs:5:10
      |
    5 | #[derive(Error, Debug)]
      |          ^^^^^
      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
      = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
      --> tests/test_lints.rs:13:21
       |
    13 |     #[derive(Debug, Error)]
       |                     ^^^^^
       |
       = note: `-D clippy::nonstandard-macro-braces` implied by `-D clippy::all`
    help: consider writing `Error`
      --> tests/test_lints.rs:13:21
       |
    13 |     #[derive(Debug, Error)]
       |                     ^^^^^
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
       = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
     --> tests/test_source.rs:7:10
      |
    7 | #[derive(Error, Debug)]
      |          ^^^^^
      |
    note: the lint level is defined here
     --> tests/test_source.rs:1:9
      |
    1 | #![deny(clippy::all, clippy::pedantic)]
      |         ^^^^^^^^^^^
      = note: `#[deny(clippy::nonstandard_macro_braces)]` implied by `#[deny(clippy::all)]`
    help: consider writing `Error`
     --> tests/test_source.rs:7:10
      |
    7 | #[derive(Error, Debug)]
      |          ^^^^^
      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
      = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
      --> tests/test_source.rs:13:10
       |
    13 | #[derive(Error, Debug)]
       |          ^^^^^
       |
    help: consider writing `Error`
      --> tests/test_source.rs:13:10
       |
    13 | #[derive(Error, Debug)]
       |          ^^^^^
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
       = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
      --> tests/test_source.rs:21:10
       |
    21 | #[derive(Error, Debug)]
       |          ^^^^^
       |
    help: consider writing `Error`
      --> tests/test_source.rs:21:10
       |
    21 | #[derive(Error, Debug)]
       |          ^^^^^
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
       = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
      --> tests/test_source.rs:54:18
       |
    54 |           #[derive(Error)]
       |                    ^^^^^
    ...
    64 | / error_from_macro! {
    65 | |     #[error("Something")]
    66 | |     Variant(#[from] io::Error)
    67 | | }
       | |_- in this macro invocation
       |
    help: consider writing `Error`
      --> tests/test_source.rs:54:18
       |
    54 |           #[derive(Error)]
       |                    ^^^^^
    ...
    64 | / error_from_macro! {
    65 | |     #[error("Something")]
    66 | |     Variant(#[from] io::Error)
    67 | | }
       | |_- in this macro invocation
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
       = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
     --> tests/test_expr.rs:9:10
      |
    9 | #[derive(Error, Debug)]
      |          ^^^^^
      |
    note: the lint level is defined here
     --> tests/test_expr.rs:1:9
      |
    1 | #![deny(clippy::all, clippy::pedantic)]
      |         ^^^^^^^^^^^
      = note: `#[deny(clippy::nonstandard_macro_braces)]` implied by `#[deny(clippy::all)]`
    help: consider writing `Error`
     --> tests/test_expr.rs:9:10
      |
    9 | #[derive(Error, Debug)]
      |          ^^^^^
      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
      = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
      --> tests/test_expr.rs:39:10
       |
    39 | #[derive(Error, Debug)]
       |          ^^^^^
       |
    help: consider writing `Error`
      --> tests/test_expr.rs:39:10
       |
    39 | #[derive(Error, Debug)]
       |          ^^^^^
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
       = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
     --> tests/test_from.rs:6:10
      |
    6 | #[derive(Error, Debug)]
      |          ^^^^^
      |
    note: the lint level is defined here
     --> tests/test_from.rs:1:9
      |
    1 | #![deny(clippy::all, clippy::pedantic)]
      |         ^^^^^^^^^^^
      = note: `#[deny(clippy::nonstandard_macro_braces)]` implied by `#[deny(clippy::all)]`
    help: consider writing `Error`
     --> tests/test_from.rs:6:10
      |
    6 | #[derive(Error, Debug)]
      |          ^^^^^
      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
      = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
      --> tests/test_from.rs:13:10
       |
    13 | #[derive(Error, Debug)]
       |          ^^^^^
       |
    help: consider writing `Error`
      --> tests/test_from.rs:13:10
       |
    13 | #[derive(Error, Debug)]
       |          ^^^^^
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
       = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
     --> tests/test_path.rs:8:10
      |
    8 | #[derive(Error, Debug)]
      |          ^^^^^
      |
    note: the lint level is defined here
     --> tests/test_path.rs:1:9
      |
    1 | #![deny(clippy::all, clippy::pedantic)]
      |         ^^^^^^^^^^^
      = note: `#[deny(clippy::nonstandard_macro_braces)]` implied by `#[deny(clippy::all)]`
    help: consider writing `Error`
     --> tests/test_path.rs:8:10
      |
    8 | #[derive(Error, Debug)]
      |          ^^^^^
      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
      = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
      --> tests/test_path.rs:14:10
       |
    14 | #[derive(Error, Debug, RefCast)]
       |          ^^^^^
       |
    help: consider writing `Error`
      --> tests/test_path.rs:14:10
       |
    14 | #[derive(Error, Debug, RefCast)]
       |          ^^^^^
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
       = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
      --> tests/test_from.rs:17:10
       |
    17 | #[derive(Error, Debug)]
       |          ^^^^^
       |
    help: consider writing `Error`
      --> tests/test_from.rs:17:10
       |
    17 | #[derive(Error, Debug)]
       |          ^^^^^
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
       = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
      --> tests/test_path.rs:21:10
       |
    21 | #[derive(Error, Debug)]
       |          ^^^^^
       |
    help: consider writing `Error`
      --> tests/test_path.rs:21:10
       |
    21 | #[derive(Error, Debug)]
       |          ^^^^^
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
       = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
      --> tests/test_transparent.rs:14:14
       |
    14 |     #[derive(Error, Debug)]
       |              ^^^^^
       |
    note: the lint level is defined here
      --> tests/test_transparent.rs:1:9
       |
    1  | #![deny(clippy::all, clippy::pedantic)]
       |         ^^^^^^^^^^^
       = note: `#[deny(clippy::nonstandard_macro_braces)]` implied by `#[deny(clippy::all)]`
    help: consider writing `Error`
      --> tests/test_transparent.rs:14:14
       |
    14 |     #[derive(Error, Debug)]
       |              ^^^^^
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
       = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
      --> tests/test_from.rs:26:10
       |
    26 | #[derive(Error, Debug)]
       |          ^^^^^
       |
    help: consider writing `Error`
      --> tests/test_from.rs:26:10
       |
    26 | #[derive(Error, Debug)]
       |          ^^^^^
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
       = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
      --> tests/test_transparent.rs:34:14
       |
    34 |     #[derive(Error, Debug)]
       |              ^^^^^
       |
    help: consider writing `Error`
      --> tests/test_transparent.rs:34:14
       |
    34 |     #[derive(Error, Debug)]
       |              ^^^^^
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
       = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
      --> tests/test_transparent.rs:69:14
       |
    69 |     #[derive(Error, Debug)]
       |              ^^^^^
       |
    help: consider writing `Error`
      --> tests/test_transparent.rs:69:14
       |
    69 |     #[derive(Error, Debug)]
       |              ^^^^^
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
       = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
      --> tests/test_display.rs:12:14
       |
    12 |     #[derive(Error, Debug)]
       |              ^^^^^
       |
    note: the lint level is defined here
      --> tests/test_display.rs:1:9
       |
    1  | #![deny(clippy::all, clippy::pedantic)]
       |         ^^^^^^^^^^^
       = note: `#[deny(clippy::nonstandard_macro_braces)]` implied by `#[deny(clippy::all)]`
    help: consider writing `Error`
      --> tests/test_display.rs:12:14
       |
    12 |     #[derive(Error, Debug)]
       |              ^^^^^
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
       = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
      --> tests/test_display.rs:24:14
       |
    24 |     #[derive(Error, Debug)]
       |              ^^^^^
       |
    help: consider writing `Error`
      --> tests/test_display.rs:24:14
       |
    24 |     #[derive(Error, Debug)]
       |              ^^^^^
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
       = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
      --> tests/test_display.rs:35:14
       |
    35 |     #[derive(Error, Debug)]
       |              ^^^^^
       |
    help: consider writing `Error`
      --> tests/test_display.rs:35:14
       |
    35 |     #[derive(Error, Debug)]
       |              ^^^^^
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
       = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
      --> tests/test_display.rs:44:14
       |
    44 |     #[derive(Error, Debug)]
       |              ^^^^^
       |
    help: consider writing `Error`
      --> tests/test_display.rs:44:14
       |
    44 |     #[derive(Error, Debug)]
       |              ^^^^^
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
       = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
      --> tests/test_display.rs:53:14
       |
    53 |     #[derive(Error, Debug)]
       |              ^^^^^
       |
    help: consider writing `Error`
      --> tests/test_display.rs:53:14
       |
    53 |     #[derive(Error, Debug)]
       |              ^^^^^
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
       = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
      --> tests/test_display.rs:70:14
       |
    70 |     #[derive(Error, Debug)]
       |              ^^^^^
       |
    help: consider writing `Error`
      --> tests/test_display.rs:70:14
       |
    70 |     #[derive(Error, Debug)]
       |              ^^^^^
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
       = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
      --> tests/test_display.rs:84:14
       |
    84 |     #[derive(Error, Debug)]
       |              ^^^^^
       |
    help: consider writing `Error`
      --> tests/test_display.rs:84:14
       |
    84 |     #[derive(Error, Debug)]
       |              ^^^^^
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
       = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
      --> tests/test_display.rs:98:14
       |
    98 |     #[derive(Error, Debug)]
       |              ^^^^^
       |
    help: consider writing `Error`
      --> tests/test_display.rs:98:14
       |
    98 |     #[derive(Error, Debug)]
       |              ^^^^^
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
       = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
       --> tests/test_display.rs:107:14
        |
    107 |     #[derive(Error, Debug)]
        |              ^^^^^
        |
    help: consider writing `Error`
       --> tests/test_display.rs:107:14
        |
    107 |     #[derive(Error, Debug)]
        |              ^^^^^
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
        = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
       --> tests/test_display.rs:115:14
        |
    115 |     #[derive(Error, Debug)]
        |              ^^^^^
        |
    help: consider writing `Error`
       --> tests/test_display.rs:115:14
        |
    115 |     #[derive(Error, Debug)]
        |              ^^^^^
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
        = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
       --> tests/test_display.rs:129:14
        |
    129 |     #[derive(Error, Debug)]
        |              ^^^^^
        |
    help: consider writing `Error`
       --> tests/test_display.rs:129:14
        |
    129 |     #[derive(Error, Debug)]
        |              ^^^^^
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
        = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
       --> tests/test_display.rs:158:14
        |
    158 |     #[derive(Error, Debug)]
        |              ^^^^^
        |
    help: consider writing `Error`
       --> tests/test_display.rs:158:14
        |
    158 |     #[derive(Error, Debug)]
        |              ^^^^^
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
        = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
       --> tests/test_display.rs:170:14
        |
    170 |     #[derive(Error, Debug)]
        |              ^^^^^
        |
    help: consider writing `Error`
       --> tests/test_display.rs:170:14
        |
    170 |     #[derive(Error, Debug)]
        |              ^^^^^
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
        = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
       --> tests/test_display.rs:184:14
        |
    184 |     #[derive(Error, Debug)]
        |              ^^^^^
        |
    help: consider writing `Error`
       --> tests/test_display.rs:184:14
        |
    184 |     #[derive(Error, Debug)]
        |              ^^^^^
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
        = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
       --> tests/test_display.rs:201:14
        |
    201 |     #[derive(Error, Debug)]
        |              ^^^^^
        |
    help: consider writing `Error`
       --> tests/test_display.rs:201:14
        |
    201 |     #[derive(Error, Debug)]
        |              ^^^^^
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
        = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
       --> tests/test_display.rs:214:29
        |
    214 |             #[derive(Debug, Error)]
        |                             ^^^^^
    ...
    228 |     decl_error!(Repro(u8));
        |     ----------------------- in this macro invocation
        |
    help: consider writing `Error`
       --> tests/test_display.rs:214:29
        |
    214 |             #[derive(Debug, Error)]
        |                             ^^^^^
    ...
    228 |     decl_error!(Repro(u8));
        |     ----------------------- in this macro invocation
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
        = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
       --> tests/test_display.rs:220:29
        |
    220 |             #[derive(Debug, Error)]
        |                             ^^^^^
    ...
    228 |     decl_error!(Repro(u8));
        |     ----------------------- in this macro invocation
        |
    help: consider writing `Error`
       --> tests/test_display.rs:220:29
        |
    220 |             #[derive(Debug, Error)]
        |                             ^^^^^
    ...
    228 |     decl_error!(Repro(u8));
        |     ----------------------- in this macro invocation
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
        = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
       --> tests/test_display.rs:236:14
        |
    236 |     #[derive(Error, Debug)]
        |              ^^^^^
        |
    help: consider writing `Error`
       --> tests/test_display.rs:236:14
        |
    236 |     #[derive(Error, Debug)]
        |              ^^^^^
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
        = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
       --> tests/test_display.rs:247:14
        |
    247 |     #[derive(Error, Debug)]
        |              ^^^^^
        |
    help: consider writing `Error`
       --> tests/test_display.rs:247:14
        |
    247 |     #[derive(Error, Debug)]
        |              ^^^^^
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
        = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
       --> tests/test_display.rs:258:14
        |
    258 |     #[derive(Error, Debug)]
        |              ^^^^^
        |
    help: consider writing `Error`
       --> tests/test_display.rs:258:14
        |
    258 |     #[derive(Error, Debug)]
        |              ^^^^^
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
        = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
       --> tests/test_display.rs:269:14
        |
    269 |     #[derive(Error, Debug)]
        |              ^^^^^
        |
    help: consider writing `Error`
       --> tests/test_display.rs:269:14
        |
    269 |     #[derive(Error, Debug)]
        |              ^^^^^
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
        = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)
2021-07-02 21:05:58 -07:00
David Tolnay e0628be8ed
Ignore doc_markdown clippy false positive
Clippy bug: https://github.com/rust-lang/rust-clippy/issues/7421

    error: backticks are unbalanced
       --> src/lib.rs:128:1
        |
    128 | / //!   Any error type that implements `std::error::Error` or dereferences to `dyn
    129 | | //!   std::error::Error` will work as a source.
    130 | | //!
    131 | | //!   ```rust
    132 | | //!   # use std::fmt::{self, Display};
        | |______________________________________^
        |
        = note: `-D clippy::doc-markdown` implied by `-D clippy::pedantic`
        = help: a backtick may be missing a pair
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown
2021-07-02 20:24:12 -07:00
Andrew Straw cd2b9db3aa fixup tests for combined from and backtrace 2021-06-13 09:44:18 +02:00
Andrew Straw 52dc286e79 test combined `#[from]` and `#[backtrace]` 2021-06-12 17:03:49 +02:00
Andrew Straw da2454f989 describe `#[from]` and `#[backtrace]` together 2021-06-12 17:02:44 +02:00
Andrew Straw 86993c25ab allow #[from] and #[backtrace] on same field
See https://github.com/dtolnay/thiserror/pull/93#pullrequestreview-666213667
2021-06-12 10:47:23 +02:00
David Tolnay a37b5ab11f
Resolve needless_borrow clippy lints
error: this expression borrows a reference (`&ast::Field`) that is immediately dereferenced by the compiler
      --> impl/src/prop.rs:68:25
       |
    68 |             return Some(&field);
       |                         ^^^^^^ help: change this to: `field`
       |
       = note: `-D clippy::needless-borrow` implied by `-D clippy::all`
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

    error: this expression borrows a reference (`&ast::Field`) that is immediately dereferenced by the compiler
      --> impl/src/prop.rs:77:25
       |
    77 |             return Some(&field);
       |                         ^^^^^^ help: change this to: `field`
       |
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

    error: this expression borrows a reference (`&ast::Field`) that is immediately dereferenced by the compiler
      --> impl/src/prop.rs:82:70
       |
    82 |             Member::Named(ident) if ident == "source" => return Some(&field),
       |                                                                      ^^^^^^ help: change this to: `field`
       |
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

    error: this expression borrows a reference (`&ast::Field`) that is immediately dereferenced by the compiler
      --> impl/src/prop.rs:92:25
       |
    92 |             return Some(&field);
       |                         ^^^^^^ help: change this to: `field`
       |
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

    error: this expression borrows a reference (`&ast::Field`) that is immediately dereferenced by the compiler
      --> impl/src/prop.rs:97:25
       |
    97 |             return Some(&field);
       |                         ^^^^^^ help: change this to: `field`
       |
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

    error: this expression borrows a reference (`&syn::Type`) that is immediately dereferenced by the compiler
       --> impl/src/valid.rs:191:41
        |
    191 |         if contains_non_static_lifetime(&source_field.ty) {
        |                                         ^^^^^^^^^^^^^^^^ help: change this to: `source_field.ty`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
2021-06-04 19:49:18 -07:00
David Tolnay 8862629bcc
Delete broken #[deprecated] test
Issue #136 tracks making this work again, or tracking down whatever
broke this in nightly.
2021-06-03 21:33:27 -07:00
David Tolnay 19cb5cee4b
Release 1.0.25 2021-05-22 14:33:15 -07:00
David Tolnay e49c10f2ba
Merge pull request #134 from dtolnay/nonstatic
Support non-static lifetime inside error(transparent)
2021-05-22 14:32:32 -07:00
David Tolnay 1ed8751081
Support non-static AsDynError lifetimes 2021-05-22 14:29:11 -07:00
David Tolnay 51a1ff6593
Add regression test for issue 113
This does not currently compile.

    error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
      --> tests/test_transparent.rs:63:14
       |
    63 |     #[derive(Error, Debug)]
       |              ^^^^^
       |
    note: first, the lifetime cannot outlive the lifetime `'a` as defined on the impl at 65:18...
      --> tests/test_transparent.rs:65:18
       |
    65 |     struct Error<'a> {
       |                  ^^
    note: ...so that the types are compatible
      --> tests/test_transparent.rs:63:14
       |
    63 |     #[derive(Error, Debug)]
       |              ^^^^^
       = note: expected `&test_non_static::ErrorKind<'_>`
                  found `&test_non_static::ErrorKind<'a>`
       = note: but, the lifetime must be valid for the static lifetime...
    note: ...so that the type `test_non_static::ErrorKind<'_>` will meet its required lifetime bounds
      --> tests/test_transparent.rs:63:14
       |
    63 |     #[derive(Error, Debug)]
       |              ^^^^^
       = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)
2021-05-22 14:28:48 -07:00
David Tolnay ee2a47d3af
Adjust macro hygiene test formatting
Different versions of rustfmt mangle this all different ways.
2021-05-22 14:28:15 -07:00
David Tolnay c610d97267
Update ui test suite to nightly-2021-05-14 2021-05-13 19:15:14 -07:00
David Tolnay c10adbc25e
Ignore manual_map clippy lint
I do not find that it makes the code clearer in this case, given the
related `if` branch right above.

    error: manual implementation of `Option::map`
       --> impl/src/ast.rs:145:16
        |
    145 |           } else if let Some(transparent) = &self.transparent {
        |  ________________^
    146 | |             Some(transparent.span)
    147 | |         } else {
    148 | |             None
    149 | |         }
        | |_________^ help: try this: `self.transparent.as_ref().map(|transparent| transparent.span)`
        |
        = note: `-D clippy::manual-map` implied by `-D clippy::all`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_map
2021-02-25 20:44:36 -08:00
David Tolnay 1b0a84996b
Release 1.0.24 2021-02-18 20:25:18 -08:00
David Tolnay d81b7466bc
Merge pull request 121 from Aaron1011/fix/source-span 2021-02-18 20:15:06 -08:00
Aaron Hill 0fa679b1b8
Consistently use `quote!` when emitting 'source'
When a macro generates part of the derive input, the call-site hygiene
may be different than the hygiene of a field. Therefore, we need to
be sure to use the same hygiene information for any identifiers we
generate, instead of relying on the hygiene from a particular span
via `quote_spanned!`
2021-02-18 12:40:04 -05:00
David Tolnay d0f521c208
Update ui test suite to nightly-2021-01-29 2021-01-28 18:37:39 -08:00
David Tolnay c09ddc2241
Fix catching clippy warnings as CI failures 2021-01-04 23:52:19 -08:00
David Tolnay dc3c5c6a87
Resolve clippy filter_map_next pedantic lint 2020-12-29 16:24:38 -08:00
David Tolnay 25f0be5e8f
Inform clippy of supported compiler version in clippy.toml 2020-12-29 16:23:19 -08:00
David Tolnay c0a56fefbe
Opt in to pedantic clippy lints 2020-12-29 16:22:54 -08:00
David Tolnay d263b4b7e4
Release 1.0.23 2020-12-26 17:37:45 -08:00
David Tolnay da6ee81909
Merge pull request #116 from dtolnay/lifetime
Detect non-static lifetime behind reference type parameter
2020-12-26 17:37:17 -08:00
David Tolnay d30890b4f7
Add ui test of Generic<&'a str> source 2020-12-26 17:33:51 -08:00
David Tolnay 0859205018
Detect non-static lifetime behind reference type parameter 2020-12-26 17:29:46 -08:00
David Tolnay cb3077c315
Merge pull request #115 from dtolnay/lifetime
Add justification to non-static lifetime diagnostic
2020-12-26 17:29:35 -08:00
David Tolnay d31d96bba2
Add justification to non-static lifetime diagnostic 2020-12-26 17:27:02 -08:00
David Tolnay 464a409608
Tweak placement of diagnostic on non-static lifetimes in source 2020-12-26 17:25:34 -08:00
David Tolnay a789be4219
Add import to make i32::MAX available on rustc <1.43
#110
2020-11-20 11:55:51 -08:00
David Tolnay 1969f03a6e
Merge pull request #110 from faern/use-newer-int-consts
Use i32::MAX instead of i32::max_value()
2020-11-20 11:54:45 -08:00
Linus Färnstrand a8c8594ae5 Use i32::MAX instead of i32::max_value() 2020-11-20 20:33:49 +01:00
David Tolnay 09f247adda
Release 1.0.22 2020-11-03 16:47:44 -08:00
David Tolnay 53bb2fbf98
Merge pull request #109 from dtolnay/keyword
Fix keyword as fmt argument
2020-11-03 16:47:17 -08:00
David Tolnay aafcf0a1b6
Fix second place that keyword fmt argument is failing 2020-11-03 16:41:37 -08:00
David Tolnay 2722f8e2c3
Fix first place that keyword fmt argument is failing 2020-11-03 16:38:35 -08:00
David Tolnay 25c73d7cdf
Add test of keyword fmt argument
Presently crashes with:

    error: proc-macro derive panicked
       --> tests/test_display.rs:269:14
        |
    269 |     #[derive(Error, Debug)]
        |              ^^^^^
        |
        = help: message: called `Result::unwrap()` on an `Err` value: Error("expected identifier")
2020-11-03 16:32:15 -08:00
David Tolnay 7a9066f000
Condense raw identifier unit tests 2020-11-03 16:31:08 -08:00