mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-21 22:34:05 +00:00
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
@ -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,
|
||||
|
@ -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`"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ use rustc_span::{symbol::Ident, Span, Symbol};
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[error(code = "E0062", slug = "typeck-field-multiply-specified-in-initializer")]
|
||||
pub struct FieldMultiplySpecifiedInInitializer {
|
||||
#[message]
|
||||
#[primary_span]
|
||||
#[label = "used more than once"]
|
||||
pub span: Span,
|
||||
#[label = "first use of `{ident}`"]
|
||||
@ -16,7 +16,7 @@ pub struct FieldMultiplySpecifiedInInitializer {
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[error(code = "E0092", slug = "typeck-unrecognized-atomic-operation")]
|
||||
pub struct UnrecognizedAtomicOperation<'a> {
|
||||
#[message]
|
||||
#[primary_span]
|
||||
#[label = "unrecognized atomic operation"]
|
||||
pub span: Span,
|
||||
pub op: &'a str,
|
||||
@ -25,7 +25,7 @@ pub struct UnrecognizedAtomicOperation<'a> {
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[error(code = "E0094", slug = "typeck-wrong-number-of-generic-arguments-to-intrinsic")]
|
||||
pub struct WrongNumberOfGenericArgumentsToIntrinsic<'a> {
|
||||
#[message]
|
||||
#[primary_span]
|
||||
#[label = "expected {expected} {descr} parameter{expected_pluralize}"]
|
||||
pub span: Span,
|
||||
pub found: usize,
|
||||
@ -37,7 +37,7 @@ pub struct WrongNumberOfGenericArgumentsToIntrinsic<'a> {
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[error(code = "E0093", slug = "typeck-unrecognized-intrinsic-function")]
|
||||
pub struct UnrecognizedIntrinsicFunction {
|
||||
#[message]
|
||||
#[primary_span]
|
||||
#[label = "unrecognized intrinsic"]
|
||||
pub span: Span,
|
||||
pub name: Symbol,
|
||||
@ -46,7 +46,7 @@ pub struct UnrecognizedIntrinsicFunction {
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[error(code = "E0195", slug = "typeck-lifetimes-or-bounds-mismatch-on-trait")]
|
||||
pub struct LifetimesOrBoundsMismatchOnTrait {
|
||||
#[message]
|
||||
#[primary_span]
|
||||
#[label = "lifetimes do not match {item_kind} in trait"]
|
||||
pub span: Span,
|
||||
#[label = "lifetimes in impl do not match this {item_kind} in trait"]
|
||||
@ -58,7 +58,7 @@ pub struct LifetimesOrBoundsMismatchOnTrait {
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[error(code = "E0120", slug = "typeck-drop-impl-on-wrong-item")]
|
||||
pub struct DropImplOnWrongItem {
|
||||
#[message]
|
||||
#[primary_span]
|
||||
#[label = "must be a struct, enum, or union"]
|
||||
pub span: Span,
|
||||
}
|
||||
@ -67,7 +67,7 @@ pub struct DropImplOnWrongItem {
|
||||
#[error(code = "E0124", slug = "typeck-field-already-declared")]
|
||||
pub struct FieldAlreadyDeclared {
|
||||
pub field_name: Ident,
|
||||
#[message]
|
||||
#[primary_span]
|
||||
#[label = "field already declared"]
|
||||
pub span: Span,
|
||||
#[label = "`{field_name}` first declared here"]
|
||||
@ -77,7 +77,7 @@ pub struct FieldAlreadyDeclared {
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[error(code = "E0184", slug = "typeck-copy-impl-on-type-with-dtor")]
|
||||
pub struct CopyImplOnTypeWithDtor {
|
||||
#[message]
|
||||
#[primary_span]
|
||||
#[label = "Copy not allowed on types with destructors"]
|
||||
pub span: Span,
|
||||
}
|
||||
@ -85,14 +85,14 @@ pub struct CopyImplOnTypeWithDtor {
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[error(code = "E0203", slug = "typeck-multiple-relaxed-default-bounds")]
|
||||
pub struct MultipleRelaxedDefaultBounds {
|
||||
#[message]
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[error(code = "E0206", slug = "typeck-copy-impl-on-non-adt")]
|
||||
pub struct CopyImplOnNonAdt {
|
||||
#[message]
|
||||
#[primary_span]
|
||||
#[label = "type is not a structure or enumeration"]
|
||||
pub span: Span,
|
||||
}
|
||||
@ -100,21 +100,21 @@ pub struct CopyImplOnNonAdt {
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[error(code = "E0224", slug = "typeck-trait-object-declared-with-no-traits")]
|
||||
pub struct TraitObjectDeclaredWithNoTraits {
|
||||
#[message]
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[error(code = "E0227", slug = "typeck-ambiguous-lifetime-bound")]
|
||||
pub struct AmbiguousLifetimeBound {
|
||||
#[message]
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[error(code = "E0229", slug = "typeck-assoc-type-binding-not-allowed")]
|
||||
pub struct AssocTypeBindingNotAllowed {
|
||||
#[message]
|
||||
#[primary_span]
|
||||
#[label = "associated type not allowed here"]
|
||||
pub span: Span,
|
||||
}
|
||||
@ -122,14 +122,14 @@ pub struct AssocTypeBindingNotAllowed {
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[error(code = "E0436", slug = "typeck-functional-record-update-on-non-struct")]
|
||||
pub struct FunctionalRecordUpdateOnNonStruct {
|
||||
#[message]
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[error(code = "E0516", slug = "typeck-typeof-reserved-keyword-used")]
|
||||
pub struct TypeofReservedKeywordUsed {
|
||||
#[message]
|
||||
#[primary_span]
|
||||
#[label = "reserved keyword"]
|
||||
pub span: Span,
|
||||
}
|
||||
@ -137,7 +137,7 @@ pub struct TypeofReservedKeywordUsed {
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[error(code = "E0572", slug = "typeck-return-stmt-outside-of-fn-body")]
|
||||
pub struct ReturnStmtOutsideOfFnBody {
|
||||
#[message]
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
#[label = "the return is part of this body..."]
|
||||
pub encl_body_span: Option<Span>,
|
||||
@ -148,14 +148,14 @@ pub struct ReturnStmtOutsideOfFnBody {
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[error(code = "E0627", slug = "typeck-yield-expr-outside-of-generator")]
|
||||
pub struct YieldExprOutsideOfGenerator {
|
||||
#[message]
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[error(code = "E0639", slug = "typeck-struct-expr-non-exhaustive")]
|
||||
pub struct StructExprNonExhaustive {
|
||||
#[message]
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
pub what: &'static str,
|
||||
}
|
||||
@ -163,14 +163,14 @@ pub struct StructExprNonExhaustive {
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[error(code = "E0699", slug = "typeck-method-call-on-unknown-type")]
|
||||
pub struct MethodCallOnUnknownType {
|
||||
#[message]
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[error(code = "E0719", slug = "typeck-value-of-associated-struct-already-specified")]
|
||||
pub struct ValueOfAssociatedStructAlreadySpecified {
|
||||
#[message]
|
||||
#[primary_span]
|
||||
#[label = "re-bound here"]
|
||||
pub span: Span,
|
||||
#[label = "`{item_name}` bound here first"]
|
||||
@ -182,7 +182,7 @@ pub struct ValueOfAssociatedStructAlreadySpecified {
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[error(code = "E0745", slug = "typeck-address-of-temporary-taken")]
|
||||
pub struct AddressOfTemporaryTaken {
|
||||
#[message]
|
||||
#[primary_span]
|
||||
#[label = "temporary value"]
|
||||
pub span: Span,
|
||||
}
|
||||
|
@ -121,8 +121,8 @@ struct CodeNotProvided {}
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[error(code = "E0123", slug = "foo")]
|
||||
struct MessageWrongType {
|
||||
#[message]
|
||||
//~^ ERROR `#[message]` attribute can only be applied to fields of type `Span`
|
||||
#[primary_span]
|
||||
//~^ ERROR `#[primary_span]` attribute can only be applied to fields of type `Span`
|
||||
foo: String,
|
||||
}
|
||||
|
||||
@ -295,7 +295,7 @@ struct OptionsInErrors {
|
||||
struct MoveOutOfBorrowError<'tcx> {
|
||||
name: Ident,
|
||||
ty: Ty<'tcx>,
|
||||
#[message]
|
||||
#[primary_span]
|
||||
#[label = "cannot move out of borrow"]
|
||||
span: Span,
|
||||
#[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
|
||||
|
||||
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
|
||||
|
|
||||
LL | #[message]
|
||||
| ^^^^^^^^^^
|
||||
LL | #[primary_span]
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: `#[nonsense]` is not a valid `SessionDiagnostic` field attribute
|
||||
--> $DIR/session-derive-errors.rs:132:5
|
||||
|
Loading…
Reference in New Issue
Block a user