// issue 8134
struct Foo;
-impl<T> Foo {
- pub fn foo(&self) {
+impl Foo {
+ pub fn foo<T>(&self) {
static X: uint = 1;
}
}
}
struct Bar;
-impl<T> Foo {
- pub fn bar(&self) {
+impl Foo {
+ pub fn bar<T>(&self) {
static X: uint = 1;
}
}
// aux-build:coherence-lib.rs
extern crate "coherence-lib" as lib;
-use lib::Remote;
+use lib::Remote1;
-impl<T> Remote for int { }
+impl<T> Remote1<T> for int { }
//~^ ERROR E0117
fn main() { }
fn result(&self) -> u64;
}
-trait StreamHasher<S: Stream> {
- fn stream(&self) -> S;
+trait StreamHasher {
+ type S : Stream;
+ fn stream(&self) -> Self::S;
}
//////////////////////////////////////////////////////////////////////////////
-trait StreamHash<S: Stream, H: StreamHasher<S>>: Hash<H> {
- fn input_stream(&self, stream: &mut S);
+trait StreamHash<H: StreamHasher>: Hash<H> {
+ fn input_stream(&self, stream: &mut H::S);
}
-impl<S: Stream, H: StreamHasher<S>> Hash<H> for u8 {
+impl<H: StreamHasher> Hash<H> for u8 {
fn hash2(&self, hasher: &H) -> u64 {
let mut stream = hasher.stream();
self.input_stream(&mut stream); //~ ERROR type annotations required
- stream.result()
+ Stream::result(&stream)
}
}
-impl<S: Stream, H: StreamHasher<S>> StreamHash<S, H> for u8 {
- fn input_stream(&self, stream: &mut S) {
- stream.input(&[*self]);
+impl<H: StreamHasher> StreamHash<H> for u8 {
+ fn input_stream(&self, stream: &mut H::S) {
+ Stream::input(&*stream, &[*self]);
}
}
}
impl<'a, T: Deserializable> Deserializable for &'a str {
- //~^ ERROR unable to infer enough type information
+ //~^ ERROR type parameter `T` is not constrained
fn deserialize_token<D: Deserializer<'a>>(_x: D, _y: &'a str) -> &'a str {
}
}
trait Collection { fn len(&self) -> uint; }
impl<T, M: MatrixShape> Collection for Col<M, uint> {
-//~^ ERROR unable to infer enough type information
+//~^ ERROR type parameter `T` is not constrained
fn len(&self) -> uint {
unimplemented!()
}
}
// Right-hand-side operator visitor pattern
-trait RhsOfVec2Mul<Result> { fn mul_vec2_by(&self, lhs: &Vec2) -> Result; }
+trait RhsOfVec2Mul {
+ type Result;
+
+ fn mul_vec2_by(&self, lhs: &Vec2) -> Self::Result;
+}
// Vec2's implementation of Mul "from the other side" using the above trait
-impl<Res, Rhs: RhsOfVec2Mul<Res>> Mul<Rhs> for Vec2 {
+impl<Res, Rhs: RhsOfVec2Mul<Result=Res>> Mul<Rhs> for Vec2 {
type Output = Res;
fn mul(self, rhs: Rhs) -> Res { rhs.mul_vec2_by(&self) }
}
// Implementation of 'f64 as right-hand-side of Vec2::Mul'
-impl RhsOfVec2Mul<Vec2> for f64 {
+impl RhsOfVec2Mul for f64 {
+ type Result = Vec2;
+
fn mul_vec2_by(&self, lhs: &Vec2) -> Vec2 { lhs.vmul(*self) }
}