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:
parent
d0fd8d7880
commit
8100541d54
5 changed files with 31 additions and 34 deletions
|
@ -66,11 +66,8 @@ decl_derive!(
|
||||||
// struct attributes
|
// struct attributes
|
||||||
warning,
|
warning,
|
||||||
error,
|
error,
|
||||||
// nested parts of struct attributes
|
|
||||||
code,
|
|
||||||
slug,
|
|
||||||
// field attributes
|
// field attributes
|
||||||
message,
|
primary_span,
|
||||||
label,
|
label,
|
||||||
suggestion,
|
suggestion,
|
||||||
suggestion_short,
|
suggestion_short,
|
||||||
|
|
|
@ -20,7 +20,7 @@ use std::collections::{BTreeSet, HashMap};
|
||||||
/// pub struct MoveOutOfBorrowError<'tcx> {
|
/// pub struct MoveOutOfBorrowError<'tcx> {
|
||||||
/// pub name: Ident,
|
/// pub name: Ident,
|
||||||
/// pub ty: Ty<'tcx>,
|
/// pub ty: Ty<'tcx>,
|
||||||
/// #[message]
|
/// #[primary_span]
|
||||||
/// #[label = "cannot move out of borrow"]
|
/// #[label = "cannot move out of borrow"]
|
||||||
/// pub span: Span,
|
/// pub span: Span,
|
||||||
/// #[label = "`{ty}` first borrowed here"]
|
/// #[label = "`{ty}` first borrowed here"]
|
||||||
|
@ -566,7 +566,7 @@ impl<'a> SessionDiagnosticDeriveBuilder<'a> {
|
||||||
let meta = attr.parse_meta()?;
|
let meta = attr.parse_meta()?;
|
||||||
match meta {
|
match meta {
|
||||||
syn::Meta::Path(_) => match name {
|
syn::Meta::Path(_) => match name {
|
||||||
"message" => {
|
"primary_span" => {
|
||||||
if type_matches_path(&info.ty, &["rustc_span", "Span"]) {
|
if type_matches_path(&info.ty, &["rustc_span", "Span"]) {
|
||||||
return Ok(quote! {
|
return Ok(quote! {
|
||||||
#diag.set_span(*#field_binding);
|
#diag.set_span(*#field_binding);
|
||||||
|
@ -574,7 +574,7 @@ impl<'a> SessionDiagnosticDeriveBuilder<'a> {
|
||||||
} else {
|
} else {
|
||||||
throw_span_err!(
|
throw_span_err!(
|
||||||
attr.span().unwrap(),
|
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`"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ use rustc_span::{symbol::Ident, Span, Symbol};
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(SessionDiagnostic)]
|
||||||
#[error(code = "E0062", slug = "typeck-field-multiply-specified-in-initializer")]
|
#[error(code = "E0062", slug = "typeck-field-multiply-specified-in-initializer")]
|
||||||
pub struct FieldMultiplySpecifiedInInitializer {
|
pub struct FieldMultiplySpecifiedInInitializer {
|
||||||
#[message]
|
#[primary_span]
|
||||||
#[label = "used more than once"]
|
#[label = "used more than once"]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
#[label = "first use of `{ident}`"]
|
#[label = "first use of `{ident}`"]
|
||||||
|
@ -16,7 +16,7 @@ pub struct FieldMultiplySpecifiedInInitializer {
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(SessionDiagnostic)]
|
||||||
#[error(code = "E0092", slug = "typeck-unrecognized-atomic-operation")]
|
#[error(code = "E0092", slug = "typeck-unrecognized-atomic-operation")]
|
||||||
pub struct UnrecognizedAtomicOperation<'a> {
|
pub struct UnrecognizedAtomicOperation<'a> {
|
||||||
#[message]
|
#[primary_span]
|
||||||
#[label = "unrecognized atomic operation"]
|
#[label = "unrecognized atomic operation"]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
pub op: &'a str,
|
pub op: &'a str,
|
||||||
|
@ -25,7 +25,7 @@ pub struct UnrecognizedAtomicOperation<'a> {
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(SessionDiagnostic)]
|
||||||
#[error(code = "E0094", slug = "typeck-wrong-number-of-generic-arguments-to-intrinsic")]
|
#[error(code = "E0094", slug = "typeck-wrong-number-of-generic-arguments-to-intrinsic")]
|
||||||
pub struct WrongNumberOfGenericArgumentsToIntrinsic<'a> {
|
pub struct WrongNumberOfGenericArgumentsToIntrinsic<'a> {
|
||||||
#[message]
|
#[primary_span]
|
||||||
#[label = "expected {expected} {descr} parameter{expected_pluralize}"]
|
#[label = "expected {expected} {descr} parameter{expected_pluralize}"]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
pub found: usize,
|
pub found: usize,
|
||||||
|
@ -37,7 +37,7 @@ pub struct WrongNumberOfGenericArgumentsToIntrinsic<'a> {
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(SessionDiagnostic)]
|
||||||
#[error(code = "E0093", slug = "typeck-unrecognized-intrinsic-function")]
|
#[error(code = "E0093", slug = "typeck-unrecognized-intrinsic-function")]
|
||||||
pub struct UnrecognizedIntrinsicFunction {
|
pub struct UnrecognizedIntrinsicFunction {
|
||||||
#[message]
|
#[primary_span]
|
||||||
#[label = "unrecognized intrinsic"]
|
#[label = "unrecognized intrinsic"]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
pub name: Symbol,
|
pub name: Symbol,
|
||||||
|
@ -46,7 +46,7 @@ pub struct UnrecognizedIntrinsicFunction {
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(SessionDiagnostic)]
|
||||||
#[error(code = "E0195", slug = "typeck-lifetimes-or-bounds-mismatch-on-trait")]
|
#[error(code = "E0195", slug = "typeck-lifetimes-or-bounds-mismatch-on-trait")]
|
||||||
pub struct LifetimesOrBoundsMismatchOnTrait {
|
pub struct LifetimesOrBoundsMismatchOnTrait {
|
||||||
#[message]
|
#[primary_span]
|
||||||
#[label = "lifetimes do not match {item_kind} in trait"]
|
#[label = "lifetimes do not match {item_kind} in trait"]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
#[label = "lifetimes in impl do not match this {item_kind} in trait"]
|
#[label = "lifetimes in impl do not match this {item_kind} in trait"]
|
||||||
|
@ -58,7 +58,7 @@ pub struct LifetimesOrBoundsMismatchOnTrait {
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(SessionDiagnostic)]
|
||||||
#[error(code = "E0120", slug = "typeck-drop-impl-on-wrong-item")]
|
#[error(code = "E0120", slug = "typeck-drop-impl-on-wrong-item")]
|
||||||
pub struct DropImplOnWrongItem {
|
pub struct DropImplOnWrongItem {
|
||||||
#[message]
|
#[primary_span]
|
||||||
#[label = "must be a struct, enum, or union"]
|
#[label = "must be a struct, enum, or union"]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ pub struct DropImplOnWrongItem {
|
||||||
#[error(code = "E0124", slug = "typeck-field-already-declared")]
|
#[error(code = "E0124", slug = "typeck-field-already-declared")]
|
||||||
pub struct FieldAlreadyDeclared {
|
pub struct FieldAlreadyDeclared {
|
||||||
pub field_name: Ident,
|
pub field_name: Ident,
|
||||||
#[message]
|
#[primary_span]
|
||||||
#[label = "field already declared"]
|
#[label = "field already declared"]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
#[label = "`{field_name}` first declared here"]
|
#[label = "`{field_name}` first declared here"]
|
||||||
|
@ -77,7 +77,7 @@ pub struct FieldAlreadyDeclared {
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(SessionDiagnostic)]
|
||||||
#[error(code = "E0184", slug = "typeck-copy-impl-on-type-with-dtor")]
|
#[error(code = "E0184", slug = "typeck-copy-impl-on-type-with-dtor")]
|
||||||
pub struct CopyImplOnTypeWithDtor {
|
pub struct CopyImplOnTypeWithDtor {
|
||||||
#[message]
|
#[primary_span]
|
||||||
#[label = "Copy not allowed on types with destructors"]
|
#[label = "Copy not allowed on types with destructors"]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
@ -85,14 +85,14 @@ pub struct CopyImplOnTypeWithDtor {
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(SessionDiagnostic)]
|
||||||
#[error(code = "E0203", slug = "typeck-multiple-relaxed-default-bounds")]
|
#[error(code = "E0203", slug = "typeck-multiple-relaxed-default-bounds")]
|
||||||
pub struct MultipleRelaxedDefaultBounds {
|
pub struct MultipleRelaxedDefaultBounds {
|
||||||
#[message]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(SessionDiagnostic)]
|
||||||
#[error(code = "E0206", slug = "typeck-copy-impl-on-non-adt")]
|
#[error(code = "E0206", slug = "typeck-copy-impl-on-non-adt")]
|
||||||
pub struct CopyImplOnNonAdt {
|
pub struct CopyImplOnNonAdt {
|
||||||
#[message]
|
#[primary_span]
|
||||||
#[label = "type is not a structure or enumeration"]
|
#[label = "type is not a structure or enumeration"]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
@ -100,21 +100,21 @@ pub struct CopyImplOnNonAdt {
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(SessionDiagnostic)]
|
||||||
#[error(code = "E0224", slug = "typeck-trait-object-declared-with-no-traits")]
|
#[error(code = "E0224", slug = "typeck-trait-object-declared-with-no-traits")]
|
||||||
pub struct TraitObjectDeclaredWithNoTraits {
|
pub struct TraitObjectDeclaredWithNoTraits {
|
||||||
#[message]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(SessionDiagnostic)]
|
||||||
#[error(code = "E0227", slug = "typeck-ambiguous-lifetime-bound")]
|
#[error(code = "E0227", slug = "typeck-ambiguous-lifetime-bound")]
|
||||||
pub struct AmbiguousLifetimeBound {
|
pub struct AmbiguousLifetimeBound {
|
||||||
#[message]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(SessionDiagnostic)]
|
||||||
#[error(code = "E0229", slug = "typeck-assoc-type-binding-not-allowed")]
|
#[error(code = "E0229", slug = "typeck-assoc-type-binding-not-allowed")]
|
||||||
pub struct AssocTypeBindingNotAllowed {
|
pub struct AssocTypeBindingNotAllowed {
|
||||||
#[message]
|
#[primary_span]
|
||||||
#[label = "associated type not allowed here"]
|
#[label = "associated type not allowed here"]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
@ -122,14 +122,14 @@ pub struct AssocTypeBindingNotAllowed {
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(SessionDiagnostic)]
|
||||||
#[error(code = "E0436", slug = "typeck-functional-record-update-on-non-struct")]
|
#[error(code = "E0436", slug = "typeck-functional-record-update-on-non-struct")]
|
||||||
pub struct FunctionalRecordUpdateOnNonStruct {
|
pub struct FunctionalRecordUpdateOnNonStruct {
|
||||||
#[message]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(SessionDiagnostic)]
|
||||||
#[error(code = "E0516", slug = "typeck-typeof-reserved-keyword-used")]
|
#[error(code = "E0516", slug = "typeck-typeof-reserved-keyword-used")]
|
||||||
pub struct TypeofReservedKeywordUsed {
|
pub struct TypeofReservedKeywordUsed {
|
||||||
#[message]
|
#[primary_span]
|
||||||
#[label = "reserved keyword"]
|
#[label = "reserved keyword"]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
@ -137,7 +137,7 @@ pub struct TypeofReservedKeywordUsed {
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(SessionDiagnostic)]
|
||||||
#[error(code = "E0572", slug = "typeck-return-stmt-outside-of-fn-body")]
|
#[error(code = "E0572", slug = "typeck-return-stmt-outside-of-fn-body")]
|
||||||
pub struct ReturnStmtOutsideOfFnBody {
|
pub struct ReturnStmtOutsideOfFnBody {
|
||||||
#[message]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
#[label = "the return is part of this body..."]
|
#[label = "the return is part of this body..."]
|
||||||
pub encl_body_span: Option<Span>,
|
pub encl_body_span: Option<Span>,
|
||||||
|
@ -148,14 +148,14 @@ pub struct ReturnStmtOutsideOfFnBody {
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(SessionDiagnostic)]
|
||||||
#[error(code = "E0627", slug = "typeck-yield-expr-outside-of-generator")]
|
#[error(code = "E0627", slug = "typeck-yield-expr-outside-of-generator")]
|
||||||
pub struct YieldExprOutsideOfGenerator {
|
pub struct YieldExprOutsideOfGenerator {
|
||||||
#[message]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(SessionDiagnostic)]
|
||||||
#[error(code = "E0639", slug = "typeck-struct-expr-non-exhaustive")]
|
#[error(code = "E0639", slug = "typeck-struct-expr-non-exhaustive")]
|
||||||
pub struct StructExprNonExhaustive {
|
pub struct StructExprNonExhaustive {
|
||||||
#[message]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
pub what: &'static str,
|
pub what: &'static str,
|
||||||
}
|
}
|
||||||
|
@ -163,14 +163,14 @@ pub struct StructExprNonExhaustive {
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(SessionDiagnostic)]
|
||||||
#[error(code = "E0699", slug = "typeck-method-call-on-unknown-type")]
|
#[error(code = "E0699", slug = "typeck-method-call-on-unknown-type")]
|
||||||
pub struct MethodCallOnUnknownType {
|
pub struct MethodCallOnUnknownType {
|
||||||
#[message]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(SessionDiagnostic)]
|
||||||
#[error(code = "E0719", slug = "typeck-value-of-associated-struct-already-specified")]
|
#[error(code = "E0719", slug = "typeck-value-of-associated-struct-already-specified")]
|
||||||
pub struct ValueOfAssociatedStructAlreadySpecified {
|
pub struct ValueOfAssociatedStructAlreadySpecified {
|
||||||
#[message]
|
#[primary_span]
|
||||||
#[label = "re-bound here"]
|
#[label = "re-bound here"]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
#[label = "`{item_name}` bound here first"]
|
#[label = "`{item_name}` bound here first"]
|
||||||
|
@ -182,7 +182,7 @@ pub struct ValueOfAssociatedStructAlreadySpecified {
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(SessionDiagnostic)]
|
||||||
#[error(code = "E0745", slug = "typeck-address-of-temporary-taken")]
|
#[error(code = "E0745", slug = "typeck-address-of-temporary-taken")]
|
||||||
pub struct AddressOfTemporaryTaken {
|
pub struct AddressOfTemporaryTaken {
|
||||||
#[message]
|
#[primary_span]
|
||||||
#[label = "temporary value"]
|
#[label = "temporary value"]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,8 +121,8 @@ struct CodeNotProvided {}
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(SessionDiagnostic)]
|
||||||
#[error(code = "E0123", slug = "foo")]
|
#[error(code = "E0123", slug = "foo")]
|
||||||
struct MessageWrongType {
|
struct MessageWrongType {
|
||||||
#[message]
|
#[primary_span]
|
||||||
//~^ ERROR `#[message]` attribute can only be applied to fields of type `Span`
|
//~^ ERROR `#[primary_span]` attribute can only be applied to fields of type `Span`
|
||||||
foo: String,
|
foo: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -295,7 +295,7 @@ struct OptionsInErrors {
|
||||||
struct MoveOutOfBorrowError<'tcx> {
|
struct MoveOutOfBorrowError<'tcx> {
|
||||||
name: Ident,
|
name: Ident,
|
||||||
ty: Ty<'tcx>,
|
ty: Ty<'tcx>,
|
||||||
#[message]
|
#[primary_span]
|
||||||
#[label = "cannot move out of borrow"]
|
#[label = "cannot move out of borrow"]
|
||||||
span: Span,
|
span: Span,
|
||||||
#[label = "`{ty}` first borrowed here"]
|
#[label = "`{ty}` first borrowed here"]
|
||||||
|
|
|
@ -156,11 +156,11 @@ LL | | struct CodeNotProvided {}
|
||||||
|
|
|
|
||||||
= help: use the `#[error(code = "...")]` attribute to set this diagnostic's error code
|
= help: use the `#[error(code = "...")]` attribute to set this diagnostic's error code
|
||||||
|
|
||||||
error: the `#[message]` attribute can only be applied to fields of type `Span`
|
error: the `#[primary_span]` attribute can only be applied to fields of type `Span`
|
||||||
--> $DIR/session-derive-errors.rs:124:5
|
--> $DIR/session-derive-errors.rs:124:5
|
||||||
|
|
|
|
||||||
LL | #[message]
|
LL | #[primary_span]
|
||||||
| ^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: `#[nonsense]` is not a valid `SessionDiagnostic` field attribute
|
error: `#[nonsense]` is not a valid `SessionDiagnostic` field attribute
|
||||||
--> $DIR/session-derive-errors.rs:132:5
|
--> $DIR/session-derive-errors.rs:132:5
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue