Skip to content

Using Rc<dyn AnyValue> as an attribute value causes unreachable code to be hit and panics #5240

@mcmah309

Description

@mcmah309

Problem

04:09:20 [web] panicked at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/dioxus-web-0.7.3/src/mutations.rs:211:18:
internal error: entered unreachable code

Stack:

Error
    at http://127.0.0.1:33870/wasm/languna.js:968:25
    at logError (http://127.0.0.1:33870/wasm/languna.js:1834:18)
    at __wbg_new_00868141024267bc (http://127.0.0.1:33870/wasm/languna.js:967:57)
    at http://127.0.0.1:33870/wasm/languna_bg.wasm:wasm-function[25102]:0x3f2a79
    at http://127.0.0.1:33870/wasm/languna_bg.wasm:wasm-function[14529]:0x383d25
    at http://127.0.0.1:33870/wasm/languna_bg.wasm:wasm-function[3959]:0x244f92
    at http://127.0.0.1:33870/wasm/languna_bg.wasm:wasm-function[19054]:0x3bed22
    at http://127.0.0.1:33870/wasm/languna_bg.wasm:wasm-function[4762]:0x2701f4
    at http://127.0.0.1:33870/wasm/languna_bg.wasm:wasm-function[8443]:0x2ff5bd
    at http://127.0.0.1:33870/wasm/languna_bg.wasm:wasm-function[25573]:0x3f419a

Line:

_ => unreachable!(),

Reproducible fragment

let val = Rc::new(String::new()) as Rc<dyn dioxus_core::AnyValue>;
rsx! {
    iframe { srcdoc: val }
}

Originally I wanted to use Rc<str> instead of Rc<String> but it does not implement IntoAttributeValue since str is not Sized. So that is what lead me to this situation.

It seems the temporary solution is to use a String with cloning. For my use case, it is a fairly large String but it won't be hit often so it is not too big of a deal.

Expected behavior

Works with no panic or compiler error.

Environment:

  • Dioxus version: v0.7.3
  • Rust version: 1.93
  • OS info: linux
  • App platform: web

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions