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:
parent
2ea7a37e11
commit
ed76b0b882
76 changed files with 296 additions and 293 deletions
|
@ -818,7 +818,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
|
|||
self.r
|
||||
.dcx()
|
||||
.struct_span_err(item.span, "`extern crate self;` requires renaming")
|
||||
.span_suggestion_mv(
|
||||
.with_span_suggestion(
|
||||
item.span,
|
||||
"rename the `self` crate to be able to import it",
|
||||
"extern crate self as name;",
|
||||
|
@ -999,7 +999,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
|
|||
let msg = format!("`{name}` is already in scope");
|
||||
let note =
|
||||
"macro-expanded `#[macro_use]`s may not shadow existing macros (see RFC 1560)";
|
||||
self.r.dcx().struct_span_err(span, msg).note_mv(note).emit();
|
||||
self.r.dcx().struct_span_err(span, msg).with_note(note).emit();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -950,9 +950,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
"item `{name}` is an associated {kind}, which doesn't match its trait `{trait_path}`",
|
||||
),
|
||||
)
|
||||
.code_mv(code)
|
||||
.span_label_mv(span, "does not match trait")
|
||||
.span_label_mv(trait_item_span, "item in trait")
|
||||
.with_code(code)
|
||||
.with_span_label(span, "does not match trait")
|
||||
.with_span_label(trait_item_span, "item in trait")
|
||||
}
|
||||
ResolutionError::TraitImplDuplicate { name, trait_item_span, old_span } => self
|
||||
.dcx()
|
||||
|
|
|
@ -2600,7 +2600,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
|
|||
E0637,
|
||||
"`'_` cannot be used here"
|
||||
)
|
||||
.span_label_mv(param.ident.span, "`'_` is a reserved lifetime name")
|
||||
.with_span_label(param.ident.span, "`'_` is a reserved lifetime name")
|
||||
.emit();
|
||||
// Record lifetime res, so lowering knows there is something fishy.
|
||||
self.record_lifetime_param(param.id, LifetimeRes::Error);
|
||||
|
@ -2615,7 +2615,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
|
|||
"invalid lifetime parameter name: `{}`",
|
||||
param.ident,
|
||||
)
|
||||
.span_label_mv(param.ident.span, "'static is a reserved lifetime name")
|
||||
.with_span_label(param.ident.span, "'static is a reserved lifetime name")
|
||||
.emit();
|
||||
// Record lifetime res, so lowering knows there is something fishy.
|
||||
self.record_lifetime_param(param.id, LifetimeRes::Error);
|
||||
|
|
|
@ -2609,8 +2609,8 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
|
|||
E0401,
|
||||
"can't use generic parameters from outer item",
|
||||
)
|
||||
.span_label_mv(lifetime_ref.ident.span, "use of generic parameter from outer item")
|
||||
.span_label_mv(outer.span, "lifetime parameter from outer item")
|
||||
.with_span_label(lifetime_ref.ident.span, "use of generic parameter from outer item")
|
||||
.with_span_label(outer.span, "lifetime parameter from outer item")
|
||||
} else {
|
||||
struct_span_code_err!(
|
||||
self.r.dcx(),
|
||||
|
@ -2619,7 +2619,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
|
|||
"use of undeclared lifetime name `{}`",
|
||||
lifetime_ref.ident
|
||||
)
|
||||
.span_label_mv(lifetime_ref.ident.span, "undeclared lifetime")
|
||||
.with_span_label(lifetime_ref.ident.span, "undeclared lifetime")
|
||||
};
|
||||
self.suggest_introducing_lifetime(
|
||||
&mut err,
|
||||
|
@ -3289,8 +3289,8 @@ pub(super) fn signal_lifetime_shadowing(sess: &Session, orig: Ident, shadower: I
|
|||
"lifetime name `{}` shadows a lifetime name that is already in scope",
|
||||
orig.name,
|
||||
)
|
||||
.span_label_mv(orig.span, "first declared here")
|
||||
.span_label_mv(shadower.span, format!("lifetime `{}` already in scope", orig.name))
|
||||
.with_span_label(orig.span, "first declared here")
|
||||
.with_span_label(shadower.span, format!("lifetime `{}` already in scope", orig.name))
|
||||
.emit();
|
||||
}
|
||||
|
||||
|
@ -3322,7 +3322,7 @@ pub(super) fn signal_label_shadowing(sess: &Session, orig: Span, shadower: Ident
|
|||
shadower,
|
||||
format!("label name `{name}` shadows a label name that is already in scope"),
|
||||
)
|
||||
.span_label_mv(orig, "first declared here")
|
||||
.span_label_mv(shadower, format!("label `{name}` already in scope"))
|
||||
.with_span_label(orig, "first declared here")
|
||||
.with_span_label(shadower, format!("label `{name}` already in scope"))
|
||||
.emit();
|
||||
}
|
||||
|
|
|
@ -128,7 +128,7 @@ pub(crate) fn registered_tools(tcx: TyCtxt<'_>, (): ()) -> RegisteredTools {
|
|||
let msg = format!("{} `{}` was already registered", "tool", ident);
|
||||
tcx.dcx()
|
||||
.struct_span_err(ident.span, msg)
|
||||
.span_label_mv(old_ident.span, "already registered here")
|
||||
.with_span_label(old_ident.span, "already registered here")
|
||||
.emit();
|
||||
}
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ pub(crate) fn registered_tools(tcx: TyCtxt<'_>, (): ()) -> RegisteredTools {
|
|||
let span = nested_meta.span();
|
||||
tcx.dcx()
|
||||
.struct_span_err(span, msg)
|
||||
.span_label_mv(span, "not an identifier")
|
||||
.with_span_label(span, "not an identifier")
|
||||
.emit();
|
||||
}
|
||||
}
|
||||
|
@ -578,7 +578,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
|
||||
self.dcx()
|
||||
.create_err(err)
|
||||
.span_label_mv(path.span, format!("not {article} {expected}"))
|
||||
.with_span_label(path.span, format!("not {article} {expected}"))
|
||||
.emit();
|
||||
|
||||
return Ok((self.dummy_ext(kind), Res::Err));
|
||||
|
@ -954,7 +954,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
E0773,
|
||||
"attempted to define built-in macro more than once"
|
||||
)
|
||||
.span_note_mv(span, "previously defined here")
|
||||
.with_span_note(span, "previously defined here")
|
||||
.emit();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue