rust-lang-deprecated / error-chain

Error boilerplate for Rust
Apache License 2.0
728 stars 111 forks source link

"use of deprecated item 'std::error::Error::cause'" on 2018-12-27 nightly #254

Closed palfrey closed 5 years ago

palfrey commented 5 years ago
error: use of deprecated item 'std::error::Error::cause': replaced by Error::source, which can support downcasting
   --> src/common.rs:184:1
    |
184 | / error_chain! {
185 | |     foreign_links {
186 | |         Io(::std::io::Error);
187 | |     }
...   |
277 | |     }
278 | | }
    | |_^
    |

Expanding it out with RUSTFLAGS="-Z external-macro-backtrace" got me

error: use of deprecated item 'std::error::Error::cause': replaced by Error::source, which can support downcasting
    |
   ::: <::error_chain::error_chain::error_chain_processing macros>:1:1
    |
1   |           (
    |         __-
    |        |__|
    |       ||__|
    |      |||
2   |      |||  ( {  } , $ b : tt , $ c : tt , $ d : tt ) types $ content : tt $ ( $ tail : tt
3   |      |||  ) * ) => {
4   |      |||  error_chain_processing ! { ( $ content , $ b , $ c , $ d ) $ ( $ tail ) * } }
...        |||
12  |      |||  error_chain_processing ! { ( $ a , $ b , $ content , $ d ) $ ( $ tail ) * } }
    |      |||  --------------------------------------------------------------------------- in this macro invocation (#3)
...        |||
16  |      |||  error_chain_processing ! { ( $ a , $ b , $ c , $ content ) $ ( $ tail ) * } }
    |      |||  --------------------------------------------------------------------------- in this macro invocation (#4)
17  |      |||  ; ( ( $ a : tt , $ b : tt , $ c : tt , $ d : tt ) ) => {
18  |      |||  impl_error_chain_processed ! {
    |  ____|||__-
19  | |    |||  types $ a links $ b foreign_links $ c errors $ d } } ;
    | |    |||                                                   -   -
    | |    |||___________________________________________________|___|
    | |    ||____________________________________________________|___in this expansion of `error_chain_processing!` (#2)
    | |    |_____________________________________________________|___in this expansion of `error_chain_processing!` (#3)
    | |__________________________________________________________|   in this expansion of `error_chain_processing!` (#4)
    |                                                            in this macro invocation (#5)
   --> <::error_chain::error_chain::impl_error_chain_processed macros>:91:40
    |
1   |           ( types {  } $ ( $ rest : tt ) * ) => {
    |      _____-
    |     |_____|
    |    ||_____|
    |   |||
2   |   |||     impl_error_chain_processed ! {
    |   |||_____-
3   |  ||||     types { Error , ErrorKind , ResultExt , Result ; } $ ( $ rest ) * } } ; (
    |  ||||_______________________________________________________________________- in this macro invocation (#6)
4   |   |||     types {
...     |||
7   | / |||     impl_error_chain_processed ! {
8   | | |||     types { $ error_name , $ error_kind_name , $ result_ext_name ; } $ ( $ rest )
9   | | |||     * } /// Convenient wrapper around `std::Result`.
    | |_|||_______- in this macro invocation (#7)
...     |||
91  |   |||     ( ref foreign_err ) => { foreign_err . cause (  ) } ) * _ => None } } } } }
    |   |||                                            ^^^^^
...     |||
154 |   |||     move || { $ crate :: ChainedError :: from_kind ( callback (  ) . into (  ) ) }
155 |   |||     ) } } } ;
    |   |||             -
    |   |||_____________|
    |   ||______________in this expansion of `impl_error_chain_processed!` (#5)
    |   |_______________in this expansion of `impl_error_chain_processed!` (#6)
    |                   in this expansion of `impl_error_chain_processed!` (#7)
    |
   ::: <::error_chain::error_chain::error_chain macros>:1:1
    |
1   |         / ( $ ( $ block_name : ident { $ ( $ block_content : tt ) * } ) * ) => {
2   |         | error_chain_processing ! {
    |  _______|_-
3   | |       | ( {  } , {  } , {  } , {  } ) $ ( $ block_name { $ ( $ block_content ) * } ) *
4   | |       | } } ;
    | |       |_-___- in this expansion of `error_chain!` (#1)
    | |_________|
    |           in this macro invocation (#2)
    |
   ::: src/common.rs:184:1
    |
184 | /         error_chain! {
185 | |             foreign_links {
186 | |                 Io(::std::io::Error);
187 | |             }
...   |
277 | |             }
278 | |         }
    | |_________- in this macro invocation (#1)
daaku commented 5 years ago

Is there a way to use #[allow(deprecated)] to silence this warning?

atorstling commented 5 years ago

@daaku Add an exclamation mark. #![allow(deprecated)] worked for me.

daaku commented 5 years ago

Adding it on the mod declaration worked, like such:

#[allow(deprecated)]
mod errors {
mark-summerfield commented 5 years ago

This error occurs in stable 1.33, so I imagine a lot more people will experience it.

dwijnand commented 5 years ago

Adding it on the mod declaration worked, like such:

#[allow(deprecated)]
mod errors {

~You can make it even tighter and put it just on the error_chain macro:~

#[allow(deprecated)] // WORKAROUND https://github.com/rust-lang-nursery/error-chain/issues/254
error_chain! {

(edit: nevermind I did something wrong and I see now that that doesn't silence the warnings.)

mark-summerfield commented 5 years ago

None of these worked for me. I just hope that error-chain will be updated so that the warning isn't needed.

palfrey commented 5 years ago

@mark-summerfield #255 should fix all this once merged, but we're having issues finding a maintainer to look at it