Skip to content

test case for closed bug now causes ICE #5946

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
jbclements opened this issue Apr 18, 2013 · 8 comments
Closed

test case for closed bug now causes ICE #5946

jbclements opened this issue Apr 18, 2013 · 8 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@jbclements
Copy link
Contributor

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);
}
@metajack
Copy link
Contributor

@jbclements Is this sufficiently serious to warrant nominating?

@emberian
Copy link
Member

Still a bug.

@emberian
Copy link
Member

(@catamorphism)

@jbclements
Copy link
Contributor Author

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.

@msullivan
Copy link
Contributor

ICE isn't fixed.

@msullivan
Copy link
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.

@msullivan
Copy link
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);
}

@msullivan
Copy link
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.

flip1995 pushed a commit to flip1995/rust that referenced this issue Aug 28, 2020
Fix `let_and_return` bad suggestion

Add a cast to the suggestion when the return expression has adjustments.
These adjustments are lost when the suggestion is applied.

This is similar to the problem in issue rust-lang#4437.

Closes rust-lang#5729

changelog: Fix `let_and_return` bad suggestion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

4 participants