Skip to content

Can not use vm_result on function taking &mut self #752

Open
@VorpalBlade

Description

@VorpalBlade

The following function:

    #[rune::function(vm_result, instance)]
    fn stdin(&mut self) -> Option<ChildStdin> {
        let inner = match &mut self.inner {
            Some(inner) => inner,
            None => {
                rune::vm_panic!("already completed");
            }
        };
        let stdin = inner.stdin.take()?;
        Some(ChildStdin { inner: stdin })
    }

gives the following error:

error[E0308]: mismatched types
   --> crates/konfigkoll_script/src/plugins/process.rs:176:17
    |
176 |                 rune::vm_panic!("already completed");
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Option<ChildStdout>`, found `VmResult<_>`
    |
    = note: expected enum `std::option::Option<plugins::process::ChildStdout>`
               found enum `VmResult<_>`
    = note: this error originates in the macro `rune::vm_panic` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
   --> crates/konfigkoll_script/src/plugins/process.rs:191:17
    |
191 |                 rune::vm_panic!("already completed");
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Option<ChildStderr>`, found `VmResult<_>`
    |
    = note: expected enum `std::option::Option<plugins::process::ChildStderr>`
               found enum `VmResult<_>`
    = note: this error originates in the macro `rune::vm_panic` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E0308`.
error: could not compile `konfigkoll_script` (lib) due to 4 previous errors

Removing the vm_result and the vm_panic makes it compile.

This is the latest on the 0.13 branch

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions