rustdoc: move the cx argument to the end of the list

This should help make things consistent.
This commit is contained in:
Michael Howell 2021-04-16 12:29:35 -07:00
parent bb0204861b
commit 755b4fb02b
3 changed files with 33 additions and 33 deletions

View File

@ -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();
@ -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))?;
}
}
@ -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)
));
}
}
@ -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_ } => {
@ -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();
@ -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(),
@ -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))?;
}
}
}

View File

@ -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)
@ -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))
@ -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();
@ -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),
)

View File

@ -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),
),
}
@ -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),
);
}
@ -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(),
@ -401,7 +401,7 @@ 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(),
@ -409,7 +409,7 @@ fn item_function(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, f: &clean::
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)
@ -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(),
@ -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),
@ -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),
);
@ -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)
@ -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(),
);
@ -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()
);
@ -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
@ -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()
);
@ -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),
);
@ -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),
)
}