forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#111170 - compiler-errors:diag-doc, r=petroc…
…henkov Diagnostic args are still args if they're documented Fixes https://rust-lang.zulipchat.com/#narrow/stream/336883-i18n/topic/.60.23.5Bderive.28Diagnostic.29.5D.60.20works.20badly.20with.20docs/near/355597997 There's a lot of really strange code incongruencies between `Diagnostic` and `Subdiagnostic` derive. Perhaps those macros need some more overhaul, but I didn't really want to do it today.
- Loading branch information
Showing
7 changed files
with
132 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)] | ||
#[diag(no_crate_example)] | ||
struct Test { | ||
#[primary_span] | ||
span: Span, | ||
/// A doc comment | ||
arg: NotIntoDiagnosticArg, | ||
//~^ ERROR the trait bound `NotIntoDiagnosticArg: IntoDiagnosticArg` is not satisfied | ||
} | ||
|
||
#[derive(Subdiagnostic)] | ||
#[label(no_crate_example)] | ||
struct SubTest { | ||
#[primary_span] | ||
span: Span, | ||
/// A doc comment | ||
arg: NotIntoDiagnosticArg, | ||
//~^ ERROR the trait bound `NotIntoDiagnosticArg: IntoDiagnosticArg` is not satisfied | ||
} |
48 changes: 48 additions & 0 deletions
48
tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
error[E0277]: the trait bound `NotIntoDiagnosticArg: IntoDiagnosticArg` is not satisfied | ||
--> $DIR/diagnostic-derive-doc-comment-field.rs:35:10 | ||
| | ||
LL | #[derive(Diagnostic)] | ||
| ---------- required by a bound introduced by this call | ||
... | ||
LL | arg: NotIntoDiagnosticArg, | ||
| ^^^^^^^^^^^^^^^^^^^^ 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 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:45:10 | ||
| | ||
LL | #[derive(Subdiagnostic)] | ||
| ------------- required by a bound introduced by this call | ||
... | ||
LL | arg: NotIntoDiagnosticArg, | ||
| ^^^^^^^^^^^^^^^^^^^^ 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 | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters