avoid &format
in error message code
This commit is contained in:
parent
0c2c243342
commit
c8960622a2
@ -278,7 +278,7 @@ pub(crate) fn cannot_move_out_of(
|
||||
move_from_span: Span,
|
||||
move_from_desc: &str,
|
||||
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
|
||||
struct_span_err!(self, move_from_span, E0507, "cannot move out of {}", move_from_desc,)
|
||||
struct_span_err!(self, move_from_span, E0507, "cannot move out of {}", move_from_desc)
|
||||
}
|
||||
|
||||
/// Signal an error due to an attempt to move out of the interior
|
||||
|
@ -54,7 +54,7 @@ fn path_to_string(path: &syn::Path) -> String {
|
||||
|
||||
/// Returns an error diagnostic on span `span` with msg `msg`.
|
||||
#[must_use]
|
||||
pub(crate) fn span_err(span: impl MultiSpan, msg: &str) -> Diagnostic {
|
||||
pub(crate) fn span_err<T: Into<String>>(span: impl MultiSpan, msg: T) -> Diagnostic {
|
||||
Diagnostic::spanned(span, Level::Error, msg)
|
||||
}
|
||||
|
||||
@ -77,11 +77,9 @@ pub(crate) fn invalid_attr(attr: &Attribute) -> Diagnostic {
|
||||
let span = attr.span().unwrap();
|
||||
let path = path_to_string(attr.path());
|
||||
match attr.meta {
|
||||
Meta::Path(_) => span_err(span, &format!("`#[{path}]` is not a valid attribute")),
|
||||
Meta::NameValue(_) => {
|
||||
span_err(span, &format!("`#[{path} = ...]` is not a valid attribute"))
|
||||
}
|
||||
Meta::List(_) => span_err(span, &format!("`#[{path}(...)]` is not a valid attribute")),
|
||||
Meta::Path(_) => span_err(span, format!("`#[{path}]` is not a valid attribute")),
|
||||
Meta::NameValue(_) => span_err(span, format!("`#[{path} = ...]` is not a valid attribute")),
|
||||
Meta::List(_) => span_err(span, format!("`#[{path}(...)]` is not a valid attribute")),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -200,7 +200,7 @@ fn identify_kind(
|
||||
|
||||
throw_span_err!(
|
||||
attr.span().unwrap(),
|
||||
&format!(
|
||||
format!(
|
||||
"diagnostic slug must be first argument of a `#[{name}(...)]` attribute"
|
||||
)
|
||||
);
|
||||
|
@ -347,7 +347,7 @@ fn build_format(&self, input: &str, span: proc_macro2::Span) -> TokenStream {
|
||||
None => {
|
||||
span_err(
|
||||
span.unwrap(),
|
||||
&format!("`{field}` doesn't refer to a field on this type"),
|
||||
format!("`{field}` doesn't refer to a field on this type"),
|
||||
)
|
||||
.emit();
|
||||
quote! {
|
||||
|
Loading…
Reference in New Issue
Block a user