Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support trait objects for source in Error #252

Merged
merged 1 commit into from
Jul 1, 2023

Commits on Jul 1, 2023

  1. Support trait objects for source in Error

    If you used boxed `dyn Error` traits as a source a compile error would
    occur:
    ```
     --> tests/error/derives_for_enums_with_source.rs:5:17
      |
    5 | #[derive(Debug, Error)]
      |                 ^^^^^ doesn't have a size known at compile-time
      |
      = help: the trait `Sized` is not implemented for `(dyn std::error::Error + Send + 'static)`
      = help: the trait `std::error::Error` is implemented for `Box<T>`
      = note: required for `Box<(dyn std::error::Error + Send + 'static)>` to implement `std::error::Error`
      = note: required for the cast from `Box<(dyn std::error::Error + Send + 'static)>` to the object type `dyn std::error::Error`
      = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)
    ```
    
    This fixes that by shamelessly "borrowing" a fix from [`thiserror`].
    
    [`thiserror`]: https://github.com/dtolnay/thiserror
    
    Fixes #122
    
    Redid this commit, because I accidentally pushed to master without a PR.
    JelteF committed Jul 1, 2023
    Configuration menu
    Copy the full SHA
    3b2b660 View commit details
    Browse the repository at this point in the history