mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Rollup merge of #155822 - mejrs:default_fmt_args, r=JonathanBrouwer
Add default field values to diagnostic FormatArgs This type has a decent amount of unused fields (and I am planning to add more).
This commit is contained in:
@@ -156,14 +156,7 @@ pub(crate) fn report_use_of_moved_or_uninitialized(
|
||||
.collect();
|
||||
generic_args.push((kw::SelfUpper, this.clone()));
|
||||
|
||||
let args = FormatArgs {
|
||||
this,
|
||||
// Unused
|
||||
this_sugared: String::new(),
|
||||
// Unused
|
||||
item_context: "",
|
||||
generic_args,
|
||||
};
|
||||
let args = FormatArgs { this, generic_args, .. };
|
||||
let CustomDiagnostic { message, label, notes, parent_label: _ } =
|
||||
directive.eval(None, &args);
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// tidy-alphabetical-start
|
||||
#![allow(internal_features)]
|
||||
#![feature(associated_type_defaults)]
|
||||
#![feature(default_field_values)]
|
||||
#![feature(macro_metavar_expr)]
|
||||
#![feature(proc_macro_diagnostic)]
|
||||
#![feature(proc_macro_internals)]
|
||||
|
||||
@@ -77,19 +77,8 @@ pub(super) fn failed_to_match_macro(
|
||||
let CustomDiagnostic {
|
||||
message: custom_message, label: custom_label, notes: custom_notes, ..
|
||||
} = {
|
||||
let macro_name = name.to_string();
|
||||
on_unmatch_args
|
||||
.map(|directive| {
|
||||
directive.eval(
|
||||
None,
|
||||
&FormatArgs {
|
||||
this: macro_name.clone(),
|
||||
this_sugared: macro_name,
|
||||
item_context: "macro invocation",
|
||||
generic_args: Vec::new(),
|
||||
},
|
||||
)
|
||||
})
|
||||
.map(|directive| directive.eval(None, &FormatArgs { this: name.to_string(), .. }))
|
||||
.unwrap_or_default()
|
||||
};
|
||||
|
||||
|
||||
@@ -218,10 +218,11 @@ fn visit_params(&self, visit: &mut impl FnMut(Symbol, Span)) {
|
||||
/// ```
|
||||
#[derive(Debug)]
|
||||
pub struct FormatArgs {
|
||||
/// The name of the item the attribute is on.
|
||||
pub this: String,
|
||||
pub this_sugared: String,
|
||||
pub item_context: &'static str,
|
||||
pub generic_args: Vec<(Symbol, String)>,
|
||||
pub this_sugared: String = String::new(),
|
||||
pub item_context: &'static str = "",
|
||||
pub generic_args: Vec<(Symbol, String)> = Vec::new(),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute)]
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#![feature(closure_track_caller)]
|
||||
#![feature(const_default)]
|
||||
#![feature(const_trait_impl)]
|
||||
#![feature(default_field_values)]
|
||||
#![feature(derive_const)]
|
||||
#![feature(exhaustive_patterns)]
|
||||
#![feature(never_type)]
|
||||
|
||||
@@ -886,12 +886,7 @@ fn throw_unresolved_import_error(
|
||||
|
||||
let args = FormatArgs {
|
||||
this,
|
||||
// Unused
|
||||
this_sugared: String::new(),
|
||||
// Unused
|
||||
item_context: "",
|
||||
// Unused
|
||||
generic_args: Vec::new(),
|
||||
..
|
||||
};
|
||||
let CustomDiagnostic { message, label, notes, .. } = directive.eval(None, &args);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user