Skip to content

combining explicit self and closures yields an LLVM failure #3247

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

Closed
nikomatsakis opened this issue Aug 22, 2012 · 1 comment
Closed

combining explicit self and closures yields an LLVM failure #3247

nikomatsakis opened this issue Aug 22, 2012 · 1 comment
Labels
A-codegen Area: Code generation I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@nikomatsakis
Copy link
Contributor

Example test:

struct Box {
    x: uint;
}

impl Box {
    fn set_many(&mut self, xs: &[uint]) {
        for xs.each |x| {
            self.x = x;
        }
    }
}

fn main() {}

I presume this is because the type is obtained by taking the type associated with the node-id of the free variable, which is a def_self that is probably generic to the impl, and not specialized to the method. The quick fix is to patch that code, perhaps the better fix is to have a distinct self-id per method? Not sure. It seems wrong to be baking in "if this is self, do something special" all over the place.

@msullivan you may have an opinion.

@ghost ghost assigned msullivan Aug 22, 2012
@msullivan
Copy link
Contributor

We do have a distinct self-id per method, as it turns out, but the type of it was tracked differently than regular variables, and as a result I missed updating it when explicit self went in. I'm fixing things to track the type of self in a more normal way.

jaisnan pushed a commit to jaisnan/rust-dev that referenced this issue Jul 29, 2024
This change adds "unused_mut" to the list of suppressed lints for
wrappers generated by the contracts macros. This will get rid of
spurious errors caused by mutable parameters to functions.

This fixes the example from
model-checking/kani#3010 .

It can be tested by adding the example from the issues to
tests/expected/test_macros/gcd.rs, creating a file
tests/expected/test_macros/gcd.expected, then running
```bash
cargo build-dev
RUST_BACKTRACE=1 cargo run -p compiletest -- --logfile logfile.txt --suite expected --mode expected --ignored --no-fail-fast --src-base tests/expected/test_macros
 ```
 
 RESOLVES rust-lang#3010 

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.

---------

Co-authored-by: Jacob Salzberg <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

2 participants