Use chaining for DiagnosticBuilder construction and emit.

To avoid the use of a mutable local variable, and because it reads more
nicely.
This commit is contained in:
Nicholas Nethercote
2024-01-03 17:03:10 +11:00
parent 589591efde
commit bd4e623485
22 changed files with 193 additions and 183 deletions

View File

@@ -190,7 +190,7 @@ pub fn recursive_type_error(
}
s
};
let mut err = struct_span_err!(
struct_span_err!(
tcx.dcx(),
err_span,
E0072,
@@ -198,13 +198,13 @@ pub fn recursive_type_error(
pluralize!(cycle_len),
items_list,
pluralize!("has", cycle_len),
);
err.multipart_suggestion(
)
.multipart_suggestion_mv(
"insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle",
suggestion,
Applicability::HasPlaceholders,
);
err.emit();
)
.emit();
}
fn find_item_ty_spans(