Skip to content

Commit 755b4fb

Browse files
committed
rustdoc: move the cx argument to the end of the list
This should help make things consistent.
1 parent bb02048 commit 755b4fb

File tree

3 files changed

+33
-33
lines changed

3 files changed

+33
-33
lines changed

src/librustdoc/html/format.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ fn comma_sep<T: fmt::Display>(items: impl Iterator<Item = T>) -> impl fmt::Displ
125125
}
126126

127127
crate fn print_generic_bounds<'a, 'tcx: 'a>(
128-
cx: &'a Context<'tcx>,
129128
bounds: &'a [clean::GenericBound],
129+
cx: &'a Context<'tcx>,
130130
) -> impl fmt::Display + 'a + Captures<'tcx> {
131131
display_fn(move |f| {
132132
let mut bounds_dup = FxHashSet::default();
@@ -155,9 +155,9 @@ impl clean::GenericParamDef {
155155

156156
if !bounds.is_empty() {
157157
if f.alternate() {
158-
write!(f, ": {:#}", print_generic_bounds(cx, bounds))?;
158+
write!(f, ": {:#}", print_generic_bounds(bounds, cx))?;
159159
} else {
160-
write!(f, ":&nbsp;{}", print_generic_bounds(cx, bounds))?;
160+
write!(f, ":&nbsp;{}", print_generic_bounds(bounds, cx))?;
161161
}
162162
}
163163

@@ -239,13 +239,13 @@ crate fn print_where_clause<'a, 'tcx: 'a>(
239239
clause.push_str(&format!(
240240
"{:#}: {:#}",
241241
ty.print(cx),
242-
print_generic_bounds(cx, bounds)
242+
print_generic_bounds(bounds, cx)
243243
));
244244
} else {
245245
clause.push_str(&format!(
246246
"{}: {}",
247247
ty.print(cx),
248-
print_generic_bounds(cx, bounds)
248+
print_generic_bounds(bounds, cx)
249249
));
250250
}
251251
}
@@ -819,9 +819,9 @@ fn fmt_type<'cx>(
819819
}
820820
clean::ImplTrait(ref bounds) => {
821821
if f.alternate() {
822-
write!(f, "impl {:#}", print_generic_bounds(cx, bounds))
822+
write!(f, "impl {:#}", print_generic_bounds(bounds, cx))
823823
} else {
824-
write!(f, "impl {}", print_generic_bounds(cx, bounds))
824+
write!(f, "impl {}", print_generic_bounds(bounds, cx))
825825
}
826826
}
827827
clean::QPath { ref name, ref self_type, ref trait_ } => {
@@ -1013,21 +1013,21 @@ impl clean::FnDecl {
10131013
/// * `asyncness`: Whether the function is async or not.
10141014
crate fn full_print<'a, 'tcx: 'a>(
10151015
&'a self,
1016-
cx: &'a Context<'tcx>,
10171016
header_len: usize,
10181017
indent: usize,
10191018
asyncness: hir::IsAsync,
1019+
cx: &'a Context<'tcx>,
10201020
) -> impl fmt::Display + 'a + Captures<'tcx> {
1021-
display_fn(move |f| self.inner_full_print(cx, header_len, indent, asyncness, f))
1021+
display_fn(move |f| self.inner_full_print(header_len, indent, asyncness, f, cx))
10221022
}
10231023

10241024
fn inner_full_print(
10251025
&self,
1026-
cx: &Context<'_>,
10271026
header_len: usize,
10281027
indent: usize,
10291028
asyncness: hir::IsAsync,
10301029
f: &mut fmt::Formatter<'_>,
1030+
cx: &Context<'_>,
10311031
) -> fmt::Result {
10321032
let amp = if f.alternate() { "&" } else { "&amp;" };
10331033
let mut args = String::new();
@@ -1134,8 +1134,8 @@ impl clean::FnDecl {
11341134
impl clean::Visibility {
11351135
crate fn print_with_space<'a, 'tcx: 'a>(
11361136
self,
1137-
cx: &'a Context<'tcx>,
11381137
item_did: DefId,
1138+
cx: &'a Context<'tcx>,
11391139
) -> impl fmt::Display + 'a + Captures<'tcx> {
11401140
let to_print = match self {
11411141
clean::Public => "pub ".to_owned(),
@@ -1320,9 +1320,9 @@ impl clean::TypeBinding {
13201320
clean::TypeBindingKind::Constraint { ref bounds } => {
13211321
if !bounds.is_empty() {
13221322
if f.alternate() {
1323-
write!(f, ": {:#}", print_generic_bounds(cx, bounds))?;
1323+
write!(f, ": {:#}", print_generic_bounds(bounds, cx))?;
13241324
} else {
1325-
write!(f, ":&nbsp;{}", print_generic_bounds(cx, bounds))?;
1325+
write!(f, ":&nbsp;{}", print_generic_bounds(bounds, cx))?;
13261326
}
13271327
}
13281328
}

src/librustdoc/html/render/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,7 @@ fn assoc_const(
815815
w,
816816
"{}{}const <a href=\"{}\" class=\"constant\"><b>{}</b></a>: {}",
817817
extra,
818-
it.visibility.print_with_space(cx, it.def_id),
818+
it.visibility.print_with_space(it.def_id, cx),
819819
naive_assoc_href(it, link, cx),
820820
it.name.as_ref().unwrap(),
821821
ty.print(cx)
@@ -839,7 +839,7 @@ fn assoc_type(
839839
it.name.as_ref().unwrap()
840840
);
841841
if !bounds.is_empty() {
842-
write!(w, ": {}", print_generic_bounds(cx, bounds))
842+
write!(w, ": {}", print_generic_bounds(bounds, cx))
843843
}
844844
if let Some(default) = default {
845845
write!(w, " = {}", default.print(cx))
@@ -910,7 +910,7 @@ fn render_assoc_item(
910910
.unwrap_or_else(|| format!("#{}.{}", ty, name))
911911
}
912912
};
913-
let vis = meth.visibility.print_with_space(cx, meth.def_id).to_string();
913+
let vis = meth.visibility.print_with_space(meth.def_id, cx).to_string();
914914
let constness = header.constness.print_with_space();
915915
let asyncness = header.asyncness.print_with_space();
916916
let unsafety = header.unsafety.print_with_space();
@@ -952,7 +952,7 @@ fn render_assoc_item(
952952
href = href,
953953
name = name,
954954
generics = g.print(cx),
955-
decl = d.full_print(cx, header_len, indent, header.asyncness),
955+
decl = d.full_print(header_len, indent, header.asyncness, cx),
956956
notable_traits = notable_traits_decl(&d, cx),
957957
where_clause = print_where_clause(g, cx, indent, end_newline),
958958
)

src/librustdoc/html/render/print_item.rs

+16-16
Original file line numberDiff line numberDiff line change
@@ -267,14 +267,14 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
267267
Some(ref src) => write!(
268268
w,
269269
"<tr><td><code>{}extern crate {} as {};",
270-
myitem.visibility.print_with_space(cx, myitem.def_id),
270+
myitem.visibility.print_with_space(myitem.def_id, cx),
271271
anchor(myitem.def_id, &*src.as_str(), cx),
272272
myitem.name.as_ref().unwrap(),
273273
),
274274
None => write!(
275275
w,
276276
"<tr><td><code>{}extern crate {};",
277-
myitem.visibility.print_with_space(cx, myitem.def_id),
277+
myitem.visibility.print_with_space(myitem.def_id, cx),
278278
anchor(myitem.def_id, &*myitem.name.as_ref().unwrap().as_str(), cx),
279279
),
280280
}
@@ -285,7 +285,7 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
285285
write!(
286286
w,
287287
"<tr><td><code>{}{}</code></td></tr>",
288-
myitem.visibility.print_with_space(cx, myitem.def_id),
288+
myitem.visibility.print_with_space(myitem.def_id, cx),
289289
import.print(cx),
290290
);
291291
}
@@ -386,7 +386,7 @@ fn extra_info_tags(item: &clean::Item, parent: &clean::Item, tcx: TyCtxt<'_>) ->
386386
fn item_function(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, f: &clean::Function) {
387387
let header_len = format!(
388388
"{}{}{}{}{:#}fn {}{:#}",
389-
it.visibility.print_with_space(cx, it.def_id),
389+
it.visibility.print_with_space(it.def_id, cx),
390390
f.header.constness.print_with_space(),
391391
f.header.asyncness.print_with_space(),
392392
f.header.unsafety.print_with_space(),
@@ -401,15 +401,15 @@ fn item_function(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, f: &clean::
401401
w,
402402
"{vis}{constness}{asyncness}{unsafety}{abi}fn \
403403
{name}{generics}{decl}{notable_traits}{where_clause}</pre>",
404-
vis = it.visibility.print_with_space(cx, it.def_id),
404+
vis = it.visibility.print_with_space(it.def_id, cx),
405405
constness = f.header.constness.print_with_space(),
406406
asyncness = f.header.asyncness.print_with_space(),
407407
unsafety = f.header.unsafety.print_with_space(),
408408
abi = print_abi_with_space(f.header.abi),
409409
name = it.name.as_ref().unwrap(),
410410
generics = f.generics.print(cx),
411411
where_clause = print_where_clause(&f.generics, cx, 0, true),
412-
decl = f.decl.full_print(cx, header_len, 0, f.header.asyncness),
412+
decl = f.decl.full_print(header_len, 0, f.header.asyncness, cx),
413413
notable_traits = notable_traits_decl(&f.decl, cx),
414414
);
415415
document(w, cx, it, None)
@@ -429,7 +429,7 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra
429429
write!(
430430
w,
431431
"{}{}{}trait {}{}{}",
432-
it.visibility.print_with_space(cx, it.def_id),
432+
it.visibility.print_with_space(it.def_id, cx),
433433
t.unsafety.print_with_space(),
434434
if t.is_auto { "auto " } else { "" },
435435
it.name.as_ref().unwrap(),
@@ -848,7 +848,7 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum
848848
write!(
849849
w,
850850
"{}enum {}{}{}",
851-
it.visibility.print_with_space(cx, it.def_id),
851+
it.visibility.print_with_space(it.def_id, cx),
852852
it.name.as_ref().unwrap(),
853853
e.generics.print(cx),
854854
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::
10291029
write!(
10301030
w,
10311031
"{vis}const {name}: {typ}",
1032-
vis = it.visibility.print_with_space(cx, it.def_id),
1032+
vis = it.visibility.print_with_space(it.def_id, cx),
10331033
name = it.name.as_ref().unwrap(),
10341034
typ = c.type_.print(cx),
10351035
);
@@ -1116,7 +1116,7 @@ fn item_static(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::St
11161116
write!(
11171117
w,
11181118
"{vis}static {mutability}{name}: {typ}</pre>",
1119-
vis = it.visibility.print_with_space(cx, it.def_id),
1119+
vis = it.visibility.print_with_space(it.def_id, cx),
11201120
mutability = s.mutability.print_with_space(),
11211121
name = it.name.as_ref().unwrap(),
11221122
typ = s.type_.print(cx)
@@ -1130,7 +1130,7 @@ fn item_foreign_type(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item) {
11301130
write!(
11311131
w,
11321132
" {}type {};\n}}</pre>",
1133-
it.visibility.print_with_space(cx, it.def_id),
1133+
it.visibility.print_with_space(it.def_id, cx),
11341134
it.name.as_ref().unwrap(),
11351135
);
11361136

@@ -1289,7 +1289,7 @@ fn render_union(
12891289
write!(
12901290
w,
12911291
"{}{}{}",
1292-
it.visibility.print_with_space(cx, it.def_id),
1292+
it.visibility.print_with_space(it.def_id, cx),
12931293
if structhead { "union " } else { "" },
12941294
it.name.as_ref().unwrap()
12951295
);
@@ -1311,7 +1311,7 @@ fn render_union(
13111311
write!(
13121312
w,
13131313
" {}{}: {},\n{}",
1314-
field.visibility.print_with_space(cx, field.def_id),
1314+
field.visibility.print_with_space(field.def_id, cx),
13151315
field.name.as_ref().unwrap(),
13161316
ty.print(cx),
13171317
tab
@@ -1341,7 +1341,7 @@ fn render_struct(
13411341
write!(
13421342
w,
13431343
"{}{}{}",
1344-
it.visibility.print_with_space(cx, it.def_id),
1344+
it.visibility.print_with_space(it.def_id, cx),
13451345
if structhead { "struct " } else { "" },
13461346
it.name.as_ref().unwrap()
13471347
);
@@ -1367,7 +1367,7 @@ fn render_struct(
13671367
w,
13681368
"\n{} {}{}: {},",
13691369
tab,
1370-
field.visibility.print_with_space(cx, field.def_id),
1370+
field.visibility.print_with_space(field.def_id, cx),
13711371
field.name.as_ref().unwrap(),
13721372
ty.print(cx),
13731373
);
@@ -1401,7 +1401,7 @@ fn render_struct(
14011401
write!(
14021402
w,
14031403
"{}{}",
1404-
field.visibility.print_with_space(cx, field.def_id),
1404+
field.visibility.print_with_space(field.def_id, cx),
14051405
ty.print(cx),
14061406
)
14071407
}

0 commit comments

Comments
 (0)