Skip to content

forbidden dyn type: dyn core::error::Error when using thiserror (#[error(transparent)]) #2071

@Dspil

Description

@Dspil

Description

When using the thiserror crate to derive Error for an enum, using the #[error(transparent)] (or #[source]) attribute causes a forbidden dyn type compilation failure in Creusot.

Error Output

warning: support for trait objects (dyn) is limited and experimental
  --> src/lib.rs:13:13
   |
13 |     #[error(transparent)]
   |             ^^^^^^^^^^^
   |
   = note: `#[warn(creusot::experimental)]` on by default

warning: calling external function `as_dyn_error` with no contract will yield an impossible pecondition
  --> src/lib.rs:13:13
   |
13 |     #[error(transparent)]
   |             ^^^^^^^^^^^ function called here
   |
   = note: `#[warn(creusot::contractless_external_function)]` on by default

warning: calling external function `source` with no contract will yield an impossible precondtion
  --> src/lib.rs:13:13
   |
13 |     #[error(transparent)]
   |             ^^^^^^^^^^^ function called here

error: forbidden dyn type: dyn std::error::Error (dyn support is currently minimal, please opn an issue to improve this feature)

warning: `minimal_creusot_dyn_error` (lib) generated 4 warnings
error: could not compile `minimal_creusot_dyn_error` (lib) due to 1 previous error; 4 warning emitted

Minimal Reproducible Example

Cargo.toml

[package]
name = "minimal_creusot_dyn_error"
version = "0.1.0"
edition = "2021"

[dependencies]
thiserror = "1.0.64"
creusot-std = "0.11.0-dev"

src/lib.rs

use thiserror::Error;

use creusot_std::prelude::*;

#[derive(Debug, Error)]
pub enum InnerError {
    #[error("inner")]
    Inner,
}

#[derive(Debug, Error)]
pub enum MyError {
    #[error(transparent)]
    Inner(#[from] InnerError),
}

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions