Fix for issue #811 (falsely inserted "::" in paths with parameterized trait cast).

This commit is contained in:
Vincent Esche 2016-03-01 16:39:43 +01:00
parent 65bc5c242d
commit a0567d4063
3 changed files with 40 additions and 1 deletions

View file

@ -53,7 +53,7 @@ pub fn rewrite_path(context: &RewriteContext,
// 3 = ">::".len()
let budget = try_opt!(width.checked_sub(extra_offset + 3));
result = try_opt!(rewrite_path_segments(expr_context,
result = try_opt!(rewrite_path_segments(false,
result,
path.segments.iter().take(skip_count),
span_lo,

19
tests/source/issue-811.rs Normal file
View file

@ -0,0 +1,19 @@
trait FooTrait<T>: Sized {
type Bar: BarTrait<T>;
}
trait BarTrait<T>: Sized {
type Baz;
fn foo();
}
type Foo<T: FooTrait> = <<T as FooTrait<U>>::Bar as BarTrait<U>>::Baz;
type Bar<T: BarTrait> = <T as BarTrait<U>>::Baz;
fn some_func<T: FooTrait<U>, U>() {
<<T as FooTrait<U>>::Bar as BarTrait<U>>::foo();
}
fn some_func<T: BarTrait<U>>() {
<T as BarTrait<U>>::foo();
}

20
tests/target/issue-811.rs Normal file
View file

@ -0,0 +1,20 @@
trait FooTrait<T>: Sized {
type Bar: BarTrait<T>;
}
trait BarTrait<T>: Sized {
type Baz;
fn foo();
}
type Foo<T: FooTrait> =
<<T as FooTrait<U>>::Bar as BarTrait<U>>::Baz;
type Bar<T: BarTrait> = <T as BarTrait<U>>::Baz;
fn some_func<T: FooTrait<U>, U>() {
<<T as FooTrait<U>>::Bar as BarTrait<U>>::foo();
}
fn some_func<T: BarTrait<U>>() {
<T as BarTrait<U>>::foo();
}