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

Calls to generic inherited methods don't work, at least in default methods #4396

Closed
catamorphism opened this Issue Jan 9, 2013 · 5 comments

Comments

Projects
None yet
4 participants
@catamorphism
Contributor

catamorphism commented Jan 9, 2013

I'm about to upload an xfailed test case for this as part of my pull request for #3979.

@ghost ghost assigned catamorphism Jan 9, 2013

@nikomatsakis

This comment has been minimized.

Show comment
Hide comment
@nikomatsakis

nikomatsakis Mar 25, 2013

Contributor

Not critical for 0.6; removing milestone

Contributor

nikomatsakis commented Mar 25, 2013

Not critical for 0.6; removing milestone

@catamorphism

This comment has been minimized.

Show comment
Hide comment
@catamorphism

catamorphism May 23, 2013

Contributor

Nominating for milestone 5, production-ready

Contributor

catamorphism commented May 23, 2013

Nominating for milestone 5, production-ready

@msullivan

This comment has been minimized.

Show comment
Hide comment
@msullivan

msullivan Jun 12, 2013

Contributor

I don't really understand what this bug is.

Edit: nevermind, I found the test case, which is issue-3979-generics.rs.

Contributor

msullivan commented Jun 12, 2013

I don't really understand what this bug is.

Edit: nevermind, I found the test case, which is issue-3979-generics.rs.

@pnkfelix

This comment has been minimized.

Show comment
Hide comment
@pnkfelix

pnkfelix Jun 16, 2013

Member

Blocks #2794 (referencing here so that it shows up, with a status, on the #2794 page).

Member

pnkfelix commented Jun 16, 2013

Blocks #2794 (referencing here so that it shows up, with a status, on the #2794 page).

@msullivan

This comment has been minimized.

Show comment
Hide comment
@msullivan

msullivan Jul 23, 2013

Contributor

Once I get the test case for this fixed up, the test passes. There are still problems, though. The following test won't pass:

// 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.

// There is some other borrowck bug, so we make the stuff not mut.

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) {
    let x = self.X() + dx;
    self.SetX(x);
  }
}

struct Point<S> { x: S, y: S }

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

impl<S: Clone + Add<S, S>> Movable<S> for Point<S>;

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

(Although it will soon.)

Contributor

msullivan commented Jul 23, 2013

Once I get the test case for this fixed up, the test passes. There are still problems, though. The following test won't pass:

// 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.

// There is some other borrowck bug, so we make the stuff not mut.

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) {
    let x = self.X() + dx;
    self.SetX(x);
  }
}

struct Point<S> { x: S, y: S }

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

impl<S: Clone + Add<S, S>> Movable<S> for Point<S>;

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

(Although it will soon.)

msullivan added a commit to msullivan/rust that referenced this issue Jul 24, 2013

Major rework of how calls to self and super methods work.
Eliminates method_super, method_self, and vtable_self, merging all of
them into the param cases.
Cloes #4396. Closes #7301.

@msullivan msullivan closed this Jul 25, 2013

@catamorphism catamorphism removed their assignment Jun 16, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment