mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
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
@ -23,7 +23,7 @@ macro_rules! gate {
|
|||||||
($visitor:expr, $feature:ident, $span:expr, $explain:expr, $help:expr) => {{
|
($visitor:expr, $feature:ident, $span:expr, $explain:expr, $help:expr) => {{
|
||||||
if !$visitor.features.$feature && !$span.allows_unstable(sym::$feature) {
|
if !$visitor.features.$feature && !$span.allows_unstable(sym::$feature) {
|
||||||
feature_err(&$visitor.sess.parse_sess, sym::$feature, $span, $explain)
|
feature_err(&$visitor.sess.parse_sess, sym::$feature, $span, $explain)
|
||||||
.help_mv($help)
|
.with_help($help)
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
}};
|
}};
|
||||||
|
@ -55,11 +55,11 @@ impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for UnknownMetaItem<'_> {
|
|||||||
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> DiagnosticBuilder<'a, G> {
|
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> DiagnosticBuilder<'a, G> {
|
||||||
let expected = self.expected.iter().map(|name| format!("`{name}`")).collect::<Vec<_>>();
|
let expected = self.expected.iter().map(|name| format!("`{name}`")).collect::<Vec<_>>();
|
||||||
DiagnosticBuilder::new(dcx, level, fluent::attr_unknown_meta_item)
|
DiagnosticBuilder::new(dcx, level, fluent::attr_unknown_meta_item)
|
||||||
.span_mv(self.span)
|
.with_span(self.span)
|
||||||
.code_mv(error_code!(E0541))
|
.with_code(error_code!(E0541))
|
||||||
.arg_mv("item", self.item)
|
.with_arg("item", self.item)
|
||||||
.arg_mv("expected", expected.join(", "))
|
.with_arg("expected", expected.join(", "))
|
||||||
.span_label_mv(self.span, fluent::attr_label)
|
.with_span_label(self.span, fluent::attr_label)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,8 +38,8 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
|||||||
"cannot use {} because it was mutably borrowed",
|
"cannot use {} because it was mutably borrowed",
|
||||||
desc,
|
desc,
|
||||||
)
|
)
|
||||||
.span_label_mv(borrow_span, format!("{borrow_desc} is borrowed here"))
|
.with_span_label(borrow_span, format!("{borrow_desc} is borrowed here"))
|
||||||
.span_label_mv(span, format!("use of borrowed {borrow_desc}"))
|
.with_span_label(span, format!("use of borrowed {borrow_desc}"))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn cannot_mutably_borrow_multiply(
|
pub(crate) fn cannot_mutably_borrow_multiply(
|
||||||
@ -243,8 +243,8 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
|||||||
"cannot assign to {} because it is borrowed",
|
"cannot assign to {} because it is borrowed",
|
||||||
desc,
|
desc,
|
||||||
)
|
)
|
||||||
.span_label_mv(borrow_span, format!("{desc} is borrowed here"))
|
.with_span_label(borrow_span, format!("{desc} is borrowed here"))
|
||||||
.span_label_mv(span, format!("{desc} is assigned to here but it was already borrowed"))
|
.with_span_label(span, format!("{desc} is assigned to here but it was already borrowed"))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn cannot_reassign_immutable(
|
pub(crate) fn cannot_reassign_immutable(
|
||||||
@ -297,7 +297,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
|||||||
ty,
|
ty,
|
||||||
type_name,
|
type_name,
|
||||||
)
|
)
|
||||||
.span_label_mv(move_from_span, "cannot move out of here")
|
.with_span_label(move_from_span, "cannot move out of here")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn cannot_move_out_of_interior_of_drop(
|
pub(crate) fn cannot_move_out_of_interior_of_drop(
|
||||||
@ -312,7 +312,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
|||||||
"cannot move out of type `{}`, which implements the `Drop` trait",
|
"cannot move out of type `{}`, which implements the `Drop` trait",
|
||||||
container_ty,
|
container_ty,
|
||||||
)
|
)
|
||||||
.span_label_mv(move_from_span, "cannot move out of here")
|
.with_span_label(move_from_span, "cannot move out of here")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn cannot_act_on_moved_value(
|
pub(crate) fn cannot_act_on_moved_value(
|
||||||
@ -368,8 +368,8 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
|||||||
immutable_place,
|
immutable_place,
|
||||||
immutable_section,
|
immutable_section,
|
||||||
)
|
)
|
||||||
.span_label_mv(mutate_span, format!("cannot {action}"))
|
.with_span_label(mutate_span, format!("cannot {action}"))
|
||||||
.span_label_mv(immutable_span, format!("value is immutable in {immutable_section}"))
|
.with_span_label(immutable_span, format!("value is immutable in {immutable_section}"))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn cannot_borrow_across_coroutine_yield(
|
pub(crate) fn cannot_borrow_across_coroutine_yield(
|
||||||
@ -384,7 +384,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
|||||||
E0626,
|
E0626,
|
||||||
"borrow may still be in use when {coroutine_kind:#} yields",
|
"borrow may still be in use when {coroutine_kind:#} yields",
|
||||||
)
|
)
|
||||||
.span_label_mv(yield_span, "possible yield occurs here")
|
.with_span_label(yield_span, "possible yield occurs here")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn cannot_borrow_across_destructor(
|
pub(crate) fn cannot_borrow_across_destructor(
|
||||||
@ -423,7 +423,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
|||||||
REFERENCE = reference_desc,
|
REFERENCE = reference_desc,
|
||||||
LOCAL = path_desc,
|
LOCAL = path_desc,
|
||||||
)
|
)
|
||||||
.span_label_mv(
|
.with_span_label(
|
||||||
span,
|
span,
|
||||||
format!("{return_kind}s a {reference_desc} data owned by the current function"),
|
format!("{return_kind}s a {reference_desc} data owned by the current function"),
|
||||||
)
|
)
|
||||||
@ -444,8 +444,8 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
|||||||
"{closure_kind} may outlive the current {scope}, but it borrows {borrowed_path}, \
|
"{closure_kind} may outlive the current {scope}, but it borrows {borrowed_path}, \
|
||||||
which is owned by the current {scope}",
|
which is owned by the current {scope}",
|
||||||
)
|
)
|
||||||
.span_label_mv(capture_span, format!("{borrowed_path} is borrowed here"))
|
.with_span_label(capture_span, format!("{borrowed_path} is borrowed here"))
|
||||||
.span_label_mv(closure_span, format!("may outlive borrowed value {borrowed_path}"))
|
.with_span_label(closure_span, format!("may outlive borrowed value {borrowed_path}"))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn thread_local_value_does_not_live_long_enough(
|
pub(crate) fn thread_local_value_does_not_live_long_enough(
|
||||||
|
@ -2225,11 +2225,11 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
self.thread_local_value_does_not_live_long_enough(borrow_span)
|
self.thread_local_value_does_not_live_long_enough(borrow_span)
|
||||||
.span_label_mv(
|
.with_span_label(
|
||||||
borrow_span,
|
borrow_span,
|
||||||
"thread-local variables cannot be borrowed beyond the end of the function",
|
"thread-local variables cannot be borrowed beyond the end of the function",
|
||||||
)
|
)
|
||||||
.span_label_mv(drop_span, "end of enclosing function is here")
|
.with_span_label(drop_span, "end of enclosing function is here")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(level = "debug", skip(self))]
|
#[instrument(level = "debug", skip(self))]
|
||||||
|
@ -334,7 +334,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
|||||||
span,
|
span,
|
||||||
&format!("`{}` in pattern guard", self.local_names[local].unwrap()),
|
&format!("`{}` in pattern guard", self.local_names[local].unwrap()),
|
||||||
)
|
)
|
||||||
.note_mv(
|
.with_note(
|
||||||
"variables bound in patterns cannot be moved from \
|
"variables bound in patterns cannot be moved from \
|
||||||
until after the end of the pattern guard",
|
until after the end of the pattern guard",
|
||||||
);
|
);
|
||||||
@ -382,8 +382,8 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
self.cannot_move_out_of(span, &place_description)
|
self.cannot_move_out_of(span, &place_description)
|
||||||
.span_label_mv(upvar_span, "captured outer variable")
|
.with_span_label(upvar_span, "captured outer variable")
|
||||||
.span_label_mv(
|
.with_span_label(
|
||||||
self.infcx.tcx.def_span(def_id),
|
self.infcx.tcx.def_span(def_id),
|
||||||
format!("captured by this `{closure_kind}` closure"),
|
format!("captured by this `{closure_kind}` closure"),
|
||||||
)
|
)
|
||||||
|
@ -421,7 +421,7 @@ fn check_opaque_type_parameter_valid(
|
|||||||
return Err(tcx
|
return Err(tcx
|
||||||
.dcx()
|
.dcx()
|
||||||
.struct_span_err(span, "non-defining opaque type use in defining scope")
|
.struct_span_err(span, "non-defining opaque type use in defining scope")
|
||||||
.span_note_mv(spans, format!("{descr} used multiple times"))
|
.with_span_note(spans, format!("{descr} used multiple times"))
|
||||||
.emit());
|
.emit());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -695,8 +695,8 @@ fn expand_preparsed_asm(ecx: &mut ExtCtxt<'_>, args: AsmArgs) -> Option<ast::Inl
|
|||||||
let (sp, msg) = unused_operands.into_iter().next().unwrap();
|
let (sp, msg) = unused_operands.into_iter().next().unwrap();
|
||||||
ecx.dcx()
|
ecx.dcx()
|
||||||
.struct_span_err(sp, msg)
|
.struct_span_err(sp, msg)
|
||||||
.span_label_mv(sp, msg)
|
.with_span_label(sp, msg)
|
||||||
.help_mv(format!(
|
.with_help(format!(
|
||||||
"if this argument is intentionally unused, \
|
"if this argument is intentionally unused, \
|
||||||
consider using it in an asm comment: `\"/*{help_str} */\"`"
|
consider using it in an asm comment: `\"/*{help_str} */\"`"
|
||||||
))
|
))
|
||||||
|
@ -817,9 +817,9 @@ impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for AsmClobberNoReg {
|
|||||||
level,
|
level,
|
||||||
crate::fluent_generated::builtin_macros_asm_clobber_no_reg,
|
crate::fluent_generated::builtin_macros_asm_clobber_no_reg,
|
||||||
)
|
)
|
||||||
.span_mv(self.spans.clone())
|
.with_span(self.spans.clone())
|
||||||
.span_labels_mv(self.clobbers, &lbl1)
|
.with_span_labels(self.clobbers, &lbl1)
|
||||||
.span_labels_mv(self.spans, &lbl2)
|
.with_span_labels(self.spans, &lbl2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,7 +194,7 @@ impl<'a> Visitor<'a> for CollectProcMacros<'a> {
|
|||||||
|
|
||||||
self.dcx
|
self.dcx
|
||||||
.struct_span_err(attr.span, msg)
|
.struct_span_err(attr.span, msg)
|
||||||
.span_label_mv(prev_attr.span, "previous attribute here")
|
.with_span_label(prev_attr.span, "previous attribute here")
|
||||||
.emit();
|
.emit();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -409,8 +409,8 @@ fn not_testable_error(cx: &ExtCtxt<'_>, attr_sp: Span, item: Option<&ast::Item>)
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
err.span_label_mv(attr_sp, "the `#[test]` macro causes a function to be run as a test and has no effect on non-functions")
|
err.with_span_label(attr_sp, "the `#[test]` macro causes a function to be run as a test and has no effect on non-functions")
|
||||||
.span_suggestion_mv(attr_sp,
|
.with_span_suggestion(attr_sp,
|
||||||
"replace with conditional compilation to make the item only exist when tests are being run",
|
"replace with conditional compilation to make the item only exist when tests are being run",
|
||||||
"#[cfg(test)]",
|
"#[cfg(test)]",
|
||||||
Applicability::MaybeIncorrect)
|
Applicability::MaybeIncorrect)
|
||||||
@ -480,7 +480,7 @@ fn should_panic(cx: &ExtCtxt<'_>, i: &ast::Item) -> ShouldPanic {
|
|||||||
"argument must be of the form: \
|
"argument must be of the form: \
|
||||||
`expected = \"error message\"`",
|
`expected = \"error message\"`",
|
||||||
)
|
)
|
||||||
.note_mv(
|
.with_note(
|
||||||
"errors in this attribute were erroneously \
|
"errors in this attribute were erroneously \
|
||||||
allowed and will become a hard error in a \
|
allowed and will become a hard error in a \
|
||||||
future release",
|
future release",
|
||||||
|
@ -106,7 +106,7 @@ impl<G: EmissionGuarantee> IntoDiagnostic<'_, G> for ParseTargetMachineConfig<'_
|
|||||||
let message = dcx.eagerly_translate_to_string(message.clone(), diag.args());
|
let message = dcx.eagerly_translate_to_string(message.clone(), diag.args());
|
||||||
|
|
||||||
DiagnosticBuilder::new(dcx, level, fluent::codegen_llvm_parse_target_machine_config)
|
DiagnosticBuilder::new(dcx, level, fluent::codegen_llvm_parse_target_machine_config)
|
||||||
.arg_mv("error", message)
|
.with_arg("error", message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,8 +204,8 @@ impl<G: EmissionGuarantee> IntoDiagnostic<'_, G> for WithLlvmError<'_> {
|
|||||||
};
|
};
|
||||||
self.0
|
self.0
|
||||||
.into_diagnostic(dcx, level)
|
.into_diagnostic(dcx, level)
|
||||||
.primary_message_mv(msg_with_llvm_err)
|
.with_primary_message(msg_with_llvm_err)
|
||||||
.arg_mv("llvm_err", self.1)
|
.with_arg("llvm_err", self.1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -309,7 +309,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
|
|||||||
attr.span,
|
attr.span,
|
||||||
"`#[target_feature(..)]` can only be applied to `unsafe` functions",
|
"`#[target_feature(..)]` can only be applied to `unsafe` functions",
|
||||||
)
|
)
|
||||||
.span_label_mv(tcx.def_span(did), "not an `unsafe` function")
|
.with_span_label(tcx.def_span(did), "not an `unsafe` function")
|
||||||
.emit();
|
.emit();
|
||||||
} else {
|
} else {
|
||||||
check_target_feature_trait_unsafe(tcx, did, attr.span);
|
check_target_feature_trait_unsafe(tcx, did, attr.span);
|
||||||
@ -478,7 +478,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
|
|||||||
InlineAttr::Never
|
InlineAttr::Never
|
||||||
} else {
|
} else {
|
||||||
struct_span_code_err!(tcx.dcx(), items[0].span(), E0535, "invalid argument")
|
struct_span_code_err!(tcx.dcx(), items[0].span(), E0535, "invalid argument")
|
||||||
.help_mv("valid inline arguments are `always` and `never`")
|
.with_help("valid inline arguments are `always` and `never`")
|
||||||
.emit();
|
.emit();
|
||||||
|
|
||||||
InlineAttr::None
|
InlineAttr::None
|
||||||
@ -663,7 +663,7 @@ fn check_link_ordinal(tcx: TyCtxt<'_>, attr: &ast::Attribute) -> Option<u16> {
|
|||||||
let msg = format!("ordinal value in `link_ordinal` is too large: `{}`", &ordinal);
|
let msg = format!("ordinal value in `link_ordinal` is too large: `{}`", &ordinal);
|
||||||
tcx.dcx()
|
tcx.dcx()
|
||||||
.struct_span_err(attr.span, msg)
|
.struct_span_err(attr.span, msg)
|
||||||
.note_mv("the value may not exceed `u16::MAX`")
|
.with_note("the value may not exceed `u16::MAX`")
|
||||||
.emit();
|
.emit();
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -230,25 +230,25 @@ impl<G: EmissionGuarantee> IntoDiagnostic<'_, G> for ThorinErrorWrapper {
|
|||||||
thorin::Error::DecompressData(_) => build(fluent::codegen_ssa_thorin_decompress_data),
|
thorin::Error::DecompressData(_) => build(fluent::codegen_ssa_thorin_decompress_data),
|
||||||
thorin::Error::NamelessSection(_, offset) => {
|
thorin::Error::NamelessSection(_, offset) => {
|
||||||
build(fluent::codegen_ssa_thorin_section_without_name)
|
build(fluent::codegen_ssa_thorin_section_without_name)
|
||||||
.arg_mv("offset", format!("0x{offset:08x}"))
|
.with_arg("offset", format!("0x{offset:08x}"))
|
||||||
}
|
}
|
||||||
thorin::Error::RelocationWithInvalidSymbol(section, offset) => {
|
thorin::Error::RelocationWithInvalidSymbol(section, offset) => {
|
||||||
build(fluent::codegen_ssa_thorin_relocation_with_invalid_symbol)
|
build(fluent::codegen_ssa_thorin_relocation_with_invalid_symbol)
|
||||||
.arg_mv("section", section)
|
.with_arg("section", section)
|
||||||
.arg_mv("offset", format!("0x{offset:08x}"))
|
.with_arg("offset", format!("0x{offset:08x}"))
|
||||||
}
|
}
|
||||||
thorin::Error::MultipleRelocations(section, offset) => {
|
thorin::Error::MultipleRelocations(section, offset) => {
|
||||||
build(fluent::codegen_ssa_thorin_multiple_relocations)
|
build(fluent::codegen_ssa_thorin_multiple_relocations)
|
||||||
.arg_mv("section", section)
|
.with_arg("section", section)
|
||||||
.arg_mv("offset", format!("0x{offset:08x}"))
|
.with_arg("offset", format!("0x{offset:08x}"))
|
||||||
}
|
}
|
||||||
thorin::Error::UnsupportedRelocation(section, offset) => {
|
thorin::Error::UnsupportedRelocation(section, offset) => {
|
||||||
build(fluent::codegen_ssa_thorin_unsupported_relocation)
|
build(fluent::codegen_ssa_thorin_unsupported_relocation)
|
||||||
.arg_mv("section", section)
|
.with_arg("section", section)
|
||||||
.arg_mv("offset", format!("0x{offset:08x}"))
|
.with_arg("offset", format!("0x{offset:08x}"))
|
||||||
}
|
}
|
||||||
thorin::Error::MissingDwoName(id) => build(fluent::codegen_ssa_thorin_missing_dwo_name)
|
thorin::Error::MissingDwoName(id) => build(fluent::codegen_ssa_thorin_missing_dwo_name)
|
||||||
.arg_mv("id", format!("0x{id:08x}")),
|
.with_arg("id", format!("0x{id:08x}")),
|
||||||
thorin::Error::NoCompilationUnits => {
|
thorin::Error::NoCompilationUnits => {
|
||||||
build(fluent::codegen_ssa_thorin_no_compilation_units)
|
build(fluent::codegen_ssa_thorin_no_compilation_units)
|
||||||
}
|
}
|
||||||
@ -258,7 +258,7 @@ impl<G: EmissionGuarantee> IntoDiagnostic<'_, G> for ThorinErrorWrapper {
|
|||||||
}
|
}
|
||||||
thorin::Error::MissingRequiredSection(section) => {
|
thorin::Error::MissingRequiredSection(section) => {
|
||||||
build(fluent::codegen_ssa_thorin_missing_required_section)
|
build(fluent::codegen_ssa_thorin_missing_required_section)
|
||||||
.arg_mv("section", section)
|
.with_arg("section", section)
|
||||||
}
|
}
|
||||||
thorin::Error::ParseUnitAbbreviations(_) => {
|
thorin::Error::ParseUnitAbbreviations(_) => {
|
||||||
build(fluent::codegen_ssa_thorin_parse_unit_abbreviations)
|
build(fluent::codegen_ssa_thorin_parse_unit_abbreviations)
|
||||||
@ -272,31 +272,30 @@ impl<G: EmissionGuarantee> IntoDiagnostic<'_, G> for ThorinErrorWrapper {
|
|||||||
thorin::Error::ParseUnit(_) => build(fluent::codegen_ssa_thorin_parse_unit),
|
thorin::Error::ParseUnit(_) => build(fluent::codegen_ssa_thorin_parse_unit),
|
||||||
thorin::Error::IncompatibleIndexVersion(section, format, actual) => {
|
thorin::Error::IncompatibleIndexVersion(section, format, actual) => {
|
||||||
build(fluent::codegen_ssa_thorin_incompatible_index_version)
|
build(fluent::codegen_ssa_thorin_incompatible_index_version)
|
||||||
.arg_mv("section", section)
|
.with_arg("section", section)
|
||||||
.arg_mv("actual", actual)
|
.with_arg("actual", actual)
|
||||||
.arg_mv("format", format)
|
.with_arg("format", format)
|
||||||
}
|
}
|
||||||
thorin::Error::OffsetAtIndex(_, index) => {
|
thorin::Error::OffsetAtIndex(_, index) => {
|
||||||
build(fluent::codegen_ssa_thorin_offset_at_index).arg_mv("index", index)
|
build(fluent::codegen_ssa_thorin_offset_at_index).with_arg("index", index)
|
||||||
}
|
}
|
||||||
thorin::Error::StrAtOffset(_, offset) => {
|
thorin::Error::StrAtOffset(_, offset) => {
|
||||||
build(fluent::codegen_ssa_thorin_str_at_offset)
|
build(fluent::codegen_ssa_thorin_str_at_offset)
|
||||||
.arg_mv("offset", format!("0x{offset:08x}"))
|
.with_arg("offset", format!("0x{offset:08x}"))
|
||||||
}
|
}
|
||||||
thorin::Error::ParseIndex(_, section) => {
|
thorin::Error::ParseIndex(_, section) => {
|
||||||
build(fluent::codegen_ssa_thorin_parse_index).arg_mv("section", section)
|
build(fluent::codegen_ssa_thorin_parse_index).with_arg("section", section)
|
||||||
}
|
}
|
||||||
thorin::Error::UnitNotInIndex(unit) => {
|
thorin::Error::UnitNotInIndex(unit) => {
|
||||||
build(fluent::codegen_ssa_thorin_unit_not_in_index)
|
build(fluent::codegen_ssa_thorin_unit_not_in_index)
|
||||||
.arg_mv("unit", format!("0x{unit:08x}"))
|
.with_arg("unit", format!("0x{unit:08x}"))
|
||||||
}
|
}
|
||||||
thorin::Error::RowNotInIndex(_, row) => {
|
thorin::Error::RowNotInIndex(_, row) => {
|
||||||
build(fluent::codegen_ssa_thorin_row_not_in_index).arg_mv("row", row)
|
build(fluent::codegen_ssa_thorin_row_not_in_index).with_arg("row", row)
|
||||||
}
|
}
|
||||||
thorin::Error::SectionNotInRow => build(fluent::codegen_ssa_thorin_section_not_in_row),
|
thorin::Error::SectionNotInRow => build(fluent::codegen_ssa_thorin_section_not_in_row),
|
||||||
thorin::Error::EmptyUnit(unit) => {
|
thorin::Error::EmptyUnit(unit) => build(fluent::codegen_ssa_thorin_empty_unit)
|
||||||
build(fluent::codegen_ssa_thorin_empty_unit).arg_mv("unit", format!("0x{unit:08x}"))
|
.with_arg("unit", format!("0x{unit:08x}")),
|
||||||
}
|
|
||||||
thorin::Error::MultipleDebugInfoSection => {
|
thorin::Error::MultipleDebugInfoSection => {
|
||||||
build(fluent::codegen_ssa_thorin_multiple_debug_info_section)
|
build(fluent::codegen_ssa_thorin_multiple_debug_info_section)
|
||||||
}
|
}
|
||||||
@ -305,10 +304,10 @@ impl<G: EmissionGuarantee> IntoDiagnostic<'_, G> for ThorinErrorWrapper {
|
|||||||
}
|
}
|
||||||
thorin::Error::NotSplitUnit => build(fluent::codegen_ssa_thorin_not_split_unit),
|
thorin::Error::NotSplitUnit => build(fluent::codegen_ssa_thorin_not_split_unit),
|
||||||
thorin::Error::DuplicateUnit(unit) => build(fluent::codegen_ssa_thorin_duplicate_unit)
|
thorin::Error::DuplicateUnit(unit) => build(fluent::codegen_ssa_thorin_duplicate_unit)
|
||||||
.arg_mv("unit", format!("0x{unit:08x}")),
|
.with_arg("unit", format!("0x{unit:08x}")),
|
||||||
thorin::Error::MissingReferencedUnit(unit) => {
|
thorin::Error::MissingReferencedUnit(unit) => {
|
||||||
build(fluent::codegen_ssa_thorin_missing_referenced_unit)
|
build(fluent::codegen_ssa_thorin_missing_referenced_unit)
|
||||||
.arg_mv("unit", format!("0x{unit:08x}"))
|
.with_arg("unit", format!("0x{unit:08x}"))
|
||||||
}
|
}
|
||||||
thorin::Error::NoOutputObjectCreated => {
|
thorin::Error::NoOutputObjectCreated => {
|
||||||
build(fluent::codegen_ssa_thorin_not_output_object_created)
|
build(fluent::codegen_ssa_thorin_not_output_object_created)
|
||||||
@ -317,19 +316,19 @@ impl<G: EmissionGuarantee> IntoDiagnostic<'_, G> for ThorinErrorWrapper {
|
|||||||
build(fluent::codegen_ssa_thorin_mixed_input_encodings)
|
build(fluent::codegen_ssa_thorin_mixed_input_encodings)
|
||||||
}
|
}
|
||||||
thorin::Error::Io(e) => {
|
thorin::Error::Io(e) => {
|
||||||
build(fluent::codegen_ssa_thorin_io).arg_mv("error", format!("{e}"))
|
build(fluent::codegen_ssa_thorin_io).with_arg("error", format!("{e}"))
|
||||||
}
|
}
|
||||||
thorin::Error::ObjectRead(e) => {
|
thorin::Error::ObjectRead(e) => {
|
||||||
build(fluent::codegen_ssa_thorin_object_read).arg_mv("error", format!("{e}"))
|
build(fluent::codegen_ssa_thorin_object_read).with_arg("error", format!("{e}"))
|
||||||
}
|
}
|
||||||
thorin::Error::ObjectWrite(e) => {
|
thorin::Error::ObjectWrite(e) => {
|
||||||
build(fluent::codegen_ssa_thorin_object_write).arg_mv("error", format!("{e}"))
|
build(fluent::codegen_ssa_thorin_object_write).with_arg("error", format!("{e}"))
|
||||||
}
|
}
|
||||||
thorin::Error::GimliRead(e) => {
|
thorin::Error::GimliRead(e) => {
|
||||||
build(fluent::codegen_ssa_thorin_gimli_read).arg_mv("error", format!("{e}"))
|
build(fluent::codegen_ssa_thorin_gimli_read).with_arg("error", format!("{e}"))
|
||||||
}
|
}
|
||||||
thorin::Error::GimliWrite(e) => {
|
thorin::Error::GimliWrite(e) => {
|
||||||
build(fluent::codegen_ssa_thorin_gimli_write).arg_mv("error", format!("{e}"))
|
build(fluent::codegen_ssa_thorin_gimli_write).with_arg("error", format!("{e}"))
|
||||||
}
|
}
|
||||||
_ => unimplemented!("Untranslated thorin error"),
|
_ => unimplemented!("Untranslated thorin error"),
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ pub fn from_target_feature(
|
|||||||
let code = "enable = \"..\"";
|
let code = "enable = \"..\"";
|
||||||
tcx.dcx()
|
tcx.dcx()
|
||||||
.struct_span_err(span, msg)
|
.struct_span_err(span, msg)
|
||||||
.span_suggestion_mv(span, "must be of the form", code, Applicability::HasPlaceholders)
|
.with_span_suggestion(span, "must be of the form", code, Applicability::HasPlaceholders)
|
||||||
.emit();
|
.emit();
|
||||||
};
|
};
|
||||||
let rust_features = tcx.features();
|
let rust_features = tcx.features();
|
||||||
|
@ -30,7 +30,7 @@ where
|
|||||||
G: EmissionGuarantee,
|
G: EmissionGuarantee,
|
||||||
{
|
{
|
||||||
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> DiagnosticBuilder<'a, G> {
|
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> DiagnosticBuilder<'a, G> {
|
||||||
self.node.into_diagnostic(dcx, level).span_mv(self.span)
|
self.node.into_diagnostic(dcx, level).with_span(self.span)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,26 +173,26 @@ impl EmissionGuarantee for rustc_span::fatal_error::FatalError {
|
|||||||
/// `Diagnostic` method. It is mostly to modify existing diagnostics, either
|
/// `Diagnostic` method. It is mostly to modify existing diagnostics, either
|
||||||
/// in a standalone fashion, e.g. `err.code(code)`, or in a chained fashion
|
/// in a standalone fashion, e.g. `err.code(code)`, or in a chained fashion
|
||||||
/// to make multiple modifications, e.g. `err.code(code).span(span)`.
|
/// to make multiple modifications, e.g. `err.code(code).span(span)`.
|
||||||
/// - A `self -> Self` method, with `_mv` suffix added (short for "move").
|
/// - A `self -> Self` method, which has a `with_` prefix added.
|
||||||
/// It is mostly used in a chained fashion when producing a new diagnostic,
|
/// It is mostly used in a chained fashion when producing a new diagnostic,
|
||||||
/// e.g. `let err = struct_err(msg).code_mv(code)`, or when emitting a new
|
/// e.g. `let err = struct_err(msg).with_code(code)`, or when emitting a new
|
||||||
/// diagnostic , e.g. `struct_err(msg).code_mv(code).emit()`.
|
/// diagnostic , e.g. `struct_err(msg).with_code(code).emit()`.
|
||||||
///
|
///
|
||||||
/// Although the latter method can be used to modify an existing diagnostic,
|
/// Although the latter method can be used to modify an existing diagnostic,
|
||||||
/// e.g. `err = err.code_mv(code)`, this should be avoided because the former
|
/// e.g. `err = err.with_code(code)`, this should be avoided because the former
|
||||||
/// method give shorter code, e.g. `err.code(code)`.
|
/// method gives shorter code, e.g. `err.code(code)`.
|
||||||
macro_rules! forward {
|
macro_rules! forward {
|
||||||
(
|
(
|
||||||
($n:ident, $n_mv:ident)($($name:ident: $ty:ty),* $(,)?)
|
($f:ident, $with_f:ident)($($name:ident: $ty:ty),* $(,)?)
|
||||||
) => {
|
) => {
|
||||||
#[doc = concat!("See [`Diagnostic::", stringify!($n), "()`].")]
|
#[doc = concat!("See [`Diagnostic::", stringify!($f), "()`].")]
|
||||||
pub fn $n(&mut self, $($name: $ty),*) -> &mut Self {
|
pub fn $f(&mut self, $($name: $ty),*) -> &mut Self {
|
||||||
self.diag.as_mut().unwrap().$n($($name),*);
|
self.diag.as_mut().unwrap().$f($($name),*);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
#[doc = concat!("See [`Diagnostic::", stringify!($n), "()`].")]
|
#[doc = concat!("See [`Diagnostic::", stringify!($f), "()`].")]
|
||||||
pub fn $n_mv(mut self, $($name: $ty),*) -> Self {
|
pub fn $with_f(mut self, $($name: $ty),*) -> Self {
|
||||||
self.diag.as_mut().unwrap().$n($($name),*);
|
self.diag.as_mut().unwrap().$f($($name),*);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -302,21 +302,21 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
|
|||||||
self.emit()
|
self.emit()
|
||||||
}
|
}
|
||||||
|
|
||||||
forward!((span_label, span_label_mv)(
|
forward!((span_label, with_span_label)(
|
||||||
span: Span,
|
span: Span,
|
||||||
label: impl Into<SubdiagnosticMessage>,
|
label: impl Into<SubdiagnosticMessage>,
|
||||||
));
|
));
|
||||||
forward!((span_labels, span_labels_mv)(
|
forward!((span_labels, with_span_labels)(
|
||||||
spans: impl IntoIterator<Item = Span>,
|
spans: impl IntoIterator<Item = Span>,
|
||||||
label: &str,
|
label: &str,
|
||||||
));
|
));
|
||||||
forward!((note_expected_found, note_expected_found_mv)(
|
forward!((note_expected_found, with_note_expected_found)(
|
||||||
expected_label: &dyn fmt::Display,
|
expected_label: &dyn fmt::Display,
|
||||||
expected: DiagnosticStyledString,
|
expected: DiagnosticStyledString,
|
||||||
found_label: &dyn fmt::Display,
|
found_label: &dyn fmt::Display,
|
||||||
found: DiagnosticStyledString,
|
found: DiagnosticStyledString,
|
||||||
));
|
));
|
||||||
forward!((note_expected_found_extra, note_expected_found_extra_mv)(
|
forward!((note_expected_found_extra, with_note_expected_found_extra)(
|
||||||
expected_label: &dyn fmt::Display,
|
expected_label: &dyn fmt::Display,
|
||||||
expected: DiagnosticStyledString,
|
expected: DiagnosticStyledString,
|
||||||
found_label: &dyn fmt::Display,
|
found_label: &dyn fmt::Display,
|
||||||
@ -324,106 +324,106 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
|
|||||||
expected_extra: &dyn fmt::Display,
|
expected_extra: &dyn fmt::Display,
|
||||||
found_extra: &dyn fmt::Display,
|
found_extra: &dyn fmt::Display,
|
||||||
));
|
));
|
||||||
forward!((note, note_mv)(
|
forward!((note, with_note)(
|
||||||
msg: impl Into<SubdiagnosticMessage>,
|
msg: impl Into<SubdiagnosticMessage>,
|
||||||
));
|
));
|
||||||
forward!((note_once, note_once_mv)(
|
forward!((note_once, with_note_once)(
|
||||||
msg: impl Into<SubdiagnosticMessage>,
|
msg: impl Into<SubdiagnosticMessage>,
|
||||||
));
|
));
|
||||||
forward!((span_note, span_note_mv)(
|
forward!((span_note, with_span_note)(
|
||||||
sp: impl Into<MultiSpan>,
|
sp: impl Into<MultiSpan>,
|
||||||
msg: impl Into<SubdiagnosticMessage>,
|
msg: impl Into<SubdiagnosticMessage>,
|
||||||
));
|
));
|
||||||
forward!((span_note_once, span_note_once_mv)(
|
forward!((span_note_once, with_span_note_once)(
|
||||||
sp: impl Into<MultiSpan>,
|
sp: impl Into<MultiSpan>,
|
||||||
msg: impl Into<SubdiagnosticMessage>,
|
msg: impl Into<SubdiagnosticMessage>,
|
||||||
));
|
));
|
||||||
forward!((warn, warn_mv)(
|
forward!((warn, with_warn)(
|
||||||
msg: impl Into<SubdiagnosticMessage>,
|
msg: impl Into<SubdiagnosticMessage>,
|
||||||
));
|
));
|
||||||
forward!((span_warn, span_warn_mv)(
|
forward!((span_warn, with_span_warn)(
|
||||||
sp: impl Into<MultiSpan>,
|
sp: impl Into<MultiSpan>,
|
||||||
msg: impl Into<SubdiagnosticMessage>,
|
msg: impl Into<SubdiagnosticMessage>,
|
||||||
));
|
));
|
||||||
forward!((help, help_mv)(
|
forward!((help, with_help)(
|
||||||
msg: impl Into<SubdiagnosticMessage>,
|
msg: impl Into<SubdiagnosticMessage>,
|
||||||
));
|
));
|
||||||
forward!((help_once, help_once_mv)(
|
forward!((help_once, with_help_once)(
|
||||||
msg: impl Into<SubdiagnosticMessage>,
|
msg: impl Into<SubdiagnosticMessage>,
|
||||||
));
|
));
|
||||||
forward!((span_help, span_help_once_mv)(
|
forward!((span_help, with_span_help_once)(
|
||||||
sp: impl Into<MultiSpan>,
|
sp: impl Into<MultiSpan>,
|
||||||
msg: impl Into<SubdiagnosticMessage>,
|
msg: impl Into<SubdiagnosticMessage>,
|
||||||
));
|
));
|
||||||
forward!((multipart_suggestion, multipart_suggestion_mv)(
|
forward!((multipart_suggestion, with_multipart_suggestion)(
|
||||||
msg: impl Into<SubdiagnosticMessage>,
|
msg: impl Into<SubdiagnosticMessage>,
|
||||||
suggestion: Vec<(Span, String)>,
|
suggestion: Vec<(Span, String)>,
|
||||||
applicability: Applicability,
|
applicability: Applicability,
|
||||||
));
|
));
|
||||||
forward!((multipart_suggestion_verbose, multipart_suggestion_verbose_mv)(
|
forward!((multipart_suggestion_verbose, with_multipart_suggestion_verbose)(
|
||||||
msg: impl Into<SubdiagnosticMessage>,
|
msg: impl Into<SubdiagnosticMessage>,
|
||||||
suggestion: Vec<(Span, String)>,
|
suggestion: Vec<(Span, String)>,
|
||||||
applicability: Applicability,
|
applicability: Applicability,
|
||||||
));
|
));
|
||||||
forward!((tool_only_multipart_suggestion, tool_only_multipart_suggestion_mv)(
|
forward!((tool_only_multipart_suggestion, with_tool_only_multipart_suggestion)(
|
||||||
msg: impl Into<SubdiagnosticMessage>,
|
msg: impl Into<SubdiagnosticMessage>,
|
||||||
suggestion: Vec<(Span, String)>,
|
suggestion: Vec<(Span, String)>,
|
||||||
applicability: Applicability,
|
applicability: Applicability,
|
||||||
));
|
));
|
||||||
forward!((span_suggestion, span_suggestion_mv)(
|
forward!((span_suggestion, with_span_suggestion)(
|
||||||
sp: Span,
|
sp: Span,
|
||||||
msg: impl Into<SubdiagnosticMessage>,
|
msg: impl Into<SubdiagnosticMessage>,
|
||||||
suggestion: impl ToString,
|
suggestion: impl ToString,
|
||||||
applicability: Applicability,
|
applicability: Applicability,
|
||||||
));
|
));
|
||||||
forward!((span_suggestions, span_suggestions_mv)(
|
forward!((span_suggestions, with_span_suggestions)(
|
||||||
sp: Span,
|
sp: Span,
|
||||||
msg: impl Into<SubdiagnosticMessage>,
|
msg: impl Into<SubdiagnosticMessage>,
|
||||||
suggestions: impl IntoIterator<Item = String>,
|
suggestions: impl IntoIterator<Item = String>,
|
||||||
applicability: Applicability,
|
applicability: Applicability,
|
||||||
));
|
));
|
||||||
forward!((multipart_suggestions, multipart_suggestions_mv)(
|
forward!((multipart_suggestions, with_multipart_suggestions)(
|
||||||
msg: impl Into<SubdiagnosticMessage>,
|
msg: impl Into<SubdiagnosticMessage>,
|
||||||
suggestions: impl IntoIterator<Item = Vec<(Span, String)>>,
|
suggestions: impl IntoIterator<Item = Vec<(Span, String)>>,
|
||||||
applicability: Applicability,
|
applicability: Applicability,
|
||||||
));
|
));
|
||||||
forward!((span_suggestion_short, span_suggestion_short_mv)(
|
forward!((span_suggestion_short, with_span_suggestion_short)(
|
||||||
sp: Span,
|
sp: Span,
|
||||||
msg: impl Into<SubdiagnosticMessage>,
|
msg: impl Into<SubdiagnosticMessage>,
|
||||||
suggestion: impl ToString,
|
suggestion: impl ToString,
|
||||||
applicability: Applicability,
|
applicability: Applicability,
|
||||||
));
|
));
|
||||||
forward!((span_suggestion_verbose, span_suggestion_verbose_mv)(
|
forward!((span_suggestion_verbose, with_span_suggestion_verbose)(
|
||||||
sp: Span,
|
sp: Span,
|
||||||
msg: impl Into<SubdiagnosticMessage>,
|
msg: impl Into<SubdiagnosticMessage>,
|
||||||
suggestion: impl ToString,
|
suggestion: impl ToString,
|
||||||
applicability: Applicability,
|
applicability: Applicability,
|
||||||
));
|
));
|
||||||
forward!((span_suggestion_hidden, span_suggestion_hidden_mv)(
|
forward!((span_suggestion_hidden, with_span_suggestion_hidden)(
|
||||||
sp: Span,
|
sp: Span,
|
||||||
msg: impl Into<SubdiagnosticMessage>,
|
msg: impl Into<SubdiagnosticMessage>,
|
||||||
suggestion: impl ToString,
|
suggestion: impl ToString,
|
||||||
applicability: Applicability,
|
applicability: Applicability,
|
||||||
));
|
));
|
||||||
forward!((tool_only_span_suggestion, tool_only_span_suggestion_mv)(
|
forward!((tool_only_span_suggestion, with_tool_only_span_suggestion)(
|
||||||
sp: Span,
|
sp: Span,
|
||||||
msg: impl Into<SubdiagnosticMessage>,
|
msg: impl Into<SubdiagnosticMessage>,
|
||||||
suggestion: impl ToString,
|
suggestion: impl ToString,
|
||||||
applicability: Applicability,
|
applicability: Applicability,
|
||||||
));
|
));
|
||||||
forward!((primary_message, primary_message_mv)(
|
forward!((primary_message, with_primary_message)(
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagnosticMessage>,
|
||||||
));
|
));
|
||||||
forward!((span, span_mv)(
|
forward!((span, with_span)(
|
||||||
sp: impl Into<MultiSpan>,
|
sp: impl Into<MultiSpan>,
|
||||||
));
|
));
|
||||||
forward!((code, code_mv)(
|
forward!((code, with_code)(
|
||||||
s: DiagnosticId,
|
s: DiagnosticId,
|
||||||
));
|
));
|
||||||
forward!((arg, arg_mv)(
|
forward!((arg, with_arg)(
|
||||||
name: impl Into<Cow<'static, str>>, arg: impl IntoDiagnosticArg,
|
name: impl Into<Cow<'static, str>>, arg: impl IntoDiagnosticArg,
|
||||||
));
|
));
|
||||||
forward!((subdiagnostic, subdiagnostic_mv)(
|
forward!((subdiagnostic, with_subdiagnostic)(
|
||||||
subdiagnostic: impl crate::AddToDiagnostic,
|
subdiagnostic: impl crate::AddToDiagnostic,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -459,7 +459,7 @@ macro_rules! struct_span_code_err {
|
|||||||
$span,
|
$span,
|
||||||
format!($($message)*),
|
format!($($message)*),
|
||||||
)
|
)
|
||||||
.code_mv($crate::error_code!($code))
|
.with_code($crate::error_code!($code))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,40 +252,40 @@ impl<G: EmissionGuarantee> IntoDiagnostic<'_, G> for TargetDataLayoutErrors<'_>
|
|||||||
match self {
|
match self {
|
||||||
TargetDataLayoutErrors::InvalidAddressSpace { addr_space, err, cause } => {
|
TargetDataLayoutErrors::InvalidAddressSpace { addr_space, err, cause } => {
|
||||||
DiagnosticBuilder::new(dcx, level, fluent::errors_target_invalid_address_space)
|
DiagnosticBuilder::new(dcx, level, fluent::errors_target_invalid_address_space)
|
||||||
.arg_mv("addr_space", addr_space)
|
.with_arg("addr_space", addr_space)
|
||||||
.arg_mv("cause", cause)
|
.with_arg("cause", cause)
|
||||||
.arg_mv("err", err)
|
.with_arg("err", err)
|
||||||
}
|
}
|
||||||
TargetDataLayoutErrors::InvalidBits { kind, bit, cause, err } => {
|
TargetDataLayoutErrors::InvalidBits { kind, bit, cause, err } => {
|
||||||
DiagnosticBuilder::new(dcx, level, fluent::errors_target_invalid_bits)
|
DiagnosticBuilder::new(dcx, level, fluent::errors_target_invalid_bits)
|
||||||
.arg_mv("kind", kind)
|
.with_arg("kind", kind)
|
||||||
.arg_mv("bit", bit)
|
.with_arg("bit", bit)
|
||||||
.arg_mv("cause", cause)
|
.with_arg("cause", cause)
|
||||||
.arg_mv("err", err)
|
.with_arg("err", err)
|
||||||
}
|
}
|
||||||
TargetDataLayoutErrors::MissingAlignment { cause } => {
|
TargetDataLayoutErrors::MissingAlignment { cause } => {
|
||||||
DiagnosticBuilder::new(dcx, level, fluent::errors_target_missing_alignment)
|
DiagnosticBuilder::new(dcx, level, fluent::errors_target_missing_alignment)
|
||||||
.arg_mv("cause", cause)
|
.with_arg("cause", cause)
|
||||||
}
|
}
|
||||||
TargetDataLayoutErrors::InvalidAlignment { cause, err } => {
|
TargetDataLayoutErrors::InvalidAlignment { cause, err } => {
|
||||||
DiagnosticBuilder::new(dcx, level, fluent::errors_target_invalid_alignment)
|
DiagnosticBuilder::new(dcx, level, fluent::errors_target_invalid_alignment)
|
||||||
.arg_mv("cause", cause)
|
.with_arg("cause", cause)
|
||||||
.arg_mv("err_kind", err.diag_ident())
|
.with_arg("err_kind", err.diag_ident())
|
||||||
.arg_mv("align", err.align())
|
.with_arg("align", err.align())
|
||||||
}
|
}
|
||||||
TargetDataLayoutErrors::InconsistentTargetArchitecture { dl, target } => {
|
TargetDataLayoutErrors::InconsistentTargetArchitecture { dl, target } => {
|
||||||
DiagnosticBuilder::new(dcx, level, fluent::errors_target_inconsistent_architecture)
|
DiagnosticBuilder::new(dcx, level, fluent::errors_target_inconsistent_architecture)
|
||||||
.arg_mv("dl", dl)
|
.with_arg("dl", dl)
|
||||||
.arg_mv("target", target)
|
.with_arg("target", target)
|
||||||
}
|
}
|
||||||
TargetDataLayoutErrors::InconsistentTargetPointerWidth { pointer_size, target } => {
|
TargetDataLayoutErrors::InconsistentTargetPointerWidth { pointer_size, target } => {
|
||||||
DiagnosticBuilder::new(dcx, level, fluent::errors_target_inconsistent_pointer_width)
|
DiagnosticBuilder::new(dcx, level, fluent::errors_target_inconsistent_pointer_width)
|
||||||
.arg_mv("pointer_size", pointer_size)
|
.with_arg("pointer_size", pointer_size)
|
||||||
.arg_mv("target", target)
|
.with_arg("target", target)
|
||||||
}
|
}
|
||||||
TargetDataLayoutErrors::InvalidBitsSize { err } => {
|
TargetDataLayoutErrors::InvalidBitsSize { err } => {
|
||||||
DiagnosticBuilder::new(dcx, level, fluent::errors_target_invalid_bits_size)
|
DiagnosticBuilder::new(dcx, level, fluent::errors_target_invalid_bits_size)
|
||||||
.arg_mv("err", err)
|
.with_arg("err", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -727,7 +727,7 @@ impl DiagCtxt {
|
|||||||
span: impl Into<MultiSpan>,
|
span: impl Into<MultiSpan>,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagnosticMessage>,
|
||||||
) -> DiagnosticBuilder<'_, ()> {
|
) -> 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`.
|
/// Construct a builder at the `Warning` level with the `msg`.
|
||||||
@ -767,7 +767,7 @@ impl DiagCtxt {
|
|||||||
span: impl Into<MultiSpan>,
|
span: impl Into<MultiSpan>,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagnosticMessage>,
|
||||||
) -> DiagnosticBuilder<'_> {
|
) -> 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`.
|
/// Construct a builder at the `Error` level with the `msg`.
|
||||||
@ -786,7 +786,7 @@ impl DiagCtxt {
|
|||||||
span: impl Into<MultiSpan>,
|
span: impl Into<MultiSpan>,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagnosticMessage>,
|
||||||
) -> DiagnosticBuilder<'_, FatalAbort> {
|
) -> 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`.
|
/// Construct a builder at the `Fatal` level with the `msg`.
|
||||||
@ -827,7 +827,7 @@ impl DiagCtxt {
|
|||||||
span: impl Into<MultiSpan>,
|
span: impl Into<MultiSpan>,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagnosticMessage>,
|
||||||
) -> DiagnosticBuilder<'_, BugAbort> {
|
) -> DiagnosticBuilder<'_, BugAbort> {
|
||||||
self.struct_bug(msg).span_mv(span)
|
self.struct_bug(msg).with_span(span)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rustc_lint_diagnostics]
|
#[rustc_lint_diagnostics]
|
||||||
@ -888,7 +888,7 @@ impl DiagCtxt {
|
|||||||
if treat_next_err_as_bug {
|
if treat_next_err_as_bug {
|
||||||
self.span_bug(sp, msg);
|
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
|
// FIXME(eddyb) note the comment inside `impl Drop for DiagCtxtInner`, that's
|
||||||
@ -913,7 +913,7 @@ impl DiagCtxt {
|
|||||||
span: impl Into<MultiSpan>,
|
span: impl Into<MultiSpan>,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagnosticMessage>,
|
||||||
) -> DiagnosticBuilder<'_, ()> {
|
) -> DiagnosticBuilder<'_, ()> {
|
||||||
DiagnosticBuilder::new(self, Note, msg).span_mv(span)
|
DiagnosticBuilder::new(self, Note, msg).with_span(span)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rustc_lint_diagnostics]
|
#[rustc_lint_diagnostics]
|
||||||
|
@ -680,7 +680,7 @@ impl TtParser {
|
|||||||
// edition-specific matching behavior for non-terminals.
|
// edition-specific matching behavior for non-terminals.
|
||||||
let nt = match parser.to_mut().parse_nonterminal(kind) {
|
let nt = match parser.to_mut().parse_nonterminal(kind) {
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
let guarantee = err.span_label_mv(
|
let guarantee = err.with_span_label(
|
||||||
span,
|
span,
|
||||||
format!(
|
format!(
|
||||||
"while parsing argument for this `{kind}` macro fragment"
|
"while parsing argument for this `{kind}` macro fragment"
|
||||||
|
@ -86,7 +86,7 @@ pub(super) fn parse(
|
|||||||
);
|
);
|
||||||
sess.dcx
|
sess.dcx
|
||||||
.struct_span_err(span, msg)
|
.struct_span_err(span, msg)
|
||||||
.help_mv(VALID_FRAGMENT_NAMES_MSG)
|
.with_help(VALID_FRAGMENT_NAMES_MSG)
|
||||||
.emit();
|
.emit();
|
||||||
token::NonterminalKind::Ident
|
token::NonterminalKind::Ident
|
||||||
},
|
},
|
||||||
|
@ -305,7 +305,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
|
|||||||
binding.span,
|
binding.span,
|
||||||
format!("{} `{}` is private", assoc_item.kind, binding.item_name),
|
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();
|
.emit();
|
||||||
}
|
}
|
||||||
tcx.check_stability(assoc_item.def_id, Some(hir_ref_id), binding.span, None);
|
tcx.check_stability(assoc_item.def_id, Some(hir_ref_id), binding.span, None);
|
||||||
|
@ -70,7 +70,7 @@ fn generic_arg_mismatch_err(
|
|||||||
Res::Err => {
|
Res::Err => {
|
||||||
add_braces_suggestion(arg, &mut err);
|
add_braces_suggestion(arg, &mut err);
|
||||||
return 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();
|
.emit();
|
||||||
}
|
}
|
||||||
Res::Def(DefKind::TyParam, src_def_id) => {
|
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
|
&& args.num_lifetime_params() != param_counts.lifetimes
|
||||||
{
|
{
|
||||||
struct_span_code_err!(tcx.dcx(), span, E0794, "{}", msg)
|
struct_span_code_err!(tcx.dcx(), span, E0794, "{}", msg)
|
||||||
.span_note_mv(span_late, note)
|
.with_span_note(span_late, note)
|
||||||
.emit();
|
.emit();
|
||||||
} else {
|
} else {
|
||||||
let mut multispan = MultiSpan::from_span(span);
|
let mut multispan = MultiSpan::from_span(span);
|
||||||
|
@ -1618,9 +1618,9 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||||||
let def_span = tcx.def_span(item);
|
let def_span = tcx.def_span(item);
|
||||||
tcx.dcx()
|
tcx.dcx()
|
||||||
.struct_span_err(span, msg)
|
.struct_span_err(span, msg)
|
||||||
.code_mv(rustc_errors::error_code!(E0624))
|
.with_code(rustc_errors::error_code!(E0624))
|
||||||
.span_label_mv(span, format!("private {kind}"))
|
.with_span_label(span, format!("private {kind}"))
|
||||||
.span_label_mv(def_span, format!("{kind} defined here"))
|
.with_span_label(def_span, format!("{kind} defined here"))
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
tcx.check_stability(item, Some(block), span, None);
|
tcx.check_stability(item, Some(block), span, None);
|
||||||
|
@ -298,7 +298,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||||||
tcx.def_descr(def_id),
|
tcx.def_descr(def_id),
|
||||||
tcx.item_name(def_id),
|
tcx.item_name(def_id),
|
||||||
)
|
)
|
||||||
.note_mv(
|
.with_note(
|
||||||
rustc_middle::traits::ObjectSafetyViolation::SupertraitSelf(smallvec![])
|
rustc_middle::traits::ObjectSafetyViolation::SupertraitSelf(smallvec![])
|
||||||
.error_msg(),
|
.error_msg(),
|
||||||
)
|
)
|
||||||
|
@ -566,8 +566,8 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) {
|
|||||||
E0044,
|
E0044,
|
||||||
"foreign items may not have {kinds} parameters",
|
"foreign items may not have {kinds} parameters",
|
||||||
)
|
)
|
||||||
.span_label_mv(item.span, format!("can't have {kinds} parameters"))
|
.with_span_label(item.span, format!("can't have {kinds} parameters"))
|
||||||
.help_mv(
|
.with_help(
|
||||||
// FIXME: once we start storing spans for type arguments, turn this
|
// FIXME: once we start storing spans for type arguments, turn this
|
||||||
// into a suggestion.
|
// into a suggestion.
|
||||||
format!(
|
format!(
|
||||||
@ -801,10 +801,9 @@ fn check_impl_items_against_trait<'tcx>(
|
|||||||
};
|
};
|
||||||
tcx.dcx()
|
tcx.dcx()
|
||||||
.struct_span_err(tcx.def_span(def_id), msg)
|
.struct_span_err(tcx.def_span(def_id), msg)
|
||||||
.note_mv(format!(
|
.with_note(format!(
|
||||||
"specialization behaves in inconsistent and \
|
"specialization behaves in inconsistent and surprising ways with \
|
||||||
surprising ways with {feature}, \
|
{feature}, and for now is disallowed"
|
||||||
and for now is disallowed"
|
|
||||||
))
|
))
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
@ -843,7 +842,7 @@ pub fn check_simd(tcx: TyCtxt<'_>, sp: Span, def_id: LocalDefId) {
|
|||||||
let e = fields[FieldIdx::from_u32(0)].ty(tcx, args);
|
let e = fields[FieldIdx::from_u32(0)].ty(tcx, args);
|
||||||
if !fields.iter().all(|f| f.ty(tcx, args) == e) {
|
if !fields.iter().all(|f| f.ty(tcx, args) == e) {
|
||||||
struct_span_code_err!(tcx.dcx(), sp, E0076, "SIMD vector should be homogeneous")
|
struct_span_code_err!(tcx.dcx(), sp, E0076, "SIMD vector should be homogeneous")
|
||||||
.span_label_mv(sp, "SIMD elements must have the same type")
|
.with_span_label(sp, "SIMD elements must have the same type")
|
||||||
.emit();
|
.emit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1120,7 +1119,7 @@ fn check_enum(tcx: TyCtxt<'_>, def_id: LocalDefId) {
|
|||||||
E0084,
|
E0084,
|
||||||
"unsupported representation for zero-variant enum"
|
"unsupported representation for zero-variant enum"
|
||||||
)
|
)
|
||||||
.span_label_mv(tcx.def_span(def_id), "zero-variant enum")
|
.with_span_label(tcx.def_span(def_id), "zero-variant enum")
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1313,7 +1312,7 @@ pub(super) fn check_type_params_are_used<'tcx>(
|
|||||||
"type parameter `{}` is unused",
|
"type parameter `{}` is unused",
|
||||||
param.name,
|
param.name,
|
||||||
)
|
)
|
||||||
.span_label_mv(span, "unused type parameter")
|
.with_span_label(span, "unused type parameter")
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -934,12 +934,12 @@ impl<'tcx> ty::FallibleTypeFolder<TyCtxt<'tcx>> for RemapHiddenTyRegions<'tcx> {
|
|||||||
return_span,
|
return_span,
|
||||||
"return type captures more lifetimes than trait definition",
|
"return type captures more lifetimes than trait definition",
|
||||||
)
|
)
|
||||||
.span_label_mv(self.tcx.def_span(def_id), "this lifetime was captured")
|
.with_span_label(self.tcx.def_span(def_id), "this lifetime was captured")
|
||||||
.span_note_mv(
|
.with_span_note(
|
||||||
self.tcx.def_span(self.def_id),
|
self.tcx.def_span(self.def_id),
|
||||||
"hidden type must only reference lifetimes captured by this impl trait",
|
"hidden type must only reference lifetimes captured by this impl trait",
|
||||||
)
|
)
|
||||||
.note_mv(format!("hidden type inferred to be `{}`", self.ty))
|
.with_note(format!("hidden type inferred to be `{}`", self.ty))
|
||||||
.emit()
|
.emit()
|
||||||
}
|
}
|
||||||
_ => self.tcx.dcx().delayed_bug("should've been able to remap region"),
|
_ => self.tcx.dcx().delayed_bug("should've been able to remap region"),
|
||||||
|
@ -165,7 +165,7 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>(
|
|||||||
"`Drop` impl requires `{root_predicate}` \
|
"`Drop` impl requires `{root_predicate}` \
|
||||||
but the {self_descr} it is implemented for does not",
|
but the {self_descr} it is implemented for does not",
|
||||||
)
|
)
|
||||||
.span_note_mv(item_span, "the implementor must specify the same requirement")
|
.with_span_note(item_span, "the implementor must specify the same requirement")
|
||||||
.emit(),
|
.emit(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -197,7 +197,7 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>(
|
|||||||
"`Drop` impl requires `{outlives}` \
|
"`Drop` impl requires `{outlives}` \
|
||||||
but the {self_descr} it is implemented for does not",
|
but the {self_descr} it is implemented for does not",
|
||||||
)
|
)
|
||||||
.span_note_mv(item_span, "the implementor must specify the same requirement")
|
.with_span_note(item_span, "the implementor must specify the same requirement")
|
||||||
.emit(),
|
.emit(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ fn equate_intrinsic_type<'tcx>(
|
|||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
struct_span_code_err!(tcx.dcx(), it.span, E0622, "intrinsic must be a function")
|
struct_span_code_err!(tcx.dcx(), it.span, E0622, "intrinsic must be a function")
|
||||||
.span_label_mv(it.span, "expected a function")
|
.with_span_label(it.span, "expected a function")
|
||||||
.emit();
|
.emit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -156,7 +156,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
|||||||
self.tcx
|
self.tcx
|
||||||
.dcx()
|
.dcx()
|
||||||
.struct_span_err(expr.span, msg)
|
.struct_span_err(expr.span, msg)
|
||||||
.note_mv(
|
.with_note(
|
||||||
"only integers, floats, SIMD vectors, pointers and function pointers \
|
"only integers, floats, SIMD vectors, pointers and function pointers \
|
||||||
can be used as arguments for inline assembly",
|
can be used as arguments for inline assembly",
|
||||||
)
|
)
|
||||||
@ -171,7 +171,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
|||||||
self.tcx
|
self.tcx
|
||||||
.dcx()
|
.dcx()
|
||||||
.struct_span_err(expr.span, msg)
|
.struct_span_err(expr.span, msg)
|
||||||
.note_mv(format!("`{ty}` does not implement the Copy trait"))
|
.with_note(format!("`{ty}` does not implement the Copy trait"))
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,9 +191,9 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
|||||||
self.tcx
|
self.tcx
|
||||||
.dcx()
|
.dcx()
|
||||||
.struct_span_err(vec![in_expr.span, expr.span], msg)
|
.struct_span_err(vec![in_expr.span, expr.span], msg)
|
||||||
.span_label_mv(in_expr.span, format!("type `{in_expr_ty}`"))
|
.with_span_label(in_expr.span, format!("type `{in_expr_ty}`"))
|
||||||
.span_label_mv(expr.span, format!("type `{ty}`"))
|
.with_span_label(expr.span, format!("type `{ty}`"))
|
||||||
.note_mv(
|
.with_note(
|
||||||
"asm inout arguments must have the same type, \
|
"asm inout arguments must have the same type, \
|
||||||
unless they are both pointers or integers of the same size",
|
unless they are both pointers or integers of the same size",
|
||||||
)
|
)
|
||||||
@ -242,7 +242,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
|||||||
self.tcx
|
self.tcx
|
||||||
.dcx()
|
.dcx()
|
||||||
.struct_span_err(expr.span, msg)
|
.struct_span_err(expr.span, msg)
|
||||||
.note_mv(format!(
|
.with_note(format!(
|
||||||
"this is required to use type `{}` with register class `{}`",
|
"this is required to use type `{}` with register class `{}`",
|
||||||
ty,
|
ty,
|
||||||
reg_class.name(),
|
reg_class.name(),
|
||||||
@ -459,11 +459,11 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
|||||||
self.tcx
|
self.tcx
|
||||||
.dcx()
|
.dcx()
|
||||||
.struct_span_err(*op_sp, "invalid `sym` operand")
|
.struct_span_err(*op_sp, "invalid `sym` operand")
|
||||||
.span_label_mv(
|
.with_span_label(
|
||||||
self.tcx.def_span(anon_const.def_id),
|
self.tcx.def_span(anon_const.def_id),
|
||||||
format!("is {} `{}`", ty.kind().article(), ty),
|
format!("is {} `{}`", ty.kind().article(), ty),
|
||||||
)
|
)
|
||||||
.help_mv(
|
.with_help(
|
||||||
"`sym` operands must refer to either a function or a static",
|
"`sym` operands must refer to either a function or a static",
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
|
@ -202,8 +202,8 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<()
|
|||||||
res = Err(tcx
|
res = Err(tcx
|
||||||
.dcx()
|
.dcx()
|
||||||
.struct_span_err(sp, "impls of auto traits cannot be default")
|
.struct_span_err(sp, "impls of auto traits cannot be default")
|
||||||
.span_labels_mv(impl_.defaultness_span, "default because of this")
|
.with_span_labels(impl_.defaultness_span, "default because of this")
|
||||||
.span_label_mv(sp, "auto trait")
|
.with_span_label(sp, "auto trait")
|
||||||
.emit());
|
.emit());
|
||||||
}
|
}
|
||||||
// We match on both `ty::ImplPolarity` and `ast::ImplPolarity` just to get the `!` span.
|
// We match on both `ty::ImplPolarity` and `ast::ImplPolarity` just to get the `!` span.
|
||||||
@ -504,19 +504,18 @@ fn check_gat_where_clauses(tcx: TyCtxt<'_>, trait_def_id: LocalDefId) {
|
|||||||
gat_item_hir.span,
|
gat_item_hir.span,
|
||||||
format!("missing required bound{} on `{}`", plural, gat_item_hir.ident),
|
format!("missing required bound{} on `{}`", plural, gat_item_hir.ident),
|
||||||
)
|
)
|
||||||
.span_suggestion_mv(
|
.with_span_suggestion(
|
||||||
gat_item_hir.generics.tail_span_for_predicate_suggestion(),
|
gat_item_hir.generics.tail_span_for_predicate_suggestion(),
|
||||||
format!("add the required where clause{plural}"),
|
format!("add the required where clause{plural}"),
|
||||||
suggestion,
|
suggestion,
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.note_mv(format!(
|
.with_note(format!(
|
||||||
"{bound} currently required to ensure that impls have maximum flexibility"
|
"{bound} currently required to ensure that impls have maximum flexibility"
|
||||||
))
|
))
|
||||||
.note_mv(
|
.with_note(
|
||||||
"we are soliciting feedback, see issue #87479 \
|
"we are soliciting feedback, see issue #87479 \
|
||||||
<https://github.com/rust-lang/rust/issues/87479> \
|
<https://github.com/rust-lang/rust/issues/87479> for more information",
|
||||||
for more information",
|
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
@ -839,8 +838,8 @@ fn check_object_unsafe_self_trait_by_name(tcx: TyCtxt<'_>, item: &hir::TraitItem
|
|||||||
trait_should_be_self,
|
trait_should_be_self,
|
||||||
"associated item referring to unboxed trait object for its own trait",
|
"associated item referring to unboxed trait object for its own trait",
|
||||||
)
|
)
|
||||||
.span_label_mv(trait_name.span, "in this trait")
|
.with_span_label(trait_name.span, "in this trait")
|
||||||
.multipart_suggestion_mv(
|
.with_multipart_suggestion(
|
||||||
"you might have meant to use `Self` to refer to the implementing type",
|
"you might have meant to use `Self` to refer to the implementing type",
|
||||||
sugg,
|
sugg,
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
@ -1600,7 +1599,7 @@ fn check_method_receiver<'tcx>(
|
|||||||
the `arbitrary_self_types` feature",
|
the `arbitrary_self_types` feature",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.help_mv(HELP_FOR_SELF_TYPE)
|
.with_help(HELP_FOR_SELF_TYPE)
|
||||||
.emit()
|
.emit()
|
||||||
} else {
|
} else {
|
||||||
// Report error; would not have worked with `arbitrary_self_types`.
|
// Report error; would not have worked with `arbitrary_self_types`.
|
||||||
@ -1613,8 +1612,8 @@ fn check_method_receiver<'tcx>(
|
|||||||
|
|
||||||
fn e0307(tcx: TyCtxt<'_>, span: Span, receiver_ty: Ty<'_>) -> ErrorGuaranteed {
|
fn e0307(tcx: TyCtxt<'_>, span: Span, receiver_ty: Ty<'_>) -> ErrorGuaranteed {
|
||||||
struct_span_code_err!(tcx.dcx(), span, E0307, "invalid `self` parameter type: {receiver_ty}")
|
struct_span_code_err!(tcx.dcx(), span, E0307, "invalid `self` parameter type: {receiver_ty}")
|
||||||
.note_mv("type of `self` must be `Self` or a type that dereferences to it")
|
.with_note("type of `self` must be `Self` or a type that dereferences to it")
|
||||||
.help_mv(HELP_FOR_SELF_TYPE)
|
.with_help(HELP_FOR_SELF_TYPE)
|
||||||
.emit()
|
.emit()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1923,7 +1922,7 @@ fn check_mod_type_wf(tcx: TyCtxt<'_>, module: LocalModDefId) -> Result<(), Error
|
|||||||
|
|
||||||
fn error_392(tcx: TyCtxt<'_>, span: Span, param_name: Symbol) -> DiagnosticBuilder<'_> {
|
fn error_392(tcx: TyCtxt<'_>, span: Span, param_name: Symbol) -> DiagnosticBuilder<'_> {
|
||||||
struct_span_code_err!(tcx.dcx(), span, E0392, "parameter `{param_name}` is never used")
|
struct_span_code_err!(tcx.dcx(), span, E0392, "parameter `{param_name}` is never used")
|
||||||
.span_label_mv(span, "unused parameter")
|
.with_span_label(span, "unused parameter")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn provide(providers: &mut Providers) {
|
pub fn provide(providers: &mut Providers) {
|
||||||
|
@ -77,8 +77,8 @@ impl<'tcx> InherentOverlapChecker<'tcx> {
|
|||||||
"duplicate definitions with name `{}`",
|
"duplicate definitions with name `{}`",
|
||||||
ident,
|
ident,
|
||||||
)
|
)
|
||||||
.span_label_mv(span, format!("duplicate definitions for `{ident}`"))
|
.with_span_label(span, format!("duplicate definitions for `{ident}`"))
|
||||||
.span_label_mv(*former, format!("other definition for `{ident}`"))
|
.with_span_label(*former, format!("other definition for `{ident}`"))
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
Entry::Vacant(entry) => {
|
Entry::Vacant(entry) => {
|
||||||
|
@ -181,7 +181,7 @@ fn check_object_overlap<'tcx>(
|
|||||||
trait_ref.self_ty(),
|
trait_ref.self_ty(),
|
||||||
tcx.def_path_str(trait_def_id)
|
tcx.def_path_str(trait_def_id)
|
||||||
)
|
)
|
||||||
.span_label_mv(
|
.with_span_label(
|
||||||
span,
|
span,
|
||||||
format!(
|
format!(
|
||||||
"`{}` automatically implements trait `{}`",
|
"`{}` automatically implements trait `{}`",
|
||||||
|
@ -25,7 +25,7 @@ pub(super) fn check_item(tcx: TyCtxt<'_>, def_id: LocalDefId) {
|
|||||||
"implementing the trait `{}` is not unsafe",
|
"implementing the trait `{}` is not unsafe",
|
||||||
trait_ref.print_trait_sugared()
|
trait_ref.print_trait_sugared()
|
||||||
)
|
)
|
||||||
.span_suggestion_verbose_mv(
|
.with_span_suggestion_verbose(
|
||||||
item.span.with_hi(item.span.lo() + rustc_span::BytePos(7)),
|
item.span.with_hi(item.span.lo() + rustc_span::BytePos(7)),
|
||||||
"remove `unsafe` from this trait implementation",
|
"remove `unsafe` from this trait implementation",
|
||||||
"",
|
"",
|
||||||
@ -42,13 +42,13 @@ pub(super) fn check_item(tcx: TyCtxt<'_>, def_id: LocalDefId) {
|
|||||||
"the trait `{}` requires an `unsafe impl` declaration",
|
"the trait `{}` requires an `unsafe impl` declaration",
|
||||||
trait_ref.print_trait_sugared()
|
trait_ref.print_trait_sugared()
|
||||||
)
|
)
|
||||||
.note_mv(format!(
|
.with_note(format!(
|
||||||
"the trait `{}` enforces invariants that the compiler can't check. \
|
"the trait `{}` enforces invariants that the compiler can't check. \
|
||||||
Review the trait documentation and make sure this implementation \
|
Review the trait documentation and make sure this implementation \
|
||||||
upholds those invariants before adding the `unsafe` keyword",
|
upholds those invariants before adding the `unsafe` keyword",
|
||||||
trait_ref.print_trait_sugared()
|
trait_ref.print_trait_sugared()
|
||||||
))
|
))
|
||||||
.span_suggestion_verbose_mv(
|
.with_span_suggestion_verbose(
|
||||||
item.span.shrink_to_lo(),
|
item.span.shrink_to_lo(),
|
||||||
"add `unsafe` to this trait implementation",
|
"add `unsafe` to this trait implementation",
|
||||||
"unsafe ",
|
"unsafe ",
|
||||||
@ -65,13 +65,13 @@ pub(super) fn check_item(tcx: TyCtxt<'_>, def_id: LocalDefId) {
|
|||||||
"requires an `unsafe impl` declaration due to `#[{}]` attribute",
|
"requires an `unsafe impl` declaration due to `#[{}]` attribute",
|
||||||
attr_name
|
attr_name
|
||||||
)
|
)
|
||||||
.note_mv(format!(
|
.with_note(format!(
|
||||||
"the trait `{}` enforces invariants that the compiler can't check. \
|
"the trait `{}` enforces invariants that the compiler can't check. \
|
||||||
Review the trait documentation and make sure this implementation \
|
Review the trait documentation and make sure this implementation \
|
||||||
upholds those invariants before adding the `unsafe` keyword",
|
upholds those invariants before adding the `unsafe` keyword",
|
||||||
trait_ref.print_trait_sugared()
|
trait_ref.print_trait_sugared()
|
||||||
))
|
))
|
||||||
.span_suggestion_verbose_mv(
|
.with_span_suggestion_verbose(
|
||||||
item.span.shrink_to_lo(),
|
item.span.shrink_to_lo(),
|
||||||
"add `unsafe` to this trait implementation",
|
"add `unsafe` to this trait implementation",
|
||||||
"unsafe ",
|
"unsafe ",
|
||||||
|
@ -751,7 +751,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
|
|||||||
lifetime.ident.span,
|
lifetime.ident.span,
|
||||||
"higher kinded lifetime bounds on nested opaque types are not supported yet",
|
"higher kinded lifetime bounds on nested opaque types are not supported yet",
|
||||||
)
|
)
|
||||||
.span_note_mv(self.tcx.def_span(def_id), "lifetime declared here")
|
.with_span_note(self.tcx.def_span(def_id), "lifetime declared here")
|
||||||
.emit();
|
.emit();
|
||||||
self.uninsert_lifetime_on_error(lifetime, def.unwrap());
|
self.uninsert_lifetime_on_error(lifetime, def.unwrap());
|
||||||
}
|
}
|
||||||
|
@ -523,7 +523,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
|
|||||||
fn start_diagnostics(&self) -> DiagnosticBuilder<'tcx> {
|
fn start_diagnostics(&self) -> DiagnosticBuilder<'tcx> {
|
||||||
let span = self.path_segment.ident.span;
|
let span = self.path_segment.ident.span;
|
||||||
let msg = self.create_error_message();
|
let msg = self.create_error_message();
|
||||||
self.tcx.dcx().struct_span_err(span, msg).code_mv(self.code())
|
self.tcx.dcx().struct_span_err(span, msg).with_code(self.code())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Builds the `expected 1 type argument / supplied 2 type arguments` message.
|
/// Builds the `expected 1 type argument / supplied 2 type arguments` message.
|
||||||
|
@ -402,7 +402,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
callee_expr.span,
|
callee_expr.span,
|
||||||
format!("evaluate({predicate:?}) = {result:?}"),
|
format!("evaluate({predicate:?}) = {result:?}"),
|
||||||
)
|
)
|
||||||
.span_label_mv(predicate_span, "predicate")
|
.with_span_label(predicate_span, "predicate")
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -269,7 +269,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
|
|||||||
}
|
}
|
||||||
CastError::NeedViaInt => {
|
CastError::NeedViaInt => {
|
||||||
make_invalid_casting_error(self.span, self.expr_ty, self.cast_ty, fcx)
|
make_invalid_casting_error(self.span, self.expr_ty, self.cast_ty, fcx)
|
||||||
.help_mv("cast through an integer first")
|
.with_help("cast through an integer first")
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
CastError::IllegalCast => {
|
CastError::IllegalCast => {
|
||||||
@ -277,7 +277,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
|
|||||||
}
|
}
|
||||||
CastError::DifferingKinds => {
|
CastError::DifferingKinds => {
|
||||||
make_invalid_casting_error(self.span, self.expr_ty, self.cast_ty, fcx)
|
make_invalid_casting_error(self.span, self.expr_ty, self.cast_ty, fcx)
|
||||||
.note_mv("vtable kinds may not match")
|
.with_note("vtable kinds may not match")
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
CastError::CastToBool => {
|
CastError::CastToBool => {
|
||||||
@ -512,7 +512,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
|
|||||||
self.cast_ty,
|
self.cast_ty,
|
||||||
fcx,
|
fcx,
|
||||||
)
|
)
|
||||||
.note_mv("cannot cast an enum with a non-exhaustive variant when it's defined in another crate")
|
.with_note("cannot cast an enum with a non-exhaustive variant when it's defined in another crate")
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2838,7 +2838,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
E0616,
|
E0616,
|
||||||
"field `{field}` of {kind_name} `{struct_path}` is private",
|
"field `{field}` of {kind_name} `{struct_path}` is private",
|
||||||
)
|
)
|
||||||
.span_label_mv(field.span, "private field")
|
.with_span_label(field.span, "private field")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_field_candidates_considering_privacy(
|
pub(crate) fn get_field_candidates_considering_privacy(
|
||||||
@ -3181,7 +3181,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
if !is_input && !expr.is_syntactic_place_expr() {
|
if !is_input && !expr.is_syntactic_place_expr() {
|
||||||
self.dcx()
|
self.dcx()
|
||||||
.struct_span_err(expr.span, "invalid asm output")
|
.struct_span_err(expr.span, "invalid asm output")
|
||||||
.span_label_mv(expr.span, "cannot assign to this expression")
|
.with_span_label(expr.span, "cannot assign to this expression")
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3282,7 +3282,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
E0599,
|
E0599,
|
||||||
"no variant named `{ident}` found for enum `{container}`",
|
"no variant named `{ident}` found for enum `{container}`",
|
||||||
)
|
)
|
||||||
.span_label_mv(field.span, "variant not found")
|
.with_span_label(field.span, "variant not found")
|
||||||
.emit();
|
.emit();
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
@ -3294,7 +3294,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
E0795,
|
E0795,
|
||||||
"`{ident}` is an enum variant; expected field at end of `offset_of`",
|
"`{ident}` is an enum variant; expected field at end of `offset_of`",
|
||||||
)
|
)
|
||||||
.span_label_mv(field.span, "enum variant")
|
.with_span_label(field.span, "enum variant")
|
||||||
.emit();
|
.emit();
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
@ -3313,8 +3313,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
E0609,
|
E0609,
|
||||||
"no field named `{subfield}` on enum variant `{container}::{ident}`",
|
"no field named `{subfield}` on enum variant `{container}::{ident}`",
|
||||||
)
|
)
|
||||||
.span_label_mv(field.span, "this enum variant...")
|
.with_span_label(field.span, "this enum variant...")
|
||||||
.span_label_mv(subident.span, "...does not have this field")
|
.with_span_label(subident.span, "...does not have this field")
|
||||||
.emit();
|
.emit();
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
|
@ -828,7 +828,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
pluralize!("was", provided_args.len())
|
pluralize!("was", provided_args.len())
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.code_mv(DiagnosticId::Error(err_code.to_owned()))
|
.with_code(DiagnosticId::Error(err_code.to_owned()))
|
||||||
};
|
};
|
||||||
|
|
||||||
// As we encounter issues, keep track of what we want to provide for the suggestion
|
// As we encounter issues, keep track of what we want to provide for the suggestion
|
||||||
@ -1386,7 +1386,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
"expected struct, variant or union type, found {}",
|
"expected struct, variant or union type, found {}",
|
||||||
ty.normalized.sort_string(self.tcx)
|
ty.normalized.sort_string(self.tcx)
|
||||||
)
|
)
|
||||||
.span_label_mv(path_span, "not a struct")
|
.with_span_label(path_span, "not a struct")
|
||||||
.emit(),
|
.emit(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -74,9 +74,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
&& size_to == Pointer(dl.instruction_address_space).size(&tcx)
|
&& size_to == Pointer(dl.instruction_address_space).size(&tcx)
|
||||||
{
|
{
|
||||||
struct_span_code_err!(tcx.dcx(), span, E0591, "can't transmute zero-sized type")
|
struct_span_code_err!(tcx.dcx(), span, E0591, "can't transmute zero-sized type")
|
||||||
.note_mv(format!("source type: {from}"))
|
.with_note(format!("source type: {from}"))
|
||||||
.note_mv(format!("target type: {to}"))
|
.with_note(format!("target type: {to}"))
|
||||||
.help_mv("cast with `as` to a pointer instead")
|
.with_help("cast with `as` to a pointer instead")
|
||||||
.emit();
|
.emit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -369,14 +369,14 @@ fn report_unexpected_variant_res(
|
|||||||
let err = tcx
|
let err = tcx
|
||||||
.dcx()
|
.dcx()
|
||||||
.struct_span_err(span, format!("expected {expected}, found {res_descr} `{path_str}`"))
|
.struct_span_err(span, format!("expected {expected}, found {res_descr} `{path_str}`"))
|
||||||
.code_mv(DiagnosticId::Error(err_code.into()));
|
.with_code(DiagnosticId::Error(err_code.into()));
|
||||||
match res {
|
match res {
|
||||||
Res::Def(DefKind::Fn | DefKind::AssocFn, _) if err_code == "E0164" => {
|
Res::Def(DefKind::Fn | DefKind::AssocFn, _) if err_code == "E0164" => {
|
||||||
let patterns_url = "https://doc.rust-lang.org/book/ch18-00-patterns.html";
|
let patterns_url = "https://doc.rust-lang.org/book/ch18-00-patterns.html";
|
||||||
err.span_label_mv(span, "`fn` calls are not allowed in patterns")
|
err.with_span_label(span, "`fn` calls are not allowed in patterns")
|
||||||
.help_mv(format!("for more information, visit {patterns_url}"))
|
.with_help(format!("for more information, visit {patterns_url}"))
|
||||||
}
|
}
|
||||||
_ => err.span_label_mv(span, format!("not a {expected}")),
|
_ => err.with_span_label(span, format!("not a {expected}")),
|
||||||
}
|
}
|
||||||
.emit()
|
.emit()
|
||||||
}
|
}
|
||||||
|
@ -1547,7 +1547,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
E0638,
|
E0638,
|
||||||
"`..` required with {descr} marked as non-exhaustive",
|
"`..` required with {descr} marked as non-exhaustive",
|
||||||
)
|
)
|
||||||
.span_suggestion_verbose_mv(
|
.with_span_suggestion_verbose(
|
||||||
sp_comma,
|
sp_comma,
|
||||||
"add `..` at the end of the field list to ignore all other fields",
|
"add `..` at the end of the field list to ignore all other fields",
|
||||||
sugg,
|
sugg,
|
||||||
@ -1569,8 +1569,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
"field `{}` bound multiple times in the pattern",
|
"field `{}` bound multiple times in the pattern",
|
||||||
ident
|
ident
|
||||||
)
|
)
|
||||||
.span_label_mv(span, format!("multiple uses of `{ident}` in pattern"))
|
.with_span_label(span, format!("multiple uses of `{ident}` in pattern"))
|
||||||
.span_label_mv(other_field, format!("first use of `{ident}`"))
|
.with_span_label(other_field, format!("first use of `{ident}`"))
|
||||||
.emit()
|
.emit()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2235,7 +2235,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
pluralize!(min_len),
|
pluralize!(min_len),
|
||||||
size,
|
size,
|
||||||
)
|
)
|
||||||
.span_label_mv(span, format!("expected {} element{}", size, pluralize!(size)))
|
.with_span_label(span, format!("expected {} element{}", size, pluralize!(size)))
|
||||||
.emit()
|
.emit()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2254,7 +2254,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
pluralize!(min_len),
|
pluralize!(min_len),
|
||||||
size,
|
size,
|
||||||
)
|
)
|
||||||
.span_label_mv(
|
.with_span_label(
|
||||||
span,
|
span,
|
||||||
format!("pattern cannot match array of {} element{}", size, pluralize!(size),),
|
format!("pattern cannot match array of {} element{}", size, pluralize!(size),),
|
||||||
)
|
)
|
||||||
|
@ -336,10 +336,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
expr.span,
|
expr.span,
|
||||||
"not automatically applying `DerefMut` on `ManuallyDrop` union field",
|
"not automatically applying `DerefMut` on `ManuallyDrop` union field",
|
||||||
)
|
)
|
||||||
.help_mv(
|
.with_help(
|
||||||
"writing to this reference calls the destructor for the old value",
|
"writing to this reference calls the destructor for the old value",
|
||||||
)
|
)
|
||||||
.help_mv("add an explicit `*` if that is desired, or call `ptr::write` to not run the destructor")
|
.with_help("add an explicit `*` if that is desired, or call `ptr::write` to not run the destructor")
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -368,7 +368,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||||||
{
|
{
|
||||||
let span = *span;
|
let span = *span;
|
||||||
self.report_concrete_failure(placeholder_origin, sub, sup)
|
self.report_concrete_failure(placeholder_origin, sub, sup)
|
||||||
.span_note_mv(span, "the lifetime requirement is introduced here")
|
.with_span_note(span, "the lifetime requirement is introduced here")
|
||||||
} else {
|
} else {
|
||||||
unreachable!(
|
unreachable!(
|
||||||
"control flow ensures we have a `BindingObligation` or `ExprBindingObligation` here..."
|
"control flow ensures we have a `BindingObligation` or `ExprBindingObligation` here..."
|
||||||
|
@ -132,7 +132,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReverseMapper<'tcx> {
|
|||||||
.tcx
|
.tcx
|
||||||
.dcx()
|
.dcx()
|
||||||
.struct_span_err(self.span, "non-defining opaque type use in defining scope")
|
.struct_span_err(self.span, "non-defining opaque type use in defining scope")
|
||||||
.span_label_mv(
|
.with_span_label(
|
||||||
self.span,
|
self.span,
|
||||||
format!(
|
format!(
|
||||||
"lifetime `{r}` is part of concrete type but not used in \
|
"lifetime `{r}` is part of concrete type but not used in \
|
||||||
|
@ -369,7 +369,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
if let Some((old_item_id, _)) = dtor_candidate {
|
if let Some((old_item_id, _)) = dtor_candidate {
|
||||||
self.dcx()
|
self.dcx()
|
||||||
.struct_span_err(self.def_span(item_id), "multiple drop impls found")
|
.struct_span_err(self.def_span(item_id), "multiple drop impls found")
|
||||||
.span_note_mv(self.def_span(old_item_id), "other impl here")
|
.with_span_note(self.def_span(old_item_id), "other impl here")
|
||||||
.delay_as_bug();
|
.delay_as_bug();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,7 +318,7 @@ pub fn recursive_type_error(
|
|||||||
items_list,
|
items_list,
|
||||||
pluralize!("has", cycle_len),
|
pluralize!("has", cycle_len),
|
||||||
)
|
)
|
||||||
.multipart_suggestion_mv(
|
.with_multipart_suggestion(
|
||||||
"insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle",
|
"insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle",
|
||||||
suggestion,
|
suggestion,
|
||||||
Applicability::HasPlaceholders,
|
Applicability::HasPlaceholders,
|
||||||
|
@ -250,7 +250,7 @@ impl<'a> StringReader<'a> {
|
|||||||
if starts_with_number {
|
if starts_with_number {
|
||||||
let span = self.mk_sp(start, self.pos);
|
let span = self.mk_sp(start, self.pos);
|
||||||
self.dcx().struct_err("lifetimes cannot start with a number")
|
self.dcx().struct_err("lifetimes cannot start with a number")
|
||||||
.span_mv(span)
|
.with_span(span)
|
||||||
.stash(span, StashKey::LifetimeIsChar);
|
.stash(span, StashKey::LifetimeIsChar);
|
||||||
}
|
}
|
||||||
let ident = Symbol::intern(lifetime_name);
|
let ident = Symbol::intern(lifetime_name);
|
||||||
@ -397,7 +397,7 @@ impl<'a> StringReader<'a> {
|
|||||||
if !terminated {
|
if !terminated {
|
||||||
self.dcx()
|
self.dcx()
|
||||||
.struct_span_fatal(self.mk_sp(start, end), "unterminated character literal")
|
.struct_span_fatal(self.mk_sp(start, end), "unterminated character literal")
|
||||||
.code_mv(error_code!(E0762))
|
.with_code(error_code!(E0762))
|
||||||
.emit()
|
.emit()
|
||||||
}
|
}
|
||||||
self.cook_quoted(token::Char, Mode::Char, start, end, 1, 1) // ' '
|
self.cook_quoted(token::Char, Mode::Char, start, end, 1, 1) // ' '
|
||||||
@ -409,7 +409,7 @@ impl<'a> StringReader<'a> {
|
|||||||
self.mk_sp(start + BytePos(1), end),
|
self.mk_sp(start + BytePos(1), end),
|
||||||
"unterminated byte constant",
|
"unterminated byte constant",
|
||||||
)
|
)
|
||||||
.code_mv(error_code!(E0763))
|
.with_code(error_code!(E0763))
|
||||||
.emit()
|
.emit()
|
||||||
}
|
}
|
||||||
self.cook_quoted(token::Byte, Mode::Byte, start, end, 2, 1) // b' '
|
self.cook_quoted(token::Byte, Mode::Byte, start, end, 2, 1) // b' '
|
||||||
@ -421,7 +421,7 @@ impl<'a> StringReader<'a> {
|
|||||||
self.mk_sp(start, end),
|
self.mk_sp(start, end),
|
||||||
"unterminated double quote string",
|
"unterminated double quote string",
|
||||||
)
|
)
|
||||||
.code_mv(error_code!(E0765))
|
.with_code(error_code!(E0765))
|
||||||
.emit()
|
.emit()
|
||||||
}
|
}
|
||||||
self.cook_quoted(token::Str, Mode::Str, start, end, 1, 1) // " "
|
self.cook_quoted(token::Str, Mode::Str, start, end, 1, 1) // " "
|
||||||
@ -433,7 +433,7 @@ impl<'a> StringReader<'a> {
|
|||||||
self.mk_sp(start + BytePos(1), end),
|
self.mk_sp(start + BytePos(1), end),
|
||||||
"unterminated double quote byte string",
|
"unterminated double quote byte string",
|
||||||
)
|
)
|
||||||
.code_mv(error_code!(E0766))
|
.with_code(error_code!(E0766))
|
||||||
.emit()
|
.emit()
|
||||||
}
|
}
|
||||||
self.cook_quoted(token::ByteStr, Mode::ByteStr, start, end, 2, 1) // b" "
|
self.cook_quoted(token::ByteStr, Mode::ByteStr, start, end, 2, 1) // b" "
|
||||||
@ -445,7 +445,7 @@ impl<'a> StringReader<'a> {
|
|||||||
self.mk_sp(start + BytePos(1), end),
|
self.mk_sp(start + BytePos(1), end),
|
||||||
"unterminated C string",
|
"unterminated C string",
|
||||||
)
|
)
|
||||||
.code_mv(error_code!(E0767))
|
.with_code(error_code!(E0767))
|
||||||
.emit()
|
.emit()
|
||||||
}
|
}
|
||||||
self.cook_c_string(token::CStr, Mode::CStr, start, end, 2, 1) // c" "
|
self.cook_c_string(token::CStr, Mode::CStr, start, end, 2, 1) // c" "
|
||||||
|
@ -246,8 +246,8 @@ pub fn parse_cfg_attr(
|
|||||||
match parse_in(parse_sess, tokens.clone(), "`cfg_attr` input", |p| p.parse_cfg_attr()) {
|
match parse_in(parse_sess, tokens.clone(), "`cfg_attr` input", |p| p.parse_cfg_attr()) {
|
||||||
Ok(r) => return Some(r),
|
Ok(r) => return Some(r),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
e.help_mv(format!("the valid syntax is `{CFG_ATTR_GRAMMAR_HELP}`"))
|
e.with_help(format!("the valid syntax is `{CFG_ATTR_GRAMMAR_HELP}`"))
|
||||||
.note_mv(CFG_ATTR_NOTE_REF)
|
.with_note(CFG_ATTR_NOTE_REF)
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -204,8 +204,11 @@ impl<'a> Parser<'a> {
|
|||||||
attr_sp,
|
attr_sp,
|
||||||
fluent::parse_inner_attr_not_permitted_after_outer_doc_comment,
|
fluent::parse_inner_attr_not_permitted_after_outer_doc_comment,
|
||||||
)
|
)
|
||||||
.span_label_mv(attr_sp, fluent::parse_label_attr)
|
.with_span_label(attr_sp, fluent::parse_label_attr)
|
||||||
.span_label_mv(prev_doc_comment_span, fluent::parse_label_prev_doc_comment)
|
.with_span_label(
|
||||||
|
prev_doc_comment_span,
|
||||||
|
fluent::parse_label_prev_doc_comment,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
Some(InnerAttrForbiddenReason::AfterOuterAttribute { prev_outer_attr_sp }) => self
|
Some(InnerAttrForbiddenReason::AfterOuterAttribute { prev_outer_attr_sp }) => self
|
||||||
.dcx()
|
.dcx()
|
||||||
@ -213,8 +216,8 @@ impl<'a> Parser<'a> {
|
|||||||
attr_sp,
|
attr_sp,
|
||||||
fluent::parse_inner_attr_not_permitted_after_outer_attr,
|
fluent::parse_inner_attr_not_permitted_after_outer_attr,
|
||||||
)
|
)
|
||||||
.span_label_mv(attr_sp, fluent::parse_label_attr)
|
.with_span_label(attr_sp, fluent::parse_label_attr)
|
||||||
.span_label_mv(prev_outer_attr_sp, fluent::parse_label_prev_attr),
|
.with_span_label(prev_outer_attr_sp, fluent::parse_label_prev_attr),
|
||||||
Some(InnerAttrForbiddenReason::InCodeBlock) | None => {
|
Some(InnerAttrForbiddenReason::InCodeBlock) | None => {
|
||||||
self.dcx().struct_span_err(attr_sp, fluent::parse_inner_attr_not_permitted)
|
self.dcx().struct_span_err(attr_sp, fluent::parse_inner_attr_not_permitted)
|
||||||
}
|
}
|
||||||
|
@ -2847,8 +2847,8 @@ impl<'a> Parser<'a> {
|
|||||||
let span = label.ident.span.to(self.prev_token.span);
|
let span = label.ident.span.to(self.prev_token.span);
|
||||||
self.dcx()
|
self.dcx()
|
||||||
.struct_span_err(span, "block label not supported here")
|
.struct_span_err(span, "block label not supported here")
|
||||||
.span_label_mv(span, "not supported here")
|
.with_span_label(span, "not supported here")
|
||||||
.tool_only_span_suggestion_mv(
|
.with_tool_only_span_suggestion(
|
||||||
label.ident.span.until(self.token.span),
|
label.ident.span.until(self.token.span),
|
||||||
"remove this block label",
|
"remove this block label",
|
||||||
"",
|
"",
|
||||||
|
@ -1753,7 +1753,7 @@ impl<'a> Parser<'a> {
|
|||||||
err: impl FnOnce(&Self) -> DiagnosticBuilder<'a>,
|
err: impl FnOnce(&Self) -> DiagnosticBuilder<'a>,
|
||||||
) -> L {
|
) -> L {
|
||||||
if let Some(diag) = self.dcx().steal_diagnostic(lifetime.span, StashKey::LifetimeIsChar) {
|
if let Some(diag) = self.dcx().steal_diagnostic(lifetime.span, StashKey::LifetimeIsChar) {
|
||||||
diag.span_suggestion_verbose_mv(
|
diag.with_span_suggestion_verbose(
|
||||||
lifetime.span.shrink_to_hi(),
|
lifetime.span.shrink_to_hi(),
|
||||||
"add `'` to close the char literal",
|
"add `'` to close the char literal",
|
||||||
"'",
|
"'",
|
||||||
@ -1762,7 +1762,7 @@ impl<'a> Parser<'a> {
|
|||||||
.emit();
|
.emit();
|
||||||
} else {
|
} else {
|
||||||
err(self)
|
err(self)
|
||||||
.span_suggestion_verbose_mv(
|
.with_span_suggestion_verbose(
|
||||||
lifetime.span.shrink_to_hi(),
|
lifetime.span.shrink_to_hi(),
|
||||||
"add `'` to close the char literal",
|
"add `'` to close the char literal",
|
||||||
"'",
|
"'",
|
||||||
|
@ -145,7 +145,7 @@ impl<'a> Parser<'a> {
|
|||||||
mistyped_const_ident.span,
|
mistyped_const_ident.span,
|
||||||
format!("`const` keyword was mistyped as `{}`", mistyped_const_ident.as_str()),
|
format!("`const` keyword was mistyped as `{}`", mistyped_const_ident.as_str()),
|
||||||
)
|
)
|
||||||
.span_suggestion_verbose_mv(
|
.with_span_suggestion_verbose(
|
||||||
mistyped_const_ident.span,
|
mistyped_const_ident.span,
|
||||||
"use the `const` keyword",
|
"use the `const` keyword",
|
||||||
kw::Const.as_str(),
|
kw::Const.as_str(),
|
||||||
|
@ -741,11 +741,11 @@ impl<'a> Parser<'a> {
|
|||||||
Ok(Some(item)) => items.extend(item),
|
Ok(Some(item)) => items.extend(item),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
self.consume_block(Delimiter::Brace, ConsumeClosingDelim::Yes);
|
self.consume_block(Delimiter::Brace, ConsumeClosingDelim::Yes);
|
||||||
err.span_label_mv(
|
err.with_span_label(
|
||||||
open_brace_span,
|
open_brace_span,
|
||||||
"while parsing this item list starting here",
|
"while parsing this item list starting here",
|
||||||
)
|
)
|
||||||
.span_label_mv(self.prev_token.span, "the item list ends here")
|
.with_span_label(self.prev_token.span, "the item list ends here")
|
||||||
.emit();
|
.emit();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -765,8 +765,8 @@ impl<'a> Parser<'a> {
|
|||||||
E0584,
|
E0584,
|
||||||
"found a documentation comment that doesn't document anything",
|
"found a documentation comment that doesn't document anything",
|
||||||
)
|
)
|
||||||
.span_label_mv(self.token.span, "this doc comment doesn't document anything")
|
.with_span_label(self.token.span, "this doc comment doesn't document anything")
|
||||||
.help_mv(
|
.with_help(
|
||||||
"doc comments must come before what they document, if a comment was \
|
"doc comments must come before what they document, if a comment was \
|
||||||
intended use `//`",
|
intended use `//`",
|
||||||
)
|
)
|
||||||
@ -1218,7 +1218,7 @@ impl<'a> Parser<'a> {
|
|||||||
|
|
||||||
let before_trait = trai.path.span.shrink_to_lo();
|
let before_trait = trai.path.span.shrink_to_lo();
|
||||||
let const_up_to_impl = const_span.with_hi(impl_span.lo());
|
let const_up_to_impl = const_span.with_hi(impl_span.lo());
|
||||||
err.multipart_suggestion_mv(
|
err.with_multipart_suggestion(
|
||||||
"you might have meant to write a const trait impl",
|
"you might have meant to write a const trait impl",
|
||||||
vec![(const_up_to_impl, "".to_owned()), (before_trait, "const ".to_owned())],
|
vec![(const_up_to_impl, "".to_owned()), (before_trait, "const ".to_owned())],
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
@ -1457,7 +1457,7 @@ impl<'a> Parser<'a> {
|
|||||||
|
|
||||||
if this.token == token::Not {
|
if this.token == token::Not {
|
||||||
if let Err(err) = this.unexpected::<()>() {
|
if let Err(err) = this.unexpected::<()>() {
|
||||||
err.note_mv(fluent::parse_macro_expands_to_enum_variant).emit();
|
err.with_note(fluent::parse_macro_expands_to_enum_variant).emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.bump();
|
this.bump();
|
||||||
@ -1855,7 +1855,7 @@ impl<'a> Parser<'a> {
|
|||||||
if eq_typo || semi_typo {
|
if eq_typo || semi_typo {
|
||||||
self.bump();
|
self.bump();
|
||||||
// Gracefully handle small typos.
|
// Gracefully handle small typos.
|
||||||
err.span_suggestion_short_mv(
|
err.with_span_suggestion_short(
|
||||||
self.prev_token.span,
|
self.prev_token.span,
|
||||||
"field names and their types are separated with `:`",
|
"field names and their types are separated with `:`",
|
||||||
":",
|
":",
|
||||||
@ -1935,10 +1935,10 @@ impl<'a> Parser<'a> {
|
|||||||
lo.to(self.prev_token.span),
|
lo.to(self.prev_token.span),
|
||||||
format!("functions are not allowed in {adt_ty} definitions"),
|
format!("functions are not allowed in {adt_ty} definitions"),
|
||||||
)
|
)
|
||||||
.help_mv(
|
.with_help(
|
||||||
"unlike in C++, Java, and C#, functions are declared in `impl` blocks",
|
"unlike in C++, Java, and C#, functions are declared in `impl` blocks",
|
||||||
)
|
)
|
||||||
.help_mv("see https://doc.rust-lang.org/book/ch05-03-method-syntax.html for more information")
|
.with_help("see https://doc.rust-lang.org/book/ch05-03-method-syntax.html for more information")
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
err.cancel();
|
err.cancel();
|
||||||
@ -1954,7 +1954,9 @@ impl<'a> Parser<'a> {
|
|||||||
lo.with_hi(ident.span.hi()),
|
lo.with_hi(ident.span.hi()),
|
||||||
format!("structs are not allowed in {adt_ty} definitions"),
|
format!("structs are not allowed in {adt_ty} definitions"),
|
||||||
)
|
)
|
||||||
.help_mv("consider creating a new `struct` definition instead of nesting"),
|
.with_help(
|
||||||
|
"consider creating a new `struct` definition instead of nesting",
|
||||||
|
),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
err.cancel();
|
err.cancel();
|
||||||
self.restore_snapshot(snapshot);
|
self.restore_snapshot(snapshot);
|
||||||
|
@ -847,7 +847,7 @@ impl<'a> Parser<'a> {
|
|||||||
pprust::token_to_string(&self.prev_token)
|
pprust::token_to_string(&self.prev_token)
|
||||||
);
|
);
|
||||||
expect_err
|
expect_err
|
||||||
.span_suggestion_verbose_mv(
|
.with_span_suggestion_verbose(
|
||||||
self.prev_token.span.shrink_to_hi().until(self.token.span),
|
self.prev_token.span.shrink_to_hi().until(self.token.span),
|
||||||
msg,
|
msg,
|
||||||
" @ ",
|
" @ ",
|
||||||
@ -863,7 +863,7 @@ impl<'a> Parser<'a> {
|
|||||||
// Parsed successfully, therefore most probably the code only
|
// Parsed successfully, therefore most probably the code only
|
||||||
// misses a separator.
|
// misses a separator.
|
||||||
expect_err
|
expect_err
|
||||||
.span_suggestion_short_mv(
|
.with_span_suggestion_short(
|
||||||
sp,
|
sp,
|
||||||
format!("missing `{token_str}`"),
|
format!("missing `{token_str}`"),
|
||||||
token_str,
|
token_str,
|
||||||
|
@ -464,7 +464,7 @@ impl<'a> Parser<'a> {
|
|||||||
self_
|
self_
|
||||||
.dcx()
|
.dcx()
|
||||||
.struct_span_err(self_.token.span, msg)
|
.struct_span_err(self_.token.span, msg)
|
||||||
.span_label_mv(self_.token.span, format!("expected {expected}"))
|
.with_span_label(self_.token.span, format!("expected {expected}"))
|
||||||
});
|
});
|
||||||
PatKind::Lit(self.mk_expr(lo, ExprKind::Lit(lit)))
|
PatKind::Lit(self.mk_expr(lo, ExprKind::Lit(lit)))
|
||||||
} else {
|
} else {
|
||||||
|
@ -128,7 +128,7 @@ impl<'a> Parser<'a> {
|
|||||||
self.prev_token.span,
|
self.prev_token.span,
|
||||||
"found single colon before projection in qualified path",
|
"found single colon before projection in qualified path",
|
||||||
)
|
)
|
||||||
.span_suggestion_mv(
|
.with_span_suggestion(
|
||||||
self.prev_token.span,
|
self.prev_token.span,
|
||||||
"use double colon",
|
"use double colon",
|
||||||
"::",
|
"::",
|
||||||
|
@ -1116,7 +1116,7 @@ impl<'a> Parser<'a> {
|
|||||||
let before_fn_path = fn_path.span.shrink_to_lo();
|
let before_fn_path = fn_path.span.shrink_to_lo();
|
||||||
self.dcx()
|
self.dcx()
|
||||||
.struct_span_err(generic_args_span, "`Fn` traits cannot take lifetime parameters")
|
.struct_span_err(generic_args_span, "`Fn` traits cannot take lifetime parameters")
|
||||||
.multipart_suggestion_mv(
|
.with_multipart_suggestion(
|
||||||
"consider using a higher-ranked trait bound instead",
|
"consider using a higher-ranked trait bound instead",
|
||||||
vec![(generic_args_span, "".to_owned()), (before_fn_path, snippet)],
|
vec![(generic_args_span, "".to_owned()), (before_fn_path, snippet)],
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
|
@ -208,7 +208,7 @@ fn emit_malformed_attribute(
|
|||||||
} else {
|
} else {
|
||||||
sess.dcx
|
sess.dcx
|
||||||
.struct_span_err(span, error_msg)
|
.struct_span_err(span, error_msg)
|
||||||
.span_suggestions_mv(
|
.with_span_suggestions(
|
||||||
span,
|
span,
|
||||||
if suggestions.len() == 1 {
|
if suggestions.len() == 1 {
|
||||||
"must be of the form"
|
"must be of the form"
|
||||||
|
@ -818,7 +818,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
|
|||||||
self.r
|
self.r
|
||||||
.dcx()
|
.dcx()
|
||||||
.struct_span_err(item.span, "`extern crate self;` requires renaming")
|
.struct_span_err(item.span, "`extern crate self;` requires renaming")
|
||||||
.span_suggestion_mv(
|
.with_span_suggestion(
|
||||||
item.span,
|
item.span,
|
||||||
"rename the `self` crate to be able to import it",
|
"rename the `self` crate to be able to import it",
|
||||||
"extern crate self as name;",
|
"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 msg = format!("`{name}` is already in scope");
|
||||||
let note =
|
let note =
|
||||||
"macro-expanded `#[macro_use]`s may not shadow existing macros (see RFC 1560)";
|
"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}`",
|
"item `{name}` is an associated {kind}, which doesn't match its trait `{trait_path}`",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.code_mv(code)
|
.with_code(code)
|
||||||
.span_label_mv(span, "does not match trait")
|
.with_span_label(span, "does not match trait")
|
||||||
.span_label_mv(trait_item_span, "item in trait")
|
.with_span_label(trait_item_span, "item in trait")
|
||||||
}
|
}
|
||||||
ResolutionError::TraitImplDuplicate { name, trait_item_span, old_span } => self
|
ResolutionError::TraitImplDuplicate { name, trait_item_span, old_span } => self
|
||||||
.dcx()
|
.dcx()
|
||||||
|
@ -2600,7 +2600,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
|
|||||||
E0637,
|
E0637,
|
||||||
"`'_` cannot be used here"
|
"`'_` 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();
|
.emit();
|
||||||
// Record lifetime res, so lowering knows there is something fishy.
|
// Record lifetime res, so lowering knows there is something fishy.
|
||||||
self.record_lifetime_param(param.id, LifetimeRes::Error);
|
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: `{}`",
|
"invalid lifetime parameter name: `{}`",
|
||||||
param.ident,
|
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();
|
.emit();
|
||||||
// Record lifetime res, so lowering knows there is something fishy.
|
// Record lifetime res, so lowering knows there is something fishy.
|
||||||
self.record_lifetime_param(param.id, LifetimeRes::Error);
|
self.record_lifetime_param(param.id, LifetimeRes::Error);
|
||||||
|
@ -2609,8 +2609,8 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
|
|||||||
E0401,
|
E0401,
|
||||||
"can't use generic parameters from outer item",
|
"can't use generic parameters from outer item",
|
||||||
)
|
)
|
||||||
.span_label_mv(lifetime_ref.ident.span, "use of generic parameter from outer item")
|
.with_span_label(lifetime_ref.ident.span, "use of generic parameter from outer item")
|
||||||
.span_label_mv(outer.span, "lifetime parameter from outer item")
|
.with_span_label(outer.span, "lifetime parameter from outer item")
|
||||||
} else {
|
} else {
|
||||||
struct_span_code_err!(
|
struct_span_code_err!(
|
||||||
self.r.dcx(),
|
self.r.dcx(),
|
||||||
@ -2619,7 +2619,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
|
|||||||
"use of undeclared lifetime name `{}`",
|
"use of undeclared lifetime name `{}`",
|
||||||
lifetime_ref.ident
|
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(
|
self.suggest_introducing_lifetime(
|
||||||
&mut err,
|
&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",
|
"lifetime name `{}` shadows a lifetime name that is already in scope",
|
||||||
orig.name,
|
orig.name,
|
||||||
)
|
)
|
||||||
.span_label_mv(orig.span, "first declared here")
|
.with_span_label(orig.span, "first declared here")
|
||||||
.span_label_mv(shadower.span, format!("lifetime `{}` already in scope", orig.name))
|
.with_span_label(shadower.span, format!("lifetime `{}` already in scope", orig.name))
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3322,7 +3322,7 @@ pub(super) fn signal_label_shadowing(sess: &Session, orig: Span, shadower: Ident
|
|||||||
shadower,
|
shadower,
|
||||||
format!("label name `{name}` shadows a label name that is already in scope"),
|
format!("label name `{name}` shadows a label name that is already in scope"),
|
||||||
)
|
)
|
||||||
.span_label_mv(orig, "first declared here")
|
.with_span_label(orig, "first declared here")
|
||||||
.span_label_mv(shadower, format!("label `{name}` already in scope"))
|
.with_span_label(shadower, format!("label `{name}` already in scope"))
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ pub(crate) fn registered_tools(tcx: TyCtxt<'_>, (): ()) -> RegisteredTools {
|
|||||||
let msg = format!("{} `{}` was already registered", "tool", ident);
|
let msg = format!("{} `{}` was already registered", "tool", ident);
|
||||||
tcx.dcx()
|
tcx.dcx()
|
||||||
.struct_span_err(ident.span, msg)
|
.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();
|
.emit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -137,7 +137,7 @@ pub(crate) fn registered_tools(tcx: TyCtxt<'_>, (): ()) -> RegisteredTools {
|
|||||||
let span = nested_meta.span();
|
let span = nested_meta.span();
|
||||||
tcx.dcx()
|
tcx.dcx()
|
||||||
.struct_span_err(span, msg)
|
.struct_span_err(span, msg)
|
||||||
.span_label_mv(span, "not an identifier")
|
.with_span_label(span, "not an identifier")
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -578,7 +578,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||||||
|
|
||||||
self.dcx()
|
self.dcx()
|
||||||
.create_err(err)
|
.create_err(err)
|
||||||
.span_label_mv(path.span, format!("not {article} {expected}"))
|
.with_span_label(path.span, format!("not {article} {expected}"))
|
||||||
.emit();
|
.emit();
|
||||||
|
|
||||||
return Ok((self.dummy_ext(kind), Res::Err));
|
return Ok((self.dummy_ext(kind), Res::Err));
|
||||||
@ -954,7 +954,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||||||
E0773,
|
E0773,
|
||||||
"attempted to define built-in macro more than once"
|
"attempted to define built-in macro more than once"
|
||||||
)
|
)
|
||||||
.span_note_mv(span, "previously defined here")
|
.with_span_note(span, "previously defined here")
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,8 @@ impl<'a> IntoDiagnostic<'a> for FeatureGateError {
|
|||||||
#[track_caller]
|
#[track_caller]
|
||||||
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> DiagnosticBuilder<'a> {
|
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> DiagnosticBuilder<'a> {
|
||||||
DiagnosticBuilder::new(dcx, level, self.explain)
|
DiagnosticBuilder::new(dcx, level, self.explain)
|
||||||
.span_mv(self.span)
|
.with_span(self.span)
|
||||||
.code_mv(error_code!(E0658))
|
.with_code(error_code!(E0658))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1488,7 +1488,7 @@ impl EarlyDiagCtxt {
|
|||||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
#[allow(rustc::diagnostic_outside_of_impl)]
|
||||||
self.dcx
|
self.dcx
|
||||||
.struct_warn(err)
|
.struct_warn(err)
|
||||||
.note_mv("the build environment is likely misconfigured")
|
.with_note("the build environment is likely misconfigured")
|
||||||
.emit()
|
.emit()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ impl<G: EmissionGuarantee> IntoDiagnostic<'_, G> for TestOutput {
|
|||||||
let TestOutput { span, kind, content } = self;
|
let TestOutput { span, kind, content } = self;
|
||||||
|
|
||||||
#[allow(rustc::untranslatable_diagnostic)]
|
#[allow(rustc::untranslatable_diagnostic)]
|
||||||
DiagnosticBuilder::new(dcx, level, format!("{kind}({content})")).span_mv(span)
|
DiagnosticBuilder::new(dcx, level, format!("{kind}({content})")).with_span(span)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,8 +122,8 @@ pub fn is_const_evaluatable<'tcx>(
|
|||||||
if span == rustc_span::DUMMY_SP { tcx.def_span(uv.def) } else { span },
|
if span == rustc_span::DUMMY_SP { tcx.def_span(uv.def) } else { span },
|
||||||
"failed to evaluate generic const expression",
|
"failed to evaluate generic const expression",
|
||||||
)
|
)
|
||||||
.note_mv("the crate this constant originates from uses `#![feature(generic_const_exprs)]`")
|
.with_note("the crate this constant originates from uses `#![feature(generic_const_exprs)]`")
|
||||||
.span_suggestion_verbose_mv(
|
.with_span_suggestion_verbose(
|
||||||
rustc_span::DUMMY_SP,
|
rustc_span::DUMMY_SP,
|
||||||
"consider enabling this feature",
|
"consider enabling this feature",
|
||||||
"#![feature(generic_const_exprs)]\n",
|
"#![feature(generic_const_exprs)]\n",
|
||||||
|
@ -2661,7 +2661,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||||||
ErrorCode::E0284,
|
ErrorCode::E0284,
|
||||||
true,
|
true,
|
||||||
)
|
)
|
||||||
.note_mv(format!("cannot satisfy `{predicate}`"))
|
.with_note(format!("cannot satisfy `{predicate}`"))
|
||||||
} else {
|
} else {
|
||||||
// If we can't find a substitution, just print a generic error
|
// If we can't find a substitution, just print a generic error
|
||||||
struct_span_code_err!(
|
struct_span_code_err!(
|
||||||
@ -2671,7 +2671,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||||||
"type annotations needed: cannot satisfy `{}`",
|
"type annotations needed: cannot satisfy `{}`",
|
||||||
predicate,
|
predicate,
|
||||||
)
|
)
|
||||||
.span_label_mv(span, format!("cannot satisfy `{predicate}`"))
|
.with_span_label(span, format!("cannot satisfy `{predicate}`"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2698,7 +2698,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||||||
"type annotations needed: cannot satisfy `{}`",
|
"type annotations needed: cannot satisfy `{}`",
|
||||||
predicate,
|
predicate,
|
||||||
)
|
)
|
||||||
.span_label_mv(span, format!("cannot satisfy `{predicate}`"))
|
.with_span_label(span, format!("cannot satisfy `{predicate}`"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
@ -2712,7 +2712,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||||||
"type annotations needed: cannot satisfy `{}`",
|
"type annotations needed: cannot satisfy `{}`",
|
||||||
predicate,
|
predicate,
|
||||||
)
|
)
|
||||||
.span_label_mv(span, format!("cannot satisfy `{predicate}`"))
|
.with_span_label(span, format!("cannot satisfy `{predicate}`"))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
self.note_obligation_cause(&mut err, obligation);
|
self.note_obligation_cause(&mut err, obligation);
|
||||||
@ -3552,7 +3552,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||||||
//
|
//
|
||||||
// Note that with `feature(generic_const_exprs)` this case should not
|
// Note that with `feature(generic_const_exprs)` this case should not
|
||||||
// be reachable.
|
// be reachable.
|
||||||
.note_mv("this may fail depending on what value the parameter takes")
|
.with_note("this may fail depending on what value the parameter takes")
|
||||||
.emit();
|
.emit();
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ use rustc_infer::traits::Normalized;
|
|||||||
use rustc_middle::ty::fold::{FallibleTypeFolder, TypeFoldable, TypeSuperFoldable};
|
use rustc_middle::ty::fold::{FallibleTypeFolder, TypeFoldable, TypeSuperFoldable};
|
||||||
use rustc_middle::ty::visit::{TypeSuperVisitable, TypeVisitable, TypeVisitableExt};
|
use rustc_middle::ty::visit::{TypeSuperVisitable, TypeVisitable, TypeVisitableExt};
|
||||||
use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitor};
|
use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitor};
|
||||||
|
use rustc_span::DUMMY_SP;
|
||||||
|
|
||||||
use std::ops::ControlFlow;
|
use std::ops::ControlFlow;
|
||||||
|
|
||||||
|
@ -969,7 +969,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||||||
self.tcx().def_span(impl_def_id),
|
self.tcx().def_span(impl_def_id),
|
||||||
"multiple drop impls found",
|
"multiple drop impls found",
|
||||||
)
|
)
|
||||||
.span_note_mv(
|
.with_span_note(
|
||||||
self.tcx().def_span(old_impl_def_id),
|
self.tcx().def_span(old_impl_def_id),
|
||||||
"other impl here",
|
"other impl here",
|
||||||
)
|
)
|
||||||
|
@ -3001,7 +3001,7 @@ fn clean_use_statement_inner<'tcx>(
|
|||||||
E0780,
|
E0780,
|
||||||
"anonymous imports cannot be inlined"
|
"anonymous imports cannot be inlined"
|
||||||
)
|
)
|
||||||
.span_label_mv(import.span, "anonymous import")
|
.with_span_label(import.span, "anonymous import")
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -577,13 +577,13 @@ impl Options {
|
|||||||
{
|
{
|
||||||
if !theme_file.is_file() {
|
if !theme_file.is_file() {
|
||||||
dcx.struct_err(format!("invalid argument: \"{theme_s}\""))
|
dcx.struct_err(format!("invalid argument: \"{theme_s}\""))
|
||||||
.help_mv("arguments to --theme must be files")
|
.with_help("arguments to --theme must be files")
|
||||||
.emit();
|
.emit();
|
||||||
return Err(1);
|
return Err(1);
|
||||||
}
|
}
|
||||||
if theme_file.extension() != Some(OsStr::new("css")) {
|
if theme_file.extension() != Some(OsStr::new("css")) {
|
||||||
dcx.struct_err(format!("invalid argument: \"{theme_s}\""))
|
dcx.struct_err(format!("invalid argument: \"{theme_s}\""))
|
||||||
.help_mv("arguments to --theme must have a .css extension")
|
.with_help("arguments to --theme must have a .css extension")
|
||||||
.emit();
|
.emit();
|
||||||
return Err(1);
|
return Err(1);
|
||||||
}
|
}
|
||||||
@ -595,8 +595,8 @@ impl Options {
|
|||||||
dcx.struct_warn(format!(
|
dcx.struct_warn(format!(
|
||||||
"theme file \"{theme_s}\" is missing CSS rules from the default theme",
|
"theme file \"{theme_s}\" is missing CSS rules from the default theme",
|
||||||
))
|
))
|
||||||
.warn_mv("the theme may appear incorrect when loaded")
|
.with_warn("the theme may appear incorrect when loaded")
|
||||||
.help_mv(format!(
|
.with_help(format!(
|
||||||
"to see what rules are missing, call `rustdoc --check-theme \"{theme_s}\"`",
|
"to see what rules are missing, call `rustdoc --check-theme \"{theme_s}\"`",
|
||||||
))
|
))
|
||||||
.emit();
|
.emit();
|
||||||
@ -809,7 +809,7 @@ fn check_deprecated_options(matches: &getopts::Matches, dcx: &rustc_errors::Diag
|
|||||||
for &flag in deprecated_flags.iter() {
|
for &flag in deprecated_flags.iter() {
|
||||||
if matches.opt_present(flag) {
|
if matches.opt_present(flag) {
|
||||||
dcx.struct_warn(format!("the `{flag}` flag is deprecated"))
|
dcx.struct_warn(format!("the `{flag}` flag is deprecated"))
|
||||||
.note_mv(
|
.with_note(
|
||||||
"see issue #44136 <https://github.com/rust-lang/rust/issues/44136> \
|
"see issue #44136 <https://github.com/rust-lang/rust/issues/44136> \
|
||||||
for more information",
|
for more information",
|
||||||
)
|
)
|
||||||
|
@ -501,9 +501,9 @@ impl<'tcx> Visitor<'tcx> for EmitIgnoredResolutionErrors<'tcx> {
|
|||||||
E0433,
|
E0433,
|
||||||
"failed to resolve: {label}",
|
"failed to resolve: {label}",
|
||||||
)
|
)
|
||||||
.span_label_mv(path.span, label)
|
.with_span_label(path.span, label)
|
||||||
.note_mv("this error was originally ignored because you are running `rustdoc`")
|
.with_note("this error was originally ignored because you are running `rustdoc`")
|
||||||
.note_mv("try running again with `rustc` or `cargo check` and you may get a more detailed error")
|
.with_note("try running again with `rustc` or `cargo check` and you may get a more detailed error")
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
// We could have an outer resolution that succeeded,
|
// We could have an outer resolution that succeeded,
|
||||||
|
@ -1228,7 +1228,7 @@ impl LinkCollector<'_, '_> {
|
|||||||
span,
|
span,
|
||||||
"linking to associated items of raw pointers is experimental",
|
"linking to associated items of raw pointers is experimental",
|
||||||
)
|
)
|
||||||
.note_mv("rustdoc does not allow disambiguating between `*const` and `*mut`, and pointers are unstable until it does")
|
.with_note("rustdoc does not allow disambiguating between `*const` and `*mut`, and pointers are unstable until it does")
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ impl Msrv {
|
|||||||
if let Some(duplicate) = msrv_attrs.last() {
|
if let Some(duplicate) = msrv_attrs.last() {
|
||||||
sess.dcx()
|
sess.dcx()
|
||||||
.struct_span_err(duplicate.span, "`clippy::msrv` is defined multiple times")
|
.struct_span_err(duplicate.span, "`clippy::msrv` is defined multiple times")
|
||||||
.span_note_mv(msrv_attr.span, "first definition found here")
|
.with_span_note(msrv_attr.span, "first definition found here")
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ pub fn get_unique_attr<'a>(
|
|||||||
if let Some(duplicate) = unique_attr {
|
if let Some(duplicate) = unique_attr {
|
||||||
sess.dcx()
|
sess.dcx()
|
||||||
.struct_span_err(attr.span, format!("`{name}` is defined multiple times"))
|
.struct_span_err(attr.span, format!("`{name}` is defined multiple times"))
|
||||||
.span_note_mv(duplicate.span, "first definition found here")
|
.with_span_note(duplicate.span, "first definition found here")
|
||||||
.emit();
|
.emit();
|
||||||
} else {
|
} else {
|
||||||
unique_attr = Some(attr);
|
unique_attr = Some(attr);
|
||||||
|
Loading…
Reference in New Issue
Block a user