Skip to content

Build error on enum with type parameter after upgrading from 0.4.5 to 0.5.5 #67

@john-h-kastner-aws

Description

@john-h-kastner-aws

I'm encountering a build error I can't figure out when attempting to upgrade from version 0.4.5 to version 0.5.5. I've managed to reproduce this issue in a minimal example.

I see no errors building this Rust file using tsify 0.4.5 as specified by the Cargo.toml

extern crate tsify;

#[derive(serde::Serialize, tsify::Tsify)]
#[tsify(into_wasm_abi)]
pub enum Enum<T = ()> {
    Unit(std::marker::PhantomData<T>),
}

fn main() {}
[package]
name = "tsify-test"
version = "0.1.0"
edition = "2024"

[dependencies]
serde = {version = "1.0.219", features = ["serde_derive"]}
tsify = "0.4.5"
wasm-bindgen = "0.2.100"

If I update to tsify = "0.5.5", I now see a build error.

    Updating crates.io index
     Locking 4 packages to latest Rust 1.88.0 compatible versions
    Updating gloo-utils v0.1.7 -> v0.2.0
    Updating serde_derive_internals v0.28.0 -> v0.29.1
    Updating tsify v0.4.5 -> v0.5.5
    Updating tsify-macros v0.4.5 -> v0.5.5
   Compiling tsify-test v0.1.0 (/Users/jkastner/tsify-test)
error[E0229]: associated item constraints are not allowed here
 --> src/main.rs:5:15
  |
5 | pub enum Enum<T = ()> {
  |               ^^^^^^ associated item constraint not allowed here
  |
help: to use `()` as a generic argument specify it directly
  |
5 - pub enum Enum<T = ()> {
5 + pub enum Enum<()> {
  |

For more information about this error, try `rustc --explain E0229`.
error: could not compile `tsify-test` (bin "tsify-test") due to 4 previous errors

I have not been able to find a workaround for this, so we're staying on 0.4.5 for the moment.

For full context see this PR cedar-policy/cedar#1719 and the relevant enum in our repository.

https://github.com/cedar-policy/cedar/blob/1bc364953e91110362eaa0fd3465ed6de0a6be9a/cedar-policy-core/src/entities/json/value.rs#L929-L950

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions