Rename some Diagnostic
setters.
`Diagnostic` has 40 methods that return `&mut Self` and could be considered setters. Four of them have a `set_` prefix. This doesn't seem necessary for a type that implements the builder pattern. This commit removes the `set_` prefixes on those four methods.
This commit is contained in:
parent
e51e98dde6
commit
505c1371d0
53 changed files with 274 additions and 281 deletions
|
@ -6,8 +6,8 @@ use crate::diagnostics::error::{
|
|||
use crate::diagnostics::utils::{
|
||||
build_field_mapping, build_suggestion_code, is_doc_comment, new_code_ident,
|
||||
report_error_if_not_applied_to_applicability, report_error_if_not_applied_to_span,
|
||||
should_generate_set_arg, AllowMultipleAlternatives, FieldInfo, FieldInnerTy, FieldMap,
|
||||
HasFieldMap, SetOnce, SpannedOption, SubdiagnosticKind,
|
||||
should_generate_arg, AllowMultipleAlternatives, FieldInfo, FieldInnerTy, FieldMap, HasFieldMap,
|
||||
SetOnce, SpannedOption, SubdiagnosticKind,
|
||||
};
|
||||
use proc_macro2::TokenStream;
|
||||
use quote::{format_ident, quote};
|
||||
|
@ -214,7 +214,7 @@ impl<'parent, 'a> SubdiagnosticDeriveVariantBuilder<'parent, 'a> {
|
|||
}
|
||||
|
||||
/// Generates the code for a field with no attributes.
|
||||
fn generate_field_set_arg(&mut self, binding_info: &BindingInfo<'_>) -> TokenStream {
|
||||
fn generate_field_arg(&mut self, binding_info: &BindingInfo<'_>) -> TokenStream {
|
||||
let diag = &self.parent.diag;
|
||||
|
||||
let field = binding_info.ast();
|
||||
|
@ -225,7 +225,7 @@ impl<'parent, 'a> SubdiagnosticDeriveVariantBuilder<'parent, 'a> {
|
|||
let ident = format_ident!("{}", ident); // strip `r#` prefix, if present
|
||||
|
||||
quote! {
|
||||
#diag.set_arg(
|
||||
#diag.arg(
|
||||
stringify!(#ident),
|
||||
#field_binding
|
||||
);
|
||||
|
@ -505,7 +505,7 @@ impl<'parent, 'a> SubdiagnosticDeriveVariantBuilder<'parent, 'a> {
|
|||
.variant
|
||||
.bindings()
|
||||
.iter()
|
||||
.filter(|binding| !should_generate_set_arg(binding.ast()))
|
||||
.filter(|binding| !should_generate_arg(binding.ast()))
|
||||
.map(|binding| self.generate_field_attr_code(binding, kind_stats))
|
||||
.collect();
|
||||
|
||||
|
@ -593,8 +593,8 @@ impl<'parent, 'a> SubdiagnosticDeriveVariantBuilder<'parent, 'a> {
|
|||
.variant
|
||||
.bindings()
|
||||
.iter()
|
||||
.filter(|binding| should_generate_set_arg(binding.ast()))
|
||||
.map(|binding| self.generate_field_set_arg(binding))
|
||||
.filter(|binding| should_generate_arg(binding.ast()))
|
||||
.map(|binding| self.generate_field_arg(binding))
|
||||
.collect();
|
||||
|
||||
let formatting_init = &self.formatting_init;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue