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

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

Closed
catamorphism opened this issue Jan 9, 2013 · 5 comments
Labels
A-traits Area: Trait system

Comments

@catamorphism
Copy link
Contributor

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
Copy link
Contributor

Not critical for 0.6; removing milestone

@catamorphism
Copy link
Contributor Author

Nominating for milestone 5, production-ready

@msullivan
Copy link
Contributor

I don't really understand what this bug is.

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

@pnkfelix
Copy link
Member

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

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

msullivan added a commit to msullivan/rust that referenced this issue Jul 24, 2013
Eliminates method_super, method_self, and vtable_self, merging all of
them into the param cases.
Cloes rust-lang#4396. Closes rust-lang#7301.
@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
Labels
A-traits Area: Trait system
Projects
None yet
Development

No branches or pull requests

4 participants