Skip to content

Incorrect types shown in an error when using rhai #120416

@Cerber-Ursi

Description

@Cerber-Ursi

Code

use std::{cell::RefCell, rc::Rc}; struct Wrapper { // this part is important - if this field is commented out, error disappears engine: rhai::Engine, // this is what actually triggers the diagnostic ctx: Rc<RefCell<()>>, } fn main() { let _ = Wrapper { engine: rhai::Engine::new_raw(), ctx: (), }; }

Current output

error[E0308]: mismatched types --> src/main.rs:13:14 | 13 | ctx: (), | ^^ expected `Shared<Locked<()>>`, found `()`  |  = note: expected struct `Rc<Locked<()>>`  found unit type `()`

Desired output

error[E0308]: mismatched types --> src/main.rs:13:14 | 13 | ctx: (), | ^^ expected `Rc<RefCell<()>>`, found `()`  |  = note: expected struct `Rc<RefCell<()>>`  found unit type `()`

Rationale and extra context

No response

Other cases

No response

Rust Version

rustc 1.75.0 (82e1608df 2023-12-21) binary: rustc commit-hash: 82e1608dfa6e0b5569232559e3d385fea5a93112 commit-date: 2023-12-21 host: x86_64-unknown-linux-gnu release: 1.75.0 LLVM version: 17.0.6

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions