diff options
| author | Michael Goulet <michael@errs.io> | 2023-05-03 23:22:57 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2023-05-08 03:19:54 +0000 |
| commit | 2b9279f3131056a1a1dd5de7513de4eb98987770 (patch) | |
| tree | c02f865cc084f3226777b785183bb4d888869b7b /tests | |
| parent | ad6b20bf5225c65aab30169c9a173719f5bdfc04 (diff) | |
| download | rust-2b9279f3131056a1a1dd5de7513de4eb98987770.tar.gz rust-2b9279f3131056a1a1dd5de7513de4eb98987770.zip | |
Diagnostic args are still args if they're documented
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.rs | 47 | ||||
| -rw-r--r-- | tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.stderr | 43 |
2 files changed, 90 insertions, 0 deletions
diff --git a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.rs b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.rs new file mode 100644 index 00000000000..7e1f7b1c5c1 --- /dev/null +++ b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.rs @@ -0,0 +1,47 @@ +// check-fail +// Tests that a doc comment will not preclude a field from being considered a diagnostic argument + +// The proc_macro2 crate handles spans differently when on beta/stable release rather than nightly, +// changing the output of this test. Since Subdiagnostic is strictly internal to the compiler +// the test is just ignored on stable and beta: +// ignore-stage1 +// ignore-beta +// ignore-stable + +#![feature(rustc_private)] +#![crate_type = "lib"] + +extern crate rustc_errors; +extern crate rustc_fluent_macro; +extern crate rustc_macros; +extern crate rustc_session; +extern crate rustc_span; + +use rustc_errors::{Applicability, DiagnosticMessage, SubdiagnosticMessage}; +use rustc_fluent_macro::fluent_messages; +use rustc_macros::{Diagnostic, Subdiagnostic}; +use rustc_span::Span; + +fluent_messages! { "./example.ftl" } + +struct NotIntoDiagnosticArg; + +#[derive(Diagnostic)] +//~^ ERROR the trait bound `NotIntoDiagnosticArg: IntoDiagnosticArg` is not satisfied +#[diag(no_crate_example)] +struct Test { + #[primary_span] + span: Span, + /// A doc comment + arg: NotIntoDiagnosticArg, +} + +#[derive(Subdiagnostic)] +//~^ ERROR the trait bound `NotIntoDiagnosticArg: IntoDiagnosticArg` is not satisfied +#[label(no_crate_example)] +struct SubTest { + #[primary_span] + span: Span, + /// A doc comment + arg: NotIntoDiagnosticArg, +} diff --git a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.stderr b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.stderr new file mode 100644 index 00000000000..27044748d08 --- /dev/null +++ b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.stderr @@ -0,0 +1,43 @@ +error[E0277]: the trait bound `NotIntoDiagnosticArg: IntoDiagnosticArg` is not satisfied + --> $DIR/diagnostic-derive-doc-comment-field.rs:29:10 + | +LL | #[derive(Diagnostic)] + | ^^^^^^^^^^ the trait `IntoDiagnosticArg` is not implemented for `NotIntoDiagnosticArg` + | + = help: the following other types implement trait `IntoDiagnosticArg`: + &'a T + &'a std::path::Path + &'a str + &rustc_target::spec::TargetTriple + Box<(dyn std::error::Error + 'static)> + CString + CguReuse + Cow<'a, str> + and 42 others +note: required by a bound in `DiagnosticBuilder::<'a, G>::set_arg` + --> $COMPILER_DIR/rustc_errors/src/diagnostic_builder.rs:747:5 + = note: this error originates in the derive macro `Diagnostic` which comes from the expansion of the macro `forward` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: the trait bound `NotIntoDiagnosticArg: IntoDiagnosticArg` is not satisfied + --> $DIR/diagnostic-derive-doc-comment-field.rs:39:10 + | +LL | #[derive(Subdiagnostic)] + | ^^^^^^^^^^^^^ the trait `IntoDiagnosticArg` is not implemented for `NotIntoDiagnosticArg` + | + = help: the following other types implement trait `IntoDiagnosticArg`: + &'a T + &'a std::path::Path + &'a str + &rustc_target::spec::TargetTriple + Box<(dyn std::error::Error + 'static)> + CString + CguReuse + Cow<'a, str> + and 42 others +note: required by a bound in `Diagnostic::set_arg` + --> $COMPILER_DIR/rustc_errors/src/diagnostic.rs:964:5 + = note: this error originates in the derive macro `Subdiagnostic` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. |
