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

Operator overloading without implementing the respective trait #3820

Closed
Blei opened this issue Oct 20, 2012 · 2 comments
Closed

Operator overloading without implementing the respective trait #3820

Blei opened this issue Oct 20, 2012 · 2 comments
Labels
A-type-system Area: Type system I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Milestone

Comments

@Blei
Copy link
Contributor

Blei commented Oct 20, 2012

Apparently it is enough to write an anonymous implementation with the correct function name and signature to get the compiler to spit out operator overloading:

struct Thing {
    x: int
}

// Look ma, no Mul!
impl Thing/*: Mul<int, Thing>*/ {
    pure fn mul(c: &int) -> Thing {
        Thing {x: self.x * *c}
    }
}

fn main() {
    let u = Thing {x: 2};
    let _v = u.mul(&3); // Works
    let w = u * 3; // Works!!
    io::println(fmt!("%i", w.x));

    /*
    // This doesn't work though.
    let u2 = u as @Mul<int, Thing>;
    let w2 = u2.mul(&4);
    io::println(fmt!("%i", w2.x));
    */
}

This is probably not intended? And it leads to nasty ICEs when the function name fits, but the function signature doesn't (eg. pure fn mul(c: int) -> Thing, no reference).

@catamorphism
Copy link
Contributor

Reproduced with 737e115

@catamorphism
Copy link
Contributor

This is fixed, I'll shortly un-xfail the test case.

RalfJung pushed a commit to RalfJung/rust that referenced this issue Aug 18, 2024
Add epollerr support

Fixes rust-lang#3816

For socketpair, if the peer fd is closed while having data in its read buffer, ``EPOLLER`` will be thrown.

This is still WIP because I am currently finding a way to check if peer fd still has something in its ``readbuf`` when it is closed and add the ``EPOLLER`` flag In ``get_epoll_ready_events``.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-type-system Area: Type system I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

2 participants