Skip to content

Commit 3ba66df

Browse files
authored
Rollup merge of #112906 - fmease:rustdoc-render-assoc-ty-body-before-where-clause, r=notriddle
rustdoc: render the body of associated types before the where-clause Fixes #112903.
2 parents cc93c5f + b866113 commit 3ba66df

File tree

2 files changed

+4
-3
lines changed
  • src/librustdoc/html/render
  • tests/rustdoc/generic-associated-types

2 files changed

+4
-3
lines changed

src/librustdoc/html/render/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -799,10 +799,11 @@ fn assoc_type(
799799
if !bounds.is_empty() {
800800
write!(w, ": {}", print_generic_bounds(bounds, cx))
801801
}
802-
write!(w, "{}", print_where_clause(generics, cx, indent, Ending::NoNewline));
802+
// Render the default before the where-clause which aligns with the new recommended style. See #89122.
803803
if let Some(default) = default {
804804
write!(w, " = {}", default.print(cx))
805805
}
806+
write!(w, "{}", print_where_clause(generics, cx, indent, Ending::NoNewline));
806807
}
807808

808809
fn assoc_method(

tests/rustdoc/generic-associated-types/gats.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ impl LendingIterator for () {
2323
pub struct Infinite<T>(T);
2424

2525
// @has foo/trait.LendingIterator.html
26-
// @has - '//*[@id="associatedtype.Item-2"]//h4[@class="code-header"]' "type Item<'a> where Self: 'a = &'a T"
26+
// @has - '//*[@id="associatedtype.Item-2"]//h4[@class="code-header"]' "type Item<'a> = &'a T where Self: 'a"
2727
impl<T> LendingIterator for Infinite<T> {
28-
type Item<'a> where Self: 'a = &'a T;
28+
type Item<'a> = &'a T where Self: 'a;
2929

3030
fn next<'a>(&'a self) -> Self::Item<'a> {
3131
&self.0

0 commit comments

Comments
 (0)