From cf94bdc0742c13e2a0cac864c478b8626b266e1b Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:11:38 +0200 Subject: Merging upstream version 1.66.0+dfsg1. Signed-off-by: Daniel Baumann --- .../ui-fulldeps/auxiliary/issue-40001-plugin.rs | 10 +- src/test/ui-fulldeps/auxiliary/lint-for-crate.rs | 8 +- .../auxiliary/lint-group-plugin-test.rs | 10 +- src/test/ui-fulldeps/auxiliary/lint-plugin-test.rs | 4 +- src/test/ui-fulldeps/auxiliary/lint-tool-test.rs | 8 +- src/test/ui-fulldeps/fluent-messages/test.rs | 5 +- src/test/ui-fulldeps/fluent-messages/test.stderr | 29 +- .../internal-lints/default_hash_types.stderr | 2 +- src/test/ui-fulldeps/internal-lints/diagnostics.rs | 52 +- .../ui-fulldeps/internal-lints/diagnostics.stderr | 14 +- .../internal-lints/existing_doc_keyword.stderr | 2 +- .../lint_pass_impl_without_macro.stderr | 2 +- .../internal-lints/query_stability.stderr | 2 +- src/test/ui-fulldeps/pprust-expr-roundtrip.rs | 4 +- .../session-diagnostic/diagnostic-derive.rs | 605 ++++++++++++++------- .../session-diagnostic/diagnostic-derive.stderr | 552 +++++++++++++------ .../session-diagnostic/subdiagnostic-derive.rs | 321 ++++++----- .../session-diagnostic/subdiagnostic-derive.stderr | 256 +++++---- 18 files changed, 1221 insertions(+), 665 deletions(-) (limited to 'src/test/ui-fulldeps') diff --git a/src/test/ui-fulldeps/auxiliary/issue-40001-plugin.rs b/src/test/ui-fulldeps/auxiliary/issue-40001-plugin.rs index 03ad3ca82..c05443488 100644 --- a/src/test/ui-fulldeps/auxiliary/issue-40001-plugin.rs +++ b/src/test/ui-fulldeps/auxiliary/issue-40001-plugin.rs @@ -44,14 +44,16 @@ impl<'tcx> LateLintPass<'tcx> for MissingAllowedAttrPass { ) { let item = match cx.tcx.hir().get(id) { Node::Item(item) => item, - _ => cx.tcx.hir().expect_item(cx.tcx.hir().get_parent_item(id)), + _ => cx.tcx.hir().expect_item(cx.tcx.hir().get_parent_item(id).def_id), }; let allowed = |attr| pprust::attribute_to_string(attr).contains("allowed_attr"); if !cx.tcx.hir().attrs(item.hir_id()).iter().any(allowed) { - cx.lint(MISSING_ALLOWED_ATTR, |lint| { - lint.build("Missing 'allowed_attr' attribute").set_span(span).emit(); - }); + cx.lint( + MISSING_ALLOWED_ATTR, + "Missing 'allowed_attr' attribute", + |lint| lint.set_span(span) + ); } } } diff --git a/src/test/ui-fulldeps/auxiliary/lint-for-crate.rs b/src/test/ui-fulldeps/auxiliary/lint-for-crate.rs index 0b1534939..073da688c 100644 --- a/src/test/ui-fulldeps/auxiliary/lint-for-crate.rs +++ b/src/test/ui-fulldeps/auxiliary/lint-for-crate.rs @@ -29,9 +29,11 @@ impl<'tcx> LateLintPass<'tcx> for Pass { let attrs = cx.tcx.hir().attrs(rustc_hir::CRATE_HIR_ID); let span = cx.tcx.def_span(CRATE_DEF_ID); if !cx.sess().contains_name(attrs, Symbol::intern("crate_okay")) { - cx.lint(CRATE_NOT_OKAY, |lint| { - lint.build("crate is not marked with #![crate_okay]").set_span(span).emit(); - }); + cx.lint( + CRATE_NOT_OKAY, + "crate is not marked with #![crate_okay]", + |lint| lint.set_span(span) + ); } } } diff --git a/src/test/ui-fulldeps/auxiliary/lint-group-plugin-test.rs b/src/test/ui-fulldeps/auxiliary/lint-group-plugin-test.rs index 2d41b5f30..4a41e7fbb 100644 --- a/src/test/ui-fulldeps/auxiliary/lint-group-plugin-test.rs +++ b/src/test/ui-fulldeps/auxiliary/lint-group-plugin-test.rs @@ -22,12 +22,10 @@ declare_lint_pass!(Pass => [TEST_LINT, PLEASE_LINT]); impl<'tcx> LateLintPass<'tcx> for Pass { fn check_item(&mut self, cx: &LateContext, it: &rustc_hir::Item) { match it.ident.as_str() { - "lintme" => cx.lint(TEST_LINT, |lint| { - lint.build("item is named 'lintme'").set_span(it.span).emit(); - }), - "pleaselintme" => cx.lint(PLEASE_LINT, |lint| { - lint.build("item is named 'pleaselintme'").set_span(it.span).emit(); - }), + "lintme" => cx.lint(TEST_LINT, "item is named 'lintme'", |lint| lint.set_span(it.span)), + "pleaselintme" => { + cx.lint(PLEASE_LINT, "item is named 'pleaselintme'", |lint| lint.set_span(it.span)) + } _ => {} } } diff --git a/src/test/ui-fulldeps/auxiliary/lint-plugin-test.rs b/src/test/ui-fulldeps/auxiliary/lint-plugin-test.rs index 285754928..30956deb7 100644 --- a/src/test/ui-fulldeps/auxiliary/lint-plugin-test.rs +++ b/src/test/ui-fulldeps/auxiliary/lint-plugin-test.rs @@ -21,9 +21,7 @@ declare_lint_pass!(Pass => [TEST_LINT]); impl EarlyLintPass for Pass { fn check_item(&mut self, cx: &EarlyContext, it: &ast::Item) { if it.ident.name.as_str() == "lintme" { - cx.lint(TEST_LINT, |lint| { - lint.build("item is named 'lintme'").set_span(it.span).emit(); - }); + cx.lint(TEST_LINT, "item is named 'lintme'", |lint| lint.set_span(it.span)); } } } diff --git a/src/test/ui-fulldeps/auxiliary/lint-tool-test.rs b/src/test/ui-fulldeps/auxiliary/lint-tool-test.rs index 3d5dba42b..c2c024865 100644 --- a/src/test/ui-fulldeps/auxiliary/lint-tool-test.rs +++ b/src/test/ui-fulldeps/auxiliary/lint-tool-test.rs @@ -31,14 +31,10 @@ declare_lint_pass!(Pass => [TEST_LINT, TEST_GROUP, TEST_RUSTC_TOOL_LINT]); impl EarlyLintPass for Pass { fn check_item(&mut self, cx: &EarlyContext, it: &ast::Item) { if it.ident.name.as_str() == "lintme" { - cx.lint(TEST_LINT, |lint| { - lint.build("item is named 'lintme'").set_span(it.span).emit(); - }); + cx.lint(TEST_LINT, "item is named 'lintme'", |lint| lint.set_span(it.span)); } if it.ident.name.as_str() == "lintmetoo" { - cx.lint(TEST_GROUP, |lint| { - lint.build("item is named 'lintmetoo'").set_span(it.span).emit(); - }); + cx.lint(TEST_GROUP, "item is named 'lintmetoo'", |lint| lint.set_span(it.span)); } } } diff --git a/src/test/ui-fulldeps/fluent-messages/test.rs b/src/test/ui-fulldeps/fluent-messages/test.rs index 256857e52..4e8147e2b 100644 --- a/src/test/ui-fulldeps/fluent-messages/test.rs +++ b/src/test/ui-fulldeps/fluent-messages/test.rs @@ -49,6 +49,7 @@ mod duplicate { use super::fluent_messages; fluent_messages! { +//~^ ERROR the name `a_b_key` is defined multiple times a => "./duplicate-a.ftl", a_b => "./duplicate-a-b.ftl", //~^ ERROR overrides existing message: `a_b_key` @@ -80,7 +81,7 @@ mod valid { valid => "./valid.ftl", } - use self::fluent_generated::{DEFAULT_LOCALE_RESOURCES, valid::key}; + use self::fluent_generated::{DEFAULT_LOCALE_RESOURCES, valid_key}; } mod missing_crate_name { @@ -93,5 +94,5 @@ mod missing_crate_name { //~| ERROR name `with-hyphens` does not start with the crate name } - use self::fluent_generated::{DEFAULT_LOCALE_RESOURCES, test_crate::{foo, with_hyphens}}; + use self::fluent_generated::{DEFAULT_LOCALE_RESOURCES, test_crate_foo, with_hyphens}; } diff --git a/src/test/ui-fulldeps/fluent-messages/test.stderr b/src/test/ui-fulldeps/fluent-messages/test.stderr index 26d87430a..d1cd4fe26 100644 --- a/src/test/ui-fulldeps/fluent-messages/test.stderr +++ b/src/test/ui-fulldeps/fluent-messages/test.stderr @@ -30,19 +30,31 @@ error: expected a message field for "missing_message" | error: overrides existing message: `a_b_key` - --> $DIR/test.rs:53:16 + --> $DIR/test.rs:54:16 | LL | a_b => "./duplicate-a-b.ftl", | ^^^^^^^^^^^^^^^^^^^^^ | help: previously defined in this resource - --> $DIR/test.rs:52:14 + --> $DIR/test.rs:53:14 | LL | a => "./duplicate-a.ftl", | ^^^^^^^^^^^^^^^^^^^ +error[E0428]: the name `a_b_key` is defined multiple times + --> $DIR/test.rs:51:5 + | +LL | fluent_messages! { + | ^^^^^^^^^^^^^^^^ + | | + | `a_b_key` redefined here + | previous definition of the value `a_b_key` here + | + = note: os-specific message + = note: os-specific message + error: name `slug_with_hyphens_this-slug-has-hyphens` contains a '-' character - --> $DIR/test.rs:62:30 + --> $DIR/test.rs:63:30 | LL | slug_with_hyphens => "./slug-with-hyphens.ftl", | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -50,7 +62,7 @@ LL | slug_with_hyphens => "./slug-with-hyphens.ftl", = help: replace any '-'s with '_'s error: attribute `label-has-hyphens` contains a '-' character - --> $DIR/test.rs:71:31 + --> $DIR/test.rs:72:31 | LL | label_with_hyphens => "./label-with-hyphens.ftl", | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -58,7 +70,7 @@ LL | label_with_hyphens => "./label-with-hyphens.ftl", = help: replace any '-'s with '_'s error: name `with-hyphens` contains a '-' character - --> $DIR/test.rs:90:23 + --> $DIR/test.rs:91:23 | LL | test_crate => "./missing-crate-name.ftl", | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -66,7 +78,7 @@ LL | test_crate => "./missing-crate-name.ftl", = help: replace any '-'s with '_'s error: name `with-hyphens` does not start with the crate name - --> $DIR/test.rs:90:23 + --> $DIR/test.rs:91:23 | LL | test_crate => "./missing-crate-name.ftl", | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -74,12 +86,13 @@ LL | test_crate => "./missing-crate-name.ftl", = help: prepend `test_crate_` to the slug name: `test_crate_with_hyphens` error: name `test-crate_foo` contains a '-' character - --> $DIR/test.rs:90:23 + --> $DIR/test.rs:91:23 | LL | test_crate => "./missing-crate-name.ftl", | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: replace any '-'s with '_'s -error: aborting due to 9 previous errors +error: aborting due to 10 previous errors +For more information about this error, try `rustc --explain E0428`. diff --git a/src/test/ui-fulldeps/internal-lints/default_hash_types.stderr b/src/test/ui-fulldeps/internal-lints/default_hash_types.stderr index 9d13ee89b..3cb13082f 100644 --- a/src/test/ui-fulldeps/internal-lints/default_hash_types.stderr +++ b/src/test/ui-fulldeps/internal-lints/default_hash_types.stderr @@ -4,12 +4,12 @@ error: prefer `FxHashMap` over `HashMap`, it has better performance LL | let _map: HashMap = HashMap::default(); | ^^^^^^^ | + = note: a `use rustc_data_structures::fx::FxHashMap` may be necessary note: the lint level is defined here --> $DIR/default_hash_types.rs:4:9 | LL | #![deny(rustc::default_hash_types)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: a `use rustc_data_structures::fx::FxHashMap` may be necessary error: prefer `FxHashMap` over `HashMap`, it has better performance --> $DIR/default_hash_types.rs:16:15 diff --git a/src/test/ui-fulldeps/internal-lints/diagnostics.rs b/src/test/ui-fulldeps/internal-lints/diagnostics.rs index e9e809fa4..643e81d99 100644 --- a/src/test/ui-fulldeps/internal-lints/diagnostics.rs +++ b/src/test/ui-fulldeps/internal-lints/diagnostics.rs @@ -12,66 +12,72 @@ extern crate rustc_session; extern crate rustc_span; use rustc_errors::{ - AddSubdiagnostic, Diagnostic, DiagnosticBuilder, ErrorGuaranteed, Handler, fluent + AddToDiagnostic, IntoDiagnostic, Diagnostic, DiagnosticBuilder, + ErrorGuaranteed, Handler, fluent, SubdiagnosticMessage, }; -use rustc_macros::{SessionDiagnostic, SessionSubdiagnostic}; -use rustc_session::SessionDiagnostic; +use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_span::Span; -#[derive(SessionDiagnostic)] -#[diag(parser::expect_path)] -struct DeriveSessionDiagnostic { +#[derive(Diagnostic)] +#[diag(compiletest_example)] +struct DeriveDiagnostic { #[primary_span] span: Span, } -#[derive(SessionSubdiagnostic)] -#[note(parser::add_paren)] +#[derive(Subdiagnostic)] +#[note(compiletest_example)] struct Note { #[primary_span] span: Span, } -pub struct UntranslatableInSessionDiagnostic; +pub struct UntranslatableInIntoDiagnostic; -impl<'a> SessionDiagnostic<'a, ErrorGuaranteed> for UntranslatableInSessionDiagnostic { +impl<'a> IntoDiagnostic<'a, ErrorGuaranteed> for UntranslatableInIntoDiagnostic { fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, ErrorGuaranteed> { handler.struct_err("untranslatable diagnostic") //~^ ERROR diagnostics should be created using translatable messages } } -pub struct TranslatableInSessionDiagnostic; +pub struct TranslatableInIntoDiagnostic; -impl<'a> SessionDiagnostic<'a, ErrorGuaranteed> for TranslatableInSessionDiagnostic { +impl<'a> IntoDiagnostic<'a, ErrorGuaranteed> for TranslatableInIntoDiagnostic { fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, ErrorGuaranteed> { - handler.struct_err(fluent::parser::expect_path) + handler.struct_err(fluent::compiletest_example) } } -pub struct UntranslatableInAddSubdiagnostic; +pub struct UntranslatableInAddToDiagnostic; -impl AddSubdiagnostic for UntranslatableInAddSubdiagnostic { - fn add_to_diagnostic(self, diag: &mut Diagnostic) { +impl AddToDiagnostic for UntranslatableInAddToDiagnostic { + fn add_to_diagnostic_with(self, diag: &mut Diagnostic, _: F) + where + F: Fn(&mut Diagnostic, SubdiagnosticMessage) -> SubdiagnosticMessage, + { diag.note("untranslatable diagnostic"); //~^ ERROR diagnostics should be created using translatable messages } } -pub struct TranslatableInAddSubdiagnostic; +pub struct TranslatableInAddToDiagnostic; -impl AddSubdiagnostic for TranslatableInAddSubdiagnostic { - fn add_to_diagnostic(self, diag: &mut Diagnostic) { - diag.note(fluent::typeck::note); +impl AddToDiagnostic for TranslatableInAddToDiagnostic { + fn add_to_diagnostic_with(self, diag: &mut Diagnostic, _: F) + where + F: Fn(&mut Diagnostic, SubdiagnosticMessage) -> SubdiagnosticMessage, + { + diag.note(fluent::note); } } pub fn make_diagnostics<'a>(handler: &'a Handler) { - let _diag = handler.struct_err(fluent::parser::expect_path); - //~^ ERROR diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls + let _diag = handler.struct_err(fluent::compiletest_example); + //~^ ERROR diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls let _diag = handler.struct_err("untranslatable diagnostic"); - //~^ ERROR diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls + //~^ ERROR diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls //~^^ ERROR diagnostics should be created using translatable messages } diff --git a/src/test/ui-fulldeps/internal-lints/diagnostics.stderr b/src/test/ui-fulldeps/internal-lints/diagnostics.stderr index e5c5bc2e9..510d6a171 100644 --- a/src/test/ui-fulldeps/internal-lints/diagnostics.stderr +++ b/src/test/ui-fulldeps/internal-lints/diagnostics.stderr @@ -11,15 +11,15 @@ LL | #![deny(rustc::untranslatable_diagnostic)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: diagnostics should be created using translatable messages - --> $DIR/diagnostics.rs:56:14 + --> $DIR/diagnostics.rs:59:14 | LL | diag.note("untranslatable diagnostic"); | ^^^^ -error: diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls - --> $DIR/diagnostics.rs:70:25 +error: diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls + --> $DIR/diagnostics.rs:76:25 | -LL | let _diag = handler.struct_err(fluent::parser::expect_path); +LL | let _diag = handler.struct_err(fluent::compiletest_example); | ^^^^^^^^^^ | note: the lint level is defined here @@ -28,14 +28,14 @@ note: the lint level is defined here LL | #![deny(rustc::diagnostic_outside_of_impl)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls - --> $DIR/diagnostics.rs:73:25 +error: diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls + --> $DIR/diagnostics.rs:79:25 | LL | let _diag = handler.struct_err("untranslatable diagnostic"); | ^^^^^^^^^^ error: diagnostics should be created using translatable messages - --> $DIR/diagnostics.rs:73:25 + --> $DIR/diagnostics.rs:79:25 | LL | let _diag = handler.struct_err("untranslatable diagnostic"); | ^^^^^^^^^^ diff --git a/src/test/ui-fulldeps/internal-lints/existing_doc_keyword.stderr b/src/test/ui-fulldeps/internal-lints/existing_doc_keyword.stderr index bc9fcdd7b..4e296fff6 100644 --- a/src/test/ui-fulldeps/internal-lints/existing_doc_keyword.stderr +++ b/src/test/ui-fulldeps/internal-lints/existing_doc_keyword.stderr @@ -4,12 +4,12 @@ error: found non-existing keyword `tadam` used in `#[doc(keyword = \"...\")]` LL | #[doc(keyword = "tadam")] | ^^^^^^^^^^^^^^^^^^^^^^^^^ | + = help: only existing keywords are allowed in core/std note: the lint level is defined here --> $DIR/existing_doc_keyword.rs:8:9 | LL | #![deny(rustc::existing_doc_keyword)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = help: only existing keywords are allowed in core/std error: aborting due to previous error diff --git a/src/test/ui-fulldeps/internal-lints/lint_pass_impl_without_macro.stderr b/src/test/ui-fulldeps/internal-lints/lint_pass_impl_without_macro.stderr index 9df6be65e..ad6e93334 100644 --- a/src/test/ui-fulldeps/internal-lints/lint_pass_impl_without_macro.stderr +++ b/src/test/ui-fulldeps/internal-lints/lint_pass_impl_without_macro.stderr @@ -4,12 +4,12 @@ error: implementing `LintPass` by hand LL | impl LintPass for Foo { | ^^^^^^^^ | + = help: try using `declare_lint_pass!` or `impl_lint_pass!` instead note: the lint level is defined here --> $DIR/lint_pass_impl_without_macro.rs:4:9 | LL | #![deny(rustc::lint_pass_impl_without_macro)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = help: try using `declare_lint_pass!` or `impl_lint_pass!` instead error: implementing `LintPass` by hand --> $DIR/lint_pass_impl_without_macro.rs:30:14 diff --git a/src/test/ui-fulldeps/internal-lints/query_stability.stderr b/src/test/ui-fulldeps/internal-lints/query_stability.stderr index 7e8b448f4..ee4ef9982 100644 --- a/src/test/ui-fulldeps/internal-lints/query_stability.stderr +++ b/src/test/ui-fulldeps/internal-lints/query_stability.stderr @@ -4,12 +4,12 @@ error: using `drain` can result in unstable query results LL | for _ in x.drain() {} | ^^^^^ | + = note: if you believe this case to be fine, allow this lint and add a comment explaining your rationale note: the lint level is defined here --> $DIR/query_stability.rs:4:9 | LL | #![deny(rustc::potential_query_instability)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: if you believe this case to be fine, allow this lint and add a comment explaining your rationale error: using `iter` can result in unstable query results --> $DIR/query_stability.rs:16:16 diff --git a/src/test/ui-fulldeps/pprust-expr-roundtrip.rs b/src/test/ui-fulldeps/pprust-expr-roundtrip.rs index da6a84bf3..117b79871 100644 --- a/src/test/ui-fulldeps/pprust-expr-roundtrip.rs +++ b/src/test/ui-fulldeps/pprust-expr-roundtrip.rs @@ -73,10 +73,10 @@ fn iter_exprs(depth: usize, f: &mut dyn FnMut(P)) { 2 => { let seg = PathSegment::from_ident(Ident::from_str("x")); iter_exprs(depth - 1, &mut |e| { - g(ExprKind::MethodCall(seg.clone(), vec![e, make_x()], DUMMY_SP)) + g(ExprKind::MethodCall(seg.clone(), e, vec![make_x()], DUMMY_SP)) }); iter_exprs(depth - 1, &mut |e| { - g(ExprKind::MethodCall(seg.clone(), vec![make_x(), e], DUMMY_SP)) + g(ExprKind::MethodCall(seg.clone(), make_x(), vec![e], DUMMY_SP)) }); } 3..=8 => { diff --git a/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.rs b/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.rs index c1c109ac1..ca77e483d 100644 --- a/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.rs +++ b/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.rs @@ -1,10 +1,10 @@ // check-fail -// Tests error conditions for specifying diagnostics using #[derive(SessionDiagnostic)] +// 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 SessionDiagnostic is strictly internal to the compiler +// 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 @@ -17,7 +17,7 @@ use rustc_span::symbol::Ident; use rustc_span::Span; extern crate rustc_macros; -use rustc_macros::{SessionDiagnostic, LintDiagnostic, SessionSubdiagnostic}; +use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic}; extern crate rustc_middle; use rustc_middle::ty::Ty; @@ -27,116 +27,120 @@ use rustc_errors::{Applicability, MultiSpan}; extern crate rustc_session; -#[derive(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] struct Hello {} -#[derive(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] struct HelloWarn {} -#[derive(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] -//~^ ERROR `#[derive(SessionDiagnostic)]` can only be used on structs -enum SessionDiagnosticOnEnum { +#[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(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] #[diag = "E0123"] //~^ ERROR `#[diag = ...]` is not a valid attribute struct WrongStructAttrStyle {} -#[derive(SessionDiagnostic)] -#[nonsense(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[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(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag("E0123")] //~^ ERROR `#[diag("...")]` is not a valid attribute //~^^ ERROR diagnostic slug not specified struct InvalidLitNestedAttr {} -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(nonsense, code = "E0123")] //~^ ERROR cannot find value `nonsense` in module `rustc_errors::fluent` struct InvalidNestedStructAttr {} -#[derive(SessionDiagnostic)] +#[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(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(nonsense = "...", code = "E0123", slug = "foo")] //~^ ERROR `#[diag(nonsense = ...)]` is not a valid attribute -//~^^ ERROR diagnostic slug not specified +//~| ERROR `#[diag(slug = ...)]` is not a valid attribute +//~| ERROR diagnostic slug not specified struct InvalidNestedStructAttr2 {} -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(nonsense = 4, code = "E0123", slug = "foo")] //~^ ERROR `#[diag(nonsense = ...)]` is not a valid attribute -//~^^ ERROR diagnostic slug not specified +//~| ERROR `#[diag(slug = ...)]` is not a valid attribute +//~| ERROR diagnostic slug not specified struct InvalidNestedStructAttr3 {} -#[derive(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123", slug = "foo")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123", slug = "foo")] //~^ ERROR `#[diag(slug = ...)]` is not a valid attribute struct InvalidNestedStructAttr4 {} -#[derive(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] struct WrongPlaceField { #[suggestion = "bar"] //~^ ERROR `#[suggestion = ...]` is not a valid attribute sp: Span, } -#[derive(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0456")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +#[diag(compiletest_example, code = "E0456")] //~^ ERROR specified multiple times //~^^ ERROR specified multiple times struct DiagSpecifiedTwice {} -#[derive(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0456", code = "E0457")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0456", code = "E0457")] //~^ ERROR specified multiple times struct CodeSpecifiedTwice {} -#[derive(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, typeck::ambiguous_lifetime_bound, code = "E0456")] -//~^ ERROR `#[diag(typeck::ambiguous_lifetime_bound)]` is not a valid attribute +#[derive(Diagnostic)] +#[diag(compiletest_example, compiletest_example, code = "E0456")] +//~^ ERROR `#[diag(compiletest_example)]` is not a valid attribute struct SlugSpecifiedTwice {} -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] struct KindNotProvided {} //~ ERROR diagnostic slug not specified -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[diag(code = "E0456")] //~^ ERROR diagnostic slug not specified struct SlugNotProvided {} -#[derive(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound)] +#[derive(Diagnostic)] +#[diag(compiletest_example)] struct CodeNotProvided {} -#[derive(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[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(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] struct InvalidPathFieldAttr { #[nonsense] //~^ ERROR `#[nonsense]` is not a valid attribute @@ -144,201 +148,204 @@ struct InvalidPathFieldAttr { foo: String, } -#[derive(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] struct ErrorWithField { name: String, - #[label(typeck::label)] + #[label(label)] span: Span, } -#[derive(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] struct ErrorWithMessageAppliedToField { - #[label(typeck::label)] + #[label(label)] //~^ ERROR the `#[label(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan` name: String, } -#[derive(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] struct ErrorWithNonexistentField { - #[suggestion(typeck::suggestion, code = "{name}")] + #[suggestion(suggestion, code = "{name}")] //~^ ERROR `name` doesn't refer to a field on this type suggestion: (Span, Applicability), } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] //~^ ERROR invalid format string: expected `'}'` -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct ErrorMissingClosingBrace { - #[suggestion(typeck::suggestion, code = "{name")] + #[suggestion(suggestion, code = "{name")] suggestion: (Span, Applicability), name: String, val: usize, } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] //~^ ERROR invalid format string: unmatched `}` -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct ErrorMissingOpeningBrace { - #[suggestion(typeck::suggestion, code = "name}")] + #[suggestion(suggestion, code = "name}")] suggestion: (Span, Applicability), name: String, val: usize, } -#[derive(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] struct LabelOnSpan { - #[label(typeck::label)] + #[label(label)] sp: Span, } -#[derive(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] struct LabelOnNonSpan { - #[label(typeck::label)] + #[label(label)] //~^ ERROR the `#[label(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan` id: u32, } -#[derive(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] struct Suggest { - #[suggestion(typeck::suggestion, code = "This is the suggested code")] - #[suggestion_short(typeck::suggestion, code = "This is the suggested code")] - #[suggestion_hidden(typeck::suggestion, code = "This is the suggested code")] - #[suggestion_verbose(typeck::suggestion, code = "This is the suggested code")] + #[suggestion(suggestion, code = "This is the suggested code")] + #[suggestion_short(suggestion, code = "This is the suggested code")] + #[suggestion_hidden(suggestion, code = "This is the suggested code")] + #[suggestion_verbose(suggestion, code = "This is the suggested code")] suggestion: (Span, Applicability), } -#[derive(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] struct SuggestWithoutCode { - #[suggestion(typeck::suggestion)] + #[suggestion(suggestion)] + //~^ ERROR suggestion without `code = "..."` suggestion: (Span, Applicability), } -#[derive(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[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(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[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(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] struct SuggestWithoutMsg { #[suggestion(code = "bar")] suggestion: (Span, Applicability), } -#[derive(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] struct SuggestWithTypesSwapped { - #[suggestion(typeck::suggestion, code = "This is suggested code")] + #[suggestion(suggestion, code = "This is suggested code")] suggestion: (Applicability, Span), } -#[derive(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] struct SuggestWithWrongTypeApplicabilityOnly { - #[suggestion(typeck::suggestion, code = "This is suggested code")] + #[suggestion(suggestion, code = "This is suggested code")] //~^ ERROR wrong field type for suggestion suggestion: Applicability, } -#[derive(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] struct SuggestWithSpanOnly { - #[suggestion(typeck::suggestion, code = "This is suggested code")] + #[suggestion(suggestion, code = "This is suggested code")] suggestion: Span, } -#[derive(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] struct SuggestWithDuplicateSpanAndApplicability { - #[suggestion(typeck::suggestion, code = "This is suggested code")] - //~^ ERROR type of field annotated with `#[suggestion(...)]` contains more than one `Span` + #[suggestion(suggestion, code = "This is suggested code")] suggestion: (Span, Span, Applicability), + //~^ ERROR specified multiple times } -#[derive(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] struct SuggestWithDuplicateApplicabilityAndSpan { - #[suggestion(typeck::suggestion, code = "This is suggested code")] - //~^ ERROR type of field annotated with `#[suggestion(...)]` contains more than one + #[suggestion(suggestion, code = "This is suggested code")] suggestion: (Applicability, Applicability, Span), + //~^ ERROR specified multiple times } -#[derive(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] struct WrongKindOfAnnotation { #[label = "bar"] //~^ ERROR `#[label = ...]` is not a valid attribute z: Span, } -#[derive(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] struct OptionsInErrors { - #[label(typeck::label)] + #[label(label)] label: Option, - #[suggestion(typeck::suggestion)] + #[suggestion(suggestion, code = "...")] opt_sugg: Option<(Span, Applicability)>, } -#[derive(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0456")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0456")] struct MoveOutOfBorrowError<'tcx> { name: Ident, ty: Ty<'tcx>, #[primary_span] - #[label(typeck::label)] + #[label(label)] span: Span, - #[label(typeck::label)] + #[label(label)] other_span: Span, - #[suggestion(typeck::suggestion, code = "{name}.clone()")] + #[suggestion(suggestion, code = "{name}.clone()")] opt_sugg: Option<(Span, Applicability)>, } -#[derive(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] struct ErrorWithLifetime<'a> { - #[label(typeck::label)] + #[label(label)] span: Span, name: &'a str, } -#[derive(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] struct ErrorWithDefaultLabelAttr<'a> { #[label] span: Span, name: &'a str, } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] //~^ ERROR the trait bound `Hello: IntoDiagnosticArg` is not satisfied -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct ArgFieldWithoutSkip { #[primary_span] span: Span, other: Hello, } -#[derive(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] struct ArgFieldWithSkip { #[primary_span] span: Span, @@ -348,236 +355,444 @@ struct ArgFieldWithSkip { other: Hello, } -#[derive(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] struct ErrorWithSpannedNote { #[note] span: Span, } -#[derive(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] struct ErrorWithSpannedNoteCustom { - #[note(typeck::note)] + #[note(note)] span: Span, } -#[derive(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] #[note] struct ErrorWithNote { val: String, } -#[derive(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] -#[note(typeck::note)] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +#[note(note)] struct ErrorWithNoteCustom { val: String, } -#[derive(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] struct ErrorWithSpannedHelp { #[help] span: Span, } -#[derive(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] struct ErrorWithSpannedHelpCustom { - #[help(typeck::help)] + #[help(help)] span: Span, } -#[derive(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] #[help] struct ErrorWithHelp { val: String, } -#[derive(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] -#[help(typeck::help)] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +#[help(help)] struct ErrorWithHelpCustom { val: String, } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[help] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct ErrorWithHelpWrongOrder { val: String, } -#[derive(SessionDiagnostic)] -#[help(typeck::help)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[help(help)] +#[diag(compiletest_example, code = "E0123")] struct ErrorWithHelpCustomWrongOrder { val: String, } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[note] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct ErrorWithNoteWrongOrder { val: String, } -#[derive(SessionDiagnostic)] -#[note(typeck::note)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[note(note)] +#[diag(compiletest_example, code = "E0123")] struct ErrorWithNoteCustomWrongOrder { val: String, } -#[derive(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] struct ApplicabilityInBoth { - #[suggestion(typeck::suggestion, code = "...", applicability = "maybe-incorrect")] - //~^ ERROR applicability cannot be set in both the field and attribute + #[suggestion(suggestion, code = "...", applicability = "maybe-incorrect")] + //~^ ERROR specified multiple times suggestion: (Span, Applicability), } -#[derive(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] struct InvalidApplicability { - #[suggestion(typeck::suggestion, code = "...", applicability = "batman")] + #[suggestion(suggestion, code = "...", applicability = "batman")] //~^ ERROR invalid applicability suggestion: Span, } -#[derive(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] struct ValidApplicability { - #[suggestion(typeck::suggestion, code = "...", applicability = "maybe-incorrect")] + #[suggestion(suggestion, code = "...", applicability = "maybe-incorrect")] suggestion: Span, } -#[derive(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] struct NoApplicability { - #[suggestion(typeck::suggestion, code = "...")] + #[suggestion(suggestion, code = "...")] suggestion: Span, } -#[derive(SessionSubdiagnostic)] -#[note(parser::add_paren)] +#[derive(Subdiagnostic)] +#[note(parser_add_paren)] struct Note; -#[derive(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound)] +#[derive(Diagnostic)] +#[diag(compiletest_example)] struct Subdiagnostic { #[subdiagnostic] note: Note, } -#[derive(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] struct VecField { #[primary_span] #[label] spans: Vec, } -#[derive(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] struct UnitField { #[primary_span] spans: Span, #[help] foo: (), - #[help(typeck::help)] + #[help(help)] bar: (), } -#[derive(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] struct OptUnitField { #[primary_span] spans: Span, #[help] foo: Option<()>, - #[help(typeck::help)] + #[help(help)] bar: Option<()>, } -#[derive(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] struct LabelWithTrailingPath { - #[label(typeck::label, foo)] - //~^ ERROR `#[label(...)]` is not a valid attribute + #[label(label, foo)] + //~^ ERROR `#[label(foo)]` is not a valid attribute span: Span, } -#[derive(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] struct LabelWithTrailingNameValue { - #[label(typeck::label, foo = "...")] - //~^ ERROR `#[label(...)]` is not a valid attribute + #[label(label, foo = "...")] + //~^ ERROR `#[label(foo = ...)]` is not a valid attribute span: Span, } -#[derive(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] struct LabelWithTrailingList { - #[label(typeck::label, foo("..."))] - //~^ ERROR `#[label(...)]` is not a valid attribute + #[label(label, foo("..."))] + //~^ ERROR `#[label(foo(...))]` is not a valid attribute span: Span, } #[derive(LintDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound)] +#[diag(compiletest_example)] struct LintsGood { } #[derive(LintDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound)] +#[diag(compiletest_example)] struct PrimarySpanOnLint { #[primary_span] //~^ ERROR `#[primary_span]` is not a valid attribute span: Span, } -#[derive(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] struct ErrorWithMultiSpan { #[primary_span] span: MultiSpan, } -#[derive(SessionDiagnostic)] -#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] #[warning] struct ErrorWithWarn { val: String, } -#[derive(SessionDiagnostic)] -#[error(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[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(SessionDiagnostic)] -#[warn_(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[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(SessionDiagnostic)] -#[lint(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[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(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[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(bad)]` 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_short( + 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, +} diff --git a/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr b/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr index ab5c28fe4..859c272b6 100644 --- a/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr +++ b/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr @@ -1,50 +1,59 @@ -error: `#[derive(SessionDiagnostic)]` can only be used on structs +error: unsupported type attribute for diagnostic derive enum --> $DIR/diagnostic-derive.rs:39:1 | -LL | / #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] -LL | | -LL | | enum SessionDiagnosticOnEnum { -LL | | Foo, -LL | | Bar, -LL | | } - | |_^ +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:48:1 + --> $DIR/diagnostic-derive.rs:50:1 | LL | #[diag = "E0123"] | ^^^^^^^^^^^^^^^^^ error: `#[nonsense(...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:53:1 + --> $DIR/diagnostic-derive.rs:55:1 | -LL | #[nonsense(typeck::ambiguous_lifetime_bound, code = "E0123")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: only `diag`, `help`, `note` and `warning` are valid attributes +LL | #[nonsense(compiletest_example, code = "E0123")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: diagnostic slug not specified - --> $DIR/diagnostic-derive.rs:53:1 + --> $DIR/diagnostic-derive.rs:55:1 | -LL | / #[nonsense(typeck::ambiguous_lifetime_bound, code = "E0123")] +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(typeck::example_error)]` + = 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:60:8 + --> $DIR/diagnostic-derive.rs:62:8 | LL | #[diag("E0123")] | ^^^^^^^ | - = help: first argument of the attribute should be the diagnostic slug + = help: a diagnostic slug is required as the first argument error: diagnostic slug not specified - --> $DIR/diagnostic-derive.rs:60:1 + --> $DIR/diagnostic-derive.rs:62:1 | LL | / #[diag("E0123")] LL | | @@ -52,18 +61,18 @@ LL | | LL | | struct InvalidLitNestedAttr {} | |______________________________^ | - = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(typeck::example_error)]` + = 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:71:8 + --> $DIR/diagnostic-derive.rs:73:8 | LL | #[diag(nonsense("foo"), code = "E0123", slug = "foo")] | ^^^^^^^^^^^^^^^ | - = help: first argument of the attribute should be the diagnostic slug + = help: a diagnostic slug is required as the first argument error: diagnostic slug not specified - --> $DIR/diagnostic-derive.rs:71:1 + --> $DIR/diagnostic-derive.rs:73:1 | LL | / #[diag(nonsense("foo"), code = "E0123", slug = "foo")] LL | | @@ -71,252 +80,300 @@ LL | | LL | | struct InvalidNestedStructAttr1 {} | |__________________________________^ | - = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(typeck::example_error)]` + = 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:77:8 + --> $DIR/diagnostic-derive.rs:79:8 | LL | #[diag(nonsense = "...", code = "E0123", slug = "foo")] | ^^^^^^^^^^^^^^^^ | - = help: first argument of the attribute should be the diagnostic slug + = 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:77:1 + --> $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(typeck::example_error)]` + = 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:83:8 + --> $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 | - = help: first argument of the attribute should be the diagnostic slug +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:83:1 + --> $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(typeck::example_error)]` + = 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:89:58 + --> $DIR/diagnostic-derive.rs:93:45 | -LL | #[diag(typeck::ambiguous_lifetime_bound, code = "E0123", slug = "foo")] - | ^^^^^^^^^^^^ +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:96:5 + --> $DIR/diagnostic-derive.rs:100:5 | LL | #[suggestion = "bar"] | ^^^^^^^^^^^^^^^^^^^^^ error: specified multiple times - --> $DIR/diagnostic-derive.rs:103:1 + --> $DIR/diagnostic-derive.rs:107:8 | -LL | #[diag(typeck::ambiguous_lifetime_bound, code = "E0456")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[diag(compiletest_example, code = "E0456")] + | ^^^^^^^^^^^^^^^^^^^ | note: previously specified here - --> $DIR/diagnostic-derive.rs:102:1 + --> $DIR/diagnostic-derive.rs:106:8 | -LL | #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[diag(compiletest_example, code = "E0123")] + | ^^^^^^^^^^^^^^^^^^^ error: specified multiple times - --> $DIR/diagnostic-derive.rs:103:49 + --> $DIR/diagnostic-derive.rs:107:36 | -LL | #[diag(typeck::ambiguous_lifetime_bound, code = "E0456")] - | ^^^^^^^ +LL | #[diag(compiletest_example, code = "E0456")] + | ^^^^^^^ | note: previously specified here - --> $DIR/diagnostic-derive.rs:102:49 + --> $DIR/diagnostic-derive.rs:106:36 | -LL | #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")] - | ^^^^^^^ +LL | #[diag(compiletest_example, code = "E0123")] + | ^^^^^^^ error: specified multiple times - --> $DIR/diagnostic-derive.rs:109:65 + --> $DIR/diagnostic-derive.rs:113:52 | -LL | #[diag(typeck::ambiguous_lifetime_bound, code = "E0456", code = "E0457")] - | ^^^^^^^ +LL | #[diag(compiletest_example, code = "E0456", code = "E0457")] + | ^^^^^^^ | note: previously specified here - --> $DIR/diagnostic-derive.rs:109:49 + --> $DIR/diagnostic-derive.rs:113:36 | -LL | #[diag(typeck::ambiguous_lifetime_bound, code = "E0456", code = "E0457")] - | ^^^^^^^ +LL | #[diag(compiletest_example, code = "E0456", code = "E0457")] + | ^^^^^^^ -error: `#[diag(typeck::ambiguous_lifetime_bound)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:114:42 +error: `#[diag(compiletest_example)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:118:29 + | +LL | #[diag(compiletest_example, compiletest_example, code = "E0456")] + | ^^^^^^^^^^^^^^^^^^^ | -LL | #[diag(typeck::ambiguous_lifetime_bound, typeck::ambiguous_lifetime_bound, code = "E0456")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = help: diagnostic slug must be the first argument error: diagnostic slug not specified - --> $DIR/diagnostic-derive.rs:119:1 + --> $DIR/diagnostic-derive.rs:123:1 | LL | struct KindNotProvided {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(typeck::example_error)]` + = 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:122:1 + --> $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(typeck::example_error)]` + = 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:133:5 + --> $DIR/diagnostic-derive.rs:137:5 | LL | #[primary_span] | ^^^^^^^^^^^^^^^ error: `#[nonsense]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:141:5 + --> $DIR/diagnostic-derive.rs:145:5 | LL | #[nonsense] | ^^^^^^^^^^^ - | - = help: only `skip_arg`, `primary_span`, `label`, `note`, `help` and `subdiagnostic` are valid field attributes error: the `#[label(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan` - --> $DIR/diagnostic-derive.rs:158:5 + --> $DIR/diagnostic-derive.rs:162:5 | -LL | #[label(typeck::label)] - | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[label(label)] + | ^^^^^^^^^^^^^^^ error: `name` doesn't refer to a field on this type - --> $DIR/diagnostic-derive.rs:166:45 + --> $DIR/diagnostic-derive.rs:170:37 | -LL | #[suggestion(typeck::suggestion, code = "{name}")] - | ^^^^^^^^ +LL | #[suggestion(suggestion, code = "{name}")] + | ^^^^^^^^ error: invalid format string: expected `'}'` but string was terminated - --> $DIR/diagnostic-derive.rs:171:16 + --> $DIR/diagnostic-derive.rs:175:10 | -LL | #[derive(SessionDiagnostic)] - | - ^ expected `'}'` in format string - | | - | because of this opening brace +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 `SessionDiagnostic` (in Nightly builds, run with -Z macro-backtrace for more info) + = 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:181:15 + --> $DIR/diagnostic-derive.rs:185:10 | -LL | #[derive(SessionDiagnostic)] - | ^ unmatched `}` in format string +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 `SessionDiagnostic` (in Nightly builds, run with -Z macro-backtrace for more info) + = 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:201:5 + --> $DIR/diagnostic-derive.rs:205:5 | -LL | #[label(typeck::label)] - | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[label(label)] + | ^^^^^^^^^^^^^^^ + +error: suggestion without `code = "..."` + --> $DIR/diagnostic-derive.rs:223:5 + | +LL | #[suggestion(suggestion)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: `#[suggestion(nonsense = ...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:226:18 + --> $DIR/diagnostic-derive.rs:231:18 | LL | #[suggestion(nonsense = "bar")] | ^^^^^^^^^^^^^^^^ | - = help: only `message`, `code` and `applicability` are valid field attributes + = help: only `code` and `applicability` are valid nested attributes + +error: suggestion without `code = "..."` + --> $DIR/diagnostic-derive.rs:231:5 + | +LL | #[suggestion(nonsense = "bar")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `#[suggestion(msg = ...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:234:18 + --> $DIR/diagnostic-derive.rs:240:18 | LL | #[suggestion(msg = "bar")] | ^^^^^^^^^^^ | - = help: only `message`, `code` and `applicability` are valid field attributes + = help: only `code` and `applicability` are valid nested attributes + +error: suggestion without `code = "..."` + --> $DIR/diagnostic-derive.rs:240:5 + | +LL | #[suggestion(msg = "bar")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: wrong field type for suggestion - --> $DIR/diagnostic-derive.rs:256:5 + --> $DIR/diagnostic-derive.rs:263:5 | -LL | / #[suggestion(typeck::suggestion, code = "This is suggested code")] +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: type of field annotated with `#[suggestion(...)]` contains more than one `Span` - --> $DIR/diagnostic-derive.rs:271:5 +error: specified multiple times + --> $DIR/diagnostic-derive.rs:279:24 | -LL | / #[suggestion(typeck::suggestion, code = "This is suggested code")] -LL | | -LL | | suggestion: (Span, Span, Applicability), - | |___________________________________________^ +LL | suggestion: (Span, Span, Applicability), + | ^^^^ + | +note: previously specified here + --> $DIR/diagnostic-derive.rs:279:18 + | +LL | suggestion: (Span, Span, Applicability), + | ^^^^ -error: type of field annotated with `#[suggestion(...)]` contains more than one Applicability - --> $DIR/diagnostic-derive.rs:279:5 +error: specified multiple times + --> $DIR/diagnostic-derive.rs:287:33 | -LL | / #[suggestion(typeck::suggestion, code = "This is suggested code")] -LL | | -LL | | suggestion: (Applicability, Applicability, Span), - | |____________________________________________________^ +LL | suggestion: (Applicability, Applicability, Span), + | ^^^^^^^^^^^^^ + | +note: previously specified here + --> $DIR/diagnostic-derive.rs:287:18 + | +LL | suggestion: (Applicability, Applicability, Span), + | ^^^^^^^^^^^^^ error: `#[label = ...]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:287:5 + --> $DIR/diagnostic-derive.rs:294:5 | LL | #[label = "bar"] | ^^^^^^^^^^^^^^^^ -error: applicability cannot be set in both the field and attribute - --> $DIR/diagnostic-derive.rs:438:52 +error: specified multiple times + --> $DIR/diagnostic-derive.rs:445:44 + | +LL | #[suggestion(suggestion, code = "...", applicability = "maybe-incorrect")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: previously specified here + --> $DIR/diagnostic-derive.rs:447:24 | -LL | #[suggestion(typeck::suggestion, code = "...", applicability = "maybe-incorrect")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | suggestion: (Span, Applicability), + | ^^^^^^^^^^^^^ error: invalid applicability - --> $DIR/diagnostic-derive.rs:446:52 + --> $DIR/diagnostic-derive.rs:453:44 | -LL | #[suggestion(typeck::suggestion, code = "...", applicability = "batman")] - | ^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[suggestion(suggestion, code = "...", applicability = "batman")] + | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: `#[label(...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:509:5 +error: `#[label(foo)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:516:20 | -LL | #[label(typeck::label, foo)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[label(label, foo)] + | ^^^ + | + = help: a diagnostic slug must be the first argument to the attribute -error: `#[label(...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:517:5 +error: `#[label(foo = ...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:524:20 | -LL | #[label(typeck::label, foo = "...")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[label(label, foo = "...")] + | ^^^^^^^^^^^ -error: `#[label(...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:525:5 +error: `#[label(foo(...))]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:532:20 | -LL | #[label(typeck::label, foo("..."))] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[label(label, foo("..."))] + | ^^^^^^^^^^ error: `#[primary_span]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:538:5 + --> $DIR/diagnostic-derive.rs:545:5 | LL | #[primary_span] | ^^^^^^^^^^^^^^^ @@ -324,132 +381,281 @@ 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:558:1 - | -LL | #[error(typeck::ambiguous_lifetime_bound, code = "E0123")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + --> $DIR/diagnostic-derive.rs:565:1 | - = help: `error` and `lint` have been replaced by `diag` +LL | #[error(compiletest_example, code = "E0123")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: diagnostic slug not specified - --> $DIR/diagnostic-derive.rs:558:1 + --> $DIR/diagnostic-derive.rs:565:1 | -LL | / #[error(typeck::ambiguous_lifetime_bound, code = "E0123")] +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(typeck::example_error)]` + = 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:565:1 - | -LL | #[warn_(typeck::ambiguous_lifetime_bound, code = "E0123")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + --> $DIR/diagnostic-derive.rs:572:1 | - = help: `warn_` have been replaced by `warning` +LL | #[warn_(compiletest_example, code = "E0123")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: diagnostic slug not specified - --> $DIR/diagnostic-derive.rs:565:1 + --> $DIR/diagnostic-derive.rs:572:1 | -LL | / #[warn_(typeck::ambiguous_lifetime_bound, code = "E0123")] +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(typeck::example_error)]` + = 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:572:1 - | -LL | #[lint(typeck::ambiguous_lifetime_bound, code = "E0123")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + --> $DIR/diagnostic-derive.rs:579:1 | - = help: `error` and `lint` have been replaced by `diag` +LL | #[lint(compiletest_example, code = "E0123")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: diagnostic slug not specified - --> $DIR/diagnostic-derive.rs:572:1 + --> $DIR/diagnostic-derive.rs:579:1 | -LL | / #[lint(typeck::ambiguous_lifetime_bound, code = "E0123")] +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(typeck::example_error)]` + = 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 + --> $DIR/diagnostic-derive.rs:586:1 | -LL | #[lint(typeck::ambiguous_lifetime_bound, code = "E0123")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[lint(compiletest_example, code = "E0123")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `#[lint(...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:586:1 | - = help: `error` and `lint` have been replaced by `diag` +LL | #[lint(compiletest_example, code = "E0123")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: diagnostic slug not specified - --> $DIR/diagnostic-derive.rs:579:1 + --> $DIR/diagnostic-derive.rs:586:1 | -LL | / #[lint(typeck::ambiguous_lifetime_bound, code = "E0123")] +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(typeck::example_error)]` + = 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(bad)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:685:21 + | +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"] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: `eager` is the only supported nested attribute for `subdiagnostic` + +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:21 + | +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:779:18 + | +LL | #[suggestion(code())] + | ^^^^^^ + +error: `code(...)` must contain only string literals + --> $DIR/diagnostic-derive.rs:787:23 + | +LL | #[suggestion(code(foo))] + | ^^^ + +error: `code = "..."`/`code(...)` must contain only string literals + --> $DIR/diagnostic-derive.rs:795:18 + | +LL | #[suggestion(code = 3)] + | ^^^^^^^^ error: cannot find attribute `nonsense` in this scope - --> $DIR/diagnostic-derive.rs:53:3 + --> $DIR/diagnostic-derive.rs:55:3 | -LL | #[nonsense(typeck::ambiguous_lifetime_bound, code = "E0123")] +LL | #[nonsense(compiletest_example, code = "E0123")] | ^^^^^^^^ error: cannot find attribute `nonsense` in this scope - --> $DIR/diagnostic-derive.rs:141:7 + --> $DIR/diagnostic-derive.rs:145:7 | LL | #[nonsense] | ^^^^^^^^ error: cannot find attribute `error` in this scope - --> $DIR/diagnostic-derive.rs:558:3 + --> $DIR/diagnostic-derive.rs:565:3 | -LL | #[error(typeck::ambiguous_lifetime_bound, code = "E0123")] +LL | #[error(compiletest_example, code = "E0123")] | ^^^^^ error: cannot find attribute `warn_` in this scope - --> $DIR/diagnostic-derive.rs:565:3 + --> $DIR/diagnostic-derive.rs:572:3 | -LL | #[warn_(typeck::ambiguous_lifetime_bound, code = "E0123")] +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:572:3 + --> $DIR/diagnostic-derive.rs:579:3 | -LL | #[lint(typeck::ambiguous_lifetime_bound, code = "E0123")] +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:579:3 + --> $DIR/diagnostic-derive.rs:586:3 | -LL | #[lint(typeck::ambiguous_lifetime_bound, code = "E0123")] +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:66:8 + --> $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:331:10 + --> $DIR/diagnostic-derive.rs:338:10 | -LL | #[derive(SessionDiagnostic)] - | ^^^^^^^^^^^^^^^^^ the trait `IntoDiagnosticArg` is not implemented for `Hello` +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` @@ -457,9 +663,9 @@ note: required by a bound in `DiagnosticBuilder::<'a, G>::set_arg` | LL | arg: impl IntoDiagnosticArg, | ^^^^^^^^^^^^^^^^^ required by this bound in `DiagnosticBuilder::<'a, G>::set_arg` - = note: this error originates in the derive macro `SessionDiagnostic` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the derive macro `Diagnostic` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 55 previous errors +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/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs b/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs index 812ca0c72..efec85eb5 100644 --- a/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs +++ b/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs @@ -1,8 +1,8 @@ // check-fail -// Tests error conditions for specifying subdiagnostics using #[derive(SessionSubdiagnostic)] +// 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 SessionSubdiagnostic is strictly internal to the compiler +// 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 @@ -17,25 +17,25 @@ extern crate rustc_macros; use rustc_errors::Applicability; use rustc_span::Span; -use rustc_macros::SessionSubdiagnostic; +use rustc_macros::Subdiagnostic; -#[derive(SessionSubdiagnostic)] -#[label(parser::add_paren)] +#[derive(Subdiagnostic)] +#[label(parser_add_paren)] struct A { #[primary_span] span: Span, var: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] enum B { - #[label(parser::add_paren)] + #[label(parser_add_paren)] A { #[primary_span] span: Span, var: String, }, - #[label(parser::add_paren)] + #[label(parser_add_paren)] B { #[primary_span] span: Span, @@ -43,23 +43,23 @@ enum B { } } -#[derive(SessionSubdiagnostic)] -#[label(parser::add_paren)] +#[derive(Subdiagnostic)] +#[label(parser_add_paren)] //~^ ERROR label without `#[primary_span]` field struct C { var: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[label] -//~^ ERROR `#[label]` is not a valid attribute +//~^ ERROR diagnostic slug must be first argument struct D { #[primary_span] span: Span, var: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[foo] //~^ ERROR `#[foo]` is not a valid attribute //~^^ ERROR cannot find attribute `foo` in this scope @@ -69,7 +69,7 @@ struct E { var: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[label = "..."] //~^ ERROR `#[label = ...]` is not a valid attribute struct F { @@ -78,43 +78,47 @@ struct F { var: String, } -#[derive(SessionSubdiagnostic)] +#[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(SessionSubdiagnostic)] +#[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(SessionSubdiagnostic)] +#[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(SessionSubdiagnostic)] +#[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(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[label(slug)] //~^ ERROR cannot find value `slug` in module `rustc_errors::fluent` //~^^ NOTE not found in `rustc_errors::fluent` @@ -124,7 +128,7 @@ struct L { var: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[label()] //~^ ERROR diagnostic slug must be first argument of a `#[label(...)]` attribute struct M { @@ -133,30 +137,30 @@ struct M { var: String, } -#[derive(SessionSubdiagnostic)] -#[label(parser::add_paren, code = "...")] -//~^ ERROR `code` is not a valid nested attribute of a `label` attribute +#[derive(Subdiagnostic)] +#[label(parser_add_paren, code = "...")] +//~^ ERROR `#[label(code = ...)]` is not a valid attribute struct N { #[primary_span] span: Span, var: String, } -#[derive(SessionSubdiagnostic)] -#[label(parser::add_paren, applicability = "machine-applicable")] -//~^ ERROR `applicability` is not a valid nested attribute of a `label` attribute +#[derive(Subdiagnostic)] +#[label(parser_add_paren, applicability = "machine-applicable")] +//~^ ERROR `#[label(applicability = ...)]` is not a valid attribute struct O { #[primary_span] span: Span, var: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[foo] //~^ ERROR cannot find attribute `foo` in this scope //~^^ ERROR unsupported type attribute for subdiagnostic enum enum P { - #[label(parser::add_paren)] + #[label(parser_add_paren)] A { #[primary_span] span: Span, @@ -164,7 +168,7 @@ enum P { } } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] enum Q { #[bar] //~^ ERROR `#[bar]` is not a valid attribute @@ -176,7 +180,7 @@ enum Q { } } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] enum R { #[bar = "..."] //~^ ERROR `#[bar = ...]` is not a valid attribute @@ -188,7 +192,7 @@ enum R { } } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] enum S { #[bar = 4] //~^ ERROR `#[bar = ...]` is not a valid attribute @@ -200,7 +204,7 @@ enum S { } } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] enum T { #[bar("...")] //~^ ERROR `#[bar(...)]` is not a valid attribute @@ -212,10 +216,11 @@ enum T { } } -#[derive(SessionSubdiagnostic)] +#[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, @@ -223,24 +228,23 @@ enum U { } } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] enum V { - #[label(parser::add_paren)] + #[label(parser_add_paren)] A { #[primary_span] span: Span, var: String, }, B { - //~^ ERROR subdiagnostic kind not specified #[primary_span] span: Span, var: String, } } -#[derive(SessionSubdiagnostic)] -#[label(parser::add_paren)] +#[derive(Subdiagnostic)] +#[label(parser_add_paren)] //~^ ERROR label without `#[primary_span]` field struct W { #[primary_span] @@ -248,8 +252,8 @@ struct W { span: String, } -#[derive(SessionSubdiagnostic)] -#[label(parser::add_paren)] +#[derive(Subdiagnostic)] +#[label(parser_add_paren)] struct X { #[primary_span] span: Span, @@ -258,8 +262,8 @@ struct X { applicability: Applicability, } -#[derive(SessionSubdiagnostic)] -#[label(parser::add_paren)] +#[derive(Subdiagnostic)] +#[label(parser_add_paren)] struct Y { #[primary_span] span: Span, @@ -269,8 +273,8 @@ struct Y { bar: String, } -#[derive(SessionSubdiagnostic)] -#[label(parser::add_paren)] +#[derive(Subdiagnostic)] +#[label(parser_add_paren)] struct Z { #[primary_span] span: Span, @@ -280,8 +284,8 @@ struct Z { bar: String, } -#[derive(SessionSubdiagnostic)] -#[label(parser::add_paren)] +#[derive(Subdiagnostic)] +#[label(parser_add_paren)] struct AA { #[primary_span] span: Span, @@ -291,8 +295,8 @@ struct AA { bar: String, } -#[derive(SessionSubdiagnostic)] -#[label(parser::add_paren)] +#[derive(Subdiagnostic)] +#[label(parser_add_paren)] struct AB { #[primary_span] span: Span, @@ -300,31 +304,31 @@ struct AB { z: Z } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] union AC { //~^ ERROR unexpected unsupported untagged union span: u32, b: u64 } -#[derive(SessionSubdiagnostic)] -#[label(parser::add_paren)] -#[label(parser::add_paren)] +#[derive(Subdiagnostic)] +#[label(parser_add_paren)] +#[label(parser_add_paren)] struct AD { #[primary_span] span: Span, } -#[derive(SessionSubdiagnostic)] -#[label(parser::add_paren, parser::add_paren)] -//~^ ERROR `#[label(parser::add_paren)]` is not a valid attribute +#[derive(Subdiagnostic)] +#[label(parser_add_paren, parser_add_paren)] +//~^ ERROR `#[label(parser_add_paren)]` is not a valid attribute struct AE { #[primary_span] span: Span, } -#[derive(SessionSubdiagnostic)] -#[label(parser::add_paren)] +#[derive(Subdiagnostic)] +#[label(parser_add_paren)] struct AF { #[primary_span] //~^ NOTE previously specified here @@ -334,15 +338,15 @@ struct AF { span_b: Span, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] struct AG { //~^ ERROR subdiagnostic kind not specified #[primary_span] span: Span, } -#[derive(SessionSubdiagnostic)] -#[suggestion(parser::add_paren, code = "...")] +#[derive(Subdiagnostic)] +#[suggestion(parser_add_paren, code = "...")] struct AH { #[primary_span] span: Span, @@ -351,9 +355,9 @@ struct AH { var: String, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] enum AI { - #[suggestion(parser::add_paren, code = "...")] + #[suggestion(parser_add_paren, code = "...")] A { #[primary_span] span: Span, @@ -361,7 +365,7 @@ enum AI { applicability: Applicability, var: String, }, - #[suggestion(parser::add_paren, code = "...")] + #[suggestion(parser_add_paren, code = "...")] B { #[primary_span] span: Span, @@ -371,8 +375,8 @@ enum AI { } } -#[derive(SessionSubdiagnostic)] -#[suggestion(parser::add_paren, code = "...", code = "...")] +#[derive(Subdiagnostic)] +#[suggestion(parser_add_paren, code = "...", code = "...")] //~^ ERROR specified multiple times //~^^ NOTE previously specified here struct AJ { @@ -382,8 +386,8 @@ struct AJ { applicability: Applicability, } -#[derive(SessionSubdiagnostic)] -#[suggestion(parser::add_paren, code = "...")] +#[derive(Subdiagnostic)] +#[suggestion(parser_add_paren, code = "...")] struct AK { #[primary_span] span: Span, @@ -395,8 +399,8 @@ struct AK { applicability_b: Applicability, } -#[derive(SessionSubdiagnostic)] -#[suggestion(parser::add_paren, code = "...")] +#[derive(Subdiagnostic)] +#[suggestion(parser_add_paren, code = "...")] struct AL { #[primary_span] span: Span, @@ -405,15 +409,15 @@ struct AL { applicability: Span, } -#[derive(SessionSubdiagnostic)] -#[suggestion(parser::add_paren, code = "...")] +#[derive(Subdiagnostic)] +#[suggestion(parser_add_paren, code = "...")] struct AM { #[primary_span] span: Span, } -#[derive(SessionSubdiagnostic)] -#[suggestion(parser::add_paren)] +#[derive(Subdiagnostic)] +#[suggestion(parser_add_paren)] //~^ ERROR suggestion without `code = "..."` struct AN { #[primary_span] @@ -422,43 +426,43 @@ struct AN { applicability: Applicability, } -#[derive(SessionSubdiagnostic)] -#[suggestion(parser::add_paren, code ="...", applicability = "foo")] +#[derive(Subdiagnostic)] +#[suggestion(parser_add_paren, code ="...", applicability = "foo")] //~^ ERROR invalid applicability struct AO { #[primary_span] span: Span, } -#[derive(SessionSubdiagnostic)] -#[help(parser::add_paren)] +#[derive(Subdiagnostic)] +#[help(parser_add_paren)] struct AP { var: String } -#[derive(SessionSubdiagnostic)] -#[note(parser::add_paren)] +#[derive(Subdiagnostic)] +#[note(parser_add_paren)] struct AQ; -#[derive(SessionSubdiagnostic)] -#[suggestion(parser::add_paren, code = "...")] +#[derive(Subdiagnostic)] +#[suggestion(parser_add_paren, code = "...")] //~^ ERROR suggestion without `#[primary_span]` field struct AR { var: String, } -#[derive(SessionSubdiagnostic)] -#[suggestion(parser::add_paren, code ="...", applicability = "machine-applicable")] +#[derive(Subdiagnostic)] +#[suggestion(parser_add_paren, code ="...", applicability = "machine-applicable")] struct AS { #[primary_span] span: Span, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] #[label] //~^ ERROR unsupported type attribute for subdiagnostic enum enum AT { - #[label(parser::add_paren)] + #[label(parser_add_paren)] A { #[primary_span] span: Span, @@ -466,25 +470,25 @@ enum AT { } } -#[derive(SessionSubdiagnostic)] -#[suggestion(parser::add_paren, code ="{var}", applicability = "machine-applicable")] +#[derive(Subdiagnostic)] +#[suggestion(parser_add_paren, code ="{var}", applicability = "machine-applicable")] struct AU { #[primary_span] span: Span, var: String, } -#[derive(SessionSubdiagnostic)] -#[suggestion(parser::add_paren, code ="{var}", applicability = "machine-applicable")] +#[derive(Subdiagnostic)] +#[suggestion(parser_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(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] enum AW { - #[suggestion(parser::add_paren, code ="{var}", applicability = "machine-applicable")] + #[suggestion(parser_add_paren, code ="{var}", applicability = "machine-applicable")] A { #[primary_span] span: Span, @@ -492,9 +496,9 @@ enum AW { } } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] enum AX { - #[suggestion(parser::add_paren, code ="{var}", applicability = "machine-applicable")] + #[suggestion(parser_add_paren, code ="{var}", applicability = "machine-applicable")] //~^ ERROR `var` doesn't refer to a field on this type A { #[primary_span] @@ -502,19 +506,19 @@ enum AX { } } -#[derive(SessionSubdiagnostic)] -#[warning(parser::add_paren)] +#[derive(Subdiagnostic)] +#[warning(parser_add_paren)] struct AY {} -#[derive(SessionSubdiagnostic)] -#[warning(parser::add_paren)] +#[derive(Subdiagnostic)] +#[warning(parser_add_paren)] struct AZ { #[primary_span] span: Span, } -#[derive(SessionSubdiagnostic)] -#[suggestion(parser::add_paren, code = "...")] +#[derive(Subdiagnostic)] +#[suggestion(parser_add_paren, code = "...")] //~^ ERROR suggestion without `#[primary_span]` field struct BA { #[suggestion_part] @@ -528,32 +532,32 @@ struct BA { var: String, } -#[derive(SessionSubdiagnostic)] -#[multipart_suggestion(parser::add_paren, code = "...", applicability = "machine-applicable")] +#[derive(Subdiagnostic)] +#[multipart_suggestion(parser_add_paren, code = "...", applicability = "machine-applicable")] //~^ ERROR multipart suggestion without any `#[suggestion_part(...)]` fields -//~| ERROR `code` is not a valid nested attribute of a `multipart_suggestion` attribute +//~| ERROR `#[multipart_suggestion(code = ...)]` is not a valid attribute struct BBa { var: String, } -#[derive(SessionSubdiagnostic)] -#[multipart_suggestion(parser::add_paren, applicability = "machine-applicable")] +#[derive(Subdiagnostic)] +#[multipart_suggestion(parser_add_paren, applicability = "machine-applicable")] struct BBb { #[suggestion_part] //~^ ERROR `#[suggestion_part(...)]` attribute without `code = "..."` span1: Span, } -#[derive(SessionSubdiagnostic)] -#[multipart_suggestion(parser::add_paren, applicability = "machine-applicable")] +#[derive(Subdiagnostic)] +#[multipart_suggestion(parser_add_paren, applicability = "machine-applicable")] struct BBc { #[suggestion_part()] //~^ ERROR `#[suggestion_part(...)]` attribute without `code = "..."` span1: Span, } -#[derive(SessionSubdiagnostic)] -#[multipart_suggestion(parser::add_paren)] +#[derive(Subdiagnostic)] +#[multipart_suggestion(parser_add_paren)] //~^ ERROR multipart suggestion without any `#[suggestion_part(...)]` fields struct BC { #[primary_span] @@ -561,8 +565,8 @@ struct BC { span: Span, } -#[derive(SessionSubdiagnostic)] -#[multipart_suggestion(parser::add_paren)] +#[derive(Subdiagnostic)] +#[multipart_suggestion(parser_add_paren)] struct BD { #[suggestion_part] //~^ ERROR `#[suggestion_part(...)]` attribute without `code = "..."` @@ -581,8 +585,8 @@ struct BD { s2: String, } -#[derive(SessionSubdiagnostic)] -#[multipart_suggestion(parser::add_paren, applicability = "machine-applicable")] +#[derive(Subdiagnostic)] +#[multipart_suggestion(parser_add_paren, applicability = "machine-applicable")] struct BE { #[suggestion_part(code = "...", code = ",,,")] //~^ ERROR specified multiple times @@ -590,8 +594,8 @@ struct BE { span: Span, } -#[derive(SessionSubdiagnostic)] -#[multipart_suggestion(parser::add_paren, applicability = "machine-applicable")] +#[derive(Subdiagnostic)] +#[multipart_suggestion(parser_add_paren, applicability = "machine-applicable")] struct BF { #[suggestion_part(code = "(")] first: Span, @@ -599,8 +603,8 @@ struct BF { second: Span, } -#[derive(SessionSubdiagnostic)] -#[multipart_suggestion(parser::add_paren)] +#[derive(Subdiagnostic)] +#[multipart_suggestion(parser_add_paren)] struct BG { #[applicability] appl: Applicability, @@ -610,12 +614,11 @@ struct BG { second: Span, } -#[derive(SessionSubdiagnostic)] -#[multipart_suggestion(parser::add_paren, applicability = "machine-applicable")] -//~^ NOTE previously specified here +#[derive(Subdiagnostic)] +#[multipart_suggestion(parser_add_paren, applicability = "machine-applicable")] struct BH { #[applicability] - //~^ ERROR specified multiple times + //~^ ERROR `#[applicability]` has no effect appl: Applicability, #[suggestion_part(code = "(")] first: Span, @@ -623,9 +626,83 @@ struct BH { second: Span, } -#[derive(SessionSubdiagnostic)] -#[multipart_suggestion(parser::add_paren, applicability = "machine-applicable")] +#[derive(Subdiagnostic)] +#[multipart_suggestion(parser_add_paren, applicability = "machine-applicable")] struct BI { #[suggestion_part(code = "")] spans: Vec, } + +#[derive(Subdiagnostic)] +#[label(parser_add_paren)] +struct BJ { + #[primary_span] + span: Span, + r#type: String, +} + +/// with a doc comment on the type.. +#[derive(Subdiagnostic)] +#[label(parser_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(parser_add_paren)] + Foo { + /// ..and the field + #[primary_span] + span: Span, + } +} + +#[derive(Subdiagnostic)] +#[multipart_suggestion(parser_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(parser_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(parser_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(parser_add_paren)] +struct BP { + #[suggestion_part(code())] + //~^ ERROR expected exactly one string literal for `code = ...` + span: Span, + r#type: String, +} + +#[derive(Subdiagnostic)] +#[multipart_suggestion(parser_add_paren)] +struct BQ { + #[suggestion_part(code = 3)] + //~^ ERROR `code = "..."`/`code(...)` must contain only string literals + span: Span, + r#type: String, +} diff --git a/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr b/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr index 0a0247e89..a85a8711e 100644 --- a/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr +++ b/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr @@ -1,14 +1,14 @@ error: label without `#[primary_span]` field --> $DIR/subdiagnostic-derive.rs:47:1 | -LL | / #[label(parser::add_paren)] +LL | / #[label(parser_add_paren)] LL | | LL | | struct C { LL | | var: String, LL | | } | |_^ -error: `#[label]` is not a valid attribute +error: diagnostic slug must be first argument of a `#[label(...)]` attribute --> $DIR/subdiagnostic-derive.rs:54:1 | LL | #[label] @@ -31,103 +31,119 @@ error: `#[label(bug = ...)]` is not a valid attribute | LL | #[label(bug = "...")] | ^^^^^^^^^^^ + +error: diagnostic slug must be first argument of a `#[label(...)]` attribute + --> $DIR/subdiagnostic-derive.rs:82:1 | - = help: first argument of the attribute should be the diagnostic slug +LL | #[label(bug = "...")] + | ^^^^^^^^^^^^^^^^^^^^^ error: `#[label("...")]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:91:9 + --> $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 | - = help: first argument of the attribute should be the diagnostic slug +LL | #[label("...")] + | ^^^^^^^^^^^^^^^ error: `#[label(slug = ...)]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:100:9 + --> $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 | - = help: first argument of the attribute should be the diagnostic slug +LL | #[label(slug = 4)] + | ^^^^^^^^^^^^^^^^^^ error: `#[label(slug(...))]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:109:9 + --> $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 | - = help: first argument of the attribute should be the diagnostic slug +LL | #[label(slug("..."))] + | ^^^^^^^^^^^^^^^^^^^^^ error: diagnostic slug must be first argument of a `#[label(...)]` attribute - --> $DIR/subdiagnostic-derive.rs:128:1 + --> $DIR/subdiagnostic-derive.rs:132:1 | LL | #[label()] | ^^^^^^^^^^ -error: `code` is not a valid nested attribute of a `label` attribute - --> $DIR/subdiagnostic-derive.rs:137:28 +error: `#[label(code = ...)]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:141:27 | -LL | #[label(parser::add_paren, code = "...")] - | ^^^^^^^^^^^^ +LL | #[label(parser_add_paren, code = "...")] + | ^^^^^^^^^^^^ -error: `applicability` is not a valid nested attribute of a `label` attribute - --> $DIR/subdiagnostic-derive.rs:146:28 +error: `#[label(applicability = ...)]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:150:27 | -LL | #[label(parser::add_paren, applicability = "machine-applicable")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[label(parser_add_paren, applicability = "machine-applicable")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: unsupported type attribute for subdiagnostic enum - --> $DIR/subdiagnostic-derive.rs:155:1 + --> $DIR/subdiagnostic-derive.rs:159:1 | LL | #[foo] | ^^^^^^ error: `#[bar]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:169:5 + --> $DIR/subdiagnostic-derive.rs:173:5 | LL | #[bar] | ^^^^^^ error: `#[bar = ...]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:181:5 + --> $DIR/subdiagnostic-derive.rs:185:5 | LL | #[bar = "..."] | ^^^^^^^^^^^^^^ error: `#[bar = ...]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:193:5 + --> $DIR/subdiagnostic-derive.rs:197:5 | LL | #[bar = 4] | ^^^^^^^^^^ error: `#[bar(...)]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:205:5 + --> $DIR/subdiagnostic-derive.rs:209:5 | LL | #[bar("...")] | ^^^^^^^^^^^^^ -error: diagnostic slug must be first argument of a `#[label(...)]` attribute - --> $DIR/subdiagnostic-derive.rs:217:5 +error: `#[label(code = ...)]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:221:13 | LL | #[label(code = "...")] - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^ -error: subdiagnostic kind not specified - --> $DIR/subdiagnostic-derive.rs:234:5 +error: diagnostic slug must be first argument of a `#[label(...)]` attribute + --> $DIR/subdiagnostic-derive.rs:221:5 | -LL | B { - | ^ +LL | #[label(code = "...")] + | ^^^^^^^^^^^^^^^^^^^^^^ error: the `#[primary_span]` attribute can only be applied to fields of type `Span` or `MultiSpan` - --> $DIR/subdiagnostic-derive.rs:246:5 + --> $DIR/subdiagnostic-derive.rs:250:5 | LL | #[primary_span] | ^^^^^^^^^^^^^^^ error: label without `#[primary_span]` field - --> $DIR/subdiagnostic-derive.rs:243:1 + --> $DIR/subdiagnostic-derive.rs:247:1 | -LL | / #[label(parser::add_paren)] +LL | / #[label(parser_add_paren)] LL | | LL | | struct W { LL | | #[primary_span] @@ -137,13 +153,13 @@ LL | | } | |_^ error: `#[applicability]` is only valid on suggestions - --> $DIR/subdiagnostic-derive.rs:256:5 + --> $DIR/subdiagnostic-derive.rs:260:5 | LL | #[applicability] | ^^^^^^^^^^^^^^^^ error: `#[bar]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:266:5 + --> $DIR/subdiagnostic-derive.rs:270:5 | LL | #[bar] | ^^^^^^ @@ -151,13 +167,13 @@ 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:277:5 + --> $DIR/subdiagnostic-derive.rs:281:5 | LL | #[bar = "..."] | ^^^^^^^^^^^^^^ error: `#[bar(...)]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:288:5 + --> $DIR/subdiagnostic-derive.rs:292:5 | LL | #[bar("...")] | ^^^^^^^^^^^^^ @@ -165,7 +181,7 @@ LL | #[bar("...")] = help: only `primary_span`, `applicability` and `skip_arg` are valid field attributes error: unexpected unsupported untagged union - --> $DIR/subdiagnostic-derive.rs:304:1 + --> $DIR/subdiagnostic-derive.rs:308:1 | LL | / union AC { LL | | @@ -174,78 +190,78 @@ LL | | b: u64 LL | | } | |_^ -error: `#[label(parser::add_paren)]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:319:28 +error: `#[label(parser_add_paren)]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:323:27 | -LL | #[label(parser::add_paren, parser::add_paren)] - | ^^^^^^^^^^^^^^^^^ +LL | #[label(parser_add_paren, parser_add_paren)] + | ^^^^^^^^^^^^^^^^ | = help: a diagnostic slug must be the first argument to the attribute error: specified multiple times - --> $DIR/subdiagnostic-derive.rs:332:5 + --> $DIR/subdiagnostic-derive.rs:336:5 | LL | #[primary_span] | ^^^^^^^^^^^^^^^ | note: previously specified here - --> $DIR/subdiagnostic-derive.rs:329:5 + --> $DIR/subdiagnostic-derive.rs:333:5 | LL | #[primary_span] | ^^^^^^^^^^^^^^^ error: subdiagnostic kind not specified - --> $DIR/subdiagnostic-derive.rs:338:8 + --> $DIR/subdiagnostic-derive.rs:342:8 | LL | struct AG { | ^^ error: specified multiple times - --> $DIR/subdiagnostic-derive.rs:375:47 + --> $DIR/subdiagnostic-derive.rs:379:46 | -LL | #[suggestion(parser::add_paren, code = "...", code = "...")] - | ^^^^^^^^^^^^ +LL | #[suggestion(parser_add_paren, code = "...", code = "...")] + | ^^^^^^^^^^^^ | note: previously specified here - --> $DIR/subdiagnostic-derive.rs:375:33 + --> $DIR/subdiagnostic-derive.rs:379:32 | -LL | #[suggestion(parser::add_paren, code = "...", code = "...")] - | ^^^^^^^^^^^^ +LL | #[suggestion(parser_add_paren, code = "...", code = "...")] + | ^^^^^^^^^^^^ error: specified multiple times - --> $DIR/subdiagnostic-derive.rs:393:5 + --> $DIR/subdiagnostic-derive.rs:397:5 | LL | #[applicability] | ^^^^^^^^^^^^^^^^ | note: previously specified here - --> $DIR/subdiagnostic-derive.rs:390:5 + --> $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:403:5 + --> $DIR/subdiagnostic-derive.rs:407:5 | LL | #[applicability] | ^^^^^^^^^^^^^^^^ error: suggestion without `code = "..."` - --> $DIR/subdiagnostic-derive.rs:416:1 + --> $DIR/subdiagnostic-derive.rs:420:1 | -LL | #[suggestion(parser::add_paren)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[suggestion(parser_add_paren)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: invalid applicability - --> $DIR/subdiagnostic-derive.rs:426:46 + --> $DIR/subdiagnostic-derive.rs:430:45 | -LL | #[suggestion(parser::add_paren, code ="...", applicability = "foo")] - | ^^^^^^^^^^^^^^^^^^^^^ +LL | #[suggestion(parser_add_paren, code ="...", applicability = "foo")] + | ^^^^^^^^^^^^^^^^^^^^^ error: suggestion without `#[primary_span]` field - --> $DIR/subdiagnostic-derive.rs:444:1 + --> $DIR/subdiagnostic-derive.rs:448:1 | -LL | / #[suggestion(parser::add_paren, code = "...")] +LL | / #[suggestion(parser_add_paren, code = "...")] LL | | LL | | struct AR { LL | | var: String, @@ -253,25 +269,25 @@ LL | | } | |_^ error: unsupported type attribute for subdiagnostic enum - --> $DIR/subdiagnostic-derive.rs:458:1 + --> $DIR/subdiagnostic-derive.rs:462:1 | LL | #[label] | ^^^^^^^^ error: `var` doesn't refer to a field on this type - --> $DIR/subdiagnostic-derive.rs:478:39 + --> $DIR/subdiagnostic-derive.rs:482:38 | -LL | #[suggestion(parser::add_paren, code ="{var}", applicability = "machine-applicable")] - | ^^^^^^^ +LL | #[suggestion(parser_add_paren, code ="{var}", applicability = "machine-applicable")] + | ^^^^^^^ error: `var` doesn't refer to a field on this type - --> $DIR/subdiagnostic-derive.rs:497:43 + --> $DIR/subdiagnostic-derive.rs:501:42 | -LL | #[suggestion(parser::add_paren, code ="{var}", applicability = "machine-applicable")] - | ^^^^^^^ +LL | #[suggestion(parser_add_paren, code ="{var}", applicability = "machine-applicable")] + | ^^^^^^^ error: `#[suggestion_part]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:520:5 + --> $DIR/subdiagnostic-derive.rs:524:5 | LL | #[suggestion_part] | ^^^^^^^^^^^^^^^^^^ @@ -279,7 +295,7 @@ 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:523:5 + --> $DIR/subdiagnostic-derive.rs:527:5 | LL | #[suggestion_part(code = "...")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -287,9 +303,9 @@ LL | #[suggestion_part(code = "...")] = help: `#[suggestion_part(...)]` is only valid in multipart suggestions error: suggestion without `#[primary_span]` field - --> $DIR/subdiagnostic-derive.rs:517:1 + --> $DIR/subdiagnostic-derive.rs:521:1 | -LL | / #[suggestion(parser::add_paren, code = "...")] +LL | / #[suggestion(parser_add_paren, code = "...")] LL | | LL | | struct BA { LL | | #[suggestion_part] @@ -298,16 +314,18 @@ LL | | var: String, LL | | } | |_^ -error: `code` is not a valid nested attribute of a `multipart_suggestion` attribute - --> $DIR/subdiagnostic-derive.rs:532:43 +error: `#[multipart_suggestion(code = ...)]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:536:42 + | +LL | #[multipart_suggestion(parser_add_paren, code = "...", applicability = "machine-applicable")] + | ^^^^^^^^^^^^ | -LL | #[multipart_suggestion(parser::add_paren, code = "...", applicability = "machine-applicable")] - | ^^^^^^^^^^^^ + = help: only `applicability` is a valid nested attributes error: multipart suggestion without any `#[suggestion_part(...)]` fields - --> $DIR/subdiagnostic-derive.rs:532:1 + --> $DIR/subdiagnostic-derive.rs:536:1 | -LL | / #[multipart_suggestion(parser::add_paren, code = "...", applicability = "machine-applicable")] +LL | / #[multipart_suggestion(parser_add_paren, code = "...", applicability = "machine-applicable")] LL | | LL | | LL | | struct BBa { @@ -316,19 +334,19 @@ LL | | } | |_^ error: `#[suggestion_part(...)]` attribute without `code = "..."` - --> $DIR/subdiagnostic-derive.rs:542:5 + --> $DIR/subdiagnostic-derive.rs:546:5 | LL | #[suggestion_part] | ^^^^^^^^^^^^^^^^^^ error: `#[suggestion_part(...)]` attribute without `code = "..."` - --> $DIR/subdiagnostic-derive.rs:550:5 + --> $DIR/subdiagnostic-derive.rs:554:5 | LL | #[suggestion_part()] | ^^^^^^^^^^^^^^^^^^^^ error: `#[primary_span]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:559:5 + --> $DIR/subdiagnostic-derive.rs:563:5 | LL | #[primary_span] | ^^^^^^^^^^^^^^^ @@ -336,9 +354,9 @@ 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:556:1 + --> $DIR/subdiagnostic-derive.rs:560:1 | -LL | / #[multipart_suggestion(parser::add_paren)] +LL | / #[multipart_suggestion(parser_add_paren)] LL | | LL | | struct BC { LL | | #[primary_span] @@ -348,19 +366,19 @@ LL | | } | |_^ error: `#[suggestion_part(...)]` attribute without `code = "..."` - --> $DIR/subdiagnostic-derive.rs:567:5 + --> $DIR/subdiagnostic-derive.rs:571:5 | LL | #[suggestion_part] | ^^^^^^^^^^^^^^^^^^ error: `#[suggestion_part(...)]` attribute without `code = "..."` - --> $DIR/subdiagnostic-derive.rs:570:5 + --> $DIR/subdiagnostic-derive.rs:574:5 | LL | #[suggestion_part()] | ^^^^^^^^^^^^^^^^^^^^ error: `#[suggestion_part(foo = ...)]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:573:23 + --> $DIR/subdiagnostic-derive.rs:577:23 | LL | #[suggestion_part(foo = "bar")] | ^^^^^^^^^^^ @@ -368,40 +386,64 @@ 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:576:5 + --> $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:579:5 + --> $DIR/subdiagnostic-derive.rs:583:5 | LL | #[suggestion_part()] | ^^^^^^^^^^^^^^^^^^^^ error: specified multiple times - --> $DIR/subdiagnostic-derive.rs:587:37 + --> $DIR/subdiagnostic-derive.rs:591:37 | LL | #[suggestion_part(code = "...", code = ",,,")] | ^^^^^^^^^^^^ | note: previously specified here - --> $DIR/subdiagnostic-derive.rs:587:23 + --> $DIR/subdiagnostic-derive.rs:591:23 | LL | #[suggestion_part(code = "...", code = ",,,")] | ^^^^^^^^^^^^ -error: specified multiple times - --> $DIR/subdiagnostic-derive.rs:617:5 +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 | -note: previously specified here - --> $DIR/subdiagnostic-derive.rs:614:43 +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 | #[multipart_suggestion(parser::add_paren, applicability = "machine-applicable")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[suggestion_part(code = 3)] + | ^^^^^^^^ error: cannot find attribute `foo` in this scope --> $DIR/subdiagnostic-derive.rs:63:3 @@ -410,59 +452,59 @@ LL | #[foo] | ^^^ error: cannot find attribute `foo` in this scope - --> $DIR/subdiagnostic-derive.rs:155:3 + --> $DIR/subdiagnostic-derive.rs:159:3 | LL | #[foo] | ^^^ error: cannot find attribute `bar` in this scope - --> $DIR/subdiagnostic-derive.rs:169:7 + --> $DIR/subdiagnostic-derive.rs:173:7 | LL | #[bar] | ^^^ error: cannot find attribute `bar` in this scope - --> $DIR/subdiagnostic-derive.rs:181:7 + --> $DIR/subdiagnostic-derive.rs:185:7 | LL | #[bar = "..."] | ^^^ error: cannot find attribute `bar` in this scope - --> $DIR/subdiagnostic-derive.rs:193:7 + --> $DIR/subdiagnostic-derive.rs:197:7 | LL | #[bar = 4] | ^^^ error: cannot find attribute `bar` in this scope - --> $DIR/subdiagnostic-derive.rs:205:7 + --> $DIR/subdiagnostic-derive.rs:209:7 | LL | #[bar("...")] | ^^^ error: cannot find attribute `bar` in this scope - --> $DIR/subdiagnostic-derive.rs:266:7 + --> $DIR/subdiagnostic-derive.rs:270:7 | LL | #[bar] | ^^^ error: cannot find attribute `bar` in this scope - --> $DIR/subdiagnostic-derive.rs:277:7 + --> $DIR/subdiagnostic-derive.rs:281:7 | LL | #[bar = "..."] | ^^^ error: cannot find attribute `bar` in this scope - --> $DIR/subdiagnostic-derive.rs:288:7 + --> $DIR/subdiagnostic-derive.rs:292:7 | LL | #[bar("...")] | ^^^ error[E0425]: cannot find value `slug` in module `rustc_errors::fluent` - --> $DIR/subdiagnostic-derive.rs:118:9 + --> $DIR/subdiagnostic-derive.rs:122:9 | LL | #[label(slug)] | ^^^^ not found in `rustc_errors::fluent` -error: aborting due to 63 previous errors +error: aborting due to 72 previous errors For more information about this error, try `rustc --explain E0425`. -- cgit v1.2.3