about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2024-01-09 09:08:49 +1100
committerNicholas Nethercote <n.nethercote@gmail.com>2024-01-10 07:40:00 +1100
commited76b0b882d0acff9295bcd76c2b119cf83e7219 (patch)
treeb40f6c489904d201833e5e446afbfbee1501e26a /compiler/rustc_codegen_ssa/src
parent2ea7a37e1113febac8603729e33fdd94f2738807 (diff)
downloadrust-ed76b0b882d0acff9295bcd76c2b119cf83e7219.tar.gz
rust-ed76b0b882d0acff9295bcd76c2b119cf83e7219.zip
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.
Diffstat (limited to 'compiler/rustc_codegen_ssa/src')
-rw-r--r--compiler/rustc_codegen_ssa/src/codegen_attrs.rs6
-rw-r--r--compiler/rustc_codegen_ssa/src/errors.rs53
-rw-r--r--compiler/rustc_codegen_ssa/src/target_features.rs2
3 files changed, 30 insertions, 31 deletions
diff --git a/compiler/rustc_codegen_ssa/src/codegen_attrs.rs b/compiler/rustc_codegen_ssa/src/codegen_attrs.rs
index abce3c6dcc9..36d7234a6ea 100644
--- a/compiler/rustc_codegen_ssa/src/codegen_attrs.rs
+++ b/compiler/rustc_codegen_ssa/src/codegen_attrs.rs
@@ -309,7 +309,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
                             attr.span,
                             "`#[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();
                     } else {
                         check_target_feature_trait_unsafe(tcx, did, attr.span);
@@ -478,7 +478,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
                     InlineAttr::Never
                 } else {
                     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();
 
                     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);
             tcx.dcx()
                 .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();
             None
         }
diff --git a/compiler/rustc_codegen_ssa/src/errors.rs b/compiler/rustc_codegen_ssa/src/errors.rs
index 7e3b69fa52f..f90e1906caf 100644
--- a/compiler/rustc_codegen_ssa/src/errors.rs
+++ b/compiler/rustc_codegen_ssa/src/errors.rs
@@ -230,25 +230,25 @@ impl<G: EmissionGuarantee> IntoDiagnostic<'_, G> for ThorinErrorWrapper {
             thorin::Error::DecompressData(_) => build(fluent::codegen_ssa_thorin_decompress_data),
             thorin::Error::NamelessSection(_, offset) => {
                 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) => {
                 build(fluent::codegen_ssa_thorin_relocation_with_invalid_symbol)
-                    .arg_mv("section", section)
-                    .arg_mv("offset", format!("0x{offset:08x}"))
+                    .with_arg("section", section)
+                    .with_arg("offset", format!("0x{offset:08x}"))
             }
             thorin::Error::MultipleRelocations(section, offset) => {
                 build(fluent::codegen_ssa_thorin_multiple_relocations)
-                    .arg_mv("section", section)
-                    .arg_mv("offset", format!("0x{offset:08x}"))
+                    .with_arg("section", section)
+                    .with_arg("offset", format!("0x{offset:08x}"))
             }
             thorin::Error::UnsupportedRelocation(section, offset) => {
                 build(fluent::codegen_ssa_thorin_unsupported_relocation)
-                    .arg_mv("section", section)
-                    .arg_mv("offset", format!("0x{offset:08x}"))
+                    .with_arg("section", section)
+                    .with_arg("offset", format!("0x{offset:08x}"))
             }
             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 => {
                 build(fluent::codegen_ssa_thorin_no_compilation_units)
             }
@@ -258,7 +258,7 @@ impl<G: EmissionGuarantee> IntoDiagnostic<'_, G> for ThorinErrorWrapper {
             }
             thorin::Error::MissingRequiredSection(section) => {
                 build(fluent::codegen_ssa_thorin_missing_required_section)
-                    .arg_mv("section", section)
+                    .with_arg("section", section)
             }
             thorin::Error::ParseUnitAbbreviations(_) => {
                 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::IncompatibleIndexVersion(section, format, actual) => {
                 build(fluent::codegen_ssa_thorin_incompatible_index_version)
-                    .arg_mv("section", section)
-                    .arg_mv("actual", actual)
-                    .arg_mv("format", format)
+                    .with_arg("section", section)
+                    .with_arg("actual", actual)
+                    .with_arg("format", format)
             }
             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) => {
                 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) => {
-                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) => {
                 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) => {
-                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::EmptyUnit(unit) => {
-                build(fluent::codegen_ssa_thorin_empty_unit).arg_mv("unit", format!("0x{unit:08x}"))
-            }
+            thorin::Error::EmptyUnit(unit) => build(fluent::codegen_ssa_thorin_empty_unit)
+                .with_arg("unit", format!("0x{unit:08x}")),
             thorin::Error::MultipleDebugInfoSection => {
                 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::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) => {
                 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 => {
                 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)
             }
             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) => {
-                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) => {
-                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) => {
-                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) => {
-                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"),
         }
diff --git a/compiler/rustc_codegen_ssa/src/target_features.rs b/compiler/rustc_codegen_ssa/src/target_features.rs
index c0ce8a54af5..0fef6bc110e 100644
--- a/compiler/rustc_codegen_ssa/src/target_features.rs
+++ b/compiler/rustc_codegen_ssa/src/target_features.rs
@@ -27,7 +27,7 @@ pub fn from_target_feature(
         let code = "enable = \"..\"";
         tcx.dcx()
             .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();
     };
     let rust_features = tcx.features();