-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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 #111170 - compiler-errors:diag-doc, r=petrochenkov
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
116 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
49 changes: 49 additions & 0 deletions
49
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,49 @@ | ||
// check-fail | ||
// Tests that a doc comment will not preclude a field from being considered a diagnostic argument | ||
// 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 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 | ||
} |
30 changes: 30 additions & 0 deletions
30
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,30 @@ | ||
error[E0277]: the trait bound `NotIntoDiagnosticArg: IntoDiagnosticArg` is not satisfied | ||
--> $DIR/diagnostic-derive-doc-comment-field.rs:37:10 | ||
| | ||
LL | #[derive(Diagnostic)] | ||
| ---------- required by a bound introduced by this call | ||
... | ||
LL | arg: NotIntoDiagnosticArg, | ||
| ^^^^^^^^^^^^^^^^^^^^ the trait `IntoDiagnosticArg` is not implemented for `NotIntoDiagnosticArg` | ||
| | ||
= help: normalized in stderr | ||
note: required by a bound in `DiagnosticBuilder::<'a, G>::set_arg` | ||
--> $COMPILER_DIR/rustc_errors/src/diagnostic_builder.rs:LL:CC | ||
= note: this error originates in the 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:47:10 | ||
| | ||
LL | #[derive(Subdiagnostic)] | ||
| ------------- required by a bound introduced by this call | ||
... | ||
LL | arg: NotIntoDiagnosticArg, | ||
| ^^^^^^^^^^^^^^^^^^^^ the trait `IntoDiagnosticArg` is not implemented for `NotIntoDiagnosticArg` | ||
| | ||
= help: normalized in stderr | ||
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