2020-08-27 05:00:21 -05:00
|
|
|
// check-fail
|
|
|
|
// Tests error conditions for specifying diagnostics using #[derive(SessionDiagnostic)]
|
|
|
|
|
2021-06-07 10:08:13 -05:00
|
|
|
// The proc_macro2 crate handles spans differently when on beta/stable release rather than nightly,
|
|
|
|
// changing the output of this test. Since SessionDiagnostic is strictly internal to the compiler
|
|
|
|
// the test is just ignored on stable and beta:
|
|
|
|
// ignore-beta
|
|
|
|
// ignore-stable
|
|
|
|
|
2020-08-27 05:00:21 -05:00
|
|
|
#![feature(rustc_private)]
|
|
|
|
#![crate_type = "lib"]
|
|
|
|
|
|
|
|
extern crate rustc_span;
|
|
|
|
use rustc_span::symbol::Ident;
|
2022-03-30 03:45:36 -05:00
|
|
|
use rustc_span::Span;
|
2020-08-27 05:00:21 -05:00
|
|
|
|
|
|
|
extern crate rustc_macros;
|
|
|
|
use rustc_macros::SessionDiagnostic;
|
|
|
|
|
|
|
|
extern crate rustc_middle;
|
|
|
|
use rustc_middle::ty::Ty;
|
|
|
|
|
|
|
|
extern crate rustc_errors;
|
|
|
|
use rustc_errors::Applicability;
|
|
|
|
|
|
|
|
extern crate rustc_session;
|
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
2022-03-31 02:35:17 -05:00
|
|
|
#[error(code = "E0123", slug = "hello-world")]
|
2020-08-27 05:00:21 -05:00
|
|
|
struct Hello {}
|
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
2022-03-31 02:35:17 -05:00
|
|
|
#[warning(code = "E0123", slug = "hello-world")]
|
|
|
|
struct HelloWarn {}
|
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
|
|
|
#[error(code = "E0123", slug = "foo")]
|
2020-08-27 05:00:21 -05:00
|
|
|
//~^ ERROR `#[derive(SessionDiagnostic)]` can only be used on structs
|
|
|
|
enum SessionDiagnosticOnEnum {
|
|
|
|
Foo,
|
|
|
|
Bar,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
2022-03-31 02:35:17 -05:00
|
|
|
#[error(code = "E0123", slug = "foo")]
|
2020-08-27 05:00:21 -05:00
|
|
|
#[error = "E0123"]
|
2022-04-26 22:06:13 -05:00
|
|
|
//~^ ERROR `#[error = ...]` is not a valid attribute
|
2022-03-31 02:35:17 -05:00
|
|
|
struct WrongStructAttrStyle {}
|
2020-08-27 05:00:21 -05:00
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
2022-03-31 02:35:17 -05:00
|
|
|
#[nonsense(code = "E0123", slug = "foo")]
|
2022-04-26 22:06:13 -05:00
|
|
|
//~^ ERROR `#[nonsense(...)]` is not a valid attribute
|
2022-03-31 02:35:17 -05:00
|
|
|
//~^^ ERROR diagnostic kind not specified
|
|
|
|
//~^^^ ERROR cannot find attribute `nonsense` in this scope
|
|
|
|
struct InvalidStructAttr {}
|
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
|
|
|
#[error("E0123")]
|
2022-04-26 22:06:13 -05:00
|
|
|
//~^ ERROR `#[error("...")]` is not a valid attribute
|
2022-03-31 02:35:17 -05:00
|
|
|
//~^^ ERROR `slug` not specified
|
|
|
|
struct InvalidLitNestedAttr {}
|
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
|
|
|
#[error(nonsense, code = "E0123", slug = "foo")]
|
2022-04-26 22:06:13 -05:00
|
|
|
//~^ ERROR `#[error(nonsense)]` is not a valid attribute
|
2022-03-31 02:35:17 -05:00
|
|
|
struct InvalidNestedStructAttr {}
|
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
|
|
|
#[error(nonsense("foo"), code = "E0123", slug = "foo")]
|
2022-04-26 22:06:13 -05:00
|
|
|
//~^ ERROR `#[error(nonsense(...))]` is not a valid attribute
|
2022-03-31 02:35:17 -05:00
|
|
|
struct InvalidNestedStructAttr1 {}
|
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
|
|
|
#[error(nonsense = "...", code = "E0123", slug = "foo")]
|
2022-04-26 22:06:13 -05:00
|
|
|
//~^ ERROR `#[error(nonsense = ...)]` is not a valid attribute
|
2022-03-31 02:35:17 -05:00
|
|
|
struct InvalidNestedStructAttr2 {}
|
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
|
|
|
#[error(nonsense = 4, code = "E0123", slug = "foo")]
|
2022-04-26 22:06:13 -05:00
|
|
|
//~^ ERROR `#[error(nonsense = ...)]` is not a valid attribute
|
2022-03-31 02:35:17 -05:00
|
|
|
struct InvalidNestedStructAttr3 {}
|
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
|
|
|
#[error(code = "E0123", slug = "foo")]
|
2020-08-27 05:00:21 -05:00
|
|
|
struct WrongPlaceField {
|
2022-03-31 07:10:13 -05:00
|
|
|
#[suggestion = "bar"]
|
2022-04-26 22:06:13 -05:00
|
|
|
//~^ ERROR `#[suggestion = ...]` is not a valid attribute
|
2020-08-27 05:00:21 -05:00
|
|
|
sp: Span,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
2022-03-31 02:35:17 -05:00
|
|
|
#[error(code = "E0123", slug = "foo")]
|
|
|
|
#[error(code = "E0456", slug = "bar")] //~ ERROR `error` specified multiple times
|
2020-08-27 05:00:21 -05:00
|
|
|
struct ErrorSpecifiedTwice {}
|
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
2022-03-31 02:35:17 -05:00
|
|
|
#[error(code = "E0123", slug = "foo")]
|
|
|
|
#[warning(code = "E0293", slug = "bar")]
|
|
|
|
//~^ ERROR `warning` specified when `error` was already specified
|
|
|
|
struct WarnSpecifiedAfterError {}
|
2020-08-27 05:00:21 -05:00
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
2022-03-31 02:35:17 -05:00
|
|
|
#[error(code = "E0456", code = "E0457", slug = "bar")] //~ ERROR `code` specified multiple times
|
|
|
|
struct CodeSpecifiedTwice {}
|
2020-08-27 05:00:21 -05:00
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
2022-03-31 02:35:17 -05:00
|
|
|
#[error(code = "E0456", slug = "foo", slug = "bar")] //~ ERROR `slug` specified multiple times
|
|
|
|
struct SlugSpecifiedTwice {}
|
2020-08-27 05:00:21 -05:00
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
2022-03-31 02:35:17 -05:00
|
|
|
struct KindNotProvided {} //~ ERROR diagnostic kind not specified
|
2020-08-27 05:00:21 -05:00
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
2022-03-31 02:35:17 -05:00
|
|
|
#[error(code = "E0456")] //~ ERROR `slug` not specified
|
|
|
|
struct SlugNotProvided {}
|
2020-08-27 05:00:21 -05:00
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
2022-03-31 03:21:42 -05:00
|
|
|
#[error(slug = "foo")]
|
2022-03-31 02:35:17 -05:00
|
|
|
struct CodeNotProvided {}
|
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
|
|
|
#[error(code = "E0123", slug = "foo")]
|
|
|
|
struct MessageWrongType {
|
2022-03-31 02:50:45 -05:00
|
|
|
#[primary_span]
|
|
|
|
//~^ ERROR `#[primary_span]` attribute can only be applied to fields of type `Span`
|
2022-03-31 02:35:17 -05:00
|
|
|
foo: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
|
|
|
#[error(code = "E0123", slug = "foo")]
|
|
|
|
struct InvalidPathFieldAttr {
|
|
|
|
#[nonsense]
|
2022-04-26 22:06:13 -05:00
|
|
|
//~^ ERROR `#[nonsense]` is not a valid attribute
|
2022-03-31 02:35:17 -05:00
|
|
|
//~^^ ERROR cannot find attribute `nonsense` in this scope
|
|
|
|
foo: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
|
|
|
#[error(code = "E0123", slug = "foo")]
|
2020-08-27 05:00:21 -05:00
|
|
|
struct ErrorWithField {
|
|
|
|
name: String,
|
2022-03-31 04:24:46 -05:00
|
|
|
#[label = "bar"]
|
2022-03-30 04:04:03 -05:00
|
|
|
span: Span,
|
2020-08-27 05:00:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
2022-03-31 02:35:17 -05:00
|
|
|
#[error(code = "E0123", slug = "foo")]
|
2020-08-27 05:00:21 -05:00
|
|
|
struct ErrorWithMessageAppliedToField {
|
2022-03-31 04:24:46 -05:00
|
|
|
#[label = "bar"]
|
2022-03-31 02:35:17 -05:00
|
|
|
//~^ ERROR the `#[label = ...]` attribute can only be applied to fields of type `Span`
|
2020-08-27 05:00:21 -05:00
|
|
|
name: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
2022-03-31 02:35:17 -05:00
|
|
|
#[error(code = "E0123", slug = "foo")]
|
2020-08-27 05:00:21 -05:00
|
|
|
struct ErrorWithNonexistentField {
|
2022-03-31 07:10:13 -05:00
|
|
|
#[suggestion(message = "bar", code = "{name}")]
|
2022-03-31 02:35:17 -05:00
|
|
|
//~^ ERROR `name` doesn't refer to a field on this type
|
2022-03-31 04:24:46 -05:00
|
|
|
suggestion: (Span, Applicability),
|
2020-08-27 05:00:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
|
|
|
//~^ ERROR invalid format string: expected `'}'`
|
2022-03-31 04:24:46 -05:00
|
|
|
#[error(code = "E0123", slug = "foo")]
|
2020-08-27 05:00:21 -05:00
|
|
|
struct ErrorMissingClosingBrace {
|
2022-03-31 07:10:13 -05:00
|
|
|
#[suggestion(message = "bar", code = "{name")]
|
2022-03-31 04:24:46 -05:00
|
|
|
suggestion: (Span, Applicability),
|
2020-08-27 05:00:21 -05:00
|
|
|
name: String,
|
2022-03-30 03:45:36 -05:00
|
|
|
val: usize,
|
2020-08-27 05:00:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
|
|
|
//~^ ERROR invalid format string: unmatched `}`
|
2022-03-31 04:24:46 -05:00
|
|
|
#[error(code = "E0123", slug = "foo")]
|
2020-08-27 05:00:21 -05:00
|
|
|
struct ErrorMissingOpeningBrace {
|
2022-03-31 07:10:13 -05:00
|
|
|
#[suggestion(message = "bar", code = "name}")]
|
2022-03-31 04:24:46 -05:00
|
|
|
suggestion: (Span, Applicability),
|
2020-08-27 05:00:21 -05:00
|
|
|
name: String,
|
2022-03-30 03:45:36 -05:00
|
|
|
val: usize,
|
2020-08-27 05:00:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
2022-03-31 02:35:17 -05:00
|
|
|
#[error(code = "E0123", slug = "foo")]
|
2020-08-27 05:00:21 -05:00
|
|
|
struct LabelOnSpan {
|
2022-03-31 04:24:46 -05:00
|
|
|
#[label = "bar"]
|
2022-03-30 04:04:03 -05:00
|
|
|
sp: Span,
|
2020-08-27 05:00:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
2022-03-31 02:35:17 -05:00
|
|
|
#[error(code = "E0123", slug = "foo")]
|
2020-08-27 05:00:21 -05:00
|
|
|
struct LabelOnNonSpan {
|
2022-03-31 04:24:46 -05:00
|
|
|
#[label = "bar"]
|
2022-03-31 02:35:17 -05:00
|
|
|
//~^ ERROR the `#[label = ...]` attribute can only be applied to fields of type `Span`
|
2020-08-27 05:00:21 -05:00
|
|
|
id: u32,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
2022-03-31 02:35:17 -05:00
|
|
|
#[error(code = "E0123", slug = "foo")]
|
2020-08-27 05:00:21 -05:00
|
|
|
struct Suggest {
|
2022-03-31 07:10:13 -05:00
|
|
|
#[suggestion(message = "bar", code = "This is the suggested code")]
|
|
|
|
#[suggestion_short(message = "qux", code = "This is the suggested code")]
|
|
|
|
#[suggestion_hidden(message = "foobar", code = "This is the suggested code")]
|
|
|
|
#[suggestion_verbose(message = "fooqux", code = "This is the suggested code")]
|
2020-08-27 05:00:21 -05:00
|
|
|
suggestion: (Span, Applicability),
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
2022-03-31 02:35:17 -05:00
|
|
|
#[error(code = "E0123", slug = "foo")]
|
2020-08-27 05:00:21 -05:00
|
|
|
struct SuggestWithoutCode {
|
2022-03-31 07:10:13 -05:00
|
|
|
#[suggestion(message = "bar")]
|
2020-08-27 05:00:21 -05:00
|
|
|
suggestion: (Span, Applicability),
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
2022-03-31 02:35:17 -05:00
|
|
|
#[error(code = "E0123", slug = "foo")]
|
2020-08-27 05:00:21 -05:00
|
|
|
struct SuggestWithBadKey {
|
2022-03-31 07:10:13 -05:00
|
|
|
#[suggestion(nonsense = "bar")]
|
2022-04-26 22:06:13 -05:00
|
|
|
//~^ ERROR `#[suggestion(nonsense = ...)]` is not a valid attribute
|
2020-08-27 05:00:21 -05:00
|
|
|
suggestion: (Span, Applicability),
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
2022-03-31 02:35:17 -05:00
|
|
|
#[error(code = "E0123", slug = "foo")]
|
2020-08-27 05:00:21 -05:00
|
|
|
struct SuggestWithShorthandMsg {
|
2022-03-31 07:10:13 -05:00
|
|
|
#[suggestion(msg = "bar")]
|
2022-04-26 22:06:13 -05:00
|
|
|
//~^ ERROR `#[suggestion(msg = ...)]` is not a valid attribute
|
2020-08-27 05:00:21 -05:00
|
|
|
suggestion: (Span, Applicability),
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
2022-03-31 02:35:17 -05:00
|
|
|
#[error(code = "E0123", slug = "foo")]
|
2020-08-27 05:00:21 -05:00
|
|
|
struct SuggestWithoutMsg {
|
2022-03-31 07:10:13 -05:00
|
|
|
#[suggestion(code = "bar")]
|
2020-08-27 05:00:21 -05:00
|
|
|
suggestion: (Span, Applicability),
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
2022-03-31 02:35:17 -05:00
|
|
|
#[error(code = "E0123", slug = "foo")]
|
2020-08-27 05:00:21 -05:00
|
|
|
struct SuggestWithTypesSwapped {
|
2022-03-31 07:10:13 -05:00
|
|
|
#[suggestion(message = "bar", code = "This is suggested code")]
|
2020-08-27 05:00:21 -05:00
|
|
|
suggestion: (Applicability, Span),
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
2022-03-31 02:35:17 -05:00
|
|
|
#[error(code = "E0123", slug = "foo")]
|
2020-08-27 05:00:21 -05:00
|
|
|
struct SuggestWithWrongTypeApplicabilityOnly {
|
2022-03-31 07:10:13 -05:00
|
|
|
#[suggestion(message = "bar", code = "This is suggested code")]
|
2020-08-27 05:00:21 -05:00
|
|
|
//~^ ERROR wrong field type for suggestion
|
|
|
|
suggestion: Applicability,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
2022-03-31 02:35:17 -05:00
|
|
|
#[error(code = "E0123", slug = "foo")]
|
2022-03-30 04:04:03 -05:00
|
|
|
struct SuggestWithSpanOnly {
|
2022-03-31 07:10:13 -05:00
|
|
|
#[suggestion(message = "bar", code = "This is suggested code")]
|
2020-08-27 05:00:21 -05:00
|
|
|
suggestion: Span,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
2022-03-31 02:35:17 -05:00
|
|
|
#[error(code = "E0123", slug = "foo")]
|
2020-08-27 05:00:21 -05:00
|
|
|
struct SuggestWithDuplicateSpanAndApplicability {
|
2022-03-31 07:10:13 -05:00
|
|
|
#[suggestion(message = "bar", code = "This is suggested code")]
|
2022-03-30 04:04:03 -05:00
|
|
|
//~^ ERROR type of field annotated with `#[suggestion(...)]` contains more than one `Span`
|
2020-08-27 05:00:21 -05:00
|
|
|
suggestion: (Span, Span, Applicability),
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
2022-03-31 02:35:17 -05:00
|
|
|
#[error(code = "E0123", slug = "foo")]
|
2020-08-27 05:00:21 -05:00
|
|
|
struct SuggestWithDuplicateApplicabilityAndSpan {
|
2022-03-31 07:10:13 -05:00
|
|
|
#[suggestion(message = "bar", code = "This is suggested code")]
|
2020-08-27 05:00:21 -05:00
|
|
|
//~^ ERROR type of field annotated with `#[suggestion(...)]` contains more than one
|
|
|
|
suggestion: (Applicability, Applicability, Span),
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
2022-03-31 02:35:17 -05:00
|
|
|
#[error(code = "E0123", slug = "foo")]
|
2020-08-27 05:00:21 -05:00
|
|
|
struct WrongKindOfAnnotation {
|
2022-03-31 04:24:46 -05:00
|
|
|
#[label("bar")]
|
2022-04-26 22:06:13 -05:00
|
|
|
//~^ ERROR `#[label(...)]` is not a valid attribute
|
2020-08-27 05:00:21 -05:00
|
|
|
z: Span,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
2022-03-31 02:35:17 -05:00
|
|
|
#[error(code = "E0123", slug = "foo")]
|
2020-08-27 05:00:21 -05:00
|
|
|
struct OptionsInErrors {
|
2022-03-31 04:24:46 -05:00
|
|
|
#[label = "bar"]
|
2020-08-27 05:00:21 -05:00
|
|
|
label: Option<Span>,
|
2022-03-31 07:10:13 -05:00
|
|
|
#[suggestion(message = "bar")]
|
2020-08-27 05:00:21 -05:00
|
|
|
opt_sugg: Option<(Span, Applicability)>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
2022-03-31 02:35:17 -05:00
|
|
|
#[error(code = "E0456", slug = "foo")]
|
2020-08-27 05:00:21 -05:00
|
|
|
struct MoveOutOfBorrowError<'tcx> {
|
|
|
|
name: Ident,
|
|
|
|
ty: Ty<'tcx>,
|
2022-03-31 02:50:45 -05:00
|
|
|
#[primary_span]
|
2022-03-31 04:24:46 -05:00
|
|
|
#[label = "bar"]
|
2020-08-27 05:00:21 -05:00
|
|
|
span: Span,
|
2022-03-31 04:24:46 -05:00
|
|
|
#[label = "qux"]
|
2020-08-27 05:00:21 -05:00
|
|
|
other_span: Span,
|
2022-03-31 07:10:13 -05:00
|
|
|
#[suggestion(message = "bar", code = "{name}.clone()")]
|
2020-08-27 05:00:21 -05:00
|
|
|
opt_sugg: Option<(Span, Applicability)>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
2022-03-31 02:35:17 -05:00
|
|
|
#[error(code = "E0123", slug = "foo")]
|
2020-08-27 05:00:21 -05:00
|
|
|
struct ErrorWithLifetime<'a> {
|
2022-03-31 04:24:46 -05:00
|
|
|
#[label = "bar"]
|
|
|
|
span: Span,
|
|
|
|
name: &'a str,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
|
|
|
#[error(code = "E0123", slug = "foo")]
|
|
|
|
struct ErrorWithDefaultLabelAttr<'a> {
|
|
|
|
#[label]
|
2020-08-27 05:00:21 -05:00
|
|
|
span: Span,
|
|
|
|
name: &'a str,
|
|
|
|
}
|
2022-03-31 03:02:31 -05:00
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
|
|
|
//~^ ERROR no method named `into_diagnostic_arg` found for struct `Hello` in the current scope
|
|
|
|
#[error(code = "E0123", slug = "foo")]
|
|
|
|
struct ArgFieldWithoutSkip {
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
other: Hello,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
|
|
|
#[error(code = "E0123", slug = "foo")]
|
|
|
|
struct ArgFieldWithSkip {
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
// `Hello` does not implement `IntoDiagnosticArg` so this would result in an error if
|
|
|
|
// not for `#[skip_arg]`.
|
|
|
|
#[skip_arg]
|
|
|
|
other: Hello,
|
|
|
|
}
|
2022-03-31 06:10:00 -05:00
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
|
|
|
#[error(code = "E0123", slug = "foo")]
|
|
|
|
struct ErrorWithSpannedNote {
|
|
|
|
#[note]
|
|
|
|
span: Span,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
|
|
|
#[error(code = "E0123", slug = "foo")]
|
|
|
|
struct ErrorWithSpannedNoteCustom {
|
|
|
|
#[note = "bar"]
|
|
|
|
span: Span,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
|
|
|
#[error(code = "E0123", slug = "foo")]
|
|
|
|
#[note]
|
|
|
|
struct ErrorWithNote {
|
|
|
|
val: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
|
|
|
#[error(code = "E0123", slug = "foo")]
|
|
|
|
#[note = "bar"]
|
|
|
|
struct ErrorWithNoteCustom {
|
|
|
|
val: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
|
|
|
#[error(code = "E0123", slug = "foo")]
|
|
|
|
struct ErrorWithSpannedHelp {
|
|
|
|
#[help]
|
|
|
|
span: Span,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
|
|
|
#[error(code = "E0123", slug = "foo")]
|
|
|
|
struct ErrorWithSpannedHelpCustom {
|
|
|
|
#[help = "bar"]
|
|
|
|
span: Span,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
|
|
|
#[error(code = "E0123", slug = "foo")]
|
|
|
|
#[help]
|
|
|
|
struct ErrorWithHelp {
|
|
|
|
val: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
|
|
|
#[error(code = "E0123", slug = "foo")]
|
|
|
|
#[help = "bar"]
|
|
|
|
struct ErrorWithHelpCustom {
|
|
|
|
val: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
|
|
|
#[help]
|
|
|
|
//~^ ERROR `#[help]` must come after `#[error(..)]` or `#[warn(..)]`
|
|
|
|
#[error(code = "E0123", slug = "foo")]
|
|
|
|
struct ErrorWithHelpWrongOrder {
|
|
|
|
val: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
|
|
|
#[help = "bar"]
|
|
|
|
//~^ ERROR `#[help = ...]` must come after `#[error(..)]` or `#[warn(..)]`
|
|
|
|
#[error(code = "E0123", slug = "foo")]
|
|
|
|
struct ErrorWithHelpCustomWrongOrder {
|
|
|
|
val: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
|
|
|
#[note]
|
|
|
|
//~^ ERROR `#[note]` must come after `#[error(..)]` or `#[warn(..)]`
|
|
|
|
#[error(code = "E0123", slug = "foo")]
|
|
|
|
struct ErrorWithNoteWrongOrder {
|
|
|
|
val: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(SessionDiagnostic)]
|
|
|
|
#[note = "bar"]
|
|
|
|
//~^ ERROR `#[note = ...]` must come after `#[error(..)]` or `#[warn(..)]`
|
|
|
|
#[error(code = "E0123", slug = "foo")]
|
|
|
|
struct ErrorWithNoteCustomWrongOrder {
|
|
|
|
val: String,
|
|
|
|
}
|