Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for member functions vanished in 0.7 #39

Open
cytrinox opened this issue Jan 2, 2024 · 1 comment
Open

Support for member functions vanished in 0.7 #39

cytrinox opened this issue Jan 2, 2024 · 1 comment

Comments

@cytrinox
Copy link

cytrinox commented Jan 2, 2024

I've used multiversion for many member functions but after upgrading to 0.7 I get compiler errors. Here is a MRE:

Compiling multiversion_7_bug v0.1.0 (/home/cytrinox/code/multiversion_7_bug)
error: cannot determine type of associated fn
 --> src/main.rs:7:13
  |
7 |     fn bar(&self) {
  |             ^^^^

error[E0599]: no method named `bar` found for struct `Foo` in the current scope
  --> src/main.rs:13:7
   |
3  | struct Foo {}
   | ---------- method `bar` not found for this struct
...
13 |     x.bar();
   |       ^^^ method not found in `Foo`

For more information about this error, try `rustc --explain E0599`.
error: could not compile `multiversion_7_bug` (bin "multiversion_7_bug") due to 2 previous errors

Example code:

use multiversion::multiversion;

struct Foo {}

impl Foo {
    #[multiversion(targets("x86_64+avx+avx2", "x86+sse", "aarch64+neon"))]
    fn bar(&self) {
    }
}

fn main() {
    let x = Foo {};
    x.bar();
    println!("Hello, world!");
}
@calebzulawski
Copy link
Owner

I unfortunately had to remove support for functions that took self or referenced Self: https://github.com/calebzulawski/multiversion/releases/tag/0.7.0

The previous implementation was buggy and conflicted with other changes necessary for the 0.7 release. You could workaround this with something like:

impl Foo {
    fn foo(self) {
        #[multiversion(...)]
        fn foo(_self: Foo) {
            /* use _self as self */
        }
        foo(self)
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants