Skip to content

test case for closed bug now causes ICE #5946

Closed

Description

@jbclements

The test case for issue #3979 was xfailed (and didn't parse), but that issue is closed, so I fixed up the syntax and ran it... and now it causes an ICE. I've committed the updated test, but it may be a while before that winds up in incoming, so I'll paste the text of the test here too:

// xfail-test
trait Positioned<S> {
  fn SetX(&mut self, S);
  fn X(&self) -> S;
}

#[allow(default_methods)]
trait Movable<S, T>: Positioned<T> {
  fn translate(&self, dx: T) {
    self.SetX(self.X() + dx);
  }
}

struct Point { x: int, y: int }

impl Positioned<int> for Point {
    fn SetX(&mut self, x: int) {
        self.x = x;
    }
    fn X(&self) -> int {
        self.x
    }
}

impl Movable<int, int> for Point;

pub fn main() {
    let p = Point{ x: 1, y: 2};
    p.translate(3);
    assert!(p.X() == 4);
}

Activity

  1. metajack commented on Jun 11, 2013

    @metajack
    Contributor

    @jbclements Is this sufficiently serious to warrant nominating?

  2. emberian commented on Jun 22, 2013

    @emberian
    Contributor

    Still a bug.

  3. emberian commented on Jun 22, 2013

    @emberian
    Contributor
  4. jbclements commented on Jul 8, 2013

    @jbclements
    ContributorAuthor

    Oog... I should have recorded the ICE. Now I get this compilation error:

    Running /usr/local/bin/rustc:
    /tmp/ggg.rs:9:14: 9:27 error: binary operation + cannot be applied to type `U`
    /tmp/ggg.rs:9     self.SetX(self.X() + dx);
                                ^~~~~~~~~~~~~
    error: aborting due to previous error
    

    ... which might be because the ICE was fixed, or might be because something about the language changed to cause an earlier breakage. Sigh.

  5. msullivan commented on Jul 23, 2013

    @msullivan
    Contributor

    ICE isn't fixed.

  6. msullivan commented on Jul 23, 2013

    @msullivan
    Contributor

    OK, I think your latest failure is due to language changes, and the test can be updated. I think that the test case was xfailed because it was broken, due to #4396. I think that I fixed the reason that it was originally xfailed with previous default method work (although there still generics problems with supertraits that I am working on at the moment).

    Dropping the &muts and getting rid of the assignment in SetX makes the test pass. issue-3979-xcrate.rs has the same failure. issue-3979.rs, on the other hand, works fine, although it was xfailed with a comment saying it was because of "ICE with explicit self". That was added by @pcwalton while demuting the test suite, in 82062a6.

  7. msullivan commented on Jul 23, 2013

    @msullivan
    Contributor

    Here is an updated version of issue-3979-generics.rs:

    // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
    // file at the top-level directory of this distribution and at
    // http://rust-lang.org/COPYRIGHT.
    //
    // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
    // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
    // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
    // option. This file may not be copied, modified, or distributed
    // except according to those terms.
    
    trait Positioned<S> {
      fn SetX(&mut self, S);
      fn X(&self) -> S;
    }
    
    trait Movable<S: Add<S, S>>: Positioned<S> {
      fn translate(&mut self, dx: S) {
        self.SetX(self.X() + dx);
      }
    }
    
    struct Point { x: int, y: int }
    
    impl Positioned<int> for Point {
        fn SetX(&mut self, x: int) {
            self.x = x;
        }
        fn X(&self) -> int {
            self.x
        }
    }
    
    impl Movable<int> for Point;
    
    pub fn main() {
        let p = Point{ x: 1, y: 2};
        p.translate(3);
        assert_eq!(p.X(), 4);
    }
    
  8. msullivan commented on Jul 23, 2013

    @msullivan
    Contributor

    OK, got it. The ICE is occuring while trying to report a borrow check error in translate. The self.X() + dx needs to be hoisted out of the method call.

    I am going to fix the bugs in these tests, close this issue, and open a new one with a reduced test case for the real problem.

  9. added a commit that references this issue on Aug 28, 2020
  10. added a commit that references this issue on Aug 21, 2026
    a871da3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions