Rename consuming chaining methods on DiagnosticBuilder.

In #119606 I added them and used a `_mv` suffix, but that wasn't great.

A `with_` prefix has three different existing uses.
- Constructors, e.g. `Vec::with_capacity`.
- Wrappers that provide an environment to execute some code, e.g.
  `with_session_globals`.
- Consuming chaining methods, e.g. `Span::with_{lo,hi,ctxt}`.

The third case is exactly what we want, so this commit changes
`DiagnosticBuilder::foo_mv` to `DiagnosticBuilder::with_foo`.

Thanks to @compiler-errors for the suggestion.
This commit is contained in:
Nicholas Nethercote
2024-01-09 09:08:49 +11:00
parent 2ea7a37e11
commit ed76b0b882
76 changed files with 296 additions and 293 deletions

View File

@@ -305,7 +305,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
binding.span,
format!("{} `{}` is private", assoc_item.kind, binding.item_name),
)
.span_label_mv(binding.span, format!("private {}", assoc_item.kind))
.with_span_label(binding.span, format!("private {}", assoc_item.kind))
.emit();
}
tcx.check_stability(assoc_item.def_id, Some(hir_ref_id), binding.span, None);

View File

@@ -70,7 +70,7 @@ fn generic_arg_mismatch_err(
Res::Err => {
add_braces_suggestion(arg, &mut err);
return err
.primary_message_mv("unresolved item provided when a constant was expected")
.with_primary_message("unresolved item provided when a constant was expected")
.emit();
}
Res::Def(DefKind::TyParam, src_def_id) => {
@@ -651,7 +651,7 @@ pub(crate) fn prohibit_explicit_late_bound_lifetimes(
&& args.num_lifetime_params() != param_counts.lifetimes
{
struct_span_code_err!(tcx.dcx(), span, E0794, "{}", msg)
.span_note_mv(span_late, note)
.with_span_note(span_late, note)
.emit();
} else {
let mut multispan = MultiSpan::from_span(span);

View File

@@ -1618,9 +1618,9 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
let def_span = tcx.def_span(item);
tcx.dcx()
.struct_span_err(span, msg)
.code_mv(rustc_errors::error_code!(E0624))
.span_label_mv(span, format!("private {kind}"))
.span_label_mv(def_span, format!("{kind} defined here"))
.with_code(rustc_errors::error_code!(E0624))
.with_span_label(span, format!("private {kind}"))
.with_span_label(def_span, format!("{kind} defined here"))
.emit();
}
tcx.check_stability(item, Some(block), span, None);

View File

@@ -298,7 +298,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
tcx.def_descr(def_id),
tcx.item_name(def_id),
)
.note_mv(
.with_note(
rustc_middle::traits::ObjectSafetyViolation::SupertraitSelf(smallvec![])
.error_msg(),
)