Skip to content

Commit 06304ed

Browse files
author
Ulrik Sverdrup
committed
rustdoc: Show where clauses in type aliases
Yes, it's allowed. Example: type MapFn<I, B> where I: Iterator = Map<I, fn(I::Item) -> B>; Fixes #25769
1 parent d1cd689 commit 06304ed

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/librustdoc/html/render.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2429,10 +2429,11 @@ fn render_impl(w: &mut fmt::Formatter, i: &Impl, link: AssocItemLink,
24292429

24302430
fn item_typedef(w: &mut fmt::Formatter, it: &clean::Item,
24312431
t: &clean::Typedef) -> fmt::Result {
2432-
try!(write!(w, "<pre class='rust typedef'>type {}{} = {};</pre>",
2432+
try!(write!(w, "<pre class='rust typedef'>type {}{}{where_clause} = {type_};</pre>",
24332433
it.name.as_ref().unwrap(),
24342434
t.generics,
2435-
t.type_));
2435+
where_clause = WhereClause(&t.generics),
2436+
type_ = t.type_));
24362437

24372438
document(w, it)
24382439
}

src/test/rustdoc/where.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,7 @@ pub enum Foxtrot<F> { Foxtrot1(F) }
4242
// @has foo/trait.MyTrait.html '//*[@id="implementors-list"]//code' \
4343
// "impl<F> MyTrait for Foxtrot<F> where F: MyTrait"
4444
impl<F> MyTrait for Foxtrot<F> where F: MyTrait {}
45+
46+
// @has foo/type.Golf.html '//pre[@class="rust typedef"]' \
47+
// "type Golf<T> where T: Clone = (T, T)"
48+
pub type Golf<T> where T: Clone = (T, T);

0 commit comments

Comments
 (0)