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

@@ -727,7 +727,7 @@ impl DiagCtxt {
span: impl Into<MultiSpan>,
msg: impl Into<DiagnosticMessage>,
) -> DiagnosticBuilder<'_, ()> {
self.struct_warn(msg).span_mv(span)
self.struct_warn(msg).with_span(span)
}
/// Construct a builder at the `Warning` level with the `msg`.
@@ -767,7 +767,7 @@ impl DiagCtxt {
span: impl Into<MultiSpan>,
msg: impl Into<DiagnosticMessage>,
) -> DiagnosticBuilder<'_> {
self.struct_err(msg).span_mv(span)
self.struct_err(msg).with_span(span)
}
/// Construct a builder at the `Error` level with the `msg`.
@@ -786,7 +786,7 @@ impl DiagCtxt {
span: impl Into<MultiSpan>,
msg: impl Into<DiagnosticMessage>,
) -> DiagnosticBuilder<'_, FatalAbort> {
self.struct_fatal(msg).span_mv(span)
self.struct_fatal(msg).with_span(span)
}
/// Construct a builder at the `Fatal` level with the `msg`.
@@ -827,7 +827,7 @@ impl DiagCtxt {
span: impl Into<MultiSpan>,
msg: impl Into<DiagnosticMessage>,
) -> DiagnosticBuilder<'_, BugAbort> {
self.struct_bug(msg).span_mv(span)
self.struct_bug(msg).with_span(span)
}
#[rustc_lint_diagnostics]
@@ -888,7 +888,7 @@ impl DiagCtxt {
if treat_next_err_as_bug {
self.span_bug(sp, msg);
}
DiagnosticBuilder::<ErrorGuaranteed>::new(self, DelayedBug, msg).span_mv(sp).emit()
DiagnosticBuilder::<ErrorGuaranteed>::new(self, DelayedBug, msg).with_span(sp).emit()
}
// FIXME(eddyb) note the comment inside `impl Drop for DiagCtxtInner`, that's
@@ -913,7 +913,7 @@ impl DiagCtxt {
span: impl Into<MultiSpan>,
msg: impl Into<DiagnosticMessage>,
) -> DiagnosticBuilder<'_, ()> {
DiagnosticBuilder::new(self, Note, msg).span_mv(span)
DiagnosticBuilder::new(self, Note, msg).with_span(span)
}
#[rustc_lint_diagnostics]