2023-05-03 18:22:57 -05:00
|
|
|
//@ check-fail
|
|
|
|
// Tests that a doc comment will not preclude a field from being considered a diagnostic argument
|
2024-03-04 23:53:24 -06:00
|
|
|
//@ normalize-stderr-test "the following other types implement trait `IntoDiagArg`:(?:.*\n){0,9}\s+and \d+ others" -> "normalized in stderr"
|
2023-09-22 03:37:05 -05:00
|
|
|
//@ normalize-stderr-test "(COMPILER_DIR/.*\.rs):[0-9]+:[0-9]+" -> "$1:LL:CC"
|
2023-05-03 18:22:57 -05:00
|
|
|
|
|
|
|
// 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;
|
|
|
|
|
2024-02-28 21:53:44 -06:00
|
|
|
use rustc_errors::{Applicability, DiagMessage, SubdiagMessage};
|
2023-05-03 18:22:57 -05:00
|
|
|
use rustc_macros::{Diagnostic, Subdiagnostic};
|
|
|
|
use rustc_span::Span;
|
|
|
|
|
2023-11-21 16:53:07 -06:00
|
|
|
rustc_fluent_macro::fluent_messages! { "./example.ftl" }
|
2023-05-03 18:22:57 -05:00
|
|
|
|
2024-03-04 23:53:24 -06:00
|
|
|
struct NotIntoDiagArg;
|
2023-05-03 18:22:57 -05:00
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(no_crate_example)]
|
|
|
|
struct Test {
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
/// A doc comment
|
2024-03-04 23:53:24 -06:00
|
|
|
arg: NotIntoDiagArg,
|
|
|
|
//~^ ERROR the trait bound `NotIntoDiagArg: IntoDiagArg` is not satisfied
|
2023-05-03 18:22:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
|
|
|
#[label(no_crate_example)]
|
|
|
|
struct SubTest {
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
/// A doc comment
|
2024-03-04 23:53:24 -06:00
|
|
|
arg: NotIntoDiagArg,
|
|
|
|
//~^ ERROR the trait bound `NotIntoDiagArg: IntoDiagArg` is not satisfied
|
2023-05-03 18:22:57 -05:00
|
|
|
}
|