From 218caa410aa38c29984be31a5229b9fa717560ee Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:13 +0200 Subject: Merging upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- .../session-diagnostic/diagnostic-derive.rs | 801 +++++++++++++++++++++ .../session-diagnostic/diagnostic-derive.stderr | 666 +++++++++++++++++ .../session-diagnostic/enforce_slug_naming.rs | 24 + .../session-diagnostic/enforce_slug_naming.stderr | 11 + .../session-diagnostic/subdiagnostic-derive.rs | 800 ++++++++++++++++++++ .../session-diagnostic/subdiagnostic-derive.stderr | 566 +++++++++++++++ 6 files changed, 2868 insertions(+) create mode 100644 tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs create mode 100644 tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr create mode 100644 tests/ui-fulldeps/session-diagnostic/enforce_slug_naming.rs create mode 100644 tests/ui-fulldeps/session-diagnostic/enforce_slug_naming.stderr create mode 100644 tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs create mode 100644 tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr (limited to 'tests/ui-fulldeps/session-diagnostic') diff --git a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs new file mode 100644 index 000000000..65d9601e7 --- /dev/null +++ b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs @@ -0,0 +1,801 @@ +// check-fail +// Tests error conditions for specifying diagnostics using #[derive(Diagnostic)] + +// normalize-stderr-test "the following other types implement trait `IntoDiagnosticArg`:(?:.*\n){0,9}\s+and \d+ others" -> "normalized in stderr" +// normalize-stderr-test "diagnostic_builder\.rs:[0-9]+:[0-9]+" -> "diagnostic_builder.rs:LL:CC" +// The proc_macro2 crate handles spans differently when on beta/stable release rather than nightly, +// changing the output of this test. Since Diagnostic is strictly internal to the compiler +// the test is just ignored on stable and beta: +// ignore-beta +// ignore-stable + +#![feature(rustc_private)] +#![crate_type = "lib"] + +extern crate rustc_span; +use rustc_span::symbol::Ident; +use rustc_span::Span; + +extern crate rustc_macros; +use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic}; + +extern crate rustc_middle; +use rustc_middle::ty::Ty; + +extern crate rustc_errors; +use rustc_errors::{Applicability, MultiSpan}; + +extern crate rustc_session; + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +struct Hello {} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +struct HelloWarn {} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +//~^ ERROR unsupported type attribute for diagnostic derive enum +enum DiagnosticOnEnum { + Foo, + //~^ ERROR diagnostic slug not specified + Bar, + //~^ ERROR diagnostic slug not specified +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +#[diag = "E0123"] +//~^ ERROR `#[diag = ...]` is not a valid attribute +struct WrongStructAttrStyle {} + +#[derive(Diagnostic)] +#[nonsense(compiletest_example, code = "E0123")] +//~^ ERROR `#[nonsense(...)]` is not a valid attribute +//~^^ ERROR diagnostic slug not specified +//~^^^ ERROR cannot find attribute `nonsense` in this scope +struct InvalidStructAttr {} + +#[derive(Diagnostic)] +#[diag("E0123")] +//~^ ERROR `#[diag("...")]` is not a valid attribute +//~^^ ERROR diagnostic slug not specified +struct InvalidLitNestedAttr {} + +#[derive(Diagnostic)] +#[diag(nonsense, code = "E0123")] +//~^ ERROR cannot find value `nonsense` in module `rustc_errors::fluent` +struct InvalidNestedStructAttr {} + +#[derive(Diagnostic)] +#[diag(nonsense("foo"), code = "E0123", slug = "foo")] +//~^ ERROR `#[diag(nonsense(...))]` is not a valid attribute +//~^^ ERROR diagnostic slug not specified +struct InvalidNestedStructAttr1 {} + +#[derive(Diagnostic)] +#[diag(nonsense = "...", code = "E0123", slug = "foo")] +//~^ ERROR `#[diag(nonsense = ...)]` is not a valid attribute +//~| ERROR `#[diag(slug = ...)]` is not a valid attribute +//~| ERROR diagnostic slug not specified +struct InvalidNestedStructAttr2 {} + +#[derive(Diagnostic)] +#[diag(nonsense = 4, code = "E0123", slug = "foo")] +//~^ ERROR `#[diag(nonsense = ...)]` is not a valid attribute +//~| ERROR `#[diag(slug = ...)]` is not a valid attribute +//~| ERROR diagnostic slug not specified +struct InvalidNestedStructAttr3 {} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123", slug = "foo")] +//~^ ERROR `#[diag(slug = ...)]` is not a valid attribute +struct InvalidNestedStructAttr4 {} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +struct WrongPlaceField { + #[suggestion = "bar"] + //~^ ERROR `#[suggestion = ...]` is not a valid attribute + sp: Span, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +#[diag(compiletest_example, code = "E0456")] +//~^ ERROR specified multiple times +//~^^ ERROR specified multiple times +struct DiagSpecifiedTwice {} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0456", code = "E0457")] +//~^ ERROR specified multiple times +struct CodeSpecifiedTwice {} + +#[derive(Diagnostic)] +#[diag(compiletest_example, compiletest_example, code = "E0456")] +//~^ ERROR `#[diag(compiletest_example)]` is not a valid attribute +struct SlugSpecifiedTwice {} + +#[derive(Diagnostic)] +struct KindNotProvided {} //~ ERROR diagnostic slug not specified + +#[derive(Diagnostic)] +#[diag(code = "E0456")] +//~^ ERROR diagnostic slug not specified +struct SlugNotProvided {} + +#[derive(Diagnostic)] +#[diag(compiletest_example)] +struct CodeNotProvided {} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +struct MessageWrongType { + #[primary_span] + //~^ ERROR `#[primary_span]` attribute can only be applied to fields of type `Span` or `MultiSpan` + foo: String, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +struct InvalidPathFieldAttr { + #[nonsense] + //~^ ERROR `#[nonsense]` is not a valid attribute + //~^^ ERROR cannot find attribute `nonsense` in this scope + foo: String, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +struct ErrorWithField { + name: String, + #[label(label)] + span: Span, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +struct ErrorWithMessageAppliedToField { + #[label(label)] + //~^ ERROR the `#[label(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan` + name: String, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +struct ErrorWithNonexistentField { + #[suggestion(suggestion, code = "{name}")] + //~^ ERROR `name` doesn't refer to a field on this type + suggestion: (Span, Applicability), +} + +#[derive(Diagnostic)] +//~^ ERROR invalid format string: expected `'}'` +#[diag(compiletest_example, code = "E0123")] +struct ErrorMissingClosingBrace { + #[suggestion(suggestion, code = "{name")] + suggestion: (Span, Applicability), + name: String, + val: usize, +} + +#[derive(Diagnostic)] +//~^ ERROR invalid format string: unmatched `}` +#[diag(compiletest_example, code = "E0123")] +struct ErrorMissingOpeningBrace { + #[suggestion(suggestion, code = "name}")] + suggestion: (Span, Applicability), + name: String, + val: usize, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +struct LabelOnSpan { + #[label(label)] + sp: Span, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +struct LabelOnNonSpan { + #[label(label)] + //~^ ERROR the `#[label(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan` + id: u32, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +struct Suggest { + #[suggestion(suggestion, code = "This is the suggested code")] + #[suggestion(suggestion, code = "This is the suggested code", style = "normal")] + #[suggestion(suggestion, code = "This is the suggested code", style = "short")] + #[suggestion(suggestion, code = "This is the suggested code", style = "hidden")] + #[suggestion(suggestion, code = "This is the suggested code", style = "verbose")] + suggestion: (Span, Applicability), +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +struct SuggestWithoutCode { + #[suggestion(suggestion)] + //~^ ERROR suggestion without `code = "..."` + suggestion: (Span, Applicability), +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +struct SuggestWithBadKey { + #[suggestion(nonsense = "bar")] + //~^ ERROR `#[suggestion(nonsense = ...)]` is not a valid attribute + //~| ERROR suggestion without `code = "..."` + suggestion: (Span, Applicability), +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +struct SuggestWithShorthandMsg { + #[suggestion(msg = "bar")] + //~^ ERROR `#[suggestion(msg = ...)]` is not a valid attribute + //~| ERROR suggestion without `code = "..."` + suggestion: (Span, Applicability), +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +struct SuggestWithoutMsg { + #[suggestion(code = "bar")] + suggestion: (Span, Applicability), +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +struct SuggestWithTypesSwapped { + #[suggestion(suggestion, code = "This is suggested code")] + suggestion: (Applicability, Span), +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +struct SuggestWithWrongTypeApplicabilityOnly { + #[suggestion(suggestion, code = "This is suggested code")] + //~^ ERROR wrong field type for suggestion + suggestion: Applicability, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +struct SuggestWithSpanOnly { + #[suggestion(suggestion, code = "This is suggested code")] + suggestion: Span, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +struct SuggestWithDuplicateSpanAndApplicability { + #[suggestion(suggestion, code = "This is suggested code")] + suggestion: (Span, Span, Applicability), + //~^ ERROR specified multiple times +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +struct SuggestWithDuplicateApplicabilityAndSpan { + #[suggestion(suggestion, code = "This is suggested code")] + suggestion: (Applicability, Applicability, Span), + //~^ ERROR specified multiple times +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +struct WrongKindOfAnnotation { + #[label = "bar"] + //~^ ERROR `#[label = ...]` is not a valid attribute + z: Span, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +struct OptionsInErrors { + #[label(label)] + label: Option, + #[suggestion(suggestion, code = "...")] + opt_sugg: Option<(Span, Applicability)>, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0456")] +struct MoveOutOfBorrowError<'tcx> { + name: Ident, + ty: Ty<'tcx>, + #[primary_span] + #[label(label)] + span: Span, + #[label(label)] + other_span: Span, + #[suggestion(suggestion, code = "{name}.clone()")] + opt_sugg: Option<(Span, Applicability)>, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +struct ErrorWithLifetime<'a> { + #[label(label)] + span: Span, + name: &'a str, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +struct ErrorWithDefaultLabelAttr<'a> { + #[label] + span: Span, + name: &'a str, +} + +#[derive(Diagnostic)] +//~^ ERROR the trait bound `Hello: IntoDiagnosticArg` is not satisfied +#[diag(compiletest_example, code = "E0123")] +struct ArgFieldWithoutSkip { + #[primary_span] + span: Span, + other: Hello, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +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, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +struct ErrorWithSpannedNote { + #[note] + span: Span, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +struct ErrorWithSpannedNoteCustom { + #[note(note)] + span: Span, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +#[note] +struct ErrorWithNote { + val: String, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +#[note(note)] +struct ErrorWithNoteCustom { + val: String, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +struct ErrorWithSpannedHelp { + #[help] + span: Span, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +struct ErrorWithSpannedHelpCustom { + #[help(help)] + span: Span, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +#[help] +struct ErrorWithHelp { + val: String, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +#[help(help)] +struct ErrorWithHelpCustom { + val: String, +} + +#[derive(Diagnostic)] +#[help] +#[diag(compiletest_example, code = "E0123")] +struct ErrorWithHelpWrongOrder { + val: String, +} + +#[derive(Diagnostic)] +#[help(help)] +#[diag(compiletest_example, code = "E0123")] +struct ErrorWithHelpCustomWrongOrder { + val: String, +} + +#[derive(Diagnostic)] +#[note] +#[diag(compiletest_example, code = "E0123")] +struct ErrorWithNoteWrongOrder { + val: String, +} + +#[derive(Diagnostic)] +#[note(note)] +#[diag(compiletest_example, code = "E0123")] +struct ErrorWithNoteCustomWrongOrder { + val: String, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +struct ApplicabilityInBoth { + #[suggestion(suggestion, code = "...", applicability = "maybe-incorrect")] + //~^ ERROR specified multiple times + suggestion: (Span, Applicability), +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +struct InvalidApplicability { + #[suggestion(suggestion, code = "...", applicability = "batman")] + //~^ ERROR invalid applicability + suggestion: Span, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +struct ValidApplicability { + #[suggestion(suggestion, code = "...", applicability = "maybe-incorrect")] + suggestion: Span, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +struct NoApplicability { + #[suggestion(suggestion, code = "...")] + suggestion: Span, +} + +#[derive(Subdiagnostic)] +#[note(parse_add_paren)] +struct Note; + +#[derive(Diagnostic)] +#[diag(compiletest_example)] +struct Subdiagnostic { + #[subdiagnostic] + note: Note, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +struct VecField { + #[primary_span] + #[label] + spans: Vec, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +struct UnitField { + #[primary_span] + spans: Span, + #[help] + foo: (), + #[help(help)] + bar: (), +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +struct OptUnitField { + #[primary_span] + spans: Span, + #[help] + foo: Option<()>, + #[help(help)] + bar: Option<()>, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +struct LabelWithTrailingPath { + #[label(label, foo)] + //~^ ERROR `#[label(foo)]` is not a valid attribute + span: Span, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +struct LabelWithTrailingNameValue { + #[label(label, foo = "...")] + //~^ ERROR `#[label(foo = ...)]` is not a valid attribute + span: Span, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +struct LabelWithTrailingList { + #[label(label, foo("..."))] + //~^ ERROR `#[label(foo(...))]` is not a valid attribute + span: Span, +} + +#[derive(LintDiagnostic)] +#[diag(compiletest_example)] +struct LintsGood {} + +#[derive(LintDiagnostic)] +#[diag(compiletest_example)] +struct PrimarySpanOnLint { + #[primary_span] + //~^ ERROR `#[primary_span]` is not a valid attribute + span: Span, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +struct ErrorWithMultiSpan { + #[primary_span] + span: MultiSpan, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +#[warning] +struct ErrorWithWarn { + val: String, +} + +#[derive(Diagnostic)] +#[error(compiletest_example, code = "E0123")] +//~^ ERROR `#[error(...)]` is not a valid attribute +//~| ERROR diagnostic slug not specified +//~| ERROR cannot find attribute `error` in this scope +struct ErrorAttribute {} + +#[derive(Diagnostic)] +#[warn_(compiletest_example, code = "E0123")] +//~^ ERROR `#[warn_(...)]` is not a valid attribute +//~| ERROR diagnostic slug not specified +//~| ERROR cannot find attribute `warn_` in this scope +struct WarnAttribute {} + +#[derive(Diagnostic)] +#[lint(compiletest_example, code = "E0123")] +//~^ ERROR `#[lint(...)]` is not a valid attribute +//~| ERROR diagnostic slug not specified +//~| ERROR cannot find attribute `lint` in this scope +struct LintAttributeOnSessionDiag {} + +#[derive(LintDiagnostic)] +#[lint(compiletest_example, code = "E0123")] +//~^ ERROR `#[lint(...)]` is not a valid attribute +//~| ERROR `#[lint(...)]` is not a valid attribute +//~| ERROR diagnostic slug not specified +//~| ERROR cannot find attribute `lint` in this scope +struct LintAttributeOnLintDiag {} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +struct DuplicatedSuggestionCode { + #[suggestion(suggestion, code = "...", code = ",,,")] + //~^ ERROR specified multiple times + suggestion: Span, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +struct InvalidTypeInSuggestionTuple { + #[suggestion(suggestion, code = "...")] + suggestion: (Span, usize), + //~^ ERROR wrong types for suggestion +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +struct MissingApplicabilityInSuggestionTuple { + #[suggestion(suggestion, code = "...")] + suggestion: (Span,), + //~^ ERROR wrong types for suggestion +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +struct MissingCodeInSuggestion { + #[suggestion(suggestion)] + //~^ ERROR suggestion without `code = "..."` + suggestion: Span, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +#[multipart_suggestion(suggestion)] +//~^ ERROR `#[multipart_suggestion(...)]` is not a valid attribute +//~| ERROR cannot find attribute `multipart_suggestion` in this scope +#[multipart_suggestion()] +//~^ ERROR `#[multipart_suggestion(...)]` is not a valid attribute +//~| ERROR cannot find attribute `multipart_suggestion` in this scope +struct MultipartSuggestion { + #[multipart_suggestion(suggestion)] + //~^ ERROR `#[multipart_suggestion(...)]` is not a valid attribute + //~| ERROR cannot find attribute `multipart_suggestion` in this scope + suggestion: Span, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +#[suggestion(suggestion, code = "...")] +//~^ ERROR `#[suggestion(...)]` is not a valid attribute +struct SuggestionOnStruct { + #[primary_span] + suggestion: Span, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +#[label] +//~^ ERROR `#[label]` is not a valid attribute +struct LabelOnStruct { + #[primary_span] + suggestion: Span, +} + +#[derive(Diagnostic)] +enum ExampleEnum { + #[diag(compiletest_example)] + Foo { + #[primary_span] + sp: Span, + #[note] + note_sp: Span, + }, + #[diag(compiletest_example)] + Bar { + #[primary_span] + sp: Span, + }, + #[diag(compiletest_example)] + Baz, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +struct RawIdentDiagnosticArg { + pub r#type: String, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example)] +struct SubdiagnosticBad { + #[subdiagnostic(bad)] + //~^ ERROR `#[subdiagnostic(...)]` is not a valid attribute + note: Note, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example)] +struct SubdiagnosticBadStr { + #[subdiagnostic = "bad"] + //~^ ERROR `#[subdiagnostic = ...]` is not a valid attribute + note: Note, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example)] +struct SubdiagnosticBadTwice { + #[subdiagnostic(bad, bad)] + //~^ ERROR `#[subdiagnostic(...)]` is not a valid attribute + note: Note, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example)] +struct SubdiagnosticBadLitStr { + #[subdiagnostic("bad")] + //~^ ERROR `#[subdiagnostic(...)]` is not a valid attribute + note: Note, +} + +#[derive(LintDiagnostic)] +#[diag(compiletest_example)] +struct SubdiagnosticEagerLint { + #[subdiagnostic(eager)] + //~^ ERROR `#[subdiagnostic(...)]` is not a valid attribute + note: Note, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example)] +struct SubdiagnosticEagerCorrect { + #[subdiagnostic(eager)] + note: Note, +} + +// Check that formatting of `correct` in suggestion doesn't move the binding for that field, making +// the `set_arg` call a compile error; and that isn't worked around by moving the `set_arg` call +// after the `span_suggestion` call - which breaks eager translation. + +#[derive(Subdiagnostic)] +#[suggestion(use_instead, applicability = "machine-applicable", code = "{correct}")] +pub(crate) struct SubdiagnosticWithSuggestion { + #[primary_span] + span: Span, + invalid: String, + correct: String, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example)] +struct SubdiagnosticEagerSuggestion { + #[subdiagnostic(eager)] + sub: SubdiagnosticWithSuggestion, +} + +/// with a doc comment on the type.. +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +struct WithDocComment { + /// ..and the field + #[primary_span] + span: Span, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example)] +struct SuggestionsGood { + #[suggestion(code("foo", "bar"))] + sub: Span, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example)] +struct SuggestionsSingleItem { + #[suggestion(code("foo"))] + sub: Span, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example)] +struct SuggestionsNoItem { + #[suggestion(code())] + //~^ ERROR expected at least one string literal for `code(...)` + sub: Span, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example)] +struct SuggestionsInvalidItem { + #[suggestion(code(foo))] + //~^ ERROR `code(...)` must contain only string literals + sub: Span, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example)] +struct SuggestionsInvalidLiteral { + #[suggestion(code = 3)] + //~^ ERROR `code = "..."`/`code(...)` must contain only string literals + sub: Span, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example)] +struct SuggestionStyleGood { + #[suggestion(code = "", style = "hidden")] + sub: Span, +} diff --git a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr new file mode 100644 index 000000000..13e806a43 --- /dev/null +++ b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr @@ -0,0 +1,666 @@ +error: unsupported type attribute for diagnostic derive enum + --> $DIR/diagnostic-derive.rs:39:1 + | +LL | #[diag(compiletest_example, code = "E0123")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: diagnostic slug not specified + --> $DIR/diagnostic-derive.rs:42:5 + | +LL | Foo, + | ^^^ + | + = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` + +error: diagnostic slug not specified + --> $DIR/diagnostic-derive.rs:44:5 + | +LL | Bar, + | ^^^ + | + = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` + +error: `#[diag = ...]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:50:1 + | +LL | #[diag = "E0123"] + | ^^^^^^^^^^^^^^^^^ + +error: `#[nonsense(...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:55:1 + | +LL | #[nonsense(compiletest_example, code = "E0123")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: diagnostic slug not specified + --> $DIR/diagnostic-derive.rs:55:1 + | +LL | / #[nonsense(compiletest_example, code = "E0123")] +LL | | +LL | | +LL | | +LL | | struct InvalidStructAttr {} + | |___________________________^ + | + = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` + +error: `#[diag("...")]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:62:8 + | +LL | #[diag("E0123")] + | ^^^^^^^ + | + = help: a diagnostic slug is required as the first argument + +error: diagnostic slug not specified + --> $DIR/diagnostic-derive.rs:62:1 + | +LL | / #[diag("E0123")] +LL | | +LL | | +LL | | struct InvalidLitNestedAttr {} + | |______________________________^ + | + = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` + +error: `#[diag(nonsense(...))]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:73:8 + | +LL | #[diag(nonsense("foo"), code = "E0123", slug = "foo")] + | ^^^^^^^^^^^^^^^ + | + = help: a diagnostic slug is required as the first argument + +error: diagnostic slug not specified + --> $DIR/diagnostic-derive.rs:73:1 + | +LL | / #[diag(nonsense("foo"), code = "E0123", slug = "foo")] +LL | | +LL | | +LL | | struct InvalidNestedStructAttr1 {} + | |__________________________________^ + | + = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` + +error: `#[diag(nonsense = ...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:79:8 + | +LL | #[diag(nonsense = "...", code = "E0123", slug = "foo")] + | ^^^^^^^^^^^^^^^^ + | + = help: only `code` is a valid nested attributes following the slug + +error: `#[diag(slug = ...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:79:42 + | +LL | #[diag(nonsense = "...", code = "E0123", slug = "foo")] + | ^^^^^^^^^^^^ + | + = help: only `code` is a valid nested attributes following the slug + +error: diagnostic slug not specified + --> $DIR/diagnostic-derive.rs:79:1 + | +LL | / #[diag(nonsense = "...", code = "E0123", slug = "foo")] +LL | | +LL | | +LL | | +LL | | struct InvalidNestedStructAttr2 {} + | |__________________________________^ + | + = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` + +error: `#[diag(nonsense = ...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:86:8 + | +LL | #[diag(nonsense = 4, code = "E0123", slug = "foo")] + | ^^^^^^^^^^^^ + +error: `#[diag(slug = ...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:86:38 + | +LL | #[diag(nonsense = 4, code = "E0123", slug = "foo")] + | ^^^^^^^^^^^^ + | + = help: only `code` is a valid nested attributes following the slug + +error: diagnostic slug not specified + --> $DIR/diagnostic-derive.rs:86:1 + | +LL | / #[diag(nonsense = 4, code = "E0123", slug = "foo")] +LL | | +LL | | +LL | | +LL | | struct InvalidNestedStructAttr3 {} + | |__________________________________^ + | + = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` + +error: `#[diag(slug = ...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:93:45 + | +LL | #[diag(compiletest_example, code = "E0123", slug = "foo")] + | ^^^^^^^^^^^^ + | + = help: only `code` is a valid nested attributes following the slug + +error: `#[suggestion = ...]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:100:5 + | +LL | #[suggestion = "bar"] + | ^^^^^^^^^^^^^^^^^^^^^ + +error: specified multiple times + --> $DIR/diagnostic-derive.rs:107:8 + | +LL | #[diag(compiletest_example, code = "E0456")] + | ^^^^^^^^^^^^^^^^^^^ + | +note: previously specified here + --> $DIR/diagnostic-derive.rs:106:8 + | +LL | #[diag(compiletest_example, code = "E0123")] + | ^^^^^^^^^^^^^^^^^^^ + +error: specified multiple times + --> $DIR/diagnostic-derive.rs:107:36 + | +LL | #[diag(compiletest_example, code = "E0456")] + | ^^^^^^^ + | +note: previously specified here + --> $DIR/diagnostic-derive.rs:106:36 + | +LL | #[diag(compiletest_example, code = "E0123")] + | ^^^^^^^ + +error: specified multiple times + --> $DIR/diagnostic-derive.rs:113:52 + | +LL | #[diag(compiletest_example, code = "E0456", code = "E0457")] + | ^^^^^^^ + | +note: previously specified here + --> $DIR/diagnostic-derive.rs:113:36 + | +LL | #[diag(compiletest_example, code = "E0456", code = "E0457")] + | ^^^^^^^ + +error: `#[diag(compiletest_example)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:118:29 + | +LL | #[diag(compiletest_example, compiletest_example, code = "E0456")] + | ^^^^^^^^^^^^^^^^^^^ + | + = help: diagnostic slug must be the first argument + +error: diagnostic slug not specified + --> $DIR/diagnostic-derive.rs:123:1 + | +LL | struct KindNotProvided {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` + +error: diagnostic slug not specified + --> $DIR/diagnostic-derive.rs:126:1 + | +LL | / #[diag(code = "E0456")] +LL | | +LL | | struct SlugNotProvided {} + | |_________________________^ + | + = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` + +error: the `#[primary_span]` attribute can only be applied to fields of type `Span` or `MultiSpan` + --> $DIR/diagnostic-derive.rs:137:5 + | +LL | #[primary_span] + | ^^^^^^^^^^^^^^^ + +error: `#[nonsense]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:145:5 + | +LL | #[nonsense] + | ^^^^^^^^^^^ + +error: the `#[label(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan` + --> $DIR/diagnostic-derive.rs:162:5 + | +LL | #[label(label)] + | ^^^^^^^^^^^^^^^ + +error: `name` doesn't refer to a field on this type + --> $DIR/diagnostic-derive.rs:170:37 + | +LL | #[suggestion(suggestion, code = "{name}")] + | ^^^^^^^^ + +error: invalid format string: expected `'}'` but string was terminated + --> $DIR/diagnostic-derive.rs:175:10 + | +LL | #[derive(Diagnostic)] + | ^^^^^^^^^^ expected `'}'` in format string + | + = note: if you intended to print `{`, you can escape it using `{{` + = note: this error originates in the derive macro `Diagnostic` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: invalid format string: unmatched `}` found + --> $DIR/diagnostic-derive.rs:185:10 + | +LL | #[derive(Diagnostic)] + | ^^^^^^^^^^ unmatched `}` in format string + | + = note: if you intended to print `}`, you can escape it using `}}` + = note: this error originates in the derive macro `Diagnostic` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: the `#[label(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan` + --> $DIR/diagnostic-derive.rs:205:5 + | +LL | #[label(label)] + | ^^^^^^^^^^^^^^^ + +error: suggestion without `code = "..."` + --> $DIR/diagnostic-derive.rs:224:5 + | +LL | #[suggestion(suggestion)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `#[suggestion(nonsense = ...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:232:18 + | +LL | #[suggestion(nonsense = "bar")] + | ^^^^^^^^^^^^^^^^ + | + = help: only `style`, `code` and `applicability` are valid nested attributes + +error: suggestion without `code = "..."` + --> $DIR/diagnostic-derive.rs:232:5 + | +LL | #[suggestion(nonsense = "bar")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `#[suggestion(msg = ...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:241:18 + | +LL | #[suggestion(msg = "bar")] + | ^^^^^^^^^^^ + | + = help: only `style`, `code` and `applicability` are valid nested attributes + +error: suggestion without `code = "..."` + --> $DIR/diagnostic-derive.rs:241:5 + | +LL | #[suggestion(msg = "bar")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: wrong field type for suggestion + --> $DIR/diagnostic-derive.rs:264:5 + | +LL | / #[suggestion(suggestion, code = "This is suggested code")] +LL | | +LL | | suggestion: Applicability, + | |_____________________________^ + | + = help: `#[suggestion(...)]` should be applied to fields of type `Span` or `(Span, Applicability)` + +error: specified multiple times + --> $DIR/diagnostic-derive.rs:280:24 + | +LL | suggestion: (Span, Span, Applicability), + | ^^^^ + | +note: previously specified here + --> $DIR/diagnostic-derive.rs:280:18 + | +LL | suggestion: (Span, Span, Applicability), + | ^^^^ + +error: specified multiple times + --> $DIR/diagnostic-derive.rs:288:33 + | +LL | suggestion: (Applicability, Applicability, Span), + | ^^^^^^^^^^^^^ + | +note: previously specified here + --> $DIR/diagnostic-derive.rs:288:18 + | +LL | suggestion: (Applicability, Applicability, Span), + | ^^^^^^^^^^^^^ + +error: `#[label = ...]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:295:5 + | +LL | #[label = "bar"] + | ^^^^^^^^^^^^^^^^ + +error: specified multiple times + --> $DIR/diagnostic-derive.rs:446:44 + | +LL | #[suggestion(suggestion, code = "...", applicability = "maybe-incorrect")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: previously specified here + --> $DIR/diagnostic-derive.rs:448:24 + | +LL | suggestion: (Span, Applicability), + | ^^^^^^^^^^^^^ + +error: invalid applicability + --> $DIR/diagnostic-derive.rs:454:44 + | +LL | #[suggestion(suggestion, code = "...", applicability = "batman")] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `#[label(foo)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:517:20 + | +LL | #[label(label, foo)] + | ^^^ + | + = help: a diagnostic slug must be the first argument to the attribute + +error: `#[label(foo = ...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:525:20 + | +LL | #[label(label, foo = "...")] + | ^^^^^^^^^^^ + +error: `#[label(foo(...))]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:533:20 + | +LL | #[label(label, foo("..."))] + | ^^^^^^^^^^ + +error: `#[primary_span]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:545:5 + | +LL | #[primary_span] + | ^^^^^^^^^^^^^^^ + | + = help: the `primary_span` field attribute is not valid for lint diagnostics + +error: `#[error(...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:565:1 + | +LL | #[error(compiletest_example, code = "E0123")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: diagnostic slug not specified + --> $DIR/diagnostic-derive.rs:565:1 + | +LL | / #[error(compiletest_example, code = "E0123")] +LL | | +LL | | +LL | | +LL | | struct ErrorAttribute {} + | |________________________^ + | + = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` + +error: `#[warn_(...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:572:1 + | +LL | #[warn_(compiletest_example, code = "E0123")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: diagnostic slug not specified + --> $DIR/diagnostic-derive.rs:572:1 + | +LL | / #[warn_(compiletest_example, code = "E0123")] +LL | | +LL | | +LL | | +LL | | struct WarnAttribute {} + | |_______________________^ + | + = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` + +error: `#[lint(...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:579:1 + | +LL | #[lint(compiletest_example, code = "E0123")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: diagnostic slug not specified + --> $DIR/diagnostic-derive.rs:579:1 + | +LL | / #[lint(compiletest_example, code = "E0123")] +LL | | +LL | | +LL | | +LL | | struct LintAttributeOnSessionDiag {} + | |____________________________________^ + | + = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` + +error: `#[lint(...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:586:1 + | +LL | #[lint(compiletest_example, code = "E0123")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `#[lint(...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:586:1 + | +LL | #[lint(compiletest_example, code = "E0123")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: diagnostic slug not specified + --> $DIR/diagnostic-derive.rs:586:1 + | +LL | / #[lint(compiletest_example, code = "E0123")] +LL | | +LL | | +LL | | +LL | | +LL | | struct LintAttributeOnLintDiag {} + | |_________________________________^ + | + = help: specify the slug as the first argument to the attribute, such as `#[diag(compiletest_example)]` + +error: specified multiple times + --> $DIR/diagnostic-derive.rs:596:44 + | +LL | #[suggestion(suggestion, code = "...", code = ",,,")] + | ^^^^^^^^^^^^ + | +note: previously specified here + --> $DIR/diagnostic-derive.rs:596:30 + | +LL | #[suggestion(suggestion, code = "...", code = ",,,")] + | ^^^^^^^^^^^^ + +error: wrong types for suggestion + --> $DIR/diagnostic-derive.rs:605:24 + | +LL | suggestion: (Span, usize), + | ^^^^^ + | + = help: `#[suggestion(...)]` on a tuple field must be applied to fields of type `(Span, Applicability)` + +error: wrong types for suggestion + --> $DIR/diagnostic-derive.rs:613:17 + | +LL | suggestion: (Span,), + | ^^^^^^^ + | + = help: `#[suggestion(...)]` on a tuple field must be applied to fields of type `(Span, Applicability)` + +error: suggestion without `code = "..."` + --> $DIR/diagnostic-derive.rs:620:5 + | +LL | #[suggestion(suggestion)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `#[multipart_suggestion(...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:627:1 + | +LL | #[multipart_suggestion(suggestion)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: consider creating a `Subdiagnostic` instead + +error: `#[multipart_suggestion(...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:630:1 + | +LL | #[multipart_suggestion()] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: consider creating a `Subdiagnostic` instead + +error: `#[multipart_suggestion(...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:634:5 + | +LL | #[multipart_suggestion(suggestion)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: consider creating a `Subdiagnostic` instead + +error: `#[suggestion(...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:642:1 + | +LL | #[suggestion(suggestion, code = "...")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: `#[label]` and `#[suggestion]` can only be applied to fields + +error: `#[label]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:651:1 + | +LL | #[label] + | ^^^^^^^^ + | + = help: `#[label]` and `#[suggestion]` can only be applied to fields + +error: `#[subdiagnostic(...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:685:5 + | +LL | #[subdiagnostic(bad)] + | ^^^^^^^^^^^^^^^^^^^^^ + | + = help: `eager` is the only supported nested attribute for `subdiagnostic` + +error: `#[subdiagnostic = ...]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:693:5 + | +LL | #[subdiagnostic = "bad"] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `#[subdiagnostic(...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:701:5 + | +LL | #[subdiagnostic(bad, bad)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: `eager` is the only supported nested attribute for `subdiagnostic` + +error: `#[subdiagnostic(...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:709:5 + | +LL | #[subdiagnostic("bad")] + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: `eager` is the only supported nested attribute for `subdiagnostic` + +error: `#[subdiagnostic(...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:717:5 + | +LL | #[subdiagnostic(eager)] + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: eager subdiagnostics are not supported on lints + +error: expected at least one string literal for `code(...)` + --> $DIR/diagnostic-derive.rs:775:18 + | +LL | #[suggestion(code())] + | ^^^^^^ + +error: `code(...)` must contain only string literals + --> $DIR/diagnostic-derive.rs:783:23 + | +LL | #[suggestion(code(foo))] + | ^^^ + +error: `code = "..."`/`code(...)` must contain only string literals + --> $DIR/diagnostic-derive.rs:791:18 + | +LL | #[suggestion(code = 3)] + | ^^^^^^^^ + +error: cannot find attribute `nonsense` in this scope + --> $DIR/diagnostic-derive.rs:55:3 + | +LL | #[nonsense(compiletest_example, code = "E0123")] + | ^^^^^^^^ + +error: cannot find attribute `nonsense` in this scope + --> $DIR/diagnostic-derive.rs:145:7 + | +LL | #[nonsense] + | ^^^^^^^^ + +error: cannot find attribute `error` in this scope + --> $DIR/diagnostic-derive.rs:565:3 + | +LL | #[error(compiletest_example, code = "E0123")] + | ^^^^^ + +error: cannot find attribute `warn_` in this scope + --> $DIR/diagnostic-derive.rs:572:3 + | +LL | #[warn_(compiletest_example, code = "E0123")] + | ^^^^^ help: a built-in attribute with a similar name exists: `warn` + +error: cannot find attribute `lint` in this scope + --> $DIR/diagnostic-derive.rs:579:3 + | +LL | #[lint(compiletest_example, code = "E0123")] + | ^^^^ help: a built-in attribute with a similar name exists: `link` + +error: cannot find attribute `lint` in this scope + --> $DIR/diagnostic-derive.rs:586:3 + | +LL | #[lint(compiletest_example, code = "E0123")] + | ^^^^ help: a built-in attribute with a similar name exists: `link` + +error: cannot find attribute `multipart_suggestion` in this scope + --> $DIR/diagnostic-derive.rs:627:3 + | +LL | #[multipart_suggestion(suggestion)] + | ^^^^^^^^^^^^^^^^^^^^ + +error: cannot find attribute `multipart_suggestion` in this scope + --> $DIR/diagnostic-derive.rs:630:3 + | +LL | #[multipart_suggestion()] + | ^^^^^^^^^^^^^^^^^^^^ + +error: cannot find attribute `multipart_suggestion` in this scope + --> $DIR/diagnostic-derive.rs:634:7 + | +LL | #[multipart_suggestion(suggestion)] + | ^^^^^^^^^^^^^^^^^^^^ + +error[E0425]: cannot find value `nonsense` in module `rustc_errors::fluent` + --> $DIR/diagnostic-derive.rs:68:8 + | +LL | #[diag(nonsense, code = "E0123")] + | ^^^^^^^^ not found in `rustc_errors::fluent` + +error[E0277]: the trait bound `Hello: IntoDiagnosticArg` is not satisfied + --> $DIR/diagnostic-derive.rs:339:10 + | +LL | #[derive(Diagnostic)] + | ^^^^^^^^^^ the trait `IntoDiagnosticArg` is not implemented for `Hello` + | + = help: normalized in stderr +note: required by a bound in `DiagnosticBuilder::<'a, G>::set_arg` + --> $COMPILER_DIR/rustc_errors/src/diagnostic_builder.rs:LL:CC + = note: this error originates in the derive macro `Diagnostic` which comes from the expansion of the macro `forward` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 83 previous errors + +Some errors have detailed explanations: E0277, E0425. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui-fulldeps/session-diagnostic/enforce_slug_naming.rs b/tests/ui-fulldeps/session-diagnostic/enforce_slug_naming.rs new file mode 100644 index 000000000..a0a8114e0 --- /dev/null +++ b/tests/ui-fulldeps/session-diagnostic/enforce_slug_naming.rs @@ -0,0 +1,24 @@ +// rustc-env:CARGO_CRATE_NAME=rustc_dummy + +#![feature(rustc_private)] +#![crate_type = "lib"] + +extern crate rustc_span; +use rustc_span::symbol::Ident; +use rustc_span::Span; + +extern crate rustc_macros; +use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic}; + +extern crate rustc_middle; +use rustc_middle::ty::Ty; + +extern crate rustc_errors; +use rustc_errors::{Applicability, MultiSpan}; + +extern crate rustc_session; + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +//~^ ERROR diagnostic slug and crate name do not match +struct Hello {} diff --git a/tests/ui-fulldeps/session-diagnostic/enforce_slug_naming.stderr b/tests/ui-fulldeps/session-diagnostic/enforce_slug_naming.stderr new file mode 100644 index 000000000..dcf4af5df --- /dev/null +++ b/tests/ui-fulldeps/session-diagnostic/enforce_slug_naming.stderr @@ -0,0 +1,11 @@ +error: diagnostic slug and crate name do not match + --> $DIR/enforce_slug_naming.rs:22:8 + | +LL | #[diag(compiletest_example, code = "E0123")] + | ^^^^^^^^^^^^^^^^^^^ + | + = note: slug is `compiletest_example` but the crate name is `rustc_dummy` + = help: expected a slug starting with `dummy_...` + +error: aborting due to previous error + diff --git a/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs b/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs new file mode 100644 index 000000000..61ac456a6 --- /dev/null +++ b/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs @@ -0,0 +1,800 @@ +// check-fail +// Tests error conditions for specifying subdiagnostics using #[derive(Subdiagnostic)] + +// The proc_macro2 crate handles spans differently when on beta/stable release rather than nightly, +// changing the output of this test. Since Subdiagnostic is strictly internal to the compiler +// the test is just ignored on stable and beta: +// ignore-beta +// ignore-stable + +#![feature(rustc_private)] +#![crate_type = "lib"] + +extern crate rustc_errors; +extern crate rustc_macros; +extern crate rustc_session; +extern crate rustc_span; + +use rustc_errors::Applicability; +use rustc_macros::Subdiagnostic; +use rustc_span::Span; + +#[derive(Subdiagnostic)] +#[label(parse_add_paren)] +struct A { + #[primary_span] + span: Span, + var: String, +} + +#[derive(Subdiagnostic)] +enum B { + #[label(parse_add_paren)] + A { + #[primary_span] + span: Span, + var: String, + }, + #[label(parse_add_paren)] + B { + #[primary_span] + span: Span, + var: String, + }, +} + +#[derive(Subdiagnostic)] +#[label(parse_add_paren)] +//~^ ERROR label without `#[primary_span]` field +struct C { + var: String, +} + +#[derive(Subdiagnostic)] +#[label] +//~^ ERROR diagnostic slug must be first argument +struct D { + #[primary_span] + span: Span, + var: String, +} + +#[derive(Subdiagnostic)] +#[foo] +//~^ ERROR `#[foo]` is not a valid attribute +//~^^ ERROR cannot find attribute `foo` in this scope +struct E { + #[primary_span] + span: Span, + var: String, +} + +#[derive(Subdiagnostic)] +#[label = "..."] +//~^ ERROR `#[label = ...]` is not a valid attribute +struct F { + #[primary_span] + span: Span, + var: String, +} + +#[derive(Subdiagnostic)] +#[label(bug = "...")] +//~^ ERROR `#[label(bug = ...)]` is not a valid attribute +//~| ERROR diagnostic slug must be first argument +struct G { + #[primary_span] + span: Span, + var: String, +} + +#[derive(Subdiagnostic)] +#[label("...")] +//~^ ERROR `#[label("...")]` is not a valid attribute +//~| ERROR diagnostic slug must be first argument +struct H { + #[primary_span] + span: Span, + var: String, +} + +#[derive(Subdiagnostic)] +#[label(slug = 4)] +//~^ ERROR `#[label(slug = ...)]` is not a valid attribute +//~| ERROR diagnostic slug must be first argument +struct J { + #[primary_span] + span: Span, + var: String, +} + +#[derive(Subdiagnostic)] +#[label(slug("..."))] +//~^ ERROR `#[label(slug(...))]` is not a valid attribute +//~| ERROR diagnostic slug must be first argument +struct K { + #[primary_span] + span: Span, + var: String, +} + +#[derive(Subdiagnostic)] +#[label(slug)] +//~^ ERROR cannot find value `slug` in module `rustc_errors::fluent` +//~^^ NOTE not found in `rustc_errors::fluent` +struct L { + #[primary_span] + span: Span, + var: String, +} + +#[derive(Subdiagnostic)] +#[label()] +//~^ ERROR diagnostic slug must be first argument of a `#[label(...)]` attribute +struct M { + #[primary_span] + span: Span, + var: String, +} + +#[derive(Subdiagnostic)] +#[label(parse_add_paren, code = "...")] +//~^ ERROR `#[label(code = ...)]` is not a valid attribute +struct N { + #[primary_span] + span: Span, + var: String, +} + +#[derive(Subdiagnostic)] +#[label(parse_add_paren, applicability = "machine-applicable")] +//~^ ERROR `#[label(applicability = ...)]` is not a valid attribute +struct O { + #[primary_span] + span: Span, + var: String, +} + +#[derive(Subdiagnostic)] +#[foo] +//~^ ERROR cannot find attribute `foo` in this scope +//~^^ ERROR unsupported type attribute for subdiagnostic enum +enum P { + #[label(parse_add_paren)] + A { + #[primary_span] + span: Span, + var: String, + }, +} + +#[derive(Subdiagnostic)] +enum Q { + #[bar] + //~^ ERROR `#[bar]` is not a valid attribute + //~^^ ERROR cannot find attribute `bar` in this scope + A { + #[primary_span] + span: Span, + var: String, + }, +} + +#[derive(Subdiagnostic)] +enum R { + #[bar = "..."] + //~^ ERROR `#[bar = ...]` is not a valid attribute + //~^^ ERROR cannot find attribute `bar` in this scope + A { + #[primary_span] + span: Span, + var: String, + }, +} + +#[derive(Subdiagnostic)] +enum S { + #[bar = 4] + //~^ ERROR `#[bar = ...]` is not a valid attribute + //~^^ ERROR cannot find attribute `bar` in this scope + A { + #[primary_span] + span: Span, + var: String, + }, +} + +#[derive(Subdiagnostic)] +enum T { + #[bar("...")] + //~^ ERROR `#[bar(...)]` is not a valid attribute + //~^^ ERROR cannot find attribute `bar` in this scope + A { + #[primary_span] + span: Span, + var: String, + }, +} + +#[derive(Subdiagnostic)] +enum U { + #[label(code = "...")] + //~^ ERROR diagnostic slug must be first argument of a `#[label(...)]` attribute + //~| ERROR `#[label(code = ...)]` is not a valid attribute + A { + #[primary_span] + span: Span, + var: String, + }, +} + +#[derive(Subdiagnostic)] +enum V { + #[label(parse_add_paren)] + A { + #[primary_span] + span: Span, + var: String, + }, + B { + #[primary_span] + span: Span, + var: String, + }, +} + +#[derive(Subdiagnostic)] +#[label(parse_add_paren)] +//~^ ERROR label without `#[primary_span]` field +struct W { + #[primary_span] + //~^ ERROR the `#[primary_span]` attribute can only be applied to fields of type `Span` or `MultiSpan` + span: String, +} + +#[derive(Subdiagnostic)] +#[label(parse_add_paren)] +struct X { + #[primary_span] + span: Span, + #[applicability] + //~^ ERROR `#[applicability]` is only valid on suggestions + applicability: Applicability, +} + +#[derive(Subdiagnostic)] +#[label(parse_add_paren)] +struct Y { + #[primary_span] + span: Span, + #[bar] + //~^ ERROR `#[bar]` is not a valid attribute + //~^^ ERROR cannot find attribute `bar` in this scope + bar: String, +} + +#[derive(Subdiagnostic)] +#[label(parse_add_paren)] +struct Z { + #[primary_span] + span: Span, + #[bar = "..."] + //~^ ERROR `#[bar = ...]` is not a valid attribute + //~^^ ERROR cannot find attribute `bar` in this scope + bar: String, +} + +#[derive(Subdiagnostic)] +#[label(parse_add_paren)] +struct AA { + #[primary_span] + span: Span, + #[bar("...")] + //~^ ERROR `#[bar(...)]` is not a valid attribute + //~^^ ERROR cannot find attribute `bar` in this scope + bar: String, +} + +#[derive(Subdiagnostic)] +#[label(parse_add_paren)] +struct AB { + #[primary_span] + span: Span, + #[skip_arg] + z: Z, +} + +#[derive(Subdiagnostic)] +union AC { + //~^ ERROR unexpected unsupported untagged union + span: u32, + b: u64, +} + +#[derive(Subdiagnostic)] +#[label(parse_add_paren)] +#[label(parse_add_paren)] +struct AD { + #[primary_span] + span: Span, +} + +#[derive(Subdiagnostic)] +#[label(parse_add_paren, parse_add_paren)] +//~^ ERROR `#[label(parse_add_paren)]` is not a valid attribute +struct AE { + #[primary_span] + span: Span, +} + +#[derive(Subdiagnostic)] +#[label(parse_add_paren)] +struct AF { + #[primary_span] + //~^ NOTE previously specified here + span_a: Span, + #[primary_span] + //~^ ERROR specified multiple times + span_b: Span, +} + +#[derive(Subdiagnostic)] +struct AG { + //~^ ERROR subdiagnostic kind not specified + #[primary_span] + span: Span, +} + +#[derive(Subdiagnostic)] +#[suggestion(parse_add_paren, code = "...")] +struct AH { + #[primary_span] + span: Span, + #[applicability] + applicability: Applicability, + var: String, +} + +#[derive(Subdiagnostic)] +enum AI { + #[suggestion(parse_add_paren, code = "...")] + A { + #[primary_span] + span: Span, + #[applicability] + applicability: Applicability, + var: String, + }, + #[suggestion(parse_add_paren, code = "...")] + B { + #[primary_span] + span: Span, + #[applicability] + applicability: Applicability, + var: String, + }, +} + +#[derive(Subdiagnostic)] +#[suggestion(parse_add_paren, code = "...", code = "...")] +//~^ ERROR specified multiple times +//~^^ NOTE previously specified here +struct AJ { + #[primary_span] + span: Span, + #[applicability] + applicability: Applicability, +} + +#[derive(Subdiagnostic)] +#[suggestion(parse_add_paren, code = "...")] +struct AK { + #[primary_span] + span: Span, + #[applicability] + //~^ NOTE previously specified here + applicability_a: Applicability, + #[applicability] + //~^ ERROR specified multiple times + applicability_b: Applicability, +} + +#[derive(Subdiagnostic)] +#[suggestion(parse_add_paren, code = "...")] +struct AL { + #[primary_span] + span: Span, + #[applicability] + //~^ ERROR the `#[applicability]` attribute can only be applied to fields of type `Applicability` + applicability: Span, +} + +#[derive(Subdiagnostic)] +#[suggestion(parse_add_paren, code = "...")] +struct AM { + #[primary_span] + span: Span, +} + +#[derive(Subdiagnostic)] +#[suggestion(parse_add_paren)] +//~^ ERROR suggestion without `code = "..."` +struct AN { + #[primary_span] + span: Span, + #[applicability] + applicability: Applicability, +} + +#[derive(Subdiagnostic)] +#[suggestion(parse_add_paren, code = "...", applicability = "foo")] +//~^ ERROR invalid applicability +struct AO { + #[primary_span] + span: Span, +} + +#[derive(Subdiagnostic)] +#[help(parse_add_paren)] +struct AP { + var: String, +} + +#[derive(Subdiagnostic)] +#[note(parse_add_paren)] +struct AQ; + +#[derive(Subdiagnostic)] +#[suggestion(parse_add_paren, code = "...")] +//~^ ERROR suggestion without `#[primary_span]` field +struct AR { + var: String, +} + +#[derive(Subdiagnostic)] +#[suggestion(parse_add_paren, code = "...", applicability = "machine-applicable")] +struct AS { + #[primary_span] + span: Span, +} + +#[derive(Subdiagnostic)] +#[label] +//~^ ERROR unsupported type attribute for subdiagnostic enum +enum AT { + #[label(parse_add_paren)] + A { + #[primary_span] + span: Span, + var: String, + }, +} + +#[derive(Subdiagnostic)] +#[suggestion(parse_add_paren, code = "{var}", applicability = "machine-applicable")] +struct AU { + #[primary_span] + span: Span, + var: String, +} + +#[derive(Subdiagnostic)] +#[suggestion(parse_add_paren, code = "{var}", applicability = "machine-applicable")] +//~^ ERROR `var` doesn't refer to a field on this type +struct AV { + #[primary_span] + span: Span, +} + +#[derive(Subdiagnostic)] +enum AW { + #[suggestion(parse_add_paren, code = "{var}", applicability = "machine-applicable")] + A { + #[primary_span] + span: Span, + var: String, + }, +} + +#[derive(Subdiagnostic)] +enum AX { + #[suggestion(parse_add_paren, code = "{var}", applicability = "machine-applicable")] + //~^ ERROR `var` doesn't refer to a field on this type + A { + #[primary_span] + span: Span, + }, +} + +#[derive(Subdiagnostic)] +#[warning(parse_add_paren)] +struct AY {} + +#[derive(Subdiagnostic)] +#[warning(parse_add_paren)] +struct AZ { + #[primary_span] + span: Span, +} + +#[derive(Subdiagnostic)] +#[suggestion(parse_add_paren, code = "...")] +//~^ ERROR suggestion without `#[primary_span]` field +struct BA { + #[suggestion_part] + //~^ ERROR `#[suggestion_part]` is not a valid attribute + span: Span, + #[suggestion_part(code = "...")] + //~^ ERROR `#[suggestion_part(...)]` is not a valid attribute + span2: Span, + #[applicability] + applicability: Applicability, + var: String, +} + +#[derive(Subdiagnostic)] +#[multipart_suggestion(parse_add_paren, code = "...", applicability = "machine-applicable")] +//~^ ERROR multipart suggestion without any `#[suggestion_part(...)]` fields +//~| ERROR `#[multipart_suggestion(code = ...)]` is not a valid attribute +struct BBa { + var: String, +} + +#[derive(Subdiagnostic)] +#[multipart_suggestion(parse_add_paren, applicability = "machine-applicable")] +struct BBb { + #[suggestion_part] + //~^ ERROR `#[suggestion_part(...)]` attribute without `code = "..."` + span1: Span, +} + +#[derive(Subdiagnostic)] +#[multipart_suggestion(parse_add_paren, applicability = "machine-applicable")] +struct BBc { + #[suggestion_part()] + //~^ ERROR `#[suggestion_part(...)]` attribute without `code = "..."` + span1: Span, +} + +#[derive(Subdiagnostic)] +#[multipart_suggestion(parse_add_paren)] +//~^ ERROR multipart suggestion without any `#[suggestion_part(...)]` fields +struct BC { + #[primary_span] + //~^ ERROR `#[primary_span]` is not a valid attribute + span: Span, +} + +#[derive(Subdiagnostic)] +#[multipart_suggestion(parse_add_paren)] +struct BD { + #[suggestion_part] + //~^ ERROR `#[suggestion_part(...)]` attribute without `code = "..."` + span1: Span, + #[suggestion_part()] + //~^ ERROR `#[suggestion_part(...)]` attribute without `code = "..."` + span2: Span, + #[suggestion_part(foo = "bar")] + //~^ ERROR `#[suggestion_part(foo = ...)]` is not a valid attribute + span4: Span, + #[suggestion_part(code = "...")] + //~^ ERROR the `#[suggestion_part(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan` + s1: String, + #[suggestion_part()] + //~^ ERROR the `#[suggestion_part(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan` + s2: String, +} + +#[derive(Subdiagnostic)] +#[multipart_suggestion(parse_add_paren, applicability = "machine-applicable")] +struct BE { + #[suggestion_part(code = "...", code = ",,,")] + //~^ ERROR specified multiple times + //~| NOTE previously specified here + span: Span, +} + +#[derive(Subdiagnostic)] +#[multipart_suggestion(parse_add_paren, applicability = "machine-applicable")] +struct BF { + #[suggestion_part(code = "(")] + first: Span, + #[suggestion_part(code = ")")] + second: Span, +} + +#[derive(Subdiagnostic)] +#[multipart_suggestion(parse_add_paren)] +struct BG { + #[applicability] + appl: Applicability, + #[suggestion_part(code = "(")] + first: Span, + #[suggestion_part(code = ")")] + second: Span, +} + +#[derive(Subdiagnostic)] +#[multipart_suggestion(parse_add_paren, applicability = "machine-applicable")] +struct BH { + #[applicability] + //~^ ERROR `#[applicability]` has no effect + appl: Applicability, + #[suggestion_part(code = "(")] + first: Span, + #[suggestion_part(code = ")")] + second: Span, +} + +#[derive(Subdiagnostic)] +#[multipart_suggestion(parse_add_paren, applicability = "machine-applicable")] +struct BI { + #[suggestion_part(code = "")] + spans: Vec, +} + +#[derive(Subdiagnostic)] +#[label(parse_add_paren)] +struct BJ { + #[primary_span] + span: Span, + r#type: String, +} + +/// with a doc comment on the type.. +#[derive(Subdiagnostic)] +#[label(parse_add_paren)] +struct BK { + /// ..and the field + #[primary_span] + span: Span, +} + +/// with a doc comment on the type.. +#[derive(Subdiagnostic)] +enum BL { + /// ..and the variant.. + #[label(parse_add_paren)] + Foo { + /// ..and the field + #[primary_span] + span: Span, + }, +} + +#[derive(Subdiagnostic)] +#[multipart_suggestion(parse_add_paren)] +struct BM { + #[suggestion_part(code("foo"))] + //~^ ERROR expected exactly one string literal for `code = ...` + span: Span, + r#type: String, +} + +#[derive(Subdiagnostic)] +#[multipart_suggestion(parse_add_paren)] +struct BN { + #[suggestion_part(code("foo", "bar"))] + //~^ ERROR expected exactly one string literal for `code = ...` + span: Span, + r#type: String, +} + +#[derive(Subdiagnostic)] +#[multipart_suggestion(parse_add_paren)] +struct BO { + #[suggestion_part(code(3))] + //~^ ERROR expected exactly one string literal for `code = ...` + span: Span, + r#type: String, +} + +#[derive(Subdiagnostic)] +#[multipart_suggestion(parse_add_paren)] +struct BP { + #[suggestion_part(code())] + //~^ ERROR expected exactly one string literal for `code = ...` + span: Span, + r#type: String, +} + +#[derive(Subdiagnostic)] +#[multipart_suggestion(parse_add_paren)] +struct BQ { + #[suggestion_part(code = 3)] + //~^ ERROR `code = "..."`/`code(...)` must contain only string literals + span: Span, + r#type: String, +} + +#[derive(Subdiagnostic)] +#[suggestion(parse_add_paren, code = "")] +struct SuggestionStyleDefault { + #[primary_span] + sub: Span, +} + +#[derive(Subdiagnostic)] +#[suggestion(parse_add_paren, code = "", style = "short")] +struct SuggestionStyleShort { + #[primary_span] + sub: Span, +} + +#[derive(Subdiagnostic)] +#[suggestion(parse_add_paren, code = "", style = "hidden")] +struct SuggestionStyleHidden { + #[primary_span] + sub: Span, +} + +#[derive(Subdiagnostic)] +#[suggestion(parse_add_paren, code = "", style = "verbose")] +struct SuggestionStyleVerbose { + #[primary_span] + sub: Span, +} + +#[derive(Subdiagnostic)] +#[suggestion(parse_add_paren, code = "", style = "tool-only")] +struct SuggestionStyleToolOnly { + #[primary_span] + sub: Span, +} + +#[derive(Subdiagnostic)] +#[suggestion(parse_add_paren, code = "", style = "hidden", style = "normal")] +//~^ ERROR specified multiple times +//~| NOTE previously specified here +struct SuggestionStyleTwice { + #[primary_span] + sub: Span, +} + +#[derive(Subdiagnostic)] +#[suggestion_hidden(parse_add_paren, code = "")] +//~^ ERROR #[suggestion_hidden(...)]` is not a valid attribute +struct SuggestionStyleOldSyntax { + #[primary_span] + sub: Span, +} + +#[derive(Subdiagnostic)] +#[suggestion_hidden(parse_add_paren, code = "", style = "normal")] +//~^ ERROR #[suggestion_hidden(...)]` is not a valid attribute +struct SuggestionStyleOldAndNewSyntax { + #[primary_span] + sub: Span, +} + +#[derive(Subdiagnostic)] +#[suggestion(parse_add_paren, code = "", style = "foo")] +//~^ ERROR invalid suggestion style +struct SuggestionStyleInvalid1 { + #[primary_span] + sub: Span, +} + +#[derive(Subdiagnostic)] +#[suggestion(parse_add_paren, code = "", style = 42)] +//~^ ERROR `#[suggestion(style = ...)]` is not a valid attribute +struct SuggestionStyleInvalid2 { + #[primary_span] + sub: Span, +} + +#[derive(Subdiagnostic)] +#[suggestion(parse_add_paren, code = "", style)] +//~^ ERROR `#[suggestion(style)]` is not a valid attribute +struct SuggestionStyleInvalid3 { + #[primary_span] + sub: Span, +} + +#[derive(Subdiagnostic)] +#[suggestion(parse_add_paren, code = "", style("foo"))] +//~^ ERROR `#[suggestion(style(...))]` is not a valid attribute +struct SuggestionStyleInvalid4 { + #[primary_span] + sub: Span, +} diff --git a/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr b/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr new file mode 100644 index 000000000..b594fa6cd --- /dev/null +++ b/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr @@ -0,0 +1,566 @@ +error: label without `#[primary_span]` field + --> $DIR/subdiagnostic-derive.rs:47:1 + | +LL | / #[label(parse_add_paren)] +LL | | +LL | | struct C { +LL | | var: String, +LL | | } + | |_^ + +error: diagnostic slug must be first argument of a `#[label(...)]` attribute + --> $DIR/subdiagnostic-derive.rs:54:1 + | +LL | #[label] + | ^^^^^^^^ + +error: `#[foo]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:63:1 + | +LL | #[foo] + | ^^^^^^ + +error: `#[label = ...]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:73:1 + | +LL | #[label = "..."] + | ^^^^^^^^^^^^^^^^ + +error: `#[label(bug = ...)]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:82:9 + | +LL | #[label(bug = "...")] + | ^^^^^^^^^^^ + +error: diagnostic slug must be first argument of a `#[label(...)]` attribute + --> $DIR/subdiagnostic-derive.rs:82:1 + | +LL | #[label(bug = "...")] + | ^^^^^^^^^^^^^^^^^^^^^ + +error: `#[label("...")]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:92:9 + | +LL | #[label("...")] + | ^^^^^ + +error: diagnostic slug must be first argument of a `#[label(...)]` attribute + --> $DIR/subdiagnostic-derive.rs:92:1 + | +LL | #[label("...")] + | ^^^^^^^^^^^^^^^ + +error: `#[label(slug = ...)]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:102:9 + | +LL | #[label(slug = 4)] + | ^^^^^^^^ + +error: diagnostic slug must be first argument of a `#[label(...)]` attribute + --> $DIR/subdiagnostic-derive.rs:102:1 + | +LL | #[label(slug = 4)] + | ^^^^^^^^^^^^^^^^^^ + +error: `#[label(slug(...))]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:112:9 + | +LL | #[label(slug("..."))] + | ^^^^^^^^^^^ + +error: diagnostic slug must be first argument of a `#[label(...)]` attribute + --> $DIR/subdiagnostic-derive.rs:112:1 + | +LL | #[label(slug("..."))] + | ^^^^^^^^^^^^^^^^^^^^^ + +error: diagnostic slug must be first argument of a `#[label(...)]` attribute + --> $DIR/subdiagnostic-derive.rs:132:1 + | +LL | #[label()] + | ^^^^^^^^^^ + +error: `#[label(code = ...)]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:141:26 + | +LL | #[label(parse_add_paren, code = "...")] + | ^^^^^^^^^^^^ + +error: `#[label(applicability = ...)]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:150:26 + | +LL | #[label(parse_add_paren, applicability = "machine-applicable")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: unsupported type attribute for subdiagnostic enum + --> $DIR/subdiagnostic-derive.rs:159:1 + | +LL | #[foo] + | ^^^^^^ + +error: `#[bar]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:173:5 + | +LL | #[bar] + | ^^^^^^ + +error: `#[bar = ...]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:185:5 + | +LL | #[bar = "..."] + | ^^^^^^^^^^^^^^ + +error: `#[bar = ...]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:197:5 + | +LL | #[bar = 4] + | ^^^^^^^^^^ + +error: `#[bar(...)]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:209:5 + | +LL | #[bar("...")] + | ^^^^^^^^^^^^^ + +error: `#[label(code = ...)]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:221:13 + | +LL | #[label(code = "...")] + | ^^^^^^^^^^^^ + +error: diagnostic slug must be first argument of a `#[label(...)]` attribute + --> $DIR/subdiagnostic-derive.rs:221:5 + | +LL | #[label(code = "...")] + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: the `#[primary_span]` attribute can only be applied to fields of type `Span` or `MultiSpan` + --> $DIR/subdiagnostic-derive.rs:250:5 + | +LL | #[primary_span] + | ^^^^^^^^^^^^^^^ + +error: label without `#[primary_span]` field + --> $DIR/subdiagnostic-derive.rs:247:1 + | +LL | / #[label(parse_add_paren)] +LL | | +LL | | struct W { +LL | | #[primary_span] +LL | | +LL | | span: String, +LL | | } + | |_^ + +error: `#[applicability]` is only valid on suggestions + --> $DIR/subdiagnostic-derive.rs:260:5 + | +LL | #[applicability] + | ^^^^^^^^^^^^^^^^ + +error: `#[bar]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:270:5 + | +LL | #[bar] + | ^^^^^^ + | + = help: only `primary_span`, `applicability` and `skip_arg` are valid field attributes + +error: `#[bar = ...]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:281:5 + | +LL | #[bar = "..."] + | ^^^^^^^^^^^^^^ + +error: `#[bar(...)]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:292:5 + | +LL | #[bar("...")] + | ^^^^^^^^^^^^^ + | + = help: only `primary_span`, `applicability` and `skip_arg` are valid field attributes + +error: unexpected unsupported untagged union + --> $DIR/subdiagnostic-derive.rs:308:1 + | +LL | / union AC { +LL | | +LL | | span: u32, +LL | | b: u64, +LL | | } + | |_^ + +error: `#[label(parse_add_paren)]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:323:26 + | +LL | #[label(parse_add_paren, parse_add_paren)] + | ^^^^^^^^^^^^^^^ + | + = help: a diagnostic slug must be the first argument to the attribute + +error: specified multiple times + --> $DIR/subdiagnostic-derive.rs:336:5 + | +LL | #[primary_span] + | ^^^^^^^^^^^^^^^ + | +note: previously specified here + --> $DIR/subdiagnostic-derive.rs:333:5 + | +LL | #[primary_span] + | ^^^^^^^^^^^^^^^ + +error: subdiagnostic kind not specified + --> $DIR/subdiagnostic-derive.rs:342:8 + | +LL | struct AG { + | ^^ + +error: specified multiple times + --> $DIR/subdiagnostic-derive.rs:379:45 + | +LL | #[suggestion(parse_add_paren, code = "...", code = "...")] + | ^^^^^^^^^^^^ + | +note: previously specified here + --> $DIR/subdiagnostic-derive.rs:379:31 + | +LL | #[suggestion(parse_add_paren, code = "...", code = "...")] + | ^^^^^^^^^^^^ + +error: specified multiple times + --> $DIR/subdiagnostic-derive.rs:397:5 + | +LL | #[applicability] + | ^^^^^^^^^^^^^^^^ + | +note: previously specified here + --> $DIR/subdiagnostic-derive.rs:394:5 + | +LL | #[applicability] + | ^^^^^^^^^^^^^^^^ + +error: the `#[applicability]` attribute can only be applied to fields of type `Applicability` + --> $DIR/subdiagnostic-derive.rs:407:5 + | +LL | #[applicability] + | ^^^^^^^^^^^^^^^^ + +error: suggestion without `code = "..."` + --> $DIR/subdiagnostic-derive.rs:420:1 + | +LL | #[suggestion(parse_add_paren)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: invalid applicability + --> $DIR/subdiagnostic-derive.rs:430:45 + | +LL | #[suggestion(parse_add_paren, code = "...", applicability = "foo")] + | ^^^^^^^^^^^^^^^^^^^^^ + +error: suggestion without `#[primary_span]` field + --> $DIR/subdiagnostic-derive.rs:448:1 + | +LL | / #[suggestion(parse_add_paren, code = "...")] +LL | | +LL | | struct AR { +LL | | var: String, +LL | | } + | |_^ + +error: unsupported type attribute for subdiagnostic enum + --> $DIR/subdiagnostic-derive.rs:462:1 + | +LL | #[label] + | ^^^^^^^^ + +error: `var` doesn't refer to a field on this type + --> $DIR/subdiagnostic-derive.rs:482:38 + | +LL | #[suggestion(parse_add_paren, code = "{var}", applicability = "machine-applicable")] + | ^^^^^^^ + +error: `var` doesn't refer to a field on this type + --> $DIR/subdiagnostic-derive.rs:501:42 + | +LL | #[suggestion(parse_add_paren, code = "{var}", applicability = "machine-applicable")] + | ^^^^^^^ + +error: `#[suggestion_part]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:524:5 + | +LL | #[suggestion_part] + | ^^^^^^^^^^^^^^^^^^ + | + = help: `#[suggestion_part(...)]` is only valid in multipart suggestions, use `#[primary_span]` instead + +error: `#[suggestion_part(...)]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:527:5 + | +LL | #[suggestion_part(code = "...")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: `#[suggestion_part(...)]` is only valid in multipart suggestions + +error: suggestion without `#[primary_span]` field + --> $DIR/subdiagnostic-derive.rs:521:1 + | +LL | / #[suggestion(parse_add_paren, code = "...")] +LL | | +LL | | struct BA { +LL | | #[suggestion_part] +... | +LL | | var: String, +LL | | } + | |_^ + +error: `#[multipart_suggestion(code = ...)]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:536:41 + | +LL | #[multipart_suggestion(parse_add_paren, code = "...", applicability = "machine-applicable")] + | ^^^^^^^^^^^^ + | + = help: only `style` and `applicability` are valid nested attributes + +error: multipart suggestion without any `#[suggestion_part(...)]` fields + --> $DIR/subdiagnostic-derive.rs:536:1 + | +LL | / #[multipart_suggestion(parse_add_paren, code = "...", applicability = "machine-applicable")] +LL | | +LL | | +LL | | struct BBa { +LL | | var: String, +LL | | } + | |_^ + +error: `#[suggestion_part(...)]` attribute without `code = "..."` + --> $DIR/subdiagnostic-derive.rs:546:5 + | +LL | #[suggestion_part] + | ^^^^^^^^^^^^^^^^^^ + +error: `#[suggestion_part(...)]` attribute without `code = "..."` + --> $DIR/subdiagnostic-derive.rs:554:5 + | +LL | #[suggestion_part()] + | ^^^^^^^^^^^^^^^^^^^^ + +error: `#[primary_span]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:563:5 + | +LL | #[primary_span] + | ^^^^^^^^^^^^^^^ + | + = help: multipart suggestions use one or more `#[suggestion_part]`s rather than one `#[primary_span]` + +error: multipart suggestion without any `#[suggestion_part(...)]` fields + --> $DIR/subdiagnostic-derive.rs:560:1 + | +LL | / #[multipart_suggestion(parse_add_paren)] +LL | | +LL | | struct BC { +LL | | #[primary_span] +LL | | +LL | | span: Span, +LL | | } + | |_^ + +error: `#[suggestion_part(...)]` attribute without `code = "..."` + --> $DIR/subdiagnostic-derive.rs:571:5 + | +LL | #[suggestion_part] + | ^^^^^^^^^^^^^^^^^^ + +error: `#[suggestion_part(...)]` attribute without `code = "..."` + --> $DIR/subdiagnostic-derive.rs:574:5 + | +LL | #[suggestion_part()] + | ^^^^^^^^^^^^^^^^^^^^ + +error: `#[suggestion_part(foo = ...)]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:577:23 + | +LL | #[suggestion_part(foo = "bar")] + | ^^^^^^^^^^^ + | + = help: `code` is the only valid nested attribute + +error: the `#[suggestion_part(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan` + --> $DIR/subdiagnostic-derive.rs:580:5 + | +LL | #[suggestion_part(code = "...")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: the `#[suggestion_part(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan` + --> $DIR/subdiagnostic-derive.rs:583:5 + | +LL | #[suggestion_part()] + | ^^^^^^^^^^^^^^^^^^^^ + +error: specified multiple times + --> $DIR/subdiagnostic-derive.rs:591:37 + | +LL | #[suggestion_part(code = "...", code = ",,,")] + | ^^^^^^^^^^^^ + | +note: previously specified here + --> $DIR/subdiagnostic-derive.rs:591:23 + | +LL | #[suggestion_part(code = "...", code = ",,,")] + | ^^^^^^^^^^^^ + +error: `#[applicability]` has no effect if all `#[suggestion]`/`#[multipart_suggestion]` attributes have a static `applicability = "..."` + --> $DIR/subdiagnostic-derive.rs:620:5 + | +LL | #[applicability] + | ^^^^^^^^^^^^^^^^ + +error: expected exactly one string literal for `code = ...` + --> $DIR/subdiagnostic-derive.rs:668:23 + | +LL | #[suggestion_part(code("foo"))] + | ^^^^^^^^^^^ + +error: expected exactly one string literal for `code = ...` + --> $DIR/subdiagnostic-derive.rs:677:23 + | +LL | #[suggestion_part(code("foo", "bar"))] + | ^^^^^^^^^^^^^^^^^^ + +error: expected exactly one string literal for `code = ...` + --> $DIR/subdiagnostic-derive.rs:686:23 + | +LL | #[suggestion_part(code(3))] + | ^^^^^^^ + +error: expected exactly one string literal for `code = ...` + --> $DIR/subdiagnostic-derive.rs:695:23 + | +LL | #[suggestion_part(code())] + | ^^^^^^ + +error: `code = "..."`/`code(...)` must contain only string literals + --> $DIR/subdiagnostic-derive.rs:704:23 + | +LL | #[suggestion_part(code = 3)] + | ^^^^^^^^ + +error: specified multiple times + --> $DIR/subdiagnostic-derive.rs:746:60 + | +LL | #[suggestion(parse_add_paren, code = "", style = "hidden", style = "normal")] + | ^^^^^^^^^^^^^^^^ + | +note: previously specified here + --> $DIR/subdiagnostic-derive.rs:746:42 + | +LL | #[suggestion(parse_add_paren, code = "", style = "hidden", style = "normal")] + | ^^^^^^^^^^^^^^^^ + +error: `#[suggestion_hidden(...)]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:755:1 + | +LL | #[suggestion_hidden(parse_add_paren, code = "")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: Use `#[suggestion(..., style = "hidden")]` instead + +error: `#[suggestion_hidden(...)]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:763:1 + | +LL | #[suggestion_hidden(parse_add_paren, code = "", style = "normal")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: Use `#[suggestion(..., style = "hidden")]` instead + +error: invalid suggestion style + --> $DIR/subdiagnostic-derive.rs:771:50 + | +LL | #[suggestion(parse_add_paren, code = "", style = "foo")] + | ^^^^^ + | + = help: valid styles are `normal`, `short`, `hidden`, `verbose` and `tool-only` + +error: `#[suggestion(style = ...)]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:779:42 + | +LL | #[suggestion(parse_add_paren, code = "", style = 42)] + | ^^^^^^^^^^ + +error: `#[suggestion(style)]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:787:42 + | +LL | #[suggestion(parse_add_paren, code = "", style)] + | ^^^^^ + | + = help: a diagnostic slug must be the first argument to the attribute + +error: `#[suggestion(style(...))]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:795:42 + | +LL | #[suggestion(parse_add_paren, code = "", style("foo"))] + | ^^^^^^^^^^^^ + +error: cannot find attribute `foo` in this scope + --> $DIR/subdiagnostic-derive.rs:63:3 + | +LL | #[foo] + | ^^^ + +error: cannot find attribute `foo` in this scope + --> $DIR/subdiagnostic-derive.rs:159:3 + | +LL | #[foo] + | ^^^ + +error: cannot find attribute `bar` in this scope + --> $DIR/subdiagnostic-derive.rs:173:7 + | +LL | #[bar] + | ^^^ + +error: cannot find attribute `bar` in this scope + --> $DIR/subdiagnostic-derive.rs:185:7 + | +LL | #[bar = "..."] + | ^^^ + +error: cannot find attribute `bar` in this scope + --> $DIR/subdiagnostic-derive.rs:197:7 + | +LL | #[bar = 4] + | ^^^ + +error: cannot find attribute `bar` in this scope + --> $DIR/subdiagnostic-derive.rs:209:7 + | +LL | #[bar("...")] + | ^^^ + +error: cannot find attribute `bar` in this scope + --> $DIR/subdiagnostic-derive.rs:270:7 + | +LL | #[bar] + | ^^^ + +error: cannot find attribute `bar` in this scope + --> $DIR/subdiagnostic-derive.rs:281:7 + | +LL | #[bar = "..."] + | ^^^ + +error: cannot find attribute `bar` in this scope + --> $DIR/subdiagnostic-derive.rs:292:7 + | +LL | #[bar("...")] + | ^^^ + +error[E0425]: cannot find value `slug` in module `rustc_errors::fluent` + --> $DIR/subdiagnostic-derive.rs:122:9 + | +LL | #[label(slug)] + | ^^^^ not found in `rustc_errors::fluent` + +error: aborting due to 79 previous errors + +For more information about this error, try `rustc --explain E0425`. -- cgit v1.2.3