Skip to content

Instantly share code, notes, and snippets.

@alexcrichton
Last active December 11, 2015 14:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexcrichton/4617145 to your computer and use it in GitHub Desktop.
Save alexcrichton/4617145 to your computer and use it in GitHub Desktop.
trait Foo {
static fn foo(int) -> @self;
}
struct A { a: int }
impl A: Foo {
static fn foo(a: int) -> @A { @A{a: a} }
}
struct B { b: int }
impl<T: Foo> B {
fn bar(&self) -> T { T::foo(self.b) }
}
fn main() {
let b = B{ b: 0 };
let a : A = b.bar();
core::util::ignore(a);
}
~ $ rustc foo.rs
foo.rs:12:23: 12:29 error: unresolved name
foo.rs:12 fn bar(&self) -> T { T::foo(self.b) }
^~~~~~
foo.rs:12:23: 12:29 error: use of undeclared module `T`
foo.rs:12 fn bar(&self) -> T { T::foo(self.b) }
^~~~~~
foo.rs:12:23: 12:29 error: unresolved name: T::foo
foo.rs:12 fn bar(&self) -> T { T::foo(self.b) }
^~~~~~
error: aborting due to 3 previous errors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment