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

Cannot use &Trait as argument for generic functions #4469

Closed
14427 opened this issue Jan 13, 2013 · 2 comments
Closed

Cannot use &Trait as argument for generic functions #4469

14427 opened this issue Jan 13, 2013 · 2 comments
Labels
A-trait-system Area: Trait system A-type-system Area: Type system
Milestone

Comments

@14427
Copy link
Contributor

14427 commented Jan 13, 2013

This code fails to compile

trait Foo {
    fn bar(&self);
}

impl int: Foo {
    fn bar(&self) { }
}

fn test<T: Foo>(arr: T) { }

fn main() {
    let x = 5;
    test(&x as &Foo);
}

with: mismatched types: expected@foobut found&/Foo(trait storage differs: expected @ but found &)

This is with the current master.

@catamorphism
Copy link
Contributor

May be related to #3794

@ghost ghost assigned catamorphism Feb 20, 2013
@pcwalton
Copy link
Contributor

This is by design.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-trait-system Area: Trait system A-type-system Area: Type system
Projects
None yet
Development

No branches or pull requests

3 participants