@@ -17,7 +17,7 @@ shown below:
1717
1818``` rust,ignore
1919#[derive(SessionDiagnostic)]
20- #[error (typeck::field_already_declared, code = "E0124")]
20+ #[diag (typeck::field_already_declared, code = "E0124")]
2121pub struct FieldAlreadyDeclared {
2222 pub field_name: Ident,
2323 #[primary_span]
@@ -29,15 +29,14 @@ pub struct FieldAlreadyDeclared {
2929```
3030
3131` SessionDiagnostic ` can only be applied to structs. Every ` SessionDiagnostic `
32- has to have one attribute applied to the struct itself: either ` #[error(..)] `
33- for defining errors, or ` #[warning(..)] ` for defining warnings.
32+ has to have one attribute ` #[diag(...)] ` , applied to the struct itself.
3433
3534If an error has an error code (e.g. "E0624"), then that can be specified using
3635the ` code ` sub-attribute. Specifying a ` code ` isn't mandatory, but if you are
3736porting a diagnostic that uses ` DiagnosticBuilder ` to use ` SessionDiagnostic `
3837then you should keep the code if there was one.
3938
40- Both ` #[error(..)] ` and ` #[warning (..)]` must provide a slug as the first
39+ ` #[diag (..)] ` must provide a slug as the first
4140positional argument (a path to an item in ` rustc_errors::fluent::* ` ). A slug
4241uniquely identifies the diagnostic and is also how the compiler knows what
4342error message to emit (in the default locale of the compiler, or in the locale
@@ -146,13 +145,10 @@ tcx.sess.emit_err(FieldAlreadyDeclared {
146145` #[derive(SessionDiagnostic)] ` and ` #[derive(LintDiagnostic)] ` support the
147146following attributes:
148147
149- - ` #[error(slug, code = "...")] ` , ` #[warning(slug, code = "...")] ` ,
150- ` #[fatal(slug, code = "...")] ` or ` #[lint(slug, code = "...")] `
148+ - ` #[diag(slug, code = "...")] `
151149 - _ Applied to struct._
152150 - _ Mandatory_
153- - Defines the struct to be representing an error, fatal error, a warning or a
154- lint. Errors, fatal errors and warnings only supported by
155- ` SessionDiagnostic ` , and lints by ` LintDiagnostic ` .
151+ - Defines the text and error code to be associated with the diagnostic.
156152 - Slug (_ Mandatory_ )
157153 - Uniquely identifies the diagnostic and corresponds to its Fluent message,
158154 mandatory.
@@ -218,7 +214,7 @@ following attributes:
218214 ` #[derive(SessionSubdiagnostic)] ` )._
219215 - Adds the subdiagnostic represented by the subdiagnostic struct.
220216- ` #[primary_span] ` (_ Optional_ )
221- - _ Applied to ` Span ` fields._
217+ - _ Applied to ` Span ` fields on ` SessionSubdiagnostic ` s. Not used for ` LintDiagnostic ` s ._
222218 - Indicates the primary span of the diagnostic.
223219- ` #[skip_arg] ` (_ Optional_ )
224220 - _ Applied to any field._
0 commit comments