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

ICE when using += with a struct field with generic type #6738

Closed
MaikKlein opened this issue May 25, 2013 · 4 comments · Fixed by #12738
Closed

ICE when using += with a struct field with generic type #6738

MaikKlein opened this issue May 25, 2013 · 4 comments · Fixed by #12738
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@MaikKlein
Copy link
Contributor

https://gist.github.com/MaikKlein/5650864

@emberian
Copy link
Member

emberian commented Aug 5, 2013

Updated:

struct Vec3<T> {
    x: T,
    y: T,
    z: T
}
impl<T: Add<T,T>+Clone> Vec3<T> {
    fn add(&mut self,v: Vec3<T>){
        self.x += v.x.clone();
        self.y += v.y.clone();
        self.z += v.z.clone();
    }
}
fn main() {
    let mut v1 : Vec3<int> = Vec3{x: 1,y: 1,z: 1,};
    let v2 : Vec3<int> = Vec3{x: 1,y: 1,z: 1,};
    v1.add(v2);
}

yields

foo.rs:8:8: 8:30 error: binary operation + cannot be applied to type `T`
foo.rs:8         self.x += v.x.clone();
                 ^~~~~~~~~~~~~~~~~~~~~~
foo.rs:9:8: 9:30 error: binary operation + cannot be applied to type `T`
foo.rs:9         self.y += v.y.clone();
                 ^~~~~~~~~~~~~~~~~~~~~~
foo.rs:10:8: 10:30 error: binary operation + cannot be applied to type `T`
foo.rs:10         self.z += v.z.clone();
                  ^~~~~~~~~~~~~~~~~~~~~~
error: internal compiler error: no type for node 36: callee_scope v.x.clone() (id=36) in fcx 7fd2bc7f4090

@pnkfelix
Copy link
Member

pnkfelix commented Aug 8, 2013

Visited for bug triage email 2013-07-29.

Updated bug title to be more descriptive.

Bug still replicates on rustc 0.8-pre (7b2163d 2013-08-05 00:56:00 -0700)

@huonw
Copy link
Member

huonw commented Jan 3, 2014

Triage, still a bug. Minimal example:

struct Foo<T> {
    x: T,
}
impl<T> Foo<T> {
    fn add(&mut self, v: Foo<T>){
        self.x += v.x;
    }
}
fn main() {}

Changing v to just be T and writing self.x += v doesn't show the ICE, but changing it to

    fn add(&self, v: &mut T){
        v += self.x;
    }

does. (Also using + instead of += doesn't ICE; changing the title to be more-r descriptive.)

@luqmana
Copy link
Member

luqmana commented Mar 4, 2014

Cannot reproduce ICE. It just errors out:

-> % rustc 6738.rs
6738.rs:6:9: 6:22 error: binary assignment operation `+=` cannot be applied to type `T`
6738.rs:6         self.x += v.x;
                  ^~~~~~~~~~~~~
error: aborting due to previous error

With rustc 0.10-pre (6e7f170 2014-03-03 05:51:38 -0800). Flagging as needs-test.

bors added a commit that referenced this issue Mar 6, 2014
Closes #6738
Closes #7061
Closes #7899
Closes #9719
Closes #10028
Closes #10228
Closes #10401
Closes #11192
Closes #11508
Closes #11529
Closes #11873
Closes #11925
flip1995 pushed a commit to flip1995/rust that referenced this issue Feb 25, 2021
…e-files, r=flip1995

Update labels in template files

It seems like we forgot to update the GitHub templates when we decided to update the label names. This PR just adjusts the templates to use the new label names :)

Context: [Zulip discussion about renaming the labels](https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/Label.20cleanup/near/224083870)

---

changelog: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants