Skip to content

Commit a0567d4

Browse files
committed
Fix for issue #811 (falsely inserted "::" in paths with parameterized trait cast).
1 parent 65bc5c2 commit a0567d4

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

src/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub fn rewrite_path(context: &RewriteContext,
5353
// 3 = ">::".len()
5454
let budget = try_opt!(width.checked_sub(extra_offset + 3));
5555

56-
result = try_opt!(rewrite_path_segments(expr_context,
56+
result = try_opt!(rewrite_path_segments(false,
5757
result,
5858
path.segments.iter().take(skip_count),
5959
span_lo,

tests/source/issue-811.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
trait FooTrait<T>: Sized {
2+
type Bar: BarTrait<T>;
3+
}
4+
5+
trait BarTrait<T>: Sized {
6+
type Baz;
7+
fn foo();
8+
}
9+
10+
type Foo<T: FooTrait> = <<T as FooTrait<U>>::Bar as BarTrait<U>>::Baz;
11+
type Bar<T: BarTrait> = <T as BarTrait<U>>::Baz;
12+
13+
fn some_func<T: FooTrait<U>, U>() {
14+
<<T as FooTrait<U>>::Bar as BarTrait<U>>::foo();
15+
}
16+
17+
fn some_func<T: BarTrait<U>>() {
18+
<T as BarTrait<U>>::foo();
19+
}

tests/target/issue-811.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
trait FooTrait<T>: Sized {
2+
type Bar: BarTrait<T>;
3+
}
4+
5+
trait BarTrait<T>: Sized {
6+
type Baz;
7+
fn foo();
8+
}
9+
10+
type Foo<T: FooTrait> =
11+
<<T as FooTrait<U>>::Bar as BarTrait<U>>::Baz;
12+
type Bar<T: BarTrait> = <T as BarTrait<U>>::Baz;
13+
14+
fn some_func<T: FooTrait<U>, U>() {
15+
<<T as FooTrait<U>>::Bar as BarTrait<U>>::foo();
16+
}
17+
18+
fn some_func<T: BarTrait<U>>() {
19+
<T as BarTrait<U>>::foo();
20+
}

0 commit comments

Comments
 (0)