Skip to content

recursive use of an object detected which would lead to unsafe aliasing in rustΒ #1578

Closed
@dtysky

Description

@dtysky

Summary

Hi, I am porting the "gl-matrix" to webassembly with wasm-bindgen. In "gl-matrix", we can find lots of those methods:

// module vec3

function add(out, a, b) {
xxx
}

In most time, arguments "out" and "a" are same variable.

I implement it in rust and have built it to wasm:

impl Vector3 {
    pub fn add(out: &mut Vector3, a: &Vector3, b: &Vector3) {
xxx
}
}

It seems lt work fine, but after running these code:

const a = Vector3.create();
const b = Vector3.create();
Vector3.add(a, a, b);

Rust thrown an error:

debug.js:21 Error: recursive use of an object detected which would lead to unsafe aliasing in rust

Do you have any good idea to solve this problem? Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions