diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:11:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:11:28 +0000 |
commit | 94a0819fe3a0d679c3042a77bfe6a2afc505daea (patch) | |
tree | 2b827afe6a05f3538db3f7803a88c4587fe85648 /src/test/ui-fulldeps | |
parent | Adding upstream version 1.64.0+dfsg1. (diff) | |
download | rustc-94a0819fe3a0d679c3042a77bfe6a2afc505daea.tar.xz rustc-94a0819fe3a0d679c3042a77bfe6a2afc505daea.zip |
Adding upstream version 1.66.0+dfsg1.upstream/1.66.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
29 files changed, 1671 insertions, 829 deletions
diff --git a/src/test/ui-fulldeps/auxiliary/issue-40001-plugin.rs b/src/test/ui-fulldeps/auxiliary/issue-40001-plugin.rs index 802b867a3..c05443488 100644 --- a/src/test/ui-fulldeps/auxiliary/issue-40001-plugin.rs +++ b/src/test/ui-fulldeps/auxiliary/issue-40001-plugin.rs @@ -21,7 +21,7 @@ use rustc_span::source_map; #[no_mangle] fn __rustc_plugin_registrar(reg: &mut Registry) { reg.lint_store.register_lints(&[&MISSING_ALLOWED_ATTR]); - reg.lint_store.register_late_pass(|| Box::new(MissingAllowedAttrPass)); + reg.lint_store.register_late_pass(|_| Box::new(MissingAllowedAttrPass)); } declare_lint! { @@ -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-rpass.rs b/src/test/ui-fulldeps/auxiliary/lint-for-crate-rpass.rs index bc153faa8..a3b570ad8 100644 --- a/src/test/ui-fulldeps/auxiliary/lint-for-crate-rpass.rs +++ b/src/test/ui-fulldeps/auxiliary/lint-for-crate-rpass.rs @@ -74,7 +74,7 @@ fn __rustc_plugin_registrar(reg: &mut Registry) { &CRATE_NOT_GREY, &CRATE_NOT_GREEN, ]); - reg.lint_store.register_late_pass(|| Box::new(PassOkay)); - reg.lint_store.register_late_pass(|| Box::new(PassRedBlue)); - reg.lint_store.register_late_pass(|| Box::new(PassGreyGreen)); + reg.lint_store.register_late_pass(|_| Box::new(PassOkay)); + reg.lint_store.register_late_pass(|_| Box::new(PassRedBlue)); + reg.lint_store.register_late_pass(|_| Box::new(PassGreyGreen)); } diff --git a/src/test/ui-fulldeps/auxiliary/lint-for-crate.rs b/src/test/ui-fulldeps/auxiliary/lint-for-crate.rs index 29d0abfbe..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) + ); } } } @@ -39,5 +41,5 @@ impl<'tcx> LateLintPass<'tcx> for Pass { #[no_mangle] fn __rustc_plugin_registrar(reg: &mut Registry) { reg.lint_store.register_lints(&[&CRATE_NOT_OKAY]); - reg.lint_store.register_late_pass(|| Box::new(Pass)); + reg.lint_store.register_late_pass(|_| Box::new(Pass)); } 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 691cfb97d..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)) + } _ => {} } } @@ -36,7 +34,7 @@ impl<'tcx> LateLintPass<'tcx> for Pass { #[no_mangle] fn __rustc_plugin_registrar(reg: &mut Registry) { reg.lint_store.register_lints(&[&TEST_LINT, &PLEASE_LINT]); - reg.lint_store.register_late_pass(|| Box::new(Pass)); + reg.lint_store.register_late_pass(|_| Box::new(Pass)); reg.lint_store.register_group( true, "lint_me", 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/duplicate-a-b.ftl b/src/test/ui-fulldeps/fluent-messages/duplicate-a-b.ftl new file mode 100644 index 000000000..9407c5170 --- /dev/null +++ b/src/test/ui-fulldeps/fluent-messages/duplicate-a-b.ftl @@ -0,0 +1 @@ +a_b_key = Value diff --git a/src/test/ui-fulldeps/fluent-messages/duplicate-a.ftl b/src/test/ui-fulldeps/fluent-messages/duplicate-a.ftl index fd9976b5a..9407c5170 100644 --- a/src/test/ui-fulldeps/fluent-messages/duplicate-a.ftl +++ b/src/test/ui-fulldeps/fluent-messages/duplicate-a.ftl @@ -1 +1 @@ -key = Value +a_b_key = Value diff --git a/src/test/ui-fulldeps/fluent-messages/duplicate-b.ftl b/src/test/ui-fulldeps/fluent-messages/duplicate-b.ftl deleted file mode 100644 index fd9976b5a..000000000 --- a/src/test/ui-fulldeps/fluent-messages/duplicate-b.ftl +++ /dev/null @@ -1 +0,0 @@ -key = Value diff --git a/src/test/ui-fulldeps/fluent-messages/label-with-hyphens.ftl b/src/test/ui-fulldeps/fluent-messages/label-with-hyphens.ftl new file mode 100644 index 000000000..016cbeef6 --- /dev/null +++ b/src/test/ui-fulldeps/fluent-messages/label-with-hyphens.ftl @@ -0,0 +1,2 @@ +label_with_hyphens_some_slug = hi + .label-has-hyphens = test diff --git a/src/test/ui-fulldeps/fluent-messages/missing-crate-name.ftl b/src/test/ui-fulldeps/fluent-messages/missing-crate-name.ftl new file mode 100644 index 000000000..9bd035c1b --- /dev/null +++ b/src/test/ui-fulldeps/fluent-messages/missing-crate-name.ftl @@ -0,0 +1,2 @@ +with-hyphens = 1234 +test-crate_foo = abcd diff --git a/src/test/ui-fulldeps/fluent-messages/missing-message.ftl b/src/test/ui-fulldeps/fluent-messages/missing-message.ftl index 372b1a2e4..74b2aa1d4 100644 --- a/src/test/ui-fulldeps/fluent-messages/missing-message.ftl +++ b/src/test/ui-fulldeps/fluent-messages/missing-message.ftl @@ -1 +1 @@ -missing-message = +missing_message = diff --git a/src/test/ui-fulldeps/fluent-messages/slug-with-hyphens.ftl b/src/test/ui-fulldeps/fluent-messages/slug-with-hyphens.ftl new file mode 100644 index 000000000..86ba9a268 --- /dev/null +++ b/src/test/ui-fulldeps/fluent-messages/slug-with-hyphens.ftl @@ -0,0 +1 @@ +slug_with_hyphens_this-slug-has-hyphens = hi diff --git a/src/test/ui-fulldeps/fluent-messages/test.rs b/src/test/ui-fulldeps/fluent-messages/test.rs index 0390a0785..4e8147e2b 100644 --- a/src/test/ui-fulldeps/fluent-messages/test.rs +++ b/src/test/ui-fulldeps/fluent-messages/test.rs @@ -49,9 +49,28 @@ mod duplicate { use super::fluent_messages; fluent_messages! { +//~^ ERROR the name `a_b_key` is defined multiple times a => "./duplicate-a.ftl", - b => "./duplicate-b.ftl", -//~^ ERROR overrides existing message: `key` + a_b => "./duplicate-a-b.ftl", +//~^ ERROR overrides existing message: `a_b_key` + } +} + +mod slug_with_hyphens { + use super::fluent_messages; + + fluent_messages! { + slug_with_hyphens => "./slug-with-hyphens.ftl", +//~^ ERROR name `slug_with_hyphens_this-slug-has-hyphens` contains a '-' character + } +} + +mod label_with_hyphens { + use super::fluent_messages; + + fluent_messages! { + label_with_hyphens => "./label-with-hyphens.ftl", +//~^ ERROR attribute `label-has-hyphens` contains a '-' character } } @@ -62,5 +81,18 @@ mod valid { valid => "./valid.ftl", } - use self::fluent_generated::{DEFAULT_LOCALE_RESOURCES, valid::valid}; + use self::fluent_generated::{DEFAULT_LOCALE_RESOURCES, valid_key}; +} + +mod missing_crate_name { + use super::fluent_messages; + + fluent_messages! { + test_crate => "./missing-crate-name.ftl", +//~^ ERROR name `test-crate_foo` contains a '-' character +//~| ERROR name `with-hyphens` contains a '-' character +//~| ERROR name `with-hyphens` does not start with the crate name + } + + 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 526bca43f..d1cd4fe26 100644 --- a/src/test/ui-fulldeps/fluent-messages/test.stderr +++ b/src/test/ui-fulldeps/fluent-messages/test.stderr @@ -22,24 +22,77 @@ LL | missing_message => "./missing-message.ftl", | = help: see additional errors emitted -error: expected a message field for "missing-message" +error: expected a message field for "missing_message" --> ./missing-message.ftl:1:1 | -1 | missing-message = - | ^^^^^^^^^^^^^^^^^^ +1 | missing_message = + | ^^^^^^^^^^^^^^^^^ | -error: overrides existing message: `key` - --> $DIR/test.rs:53:9 +error: overrides existing message: `a_b_key` + --> $DIR/test.rs:54:16 | -LL | b => "./duplicate-b.ftl", - | ^ +LL | a_b => "./duplicate-a-b.ftl", + | ^^^^^^^^^^^^^^^^^^^^^ | help: previously defined in this resource - --> $DIR/test.rs:52:9 + --> $DIR/test.rs:53:14 | LL | a => "./duplicate-a.ftl", - | ^ + | ^^^^^^^^^^^^^^^^^^^ -error: aborting due to 4 previous errors +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:63:30 + | +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:72:31 + | +LL | label_with_hyphens => "./label-with-hyphens.ftl", + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: replace any '-'s with '_'s + +error: name `with-hyphens` contains a '-' character + --> $DIR/test.rs:91:23 + | +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:91:23 + | +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:91:23 + | +LL | test_crate => "./missing-crate-name.ftl", + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: replace any '-'s with '_'s + +error: aborting due to 10 previous errors +For more information about this error, try `rustc --explain E0428`. diff --git a/src/test/ui-fulldeps/fluent-messages/valid.ftl b/src/test/ui-fulldeps/fluent-messages/valid.ftl index 0eee4a02b..549274306 100644 --- a/src/test/ui-fulldeps/fluent-messages/valid.ftl +++ b/src/test/ui-fulldeps/fluent-messages/valid.ftl @@ -1 +1 @@ -valid = Valid! +valid_key = Valid! 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<String, String> = 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 d6f63d44b..643e81d99 100644 --- a/src/test/ui-fulldeps/internal-lints/diagnostics.rs +++ b/src/test/ui-fulldeps/internal-lints/diagnostics.rs @@ -1,6 +1,7 @@ // compile-flags: -Z unstable-options #![crate_type = "lib"] +#![feature(rustc_attrs)] #![feature(rustc_private)] #![deny(rustc::untranslatable_diagnostic)] #![deny(rustc::diagnostic_outside_of_impl)] @@ -10,64 +11,79 @@ extern crate rustc_macros; extern crate rustc_session; extern crate rustc_span; -use rustc_errors::{AddSubdiagnostic, Diagnostic, DiagnosticBuilder, ErrorGuaranteed, fluent}; -use rustc_macros::{SessionDiagnostic, SessionSubdiagnostic}; -use rustc_session::{parse::ParseSess, SessionDiagnostic}; +use rustc_errors::{ + AddToDiagnostic, IntoDiagnostic, Diagnostic, DiagnosticBuilder, + ErrorGuaranteed, Handler, fluent, SubdiagnosticMessage, +}; +use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_span::Span; -#[derive(SessionDiagnostic)] -#[error(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 { - fn into_diagnostic(self, sess: &'a ParseSess) -> DiagnosticBuilder<'a, ErrorGuaranteed> { - sess.struct_err("untranslatable diagnostic") +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 { - fn into_diagnostic(self, sess: &'a ParseSess) -> DiagnosticBuilder<'a, ErrorGuaranteed> { - sess.struct_err(fluent::parser::expect_path) +impl<'a> IntoDiagnostic<'a, ErrorGuaranteed> for TranslatableInIntoDiagnostic { + fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, ErrorGuaranteed> { + 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<F>(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<F>(self, diag: &mut Diagnostic, _: F) + where + F: Fn(&mut Diagnostic, SubdiagnosticMessage) -> SubdiagnosticMessage, + { + diag.note(fluent::note); } } -pub fn make_diagnostics<'a>(sess: &'a ParseSess) { - let _diag = sess.struct_err(fluent::parser::expect_path); - //~^ ERROR diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls +pub fn make_diagnostics<'a>(handler: &'a Handler) { + let _diag = handler.struct_err(fluent::compiletest_example); + //~^ ERROR diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls - let _diag = sess.struct_err("untranslatable diagnostic"); - //~^ ERROR diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls + let _diag = handler.struct_err("untranslatable diagnostic"); + //~^ ERROR diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls //~^^ ERROR diagnostics should be created using translatable messages } + +// Check that `rustc_lint_diagnostics`-annotated functions aren't themselves linted. + +#[rustc_lint_diagnostics] +pub fn skipped_because_of_annotation<'a>(handler: &'a Handler) { + let _diag = handler.struct_err("untranslatable diagnostic"); // okay! +} diff --git a/src/test/ui-fulldeps/internal-lints/diagnostics.stderr b/src/test/ui-fulldeps/internal-lints/diagnostics.stderr index bae78ffdc..510d6a171 100644 --- a/src/test/ui-fulldeps/internal-lints/diagnostics.stderr +++ b/src/test/ui-fulldeps/internal-lints/diagnostics.stderr @@ -1,44 +1,44 @@ error: diagnostics should be created using translatable messages - --> $DIR/diagnostics.rs:36:14 + --> $DIR/diagnostics.rs:39:17 | -LL | sess.struct_err("untranslatable diagnostic") - | ^^^^^^^^^^ +LL | handler.struct_err("untranslatable diagnostic") + | ^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/diagnostics.rs:5:9 + --> $DIR/diagnostics.rs:6:9 | LL | #![deny(rustc::untranslatable_diagnostic)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: diagnostics should be created using translatable messages - --> $DIR/diagnostics.rs:53:14 + --> $DIR/diagnostics.rs:59:14 | LL | diag.note("untranslatable diagnostic"); | ^^^^ -error: diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls - --> $DIR/diagnostics.rs:67:22 +error: diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls + --> $DIR/diagnostics.rs:76:25 | -LL | let _diag = sess.struct_err(fluent::parser::expect_path); - | ^^^^^^^^^^ +LL | let _diag = handler.struct_err(fluent::compiletest_example); + | ^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/diagnostics.rs:6:9 + --> $DIR/diagnostics.rs:7:9 | LL | #![deny(rustc::diagnostic_outside_of_impl)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls - --> $DIR/diagnostics.rs:70:22 +error: diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls + --> $DIR/diagnostics.rs:79:25 | -LL | let _diag = sess.struct_err("untranslatable diagnostic"); - | ^^^^^^^^^^ +LL | let _diag = handler.struct_err("untranslatable diagnostic"); + | ^^^^^^^^^^ error: diagnostics should be created using translatable messages - --> $DIR/diagnostics.rs:70:22 + --> $DIR/diagnostics.rs:79:25 | -LL | let _diag = sess.struct_err("untranslatable diagnostic"); - | ^^^^^^^^^^ +LL | let _diag = handler.struct_err("untranslatable diagnostic"); + | ^^^^^^^^^^ error: aborting due to 5 previous errors 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/issue-15778-pass.rs b/src/test/ui-fulldeps/issue-15778-pass.rs deleted file mode 100644 index c031dbc71..000000000 --- a/src/test/ui-fulldeps/issue-15778-pass.rs +++ /dev/null @@ -1,23 +0,0 @@ -// check-pass -// aux-build:lint-for-crate-rpass.rs -// ignore-stage1 -// compile-flags: -D crate-not-okay - -#![feature(plugin, register_attr, custom_inner_attributes)] - -#![register_attr( - crate_okay, - crate_blue, - crate_red, - crate_grey, - crate_green, -)] - -#![plugin(lint_for_crate_rpass)] //~ WARNING compiler plugins are deprecated -#![crate_okay] -#![crate_blue] -#![crate_red] -#![crate_grey] -#![crate_green] - -fn main() {} diff --git a/src/test/ui-fulldeps/issue-15778-pass.stderr b/src/test/ui-fulldeps/issue-15778-pass.stderr deleted file mode 100644 index a9d9721ac..000000000 --- a/src/test/ui-fulldeps/issue-15778-pass.stderr +++ /dev/null @@ -1,10 +0,0 @@ -warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675 - --> $DIR/issue-15778-pass.rs:16:1 - | -LL | #![plugin(lint_for_crate_rpass)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version - | - = note: `#[warn(deprecated)]` on by default - -warning: 1 warning emitted - diff --git a/src/test/ui-fulldeps/pprust-expr-roundtrip.rs b/src/test/ui-fulldeps/pprust-expr-roundtrip.rs index a679b7b4e..117b79871 100644 --- a/src/test/ui-fulldeps/pprust-expr-roundtrip.rs +++ b/src/test/ui-fulldeps/pprust-expr-roundtrip.rs @@ -30,7 +30,6 @@ use rustc_ast::mut_visit::{self, visit_clobber, MutVisitor}; use rustc_ast::ptr::P; use rustc_ast::*; use rustc_ast_pretty::pprust; -use rustc_data_structures::thin_vec::ThinVec; use rustc_parse::new_parser_from_source_str; use rustc_session::parse::ParseSess; use rustc_span::source_map::FilePathMapping; @@ -47,7 +46,7 @@ fn parse_expr(ps: &ParseSess, src: &str) -> Option<P<Expr>> { // Helper functions for building exprs fn expr(kind: ExprKind) -> P<Expr> { - P(Expr { id: DUMMY_NODE_ID, kind, span: DUMMY_SP, attrs: ThinVec::new(), tokens: None }) + P(Expr { id: DUMMY_NODE_ID, kind, span: DUMMY_SP, attrs: AttrVec::new(), tokens: None }) } fn make_x() -> P<Expr> { @@ -74,10 +73,10 @@ fn iter_exprs(depth: usize, f: &mut dyn FnMut(P<Expr>)) { 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 => { @@ -196,7 +195,7 @@ impl MutVisitor for AddParens { id: DUMMY_NODE_ID, kind: ExprKind::Paren(e), span: DUMMY_SP, - attrs: ThinVec::new(), + attrs: AttrVec::new(), tokens: None, }) }); diff --git a/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.rs b/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.rs index 0a210cbdc..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,125 +27,120 @@ use rustc_errors::{Applicability, MultiSpan}; extern crate rustc_session; -#[derive(SessionDiagnostic)] -#[error(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] struct Hello {} -#[derive(SessionDiagnostic)] -#[warning(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] struct HelloWarn {} -#[derive(SessionDiagnostic)] -#[error(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)] -#[error(typeck::ambiguous_lifetime_bound, code = "E0123")] -#[error = "E0123"] -//~^ ERROR `#[error = ...]` is not a valid attribute +#[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 kind not specified +//~^^ ERROR diagnostic slug not specified //~^^^ ERROR cannot find attribute `nonsense` in this scope struct InvalidStructAttr {} -#[derive(SessionDiagnostic)] -#[error("E0123")] -//~^ ERROR `#[error("...")]` is not a valid attribute +#[derive(Diagnostic)] +#[diag("E0123")] +//~^ ERROR `#[diag("...")]` is not a valid attribute //~^^ ERROR diagnostic slug not specified struct InvalidLitNestedAttr {} -#[derive(SessionDiagnostic)] -#[error(nonsense, code = "E0123")] +#[derive(Diagnostic)] +#[diag(nonsense, code = "E0123")] //~^ ERROR cannot find value `nonsense` in module `rustc_errors::fluent` struct InvalidNestedStructAttr {} -#[derive(SessionDiagnostic)] -#[error(nonsense("foo"), code = "E0123", slug = "foo")] -//~^ ERROR `#[error(nonsense(...))]` is not a valid attribute +#[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)] -#[error(nonsense = "...", code = "E0123", slug = "foo")] -//~^ ERROR `#[error(nonsense = ...)]` is not a valid attribute -//~^^ ERROR diagnostic slug not specified +#[derive(Diagnostic)] +#[diag(nonsense = "...", code = "E0123", slug = "foo")] +//~^ ERROR `#[diag(nonsense = ...)]` is not a valid attribute +//~| ERROR `#[diag(slug = ...)]` is not a valid attribute +//~| ERROR diagnostic slug not specified struct InvalidNestedStructAttr2 {} -#[derive(SessionDiagnostic)] -#[error(nonsense = 4, code = "E0123", slug = "foo")] -//~^ ERROR `#[error(nonsense = ...)]` is not a valid attribute -//~^^ ERROR diagnostic slug not specified +#[derive(Diagnostic)] +#[diag(nonsense = 4, code = "E0123", slug = "foo")] +//~^ ERROR `#[diag(nonsense = ...)]` is not a valid attribute +//~| ERROR `#[diag(slug = ...)]` is not a valid attribute +//~| ERROR diagnostic slug not specified struct InvalidNestedStructAttr3 {} -#[derive(SessionDiagnostic)] -#[error(typeck::ambiguous_lifetime_bound, code = "E0123", slug = "foo")] -//~^ ERROR `#[error(slug = ...)]` is not a valid attribute +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123", slug = "foo")] +//~^ ERROR `#[diag(slug = ...)]` is not a valid attribute struct InvalidNestedStructAttr4 {} -#[derive(SessionDiagnostic)] -#[error(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)] -#[error(typeck::ambiguous_lifetime_bound, code = "E0123")] -#[error(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 -//~^^^ ERROR specified multiple times -struct ErrorSpecifiedTwice {} +struct DiagSpecifiedTwice {} -#[derive(SessionDiagnostic)] -#[error(typeck::ambiguous_lifetime_bound, code = "E0123")] -#[warning(typeck::ambiguous_lifetime_bound, code = "E0293")] -//~^ ERROR specified multiple times -//~^^ ERROR specified multiple times -//~^^^ ERROR specified multiple times -struct WarnSpecifiedAfterError {} - -#[derive(SessionDiagnostic)] -#[error(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)] -#[error(typeck::ambiguous_lifetime_bound, typeck::ambiguous_lifetime_bound, code = "E0456")] -//~^ ERROR `#[error(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)] -struct KindNotProvided {} //~ ERROR diagnostic kind not specified +#[derive(Diagnostic)] +struct KindNotProvided {} //~ ERROR diagnostic slug not specified -#[derive(SessionDiagnostic)] -#[error(code = "E0456")] +#[derive(Diagnostic)] +#[diag(code = "E0456")] //~^ ERROR diagnostic slug not specified struct SlugNotProvided {} -#[derive(SessionDiagnostic)] -#[error(typeck::ambiguous_lifetime_bound)] +#[derive(Diagnostic)] +#[diag(compiletest_example)] struct CodeNotProvided {} -#[derive(SessionDiagnostic)] -#[error(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)] -#[error(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] struct InvalidPathFieldAttr { #[nonsense] //~^ ERROR `#[nonsense]` is not a valid attribute @@ -153,201 +148,204 @@ struct InvalidPathFieldAttr { foo: String, } -#[derive(SessionDiagnostic)] -#[error(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)] -#[error(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)] -#[error(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 `'}'` -#[error(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 `}` -#[error(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)] -#[error(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] struct LabelOnSpan { - #[label(typeck::label)] + #[label(label)] sp: Span, } -#[derive(SessionDiagnostic)] -#[error(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)] -#[error(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)] -#[error(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)] -#[error(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)] -#[error(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)] -#[error(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] struct SuggestWithoutMsg { #[suggestion(code = "bar")] suggestion: (Span, Applicability), } -#[derive(SessionDiagnostic)] -#[error(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)] -#[error(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)] -#[error(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)] -#[error(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)] -#[error(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)] -#[error(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)] -#[error(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] struct OptionsInErrors { - #[label(typeck::label)] + #[label(label)] label: Option<Span>, - #[suggestion(typeck::suggestion)] + #[suggestion(suggestion, code = "...")] opt_sugg: Option<(Span, Applicability)>, } -#[derive(SessionDiagnostic)] -#[error(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)] -#[error(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)] -#[error(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 -#[error(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct ArgFieldWithoutSkip { #[primary_span] span: Span, other: Hello, } -#[derive(SessionDiagnostic)] -#[error(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] struct ArgFieldWithSkip { #[primary_span] span: Span, @@ -357,212 +355,444 @@ struct ArgFieldWithSkip { other: Hello, } -#[derive(SessionDiagnostic)] -#[error(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] struct ErrorWithSpannedNote { #[note] span: Span, } -#[derive(SessionDiagnostic)] -#[error(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] struct ErrorWithSpannedNoteCustom { - #[note(typeck::note)] + #[note(note)] span: Span, } -#[derive(SessionDiagnostic)] -#[error(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] #[note] struct ErrorWithNote { val: String, } -#[derive(SessionDiagnostic)] -#[error(typeck::ambiguous_lifetime_bound, code = "E0123")] -#[note(typeck::note)] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +#[note(note)] struct ErrorWithNoteCustom { val: String, } -#[derive(SessionDiagnostic)] -#[error(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] struct ErrorWithSpannedHelp { #[help] span: Span, } -#[derive(SessionDiagnostic)] -#[error(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] struct ErrorWithSpannedHelpCustom { - #[help(typeck::help)] + #[help(help)] span: Span, } -#[derive(SessionDiagnostic)] -#[error(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] #[help] struct ErrorWithHelp { val: String, } -#[derive(SessionDiagnostic)] -#[error(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] -#[error(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct ErrorWithHelpWrongOrder { val: String, } -#[derive(SessionDiagnostic)] -#[help(typeck::help)] -#[error(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[help(help)] +#[diag(compiletest_example, code = "E0123")] struct ErrorWithHelpCustomWrongOrder { val: String, } -#[derive(SessionDiagnostic)] +#[derive(Diagnostic)] #[note] -#[error(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[diag(compiletest_example, code = "E0123")] struct ErrorWithNoteWrongOrder { val: String, } -#[derive(SessionDiagnostic)] -#[note(typeck::note)] -#[error(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[note(note)] +#[diag(compiletest_example, code = "E0123")] struct ErrorWithNoteCustomWrongOrder { val: String, } -#[derive(SessionDiagnostic)] -#[error(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)] -#[error(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)] -#[error(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)] -#[error(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)] -#[error(typeck::ambiguous_lifetime_bound)] +#[derive(Diagnostic)] +#[diag(compiletest_example)] struct Subdiagnostic { #[subdiagnostic] note: Note, } -#[derive(SessionDiagnostic)] -#[error(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] struct VecField { #[primary_span] #[label] spans: Vec<Span>, } -#[derive(SessionDiagnostic)] -#[error(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)] -#[error(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)] -#[error(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)] -#[error(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)] -#[error(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(SessionDiagnostic)] -#[lint(typeck::ambiguous_lifetime_bound)] -//~^ ERROR only `#[error(..)]` and `#[warning(..)]` are supported -struct LintsBad { -} - #[derive(LintDiagnostic)] -#[lint(typeck::ambiguous_lifetime_bound)] +#[diag(compiletest_example)] struct LintsGood { } #[derive(LintDiagnostic)] -#[error(typeck::ambiguous_lifetime_bound)] -//~^ ERROR only `#[lint(..)]` is supported -struct ErrorsBad { +#[diag(compiletest_example)] +struct PrimarySpanOnLint { + #[primary_span] + //~^ ERROR `#[primary_span]` is not a valid attribute + span: Span, } -#[derive(SessionDiagnostic)] -#[error(typeck::ambiguous_lifetime_bound, code = "E0123")] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] struct ErrorWithMultiSpan { #[primary_span] span: MultiSpan, } -#[derive(SessionDiagnostic)] -#[error(typeck::ambiguous_lifetime_bound, code = "E0123")] -#[warn_] +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +#[warning] struct ErrorWithWarn { val: String, } + +#[derive(Diagnostic)] +#[error(compiletest_example, code = "E0123")] +//~^ ERROR `#[error(...)]` is not a valid attribute +//~| ERROR diagnostic slug not specified +//~| ERROR cannot find attribute `error` in this scope +struct ErrorAttribute {} + +#[derive(Diagnostic)] +#[warn_(compiletest_example, code = "E0123")] +//~^ ERROR `#[warn_(...)]` is not a valid attribute +//~| ERROR diagnostic slug not specified +//~| ERROR cannot find attribute `warn_` in this scope +struct WarnAttribute {} + +#[derive(Diagnostic)] +#[lint(compiletest_example, code = "E0123")] +//~^ ERROR `#[lint(...)]` is not a valid attribute +//~| ERROR diagnostic slug not specified +//~| ERROR cannot find attribute `lint` in this scope +struct LintAttributeOnSessionDiag {} + +#[derive(LintDiagnostic)] +#[lint(compiletest_example, code = "E0123")] +//~^ ERROR `#[lint(...)]` is not a valid attribute +//~| ERROR `#[lint(...)]` is not a valid attribute +//~| ERROR diagnostic slug not specified +//~| ERROR cannot find attribute `lint` in this scope +struct LintAttributeOnLintDiag {} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +struct DuplicatedSuggestionCode { + #[suggestion(suggestion, code = "...", code = ",,,")] + //~^ ERROR specified multiple times + suggestion: Span, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +struct InvalidTypeInSuggestionTuple { + #[suggestion(suggestion, code = "...")] + suggestion: (Span, usize), + //~^ ERROR wrong types for suggestion +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +struct MissingApplicabilityInSuggestionTuple { + #[suggestion(suggestion, code = "...")] + suggestion: (Span,), + //~^ ERROR wrong types for suggestion +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +struct MissingCodeInSuggestion { + #[suggestion(suggestion)] + //~^ ERROR suggestion without `code = "..."` + suggestion: Span, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +#[multipart_suggestion(suggestion)] +//~^ ERROR `#[multipart_suggestion(...)]` is not a valid attribute +//~| ERROR cannot find attribute `multipart_suggestion` in this scope +#[multipart_suggestion()] +//~^ ERROR `#[multipart_suggestion(...)]` is not a valid attribute +//~| ERROR cannot find attribute `multipart_suggestion` in this scope +struct MultipartSuggestion { + #[multipart_suggestion(suggestion)] + //~^ ERROR `#[multipart_suggestion(...)]` is not a valid attribute + //~| ERROR cannot find attribute `multipart_suggestion` in this scope + suggestion: Span, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +#[suggestion(suggestion, code = "...")] +//~^ ERROR `#[suggestion(...)]` is not a valid attribute +struct SuggestionOnStruct { + #[primary_span] + suggestion: Span, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +#[label] +//~^ ERROR `#[label]` is not a valid attribute +struct LabelOnStruct { + #[primary_span] + suggestion: Span, +} + +#[derive(Diagnostic)] +enum ExampleEnum { + #[diag(compiletest_example)] + Foo { + #[primary_span] + sp: Span, + #[note] + note_sp: Span, + }, + #[diag(compiletest_example)] + Bar { + #[primary_span] + sp: Span, + }, + #[diag(compiletest_example)] + Baz, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example, code = "E0123")] +struct RawIdentDiagnosticArg { + pub r#type: String, +} + +#[derive(Diagnostic)] +#[diag(compiletest_example)] +struct SubdiagnosticBad { + #[subdiagnostic(bad)] +//~^ ERROR `#[subdiagnostic(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 c1080aa24..859c272b6 100644 --- a/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr +++ b/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr @@ -1,423 +1,671 @@ -error: `#[derive(SessionDiagnostic)]` can only be used on structs +error: unsupported type attribute for diagnostic derive enum --> $DIR/diagnostic-derive.rs:39:1 | -LL | / #[error(typeck::ambiguous_lifetime_bound, code = "E0123")] -LL | | -LL | | enum SessionDiagnosticOnEnum { -LL | | Foo, -LL | | Bar, -LL | | } - | |_^ +LL | #[diag(compiletest_example, code = "E0123")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: `#[error = ...]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:48:1 +error: diagnostic slug not specified + --> $DIR/diagnostic-derive.rs:42:5 + | +LL | Foo, + | ^^^ | -LL | #[error = "E0123"] - | ^^^^^^^^^^^^^^^^^^ + = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` -error: `#[nonsense(...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:53:1 +error: diagnostic slug not specified + --> $DIR/diagnostic-derive.rs:44:5 + | +LL | Bar, + | ^^^ | -LL | #[nonsense(typeck::ambiguous_lifetime_bound, code = "E0123")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` + +error: `#[diag = ...]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:50:1 + | +LL | #[diag = "E0123"] + | ^^^^^^^^^^^^^^^^^ + +error: `#[nonsense(...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:55:1 | - = help: only `error`, `warning`, `help`, `note` and `warn_` are valid attributes +LL | #[nonsense(compiletest_example, code = "E0123")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: diagnostic kind not specified - --> $DIR/diagnostic-derive.rs:53:1 +error: diagnostic slug not specified + --> $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: use the `#[error(...)]` attribute to create an error + = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` -error: `#[error("...")]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:60:9 +error: `#[diag("...")]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:62:8 | -LL | #[error("E0123")] - | ^^^^^^^ +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 | / #[error("E0123")] +LL | / #[diag("E0123")] LL | | LL | | LL | | struct InvalidLitNestedAttr {} | |______________________________^ | - = help: specify the slug as the first argument to the attribute, such as `#[error(typeck::example_error)]` + = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` -error: `#[error(nonsense(...))]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:71:9 +error: `#[diag(nonsense(...))]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:73:8 | -LL | #[error(nonsense("foo"), code = "E0123", slug = "foo")] - | ^^^^^^^^^^^^^^^ +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 | / #[error(nonsense("foo"), code = "E0123", slug = "foo")] +LL | / #[diag(nonsense("foo"), code = "E0123", slug = "foo")] LL | | LL | | LL | | struct InvalidNestedStructAttr1 {} | |__________________________________^ | - = help: specify the slug as the first argument to the attribute, such as `#[error(typeck::example_error)]` + = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` -error: `#[error(nonsense = ...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:77:9 +error: `#[diag(nonsense = ...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:79:8 | -LL | #[error(nonsense = "...", code = "E0123", slug = "foo")] - | ^^^^^^^^^^^^^^^^ +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 | / #[error(nonsense = "...", code = "E0123", slug = "foo")] +LL | / #[diag(nonsense = "...", code = "E0123", slug = "foo")] +LL | | LL | | LL | | LL | | struct InvalidNestedStructAttr2 {} | |__________________________________^ | - = help: specify the slug as the first argument to the attribute, such as `#[error(typeck::example_error)]` + = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` -error: `#[error(nonsense = ...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:83:9 +error: `#[diag(nonsense = ...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:86:8 | -LL | #[error(nonsense = 4, code = "E0123", slug = "foo")] - | ^^^^^^^^^^^^ +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 | / #[error(nonsense = 4, code = "E0123", slug = "foo")] +LL | / #[diag(nonsense = 4, code = "E0123", slug = "foo")] +LL | | LL | | LL | | LL | | struct InvalidNestedStructAttr3 {} | |__________________________________^ | - = help: specify the slug as the first argument to the attribute, such as `#[error(typeck::example_error)]` + = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` -error: `#[error(slug = ...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:89:59 +error: `#[diag(slug = ...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:93:45 | -LL | #[error(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 | #[error(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 | #[error(typeck::ambiguous_lifetime_bound, code = "E0123")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[diag(compiletest_example, code = "E0123")] + | ^^^^^^^^^^^^^^^^^^^ error: specified multiple times - --> $DIR/diagnostic-derive.rs:103:1 + --> $DIR/diagnostic-derive.rs:107:36 | -LL | #[error(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:36 | -LL | #[error(typeck::ambiguous_lifetime_bound, code = "E0123")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[diag(compiletest_example, code = "E0123")] + | ^^^^^^^ error: specified multiple times - --> $DIR/diagnostic-derive.rs:103:50 + --> $DIR/diagnostic-derive.rs:113:52 | -LL | #[error(typeck::ambiguous_lifetime_bound, code = "E0456")] - | ^^^^^^^ - | -note: previously specified here - --> $DIR/diagnostic-derive.rs:102:50 - | -LL | #[error(typeck::ambiguous_lifetime_bound, code = "E0123")] - | ^^^^^^^ - -error: specified multiple times - --> $DIR/diagnostic-derive.rs:111:1 - | -LL | #[warning(typeck::ambiguous_lifetime_bound, code = "E0293")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: previously specified here - --> $DIR/diagnostic-derive.rs:110:1 - | -LL | #[error(typeck::ambiguous_lifetime_bound, code = "E0123")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: specified multiple times - --> $DIR/diagnostic-derive.rs:111:1 - | -LL | #[warning(typeck::ambiguous_lifetime_bound, code = "E0293")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: previously specified here - --> $DIR/diagnostic-derive.rs:110:1 - | -LL | #[error(typeck::ambiguous_lifetime_bound, code = "E0123")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: specified multiple times - --> $DIR/diagnostic-derive.rs:111:52 - | -LL | #[warning(typeck::ambiguous_lifetime_bound, code = "E0293")] +LL | #[diag(compiletest_example, code = "E0456", code = "E0457")] | ^^^^^^^ | note: previously specified here - --> $DIR/diagnostic-derive.rs:110:50 + --> $DIR/diagnostic-derive.rs:113:36 | -LL | #[error(typeck::ambiguous_lifetime_bound, code = "E0123")] - | ^^^^^^^ +LL | #[diag(compiletest_example, code = "E0456", code = "E0457")] + | ^^^^^^^ -error: specified multiple times - --> $DIR/diagnostic-derive.rs:118:66 +error: `#[diag(compiletest_example)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:118:29 | -LL | #[error(typeck::ambiguous_lifetime_bound, code = "E0456", code = "E0457")] - | ^^^^^^^ +LL | #[diag(compiletest_example, compiletest_example, code = "E0456")] + | ^^^^^^^^^^^^^^^^^^^ | -note: previously specified here - --> $DIR/diagnostic-derive.rs:118:50 - | -LL | #[error(typeck::ambiguous_lifetime_bound, code = "E0456", code = "E0457")] - | ^^^^^^^ + = help: diagnostic slug must be the first argument -error: `#[error(typeck::ambiguous_lifetime_bound)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:123:43 - | -LL | #[error(typeck::ambiguous_lifetime_bound, typeck::ambiguous_lifetime_bound, code = "E0456")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: diagnostic kind not specified - --> $DIR/diagnostic-derive.rs:128:1 +error: diagnostic slug not specified + --> $DIR/diagnostic-derive.rs:123:1 | LL | struct KindNotProvided {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: use the `#[error(...)]` attribute to create an 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:131:1 + --> $DIR/diagnostic-derive.rs:126:1 | -LL | / #[error(code = "E0456")] +LL | / #[diag(code = "E0456")] LL | | LL | | struct SlugNotProvided {} | |_________________________^ | - = help: specify the slug as the first argument to the attribute, such as `#[error(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:142:5 + --> $DIR/diagnostic-derive.rs:137:5 | LL | #[primary_span] | ^^^^^^^^^^^^^^^ error: `#[nonsense]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:150: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:167: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:175: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:180: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:190: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:210: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:235: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:243: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:265: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:280: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:288: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:296: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:447:52 +error: specified multiple times + --> $DIR/diagnostic-derive.rs:445:44 + | +LL | #[suggestion(suggestion, code = "...", applicability = "maybe-incorrect")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -LL | #[suggestion(typeck::suggestion, code = "...", applicability = "maybe-incorrect")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: previously specified here + --> $DIR/diagnostic-derive.rs:447:24 + | +LL | suggestion: (Span, Applicability), + | ^^^^^^^^^^^^^ error: invalid applicability - --> $DIR/diagnostic-derive.rs:455: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:518:5 +error: `#[label(foo)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:516:20 + | +LL | #[label(label, foo)] + | ^^^ | -LL | #[label(typeck::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:526: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:534: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:545:5 + | +LL | #[primary_span] + | ^^^^^^^^^^^^^^^ + | + = help: the `primary_span` field attribute is not valid for lint diagnostics + +error: `#[error(...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:565:1 + | +LL | #[error(compiletest_example, code = "E0123")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: only `#[error(..)]` and `#[warning(..)]` are supported - --> $DIR/diagnostic-derive.rs:540:1 +error: diagnostic slug not specified + --> $DIR/diagnostic-derive.rs:565:1 | -LL | / #[lint(typeck::ambiguous_lifetime_bound)] +LL | / #[error(compiletest_example, code = "E0123")] +LL | | +LL | | LL | | -LL | | struct LintsBad { -LL | | } - | |_^ +LL | | struct ErrorAttribute {} + | |________________________^ | - = help: use the `#[error(...)]` attribute to create a error + = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` -error: only `#[lint(..)]` is supported - --> $DIR/diagnostic-derive.rs:551:1 +error: `#[warn_(...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:572:1 | -LL | / #[error(typeck::ambiguous_lifetime_bound)] +LL | #[warn_(compiletest_example, code = "E0123")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: diagnostic slug not specified + --> $DIR/diagnostic-derive.rs:572:1 + | +LL | / #[warn_(compiletest_example, code = "E0123")] +LL | | +LL | | LL | | -LL | | struct ErrorsBad { -LL | | } - | |_^ +LL | | struct WarnAttribute {} + | |_______________________^ | - = help: use the `#[lint(...)]` attribute to create a lint + = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` + +error: `#[lint(...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:579:1 + | +LL | #[lint(compiletest_example, code = "E0123")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: diagnostic slug not specified + --> $DIR/diagnostic-derive.rs:579:1 + | +LL | / #[lint(compiletest_example, code = "E0123")] +LL | | +LL | | +LL | | +LL | | struct LintAttributeOnSessionDiag {} + | |____________________________________^ + | + = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` + +error: `#[lint(...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:586:1 + | +LL | #[lint(compiletest_example, code = "E0123")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `#[lint(...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:586:1 + | +LL | #[lint(compiletest_example, code = "E0123")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: diagnostic slug not specified + --> $DIR/diagnostic-derive.rs:586:1 + | +LL | / #[lint(compiletest_example, code = "E0123")] +LL | | +LL | | +LL | | +LL | | +LL | | struct LintAttributeOnLintDiag {} + | |_________________________________^ + | + = help: specify the slug as the first argument to the attribute, such as `#[diag(compiletest_example)]` + +error: specified multiple times + --> $DIR/diagnostic-derive.rs:596:44 + | +LL | #[suggestion(suggestion, code = "...", code = ",,,")] + | ^^^^^^^^^^^^ + | +note: previously specified here + --> $DIR/diagnostic-derive.rs:596:30 + | +LL | #[suggestion(suggestion, code = "...", code = ",,,")] + | ^^^^^^^^^^^^ + +error: wrong types for suggestion + --> $DIR/diagnostic-derive.rs:605:24 + | +LL | suggestion: (Span, usize), + | ^^^^^ + | + = help: `#[suggestion(...)]` on a tuple field must be applied to fields of type `(Span, Applicability)` + +error: wrong types for suggestion + --> $DIR/diagnostic-derive.rs:613:17 + | +LL | suggestion: (Span,), + | ^^^^^^^ + | + = help: `#[suggestion(...)]` on a tuple field must be applied to fields of type `(Span, Applicability)` + +error: suggestion without `code = "..."` + --> $DIR/diagnostic-derive.rs:620:5 + | +LL | #[suggestion(suggestion)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `#[multipart_suggestion(...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:627:1 + | +LL | #[multipart_suggestion(suggestion)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: consider creating a `Subdiagnostic` instead + +error: `#[multipart_suggestion(...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:630:1 + | +LL | #[multipart_suggestion()] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: consider creating a `Subdiagnostic` instead + +error: `#[multipart_suggestion(...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:634:5 + | +LL | #[multipart_suggestion(suggestion)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: consider creating a `Subdiagnostic` instead + +error: `#[suggestion(...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:642:1 + | +LL | #[suggestion(suggestion, code = "...")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: `#[label]` and `#[suggestion]` can only be applied to fields + +error: `#[label]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:651:1 + | +LL | #[label] + | ^^^^^^^^ + | + = help: `#[label]` and `#[suggestion]` can only be applied to fields + +error: `#[subdiagnostic(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:150:7 + --> $DIR/diagnostic-derive.rs:145:7 | LL | #[nonsense] | ^^^^^^^^ +error: cannot find attribute `error` in this scope + --> $DIR/diagnostic-derive.rs:565:3 + | +LL | #[error(compiletest_example, code = "E0123")] + | ^^^^^ + +error: cannot find attribute `warn_` in this scope + --> $DIR/diagnostic-derive.rs:572:3 + | +LL | #[warn_(compiletest_example, code = "E0123")] + | ^^^^^ help: a built-in attribute with a similar name exists: `warn` + +error: cannot find attribute `lint` in this scope + --> $DIR/diagnostic-derive.rs:579:3 + | +LL | #[lint(compiletest_example, code = "E0123")] + | ^^^^ help: a built-in attribute with a similar name exists: `link` + +error: cannot find attribute `lint` in this scope + --> $DIR/diagnostic-derive.rs:586:3 + | +LL | #[lint(compiletest_example, code = "E0123")] + | ^^^^ help: a built-in attribute with a similar name exists: `link` + +error: cannot find attribute `multipart_suggestion` in this scope + --> $DIR/diagnostic-derive.rs:627:3 + | +LL | #[multipart_suggestion(suggestion)] + | ^^^^^^^^^^^^^^^^^^^^ + +error: cannot find attribute `multipart_suggestion` in this scope + --> $DIR/diagnostic-derive.rs:630:3 + | +LL | #[multipart_suggestion()] + | ^^^^^^^^^^^^^^^^^^^^ + +error: cannot find attribute `multipart_suggestion` in this scope + --> $DIR/diagnostic-derive.rs:634:7 + | +LL | #[multipart_suggestion(suggestion)] + | ^^^^^^^^^^^^^^^^^^^^ + error[E0425]: cannot find value `nonsense` in module `rustc_errors::fluent` - --> $DIR/diagnostic-derive.rs:66:9 + --> $DIR/diagnostic-derive.rs:68:8 | -LL | #[error(nonsense, code = "E0123")] - | ^^^^^^^^ not found in `rustc_errors::fluent` +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:340: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` - --> $COMPILER_DIR/rustc_errors/src/diagnostic_builder.rs:539:19 + --> $COMPILER_DIR/rustc_errors/src/diagnostic_builder.rs:LL:CC | 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 48 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 16da25c40..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,11 +168,11 @@ enum P { } } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] enum Q { #[bar] -//~^ ERROR `#[bar]` is not a valid attribute -//~^^ ERROR cannot find attribute `bar` in this scope + //~^ ERROR `#[bar]` is not a valid attribute + //~^^ ERROR cannot find attribute `bar` in this scope A { #[primary_span] span: Span, @@ -176,11 +180,11 @@ enum Q { } } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] enum R { #[bar = "..."] -//~^ ERROR `#[bar = ...]` is not a valid attribute -//~^^ ERROR cannot find attribute `bar` in this scope + //~^ ERROR `#[bar = ...]` is not a valid attribute + //~^^ ERROR cannot find attribute `bar` in this scope A { #[primary_span] span: Span, @@ -188,11 +192,11 @@ enum R { } } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] enum S { #[bar = 4] -//~^ ERROR `#[bar = ...]` is not a valid attribute -//~^^ ERROR cannot find attribute `bar` in this scope + //~^ ERROR `#[bar = ...]` is not a valid attribute + //~^^ ERROR cannot find attribute `bar` in this scope A { #[primary_span] span: Span, @@ -200,11 +204,11 @@ enum S { } } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] enum T { #[bar("...")] -//~^ ERROR `#[bar("...")]` is not a valid attribute -//~^^ ERROR cannot find attribute `bar` in this scope + //~^ ERROR `#[bar(...)]` is not a valid attribute + //~^^ ERROR cannot find attribute `bar` in this scope A { #[primary_span] span: Span, @@ -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 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,53 +304,49 @@ 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)] -//~^ NOTE previously specified here -//~^^ NOTE previously specified here -#[label(parser::add_paren)] -//~^ ERROR specified multiple times -//~^^ ERROR specified multiple times +#[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 + //~^ NOTE previously specified here span_a: Span, #[primary_span] -//~^ ERROR specified multiple times + //~^ ERROR specified multiple times span_b: Span, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] struct AG { -//~^ ERROR subdiagnostic kind not specified + //~^ 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, @@ -355,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, @@ -365,7 +365,7 @@ enum AI { applicability: Applicability, var: String, }, - #[suggestion(parser::add_paren, code = "...")] + #[suggestion(parser_add_paren, code = "...")] B { #[primary_span] span: Span, @@ -375,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 { @@ -386,40 +386,38 @@ struct AJ { applicability: Applicability, } -#[derive(SessionSubdiagnostic)] -#[suggestion(parser::add_paren, code = "...")] +#[derive(Subdiagnostic)] +#[suggestion(parser_add_paren, code = "...")] struct AK { #[primary_span] span: Span, #[applicability] -//~^ NOTE previously specified here + //~^ NOTE previously specified here applicability_a: Applicability, #[applicability] -//~^ ERROR specified multiple times + //~^ ERROR specified multiple times applicability_b: Applicability, } -#[derive(SessionSubdiagnostic)] -#[suggestion(parser::add_paren, code = "...")] -//~^ ERROR suggestion without `applicability` +#[derive(Subdiagnostic)] +#[suggestion(parser_add_paren, code = "...")] struct AL { #[primary_span] span: Span, #[applicability] -//~^ ERROR the `#[applicability]` attribute can only be applied to fields of type `Applicability` + //~^ ERROR the `#[applicability]` attribute can only be applied to fields of type `Applicability` applicability: Span, } -#[derive(SessionSubdiagnostic)] -#[suggestion(parser::add_paren, code = "...")] -//~^ ERROR suggestion without `applicability` +#[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] @@ -428,44 +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 = "...")] -//~^ ERROR suggestion without `applicability` -//~^^ ERROR suggestion without `#[primary_span]` field +#[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, @@ -473,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, @@ -499,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] @@ -509,14 +506,203 @@ enum AX { } } -#[derive(SessionSubdiagnostic)] -#[warn_(parser::add_paren)] -struct AY { -} +#[derive(Subdiagnostic)] +#[warning(parser_add_paren)] +struct AY {} -#[derive(SessionSubdiagnostic)] -#[warn_(parser::add_paren)] +#[derive(Subdiagnostic)] +#[warning(parser_add_paren)] struct AZ { #[primary_span] span: Span, } + +#[derive(Subdiagnostic)] +#[suggestion(parser_add_paren, code = "...")] +//~^ ERROR suggestion without `#[primary_span]` field +struct BA { + #[suggestion_part] + //~^ ERROR `#[suggestion_part]` is not a valid attribute + span: Span, + #[suggestion_part(code = "...")] + //~^ ERROR `#[suggestion_part(...)]` is not a valid attribute + span2: Span, + #[applicability] + applicability: Applicability, + var: String, +} + +#[derive(Subdiagnostic)] +#[multipart_suggestion(parser_add_paren, code = "...", applicability = "machine-applicable")] +//~^ ERROR multipart suggestion without any `#[suggestion_part(...)]` fields +//~| ERROR `#[multipart_suggestion(code = ...)]` is not a valid attribute +struct BBa { + var: String, +} + +#[derive(Subdiagnostic)] +#[multipart_suggestion(parser_add_paren, applicability = "machine-applicable")] +struct BBb { + #[suggestion_part] + //~^ ERROR `#[suggestion_part(...)]` attribute without `code = "..."` + span1: Span, +} + +#[derive(Subdiagnostic)] +#[multipart_suggestion(parser_add_paren, applicability = "machine-applicable")] +struct BBc { + #[suggestion_part()] + //~^ ERROR `#[suggestion_part(...)]` attribute without `code = "..."` + span1: Span, +} + +#[derive(Subdiagnostic)] +#[multipart_suggestion(parser_add_paren)] +//~^ ERROR multipart suggestion without any `#[suggestion_part(...)]` fields +struct BC { + #[primary_span] + //~^ ERROR `#[primary_span]` is not a valid attribute + span: Span, +} + +#[derive(Subdiagnostic)] +#[multipart_suggestion(parser_add_paren)] +struct BD { + #[suggestion_part] + //~^ ERROR `#[suggestion_part(...)]` attribute without `code = "..."` + span1: Span, + #[suggestion_part()] + //~^ ERROR `#[suggestion_part(...)]` attribute without `code = "..."` + span2: Span, + #[suggestion_part(foo = "bar")] + //~^ ERROR `#[suggestion_part(foo = ...)]` is not a valid attribute + span4: Span, + #[suggestion_part(code = "...")] + //~^ ERROR the `#[suggestion_part(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan` + s1: String, + #[suggestion_part()] + //~^ ERROR the `#[suggestion_part(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan` + s2: String, +} + +#[derive(Subdiagnostic)] +#[multipart_suggestion(parser_add_paren, applicability = "machine-applicable")] +struct BE { + #[suggestion_part(code = "...", code = ",,,")] + //~^ ERROR specified multiple times + //~| NOTE previously specified here + span: Span, +} + +#[derive(Subdiagnostic)] +#[multipart_suggestion(parser_add_paren, applicability = "machine-applicable")] +struct BF { + #[suggestion_part(code = "(")] + first: Span, + #[suggestion_part(code = ")")] + second: Span, +} + +#[derive(Subdiagnostic)] +#[multipart_suggestion(parser_add_paren)] +struct BG { + #[applicability] + appl: Applicability, + #[suggestion_part(code = "(")] + first: Span, + #[suggestion_part(code = ")")] + second: Span, +} + +#[derive(Subdiagnostic)] +#[multipart_suggestion(parser_add_paren, applicability = "machine-applicable")] +struct BH { + #[applicability] + //~^ ERROR `#[applicability]` has no effect + appl: Applicability, + #[suggestion_part(code = "(")] + first: Span, + #[suggestion_part(code = ")")] + second: Span, +} + +#[derive(Subdiagnostic)] +#[multipart_suggestion(parser_add_paren, applicability = "machine-applicable")] +struct BI { + #[suggestion_part(code = "")] + spans: Vec<Span>, +} + +#[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 a289c4fff..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,105 +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:1 +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:1 +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:11 +error: `#[bar(...)]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:209:5 | LL | #[bar("...")] - | ^^^^^ + | ^^^^^^^^^^^^^ + +error: `#[label(code = ...)]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:221:13 | - = help: first argument of the attribute should be the diagnostic slug +LL | #[label(code = "...")] + | ^^^^^^^^^^^^ error: diagnostic slug must be first argument of a `#[label(...)]` attribute - --> $DIR/subdiagnostic-derive.rs:217:5 + --> $DIR/subdiagnostic-derive.rs:221:5 | LL | #[label(code = "...")] | ^^^^^^^^^^^^^^^^^^^^^^ -error: subdiagnostic kind not specified - --> $DIR/subdiagnostic-derive.rs:234:5 - | -LL | B { - | ^ - 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] @@ -139,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] | ^^^^^^ @@ -153,19 +167,21 @@ 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("...")] | ^^^^^^^^^^^^^ + | + = 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,35 +190,11 @@ LL | | b: u64 LL | | } | |_^ -error: specified multiple times - --> $DIR/subdiagnostic-derive.rs:314:1 - | -LL | #[label(parser::add_paren)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: previously specified here - --> $DIR/subdiagnostic-derive.rs:311:1 - | -LL | #[label(parser::add_paren)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: specified multiple times - --> $DIR/subdiagnostic-derive.rs:314:1 - | -LL | #[label(parser::add_paren)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: previously specified here - --> $DIR/subdiagnostic-derive.rs:311:1 - | -LL | #[label(parser::add_paren)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: `#[label(parser::add_paren)]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:323: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 @@ -225,16 +217,16 @@ LL | struct AG { | ^^ error: specified multiple times - --> $DIR/subdiagnostic-derive.rs:379: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:379: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:397:5 @@ -249,91 +241,209 @@ LL | #[applicability] | ^^^^^^^^^^^^^^^^ error: the `#[applicability]` attribute can only be applied to fields of type `Applicability` - --> $DIR/subdiagnostic-derive.rs:408:5 + --> $DIR/subdiagnostic-derive.rs:407:5 | LL | #[applicability] | ^^^^^^^^^^^^^^^^ -error: suggestion without `applicability` - --> $DIR/subdiagnostic-derive.rs:403:1 +error: suggestion without `code = "..."` + --> $DIR/subdiagnostic-derive.rs:420:1 | -LL | / #[suggestion(parser::add_paren, code = "...")] -LL | | -LL | | struct AL { -LL | | #[primary_span] -... | -LL | | applicability: Span, -LL | | } - | |_^ +LL | #[suggestion(parser_add_paren)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: suggestion without `applicability` - --> $DIR/subdiagnostic-derive.rs:414:1 +error: invalid applicability + --> $DIR/subdiagnostic-derive.rs:430:45 + | +LL | #[suggestion(parser_add_paren, code ="...", applicability = "foo")] + | ^^^^^^^^^^^^^^^^^^^^^ + +error: suggestion without `#[primary_span]` field + --> $DIR/subdiagnostic-derive.rs:448:1 | -LL | / #[suggestion(parser::add_paren, code = "...")] +LL | / #[suggestion(parser_add_paren, code = "...")] LL | | -LL | | struct AM { -LL | | #[primary_span] -LL | | span: Span, +LL | | struct AR { +LL | | var: String, LL | | } | |_^ -error: suggestion without `code = "..."` - --> $DIR/subdiagnostic-derive.rs:422:1 +error: unsupported type attribute for subdiagnostic enum + --> $DIR/subdiagnostic-derive.rs:462:1 + | +LL | #[label] + | ^^^^^^^^ + +error: `var` doesn't refer to a field on this type + --> $DIR/subdiagnostic-derive.rs:482:38 + | +LL | #[suggestion(parser_add_paren, code ="{var}", applicability = "machine-applicable")] + | ^^^^^^^ + +error: `var` doesn't refer to a field on this type + --> $DIR/subdiagnostic-derive.rs:501:42 | -LL | / #[suggestion(parser::add_paren)] +LL | #[suggestion(parser_add_paren, code ="{var}", applicability = "machine-applicable")] + | ^^^^^^^ + +error: `#[suggestion_part]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:524:5 + | +LL | #[suggestion_part] + | ^^^^^^^^^^^^^^^^^^ + | + = help: `#[suggestion_part(...)]` is only valid in multipart suggestions, use `#[primary_span]` instead + +error: `#[suggestion_part(...)]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:527:5 + | +LL | #[suggestion_part(code = "...")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: `#[suggestion_part(...)]` is only valid in multipart suggestions + +error: suggestion without `#[primary_span]` field + --> $DIR/subdiagnostic-derive.rs:521:1 + | +LL | / #[suggestion(parser_add_paren, code = "...")] LL | | -LL | | struct AN { -LL | | #[primary_span] +LL | | struct BA { +LL | | #[suggestion_part] ... | -LL | | applicability: Applicability, +LL | | var: String, LL | | } | |_^ -error: invalid applicability - --> $DIR/subdiagnostic-derive.rs:432:46 +error: `#[multipart_suggestion(code = ...)]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:536:42 | -LL | #[suggestion(parser::add_paren, code ="...", applicability = "foo")] - | ^^^^^^^^^^^^^^^^^^^^^ +LL | #[multipart_suggestion(parser_add_paren, code = "...", applicability = "machine-applicable")] + | ^^^^^^^^^^^^ + | + = help: only `applicability` is a valid nested attributes -error: suggestion without `applicability` - --> $DIR/subdiagnostic-derive.rs:450:1 +error: multipart suggestion without any `#[suggestion_part(...)]` fields + --> $DIR/subdiagnostic-derive.rs:536:1 | -LL | / #[suggestion(parser::add_paren, code = "...")] +LL | / #[multipart_suggestion(parser_add_paren, code = "...", applicability = "machine-applicable")] LL | | LL | | -LL | | struct AR { +LL | | struct BBa { LL | | var: String, LL | | } | |_^ -error: suggestion without `#[primary_span]` field - --> $DIR/subdiagnostic-derive.rs:450:1 +error: `#[suggestion_part(...)]` attribute without `code = "..."` + --> $DIR/subdiagnostic-derive.rs:546:5 | -LL | / #[suggestion(parser::add_paren, code = "...")] +LL | #[suggestion_part] + | ^^^^^^^^^^^^^^^^^^ + +error: `#[suggestion_part(...)]` attribute without `code = "..."` + --> $DIR/subdiagnostic-derive.rs:554:5 + | +LL | #[suggestion_part()] + | ^^^^^^^^^^^^^^^^^^^^ + +error: `#[primary_span]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:563:5 + | +LL | #[primary_span] + | ^^^^^^^^^^^^^^^ + | + = help: multipart suggestions use one or more `#[suggestion_part]`s rather than one `#[primary_span]` + +error: multipart suggestion without any `#[suggestion_part(...)]` fields + --> $DIR/subdiagnostic-derive.rs:560:1 + | +LL | / #[multipart_suggestion(parser_add_paren)] LL | | +LL | | struct BC { +LL | | #[primary_span] LL | | -LL | | struct AR { -LL | | var: String, +LL | | span: Span, LL | | } | |_^ -error: unsupported type attribute for subdiagnostic enum - --> $DIR/subdiagnostic-derive.rs:465:1 +error: `#[suggestion_part(...)]` attribute without `code = "..."` + --> $DIR/subdiagnostic-derive.rs:571:5 | -LL | #[label] - | ^^^^^^^^ +LL | #[suggestion_part] + | ^^^^^^^^^^^^^^^^^^ -error: `var` doesn't refer to a field on this type - --> $DIR/subdiagnostic-derive.rs:485:39 +error: `#[suggestion_part(...)]` attribute without `code = "..."` + --> $DIR/subdiagnostic-derive.rs:574:5 | -LL | #[suggestion(parser::add_paren, code ="{var}", applicability = "machine-applicable")] - | ^^^^^^^ +LL | #[suggestion_part()] + | ^^^^^^^^^^^^^^^^^^^^ -error: `var` doesn't refer to a field on this type - --> $DIR/subdiagnostic-derive.rs:504:43 +error: `#[suggestion_part(foo = ...)]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:577:23 + | +LL | #[suggestion_part(foo = "bar")] + | ^^^^^^^^^^^ + | + = help: `code` is the only valid nested attribute + +error: the `#[suggestion_part(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan` + --> $DIR/subdiagnostic-derive.rs:580:5 + | +LL | #[suggestion_part(code = "...")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: the `#[suggestion_part(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan` + --> $DIR/subdiagnostic-derive.rs:583:5 + | +LL | #[suggestion_part()] + | ^^^^^^^^^^^^^^^^^^^^ + +error: specified multiple times + --> $DIR/subdiagnostic-derive.rs:591:37 + | +LL | #[suggestion_part(code = "...", code = ",,,")] + | ^^^^^^^^^^^^ + | +note: previously specified here + --> $DIR/subdiagnostic-derive.rs:591:23 + | +LL | #[suggestion_part(code = "...", code = ",,,")] + | ^^^^^^^^^^^^ + +error: `#[applicability]` has no effect if all `#[suggestion]`/`#[multipart_suggestion]` attributes have a static `applicability = "..."` + --> $DIR/subdiagnostic-derive.rs:620:5 + | +LL | #[applicability] + | ^^^^^^^^^^^^^^^^ + +error: expected exactly one string literal for `code = ...` + --> $DIR/subdiagnostic-derive.rs:668:23 + | +LL | #[suggestion_part(code("foo"))] + | ^^^^^^^^^^^ + +error: expected exactly one string literal for `code = ...` + --> $DIR/subdiagnostic-derive.rs:677:23 + | +LL | #[suggestion_part(code("foo", "bar"))] + | ^^^^^^^^^^^^^^^^^^ + +error: expected exactly one string literal for `code = ...` + --> $DIR/subdiagnostic-derive.rs:686:23 + | +LL | #[suggestion_part(code(3))] + | ^^^^^^^ + +error: expected exactly one string literal for `code = ...` + --> $DIR/subdiagnostic-derive.rs:695:23 + | +LL | #[suggestion_part(code())] + | ^^^^^^ + +error: `code = "..."`/`code(...)` must contain only string literals + --> $DIR/subdiagnostic-derive.rs:704:23 | -LL | #[suggestion(parser::add_paren, code ="{var}", applicability = "machine-applicable")] - | ^^^^^^^ +LL | #[suggestion_part(code = 3)] + | ^^^^^^^^ error: cannot find attribute `foo` in this scope --> $DIR/subdiagnostic-derive.rs:63:3 @@ -342,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 52 previous errors +error: aborting due to 72 previous errors For more information about this error, try `rustc --explain E0425`. |