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

Calling default methods on type parameters that are type parameterized traits does not work #4102

Closed
brson opened this Issue Dec 3, 2012 · 8 comments

Comments

Projects
None yet
4 participants
@brson
Contributor

brson commented Dec 3, 2012

Up-to-date (forward-ported) test case

trait A<T> {
    fn g(x: T) -> T { x }
}

impl A<int> for int { }

fn f<T, V: A<T>>(i: V, j: T) -> T {
    i.g(j)
}

fn main () {
    fail_unless!(f(0, 2) == 2);
}

Original Report

This assumes #4101 is merged. Fails in trans because substs for the parameterized trait A are not handled correctly.

trait A<T> {
    fn g(x: T) -> T { move x }
}

impl int: A<int> { }

fn f<T, V: A<T>>(i: V, j: T) -> T {
    i.g(move j)
}

fn main () {
    assert f(0, 2) == 2;
}
@catamorphism

This comment has been minimized.

Show comment
Hide comment
@catamorphism

catamorphism Feb 21, 2013

Contributor

Reproduced as of eed2ca6

Contributor

catamorphism commented Feb 21, 2013

Reproduced as of eed2ca6

@pnkfelix

This comment has been minimized.

Show comment
Hide comment
@pnkfelix

pnkfelix Mar 25, 2013

Member

Reproduced as of c202430

Member

pnkfelix commented Mar 25, 2013

Reproduced as of c202430

@pnkfelix

This comment has been minimized.

Show comment
Hide comment
@pnkfelix

pnkfelix Mar 25, 2013

Member

Not critical for 0.6; de-milestoning

Member

pnkfelix commented Mar 25, 2013

Not critical for 0.6; de-milestoning

@catamorphism

This comment has been minimized.

Show comment
Hide comment
@catamorphism

catamorphism May 24, 2013

Contributor

Nominating for milestone 5, production-ready

Contributor

catamorphism commented May 24, 2013

Nominating for milestone 5, production-ready

@msullivan

This comment has been minimized.

Show comment
Hide comment
@msullivan

msullivan Jun 7, 2013

Contributor

Fails in typecheck now...

Contributor

msullivan commented Jun 7, 2013

Fails in typecheck now...

@msullivan

This comment has been minimized.

Show comment
Hide comment
@msullivan

msullivan Jun 7, 2013

Contributor

Oh, wait, that is because implicit self is gone. It still fails in trans.

#[allow(default_methods)];

trait A<T> {
    fn g(&self, x: T) -> T { x }
}

impl A<int> for int { }

fn f<T, V: A<T>>(i: V, j: T) -> T {
    i.g(j)
}

fn main () {
    assert!(f(0, 2) == 2);
}

is an updated version

Contributor

msullivan commented Jun 7, 2013

Oh, wait, that is because implicit self is gone. It still fails in trans.

#[allow(default_methods)];

trait A<T> {
    fn g(&self, x: T) -> T { x }
}

impl A<int> for int { }

fn f<T, V: A<T>>(i: V, j: T) -> T {
    i.g(j)
}

fn main () {
    assert!(f(0, 2) == 2);
}

is an updated version

@msullivan

This comment has been minimized.

Show comment
Hide comment
@msullivan

msullivan Jun 15, 2013

Contributor

Marking that this is part of #2794 for tracking purposes.

Contributor

msullivan commented Jun 15, 2013

Marking that this is part of #2794 for tracking purposes.

@msullivan

This comment has been minimized.

Show comment
Hide comment
@msullivan

msullivan Jun 15, 2013

Contributor

I claimed that I fixed this in an earlier commit, but I found another case that could cause a similar failure. Will be pushing a fix soon.

Contributor

msullivan commented Jun 15, 2013

I claimed that I fixed this in an earlier commit, but I found another case that could cause a similar failure. Will be pushing a fix soon.

bors added a commit that referenced this issue Jun 21, 2013

auto merge of #7203 : msullivan/rust/default-methods, r=graydon
This fixes the large number of problems that prevented cross crate
methods from ever working. It also fixes a couple lingering bugs with
polymorphic default methods and cleans up some of the code paths.

Closes #4102. Closes #4103.

r? nikomatsakis

@msullivan msullivan closed this in 1a8969f Jun 21, 2013

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