Skip to content

Commit ff52416

Browse files
committed
Remove unused let bindings in render calls
1 parent 273d673 commit ff52416

2 files changed

Lines changed: 25 additions & 24 deletions

File tree

src/librustdoc/html/render/mod.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,7 +1038,7 @@ fn assoc_const(
10381038
) -> impl fmt::Display {
10391039
let tcx = cx.tcx();
10401040
fmt::from_fn(move |w| {
1041-
let _ = render_attributes_in_code(w, it, &" ".repeat(indent), cx)?;
1041+
render_attributes_in_code(w, it, &" ".repeat(indent), cx)?;
10421042
write!(
10431043
w,
10441044
"{indent}{vis}const <a{href} class=\"constant\">{name}</a>{generics}: {ty}",
@@ -1078,7 +1078,7 @@ fn assoc_type(
10781078
cx: &Context<'_>,
10791079
) -> impl fmt::Display {
10801080
fmt::from_fn(move |w| {
1081-
let _ = render_attributes_in_code(w, it, &" ".repeat(indent), cx)?;
1081+
render_attributes_in_code(w, it, &" ".repeat(indent), cx)?;
10821082
write!(
10831083
w,
10841084
"{indent}{vis}type <a{href} class=\"associatedtype\">{name}</a>{generics}",
@@ -1147,10 +1147,10 @@ fn assoc_method(
11471147
let (indent, indent_str, end_newline) = if parent == ItemType::Trait {
11481148
header_len += 4;
11491149
let indent_str = " ";
1150-
let _ = render_attributes_in_code(w, meth, indent_str, cx)?;
1150+
render_attributes_in_code(w, meth, indent_str, cx)?;
11511151
(4, indent_str, Ending::NoNewline)
11521152
} else {
1153-
let _ = render_attributes_in_code(w, meth, "", cx)?;
1153+
render_attributes_in_code(w, meth, "", cx)?;
11541154
(0, "", Ending::Newline)
11551155
};
11561156
write!(
@@ -2915,8 +2915,9 @@ fn render_attributes_in_code(
29152915
item: &clean::Item,
29162916
prefix: &str,
29172917
cx: &Context<'_>,
2918-
) -> Result<bool, fmt::Error> {
2919-
render_attributes_in_code_with_options(w, item, prefix, cx, true, None)
2918+
) -> fmt::Result {
2919+
let _ = render_attributes_in_code_with_options(w, item, prefix, cx, true, None)?;
2920+
Ok(())
29202921
}
29212922

29222923
pub(super) fn render_attributes_in_code_with_options(

src/librustdoc/html/render/print_item.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ fn item_function(cx: &Context<'_>, it: &clean::Item, f: &clean::Function) -> imp
571571
let notable_traits = notable_traits_button(&f.decl.output, cx).maybe_display();
572572

573573
wrap_item(w, |w| {
574-
let _ = render_attributes_in_code(w, it, "", cx)?;
574+
render_attributes_in_code(w, it, "", cx)?;
575575
write!(
576576
w,
577577
"{vis}{constness}{asyncness}{safety}{abi}fn \
@@ -633,7 +633,7 @@ fn item_trait(cx: &Context<'_>, it: &clean::Item, t: &clean::Trait) -> impl fmt:
633633

634634
// Output the trait definition
635635
wrap_item(w, |mut w| {
636-
let _ = render_attributes_in_code(&mut w, it, "", cx)?;
636+
render_attributes_in_code(&mut w, it, "", cx)?;
637637
write!(
638638
w,
639639
"{vis}{safety}{is_auto}trait {name}{generics}{bounds}",
@@ -1211,7 +1211,7 @@ fn item_trait_alias(
12111211
) -> impl fmt::Display {
12121212
fmt::from_fn(|w| {
12131213
wrap_item(w, |w| {
1214-
let _ = render_attributes_in_code(w, it, "", cx)?;
1214+
render_attributes_in_code(w, it, "", cx)?;
12151215
write!(
12161216
w,
12171217
"trait {name}{generics} = {bounds}{where_clause};",
@@ -1239,7 +1239,7 @@ fn item_trait_alias(
12391239
fn item_type_alias(cx: &Context<'_>, it: &clean::Item, t: &clean::TypeAlias) -> impl fmt::Display {
12401240
fmt::from_fn(|w| {
12411241
wrap_item(w, |w| {
1242-
let _ = render_attributes_in_code(w, it, "", cx)?;
1242+
render_attributes_in_code(w, it, "", cx)?;
12431243
write!(
12441244
w,
12451245
"{vis}type {name}{generics}{where_clause} = {type_};",
@@ -1447,7 +1447,7 @@ impl<'a, 'cx: 'a> ItemUnion<'a, 'cx> {
14471447

14481448
fn print_field_attrs(&self, field: &'a clean::Item) -> impl Display {
14491449
fmt::from_fn(move |w| {
1450-
let _ = render_attributes_in_code(w, field, "", self.cx)?;
1450+
render_attributes_in_code(w, field, "", self.cx)?;
14511451
Ok(())
14521452
})
14531453
}
@@ -1539,7 +1539,7 @@ impl<'clean> DisplayEnum<'clean> {
15391539
// For now the only attributes we render for type aliases are `repr` attributes.
15401540
render_repr_attribute_in_code(w, cx, self.def_id)?;
15411541
} else {
1542-
let _ = render_attributes_in_code(w, it, "", cx)?;
1542+
render_attributes_in_code(w, it, "", cx)?;
15431543
}
15441544
write!(
15451545
w,
@@ -1678,7 +1678,7 @@ fn render_enum_fields(
16781678
if v.is_stripped() {
16791679
continue;
16801680
}
1681-
let _ = render_attributes_in_code(w, v, TAB, cx)?;
1681+
render_attributes_in_code(w, v, TAB, cx)?;
16821682
w.write_str(TAB)?;
16831683
match v.kind {
16841684
clean::VariantItem(ref var) => match var.kind {
@@ -1762,7 +1762,7 @@ fn item_variants(
17621762
)
17631763
.maybe_display()
17641764
)?;
1765-
let _ = render_attributes_in_code(w, variant, "", cx)?;
1765+
render_attributes_in_code(w, variant, "", cx)?;
17661766
if let clean::VariantItem(ref var) = variant.kind
17671767
&& let clean::VariantKind::CLike = var.kind
17681768
{
@@ -1838,7 +1838,7 @@ fn item_variants(
18381838
<a href=\"#{id}\" class=\"anchor field\">§</a>\
18391839
<code>"
18401840
)?;
1841-
let _ = render_attributes_in_code(w, field, "", cx)?;
1841+
render_attributes_in_code(w, field, "", cx)?;
18421842
write!(
18431843
w,
18441844
"{f}: {t}</code>\
@@ -1863,7 +1863,7 @@ fn item_variants(
18631863
fn item_macro(cx: &Context<'_>, it: &clean::Item, t: &clean::Macro) -> impl fmt::Display {
18641864
fmt::from_fn(|w| {
18651865
wrap_item(w, |w| {
1866-
let _ = render_attributes_in_code(w, it, "", cx)?;
1866+
render_attributes_in_code(w, it, "", cx)?;
18671867
if !t.macro_rules {
18681868
write!(w, "{}", visibility_print_with_space(it, cx))?;
18691869
}
@@ -1931,7 +1931,7 @@ fn item_constant(
19311931
fmt::from_fn(|w| {
19321932
wrap_item(w, |w| {
19331933
let tcx = cx.tcx();
1934-
let _ = render_attributes_in_code(w, it, "", cx)?;
1934+
render_attributes_in_code(w, it, "", cx)?;
19351935

19361936
write!(
19371937
w,
@@ -1999,7 +1999,7 @@ impl<'a> DisplayStruct<'a> {
19991999
// For now the only attributes we render for type aliases are `repr` attributes.
20002000
render_repr_attribute_in_code(w, cx, self.def_id)?;
20012001
} else {
2002-
let _ = render_attributes_in_code(w, it, "", cx)?;
2002+
render_attributes_in_code(w, it, "", cx)?;
20032003
}
20042004
write!(
20052005
w,
@@ -2078,7 +2078,7 @@ fn item_fields(
20782078
<code>",
20792079
item_type = ItemType::StructField,
20802080
)?;
2081-
let _ = render_attributes_in_code(w, field, "", cx)?;
2081+
render_attributes_in_code(w, field, "", cx)?;
20822082
write!(
20832083
w,
20842084
"{field_name}: {ty}</code>\
@@ -2101,7 +2101,7 @@ fn item_static(
21012101
) -> impl fmt::Display {
21022102
fmt::from_fn(move |w| {
21032103
wrap_item(w, |w| {
2104-
let _ = render_attributes_in_code(w, it, "", cx)?;
2104+
render_attributes_in_code(w, it, "", cx)?;
21052105
write!(
21062106
w,
21072107
"{vis}{safe}static {mutability}{name}: {typ}",
@@ -2121,7 +2121,7 @@ fn item_foreign_type(cx: &Context<'_>, it: &clean::Item) -> impl fmt::Display {
21212121
fmt::from_fn(|w| {
21222122
wrap_item(w, |w| {
21232123
w.write_str("extern {\n")?;
2124-
let _ = render_attributes_in_code(w, it, "", cx)?;
2124+
render_attributes_in_code(w, it, "", cx)?;
21252125
write!(w, " {}type {};\n}}", visibility_print_with_space(it, cx), it.name.unwrap())
21262126
})?;
21272127

@@ -2364,7 +2364,7 @@ fn render_union(
23642364
// For now the only attributes we render for type aliases are `repr` attributes.
23652365
render_repr_attribute_in_code(f, cx, def_id)?;
23662366
} else {
2367-
let _ = render_attributes_in_code(f, it, "", cx)?;
2367+
render_attributes_in_code(f, it, "", cx)?;
23682368
}
23692369
write!(f, "{}union {}", visibility_print_with_space(it, cx), it.name.unwrap(),)?;
23702370

@@ -2395,7 +2395,7 @@ fn render_union(
23952395

23962396
for field in fields {
23972397
if let clean::StructFieldItem(ref ty) = field.kind {
2398-
let _ = render_attributes_in_code(&mut f, field, " ", cx)?;
2398+
render_attributes_in_code(&mut f, field, " ", cx)?;
23992399
writeln!(
24002400
f,
24012401
" {}{}: {},",
@@ -2492,7 +2492,7 @@ fn render_struct_fields(
24922492
}
24932493
for field in fields {
24942494
if let clean::StructFieldItem(ref ty) = field.kind {
2495-
let _ = render_attributes_in_code(w, field, &format!("{tab} "), cx)?;
2495+
render_attributes_in_code(w, field, &format!("{tab} "), cx)?;
24962496
writeln!(
24972497
w,
24982498
"{tab} {vis}{name}: {ty},",

0 commit comments

Comments
 (0)