1
Fork 0

macros: rename #[message] to #[primary_span]

Small commit renaming `#[message]` to `#[primary_span]` as this more
accurately reflects what it does now.

Signed-off-by: David Wood <david.wood@huawei.com>
This commit is contained in:
David Wood 2022-03-31 08:50:45 +01:00
parent d0fd8d7880
commit 8100541d54
5 changed files with 31 additions and 34 deletions

View file

@ -66,11 +66,8 @@ decl_derive!(
// struct attributes
warning,
error,
// nested parts of struct attributes
code,
slug,
// field attributes
message,
primary_span,
label,
suggestion,
suggestion_short,

View file

@ -20,7 +20,7 @@ use std::collections::{BTreeSet, HashMap};
/// pub struct MoveOutOfBorrowError<'tcx> {
/// pub name: Ident,
/// pub ty: Ty<'tcx>,
/// #[message]
/// #[primary_span]
/// #[label = "cannot move out of borrow"]
/// pub span: Span,
/// #[label = "`{ty}` first borrowed here"]
@ -566,7 +566,7 @@ impl<'a> SessionDiagnosticDeriveBuilder<'a> {
let meta = attr.parse_meta()?;
match meta {
syn::Meta::Path(_) => match name {
"message" => {
"primary_span" => {
if type_matches_path(&info.ty, &["rustc_span", "Span"]) {
return Ok(quote! {
#diag.set_span(*#field_binding);
@ -574,7 +574,7 @@ impl<'a> SessionDiagnosticDeriveBuilder<'a> {
} else {
throw_span_err!(
attr.span().unwrap(),
"the `#[message]` attribute can only be applied to fields of type `Span`"
"the `#[primary_span]` attribute can only be applied to fields of type `Span`"
);
}
}