Skip to content

Commit

Permalink
rustdoc: move the cx argument to the end of the list
Browse files Browse the repository at this point in the history
This should help make things consistent.
  • Loading branch information
notriddle committed Apr 17, 2021
1 parent bb02048 commit 755b4fb
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 33 deletions.
26 changes: 13 additions & 13 deletions src/librustdoc/html/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ fn comma_sep<T: fmt::Display>(items: impl Iterator<Item = T>) -> impl fmt::Displ
}

crate fn print_generic_bounds<'a, 'tcx: 'a>(
cx: &'a Context<'tcx>,
bounds: &'a [clean::GenericBound],
cx: &'a Context<'tcx>,
) -> impl fmt::Display + 'a + Captures<'tcx> {
display_fn(move |f| {
let mut bounds_dup = FxHashSet::default();
Expand Down Expand Up @@ -155,9 +155,9 @@ impl clean::GenericParamDef {

if !bounds.is_empty() {
if f.alternate() {
write!(f, ": {:#}", print_generic_bounds(cx, bounds))?;
write!(f, ": {:#}", print_generic_bounds(bounds, cx))?;
} else {
write!(f, ":&nbsp;{}", print_generic_bounds(cx, bounds))?;
write!(f, ":&nbsp;{}", print_generic_bounds(bounds, cx))?;
}
}

Expand Down Expand Up @@ -239,13 +239,13 @@ crate fn print_where_clause<'a, 'tcx: 'a>(
clause.push_str(&format!(
"{:#}: {:#}",
ty.print(cx),
print_generic_bounds(cx, bounds)
print_generic_bounds(bounds, cx)
));
} else {
clause.push_str(&format!(
"{}: {}",
ty.print(cx),
print_generic_bounds(cx, bounds)
print_generic_bounds(bounds, cx)
));
}
}
Expand Down Expand Up @@ -819,9 +819,9 @@ fn fmt_type<'cx>(
}
clean::ImplTrait(ref bounds) => {
if f.alternate() {
write!(f, "impl {:#}", print_generic_bounds(cx, bounds))
write!(f, "impl {:#}", print_generic_bounds(bounds, cx))
} else {
write!(f, "impl {}", print_generic_bounds(cx, bounds))
write!(f, "impl {}", print_generic_bounds(bounds, cx))
}
}
clean::QPath { ref name, ref self_type, ref trait_ } => {
Expand Down Expand Up @@ -1013,21 +1013,21 @@ impl clean::FnDecl {
/// * `asyncness`: Whether the function is async or not.
crate fn full_print<'a, 'tcx: 'a>(
&'a self,
cx: &'a Context<'tcx>,
header_len: usize,
indent: usize,
asyncness: hir::IsAsync,
cx: &'a Context<'tcx>,
) -> impl fmt::Display + 'a + Captures<'tcx> {
display_fn(move |f| self.inner_full_print(cx, header_len, indent, asyncness, f))
display_fn(move |f| self.inner_full_print(header_len, indent, asyncness, f, cx))
}

fn inner_full_print(
&self,
cx: &Context<'_>,
header_len: usize,
indent: usize,
asyncness: hir::IsAsync,
f: &mut fmt::Formatter<'_>,
cx: &Context<'_>,
) -> fmt::Result {
let amp = if f.alternate() { "&" } else { "&amp;" };
let mut args = String::new();
Expand Down Expand Up @@ -1134,8 +1134,8 @@ impl clean::FnDecl {
impl clean::Visibility {
crate fn print_with_space<'a, 'tcx: 'a>(
self,
cx: &'a Context<'tcx>,
item_did: DefId,
cx: &'a Context<'tcx>,
) -> impl fmt::Display + 'a + Captures<'tcx> {
let to_print = match self {
clean::Public => "pub ".to_owned(),
Expand Down Expand Up @@ -1320,9 +1320,9 @@ impl clean::TypeBinding {
clean::TypeBindingKind::Constraint { ref bounds } => {
if !bounds.is_empty() {
if f.alternate() {
write!(f, ": {:#}", print_generic_bounds(cx, bounds))?;
write!(f, ": {:#}", print_generic_bounds(bounds, cx))?;
} else {
write!(f, ":&nbsp;{}", print_generic_bounds(cx, bounds))?;
write!(f, ":&nbsp;{}", print_generic_bounds(bounds, cx))?;
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/librustdoc/html/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,7 @@ fn assoc_const(
w,
"{}{}const <a href=\"{}\" class=\"constant\"><b>{}</b></a>: {}",
extra,
it.visibility.print_with_space(cx, it.def_id),
it.visibility.print_with_space(it.def_id, cx),
naive_assoc_href(it, link, cx),
it.name.as_ref().unwrap(),
ty.print(cx)
Expand All @@ -839,7 +839,7 @@ fn assoc_type(
it.name.as_ref().unwrap()
);
if !bounds.is_empty() {
write!(w, ": {}", print_generic_bounds(cx, bounds))
write!(w, ": {}", print_generic_bounds(bounds, cx))
}
if let Some(default) = default {
write!(w, " = {}", default.print(cx))
Expand Down Expand Up @@ -910,7 +910,7 @@ fn render_assoc_item(
.unwrap_or_else(|| format!("#{}.{}", ty, name))
}
};
let vis = meth.visibility.print_with_space(cx, meth.def_id).to_string();
let vis = meth.visibility.print_with_space(meth.def_id, cx).to_string();
let constness = header.constness.print_with_space();
let asyncness = header.asyncness.print_with_space();
let unsafety = header.unsafety.print_with_space();
Expand Down Expand Up @@ -952,7 +952,7 @@ fn render_assoc_item(
href = href,
name = name,
generics = g.print(cx),
decl = d.full_print(cx, header_len, indent, header.asyncness),
decl = d.full_print(header_len, indent, header.asyncness, cx),
notable_traits = notable_traits_decl(&d, cx),
where_clause = print_where_clause(g, cx, indent, end_newline),
)
Expand Down
32 changes: 16 additions & 16 deletions src/librustdoc/html/render/print_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,14 +267,14 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
Some(ref src) => write!(
w,
"<tr><td><code>{}extern crate {} as {};",
myitem.visibility.print_with_space(cx, myitem.def_id),
myitem.visibility.print_with_space(myitem.def_id, cx),
anchor(myitem.def_id, &*src.as_str(), cx),
myitem.name.as_ref().unwrap(),
),
None => write!(
w,
"<tr><td><code>{}extern crate {};",
myitem.visibility.print_with_space(cx, myitem.def_id),
myitem.visibility.print_with_space(myitem.def_id, cx),
anchor(myitem.def_id, &*myitem.name.as_ref().unwrap().as_str(), cx),
),
}
Expand All @@ -285,7 +285,7 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
write!(
w,
"<tr><td><code>{}{}</code></td></tr>",
myitem.visibility.print_with_space(cx, myitem.def_id),
myitem.visibility.print_with_space(myitem.def_id, cx),
import.print(cx),
);
}
Expand Down Expand Up @@ -386,7 +386,7 @@ fn extra_info_tags(item: &clean::Item, parent: &clean::Item, tcx: TyCtxt<'_>) ->
fn item_function(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, f: &clean::Function) {
let header_len = format!(
"{}{}{}{}{:#}fn {}{:#}",
it.visibility.print_with_space(cx, it.def_id),
it.visibility.print_with_space(it.def_id, cx),
f.header.constness.print_with_space(),
f.header.asyncness.print_with_space(),
f.header.unsafety.print_with_space(),
Expand All @@ -401,15 +401,15 @@ fn item_function(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, f: &clean::
w,
"{vis}{constness}{asyncness}{unsafety}{abi}fn \
{name}{generics}{decl}{notable_traits}{where_clause}</pre>",
vis = it.visibility.print_with_space(cx, it.def_id),
vis = it.visibility.print_with_space(it.def_id, cx),
constness = f.header.constness.print_with_space(),
asyncness = f.header.asyncness.print_with_space(),
unsafety = f.header.unsafety.print_with_space(),
abi = print_abi_with_space(f.header.abi),
name = it.name.as_ref().unwrap(),
generics = f.generics.print(cx),
where_clause = print_where_clause(&f.generics, cx, 0, true),
decl = f.decl.full_print(cx, header_len, 0, f.header.asyncness),
decl = f.decl.full_print(header_len, 0, f.header.asyncness, cx),
notable_traits = notable_traits_decl(&f.decl, cx),
);
document(w, cx, it, None)
Expand All @@ -429,7 +429,7 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra
write!(
w,
"{}{}{}trait {}{}{}",
it.visibility.print_with_space(cx, it.def_id),
it.visibility.print_with_space(it.def_id, cx),
t.unsafety.print_with_space(),
if t.is_auto { "auto " } else { "" },
it.name.as_ref().unwrap(),
Expand Down Expand Up @@ -848,7 +848,7 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum
write!(
w,
"{}enum {}{}{}",
it.visibility.print_with_space(cx, it.def_id),
it.visibility.print_with_space(it.def_id, cx),
it.name.as_ref().unwrap(),
e.generics.print(cx),
print_where_clause(&e.generics, cx, 0, true),
Expand Down Expand Up @@ -1029,7 +1029,7 @@ fn item_constant(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, c: &clean::
write!(
w,
"{vis}const {name}: {typ}",
vis = it.visibility.print_with_space(cx, it.def_id),
vis = it.visibility.print_with_space(it.def_id, cx),
name = it.name.as_ref().unwrap(),
typ = c.type_.print(cx),
);
Expand Down Expand Up @@ -1116,7 +1116,7 @@ fn item_static(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::St
write!(
w,
"{vis}static {mutability}{name}: {typ}</pre>",
vis = it.visibility.print_with_space(cx, it.def_id),
vis = it.visibility.print_with_space(it.def_id, cx),
mutability = s.mutability.print_with_space(),
name = it.name.as_ref().unwrap(),
typ = s.type_.print(cx)
Expand All @@ -1130,7 +1130,7 @@ fn item_foreign_type(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item) {
write!(
w,
" {}type {};\n}}</pre>",
it.visibility.print_with_space(cx, it.def_id),
it.visibility.print_with_space(it.def_id, cx),
it.name.as_ref().unwrap(),
);

Expand Down Expand Up @@ -1289,7 +1289,7 @@ fn render_union(
write!(
w,
"{}{}{}",
it.visibility.print_with_space(cx, it.def_id),
it.visibility.print_with_space(it.def_id, cx),
if structhead { "union " } else { "" },
it.name.as_ref().unwrap()
);
Expand All @@ -1311,7 +1311,7 @@ fn render_union(
write!(
w,
" {}{}: {},\n{}",
field.visibility.print_with_space(cx, field.def_id),
field.visibility.print_with_space(field.def_id, cx),
field.name.as_ref().unwrap(),
ty.print(cx),
tab
Expand Down Expand Up @@ -1341,7 +1341,7 @@ fn render_struct(
write!(
w,
"{}{}{}",
it.visibility.print_with_space(cx, it.def_id),
it.visibility.print_with_space(it.def_id, cx),
if structhead { "struct " } else { "" },
it.name.as_ref().unwrap()
);
Expand All @@ -1367,7 +1367,7 @@ fn render_struct(
w,
"\n{} {}{}: {},",
tab,
field.visibility.print_with_space(cx, field.def_id),
field.visibility.print_with_space(field.def_id, cx),
field.name.as_ref().unwrap(),
ty.print(cx),
);
Expand Down Expand Up @@ -1401,7 +1401,7 @@ fn render_struct(
write!(
w,
"{}{}",
field.visibility.print_with_space(cx, field.def_id),
field.visibility.print_with_space(field.def_id, cx),
ty.print(cx),
)
}
Expand Down

0 comments on commit 755b4fb

Please sign in to comment.