Remove obsolote diagnostic tests
This commit is contained in:
parent
b7f6e85fa0
commit
0fa5589e0a
5 changed files with 0 additions and 236 deletions
|
|
@ -1,5 +0,0 @@
|
||||||
no_crate_example = this is an example message used in testing
|
|
||||||
.note = with a note
|
|
||||||
.help = with a help
|
|
||||||
.suggestion = with a suggestion
|
|
||||||
.label = with a label
|
|
||||||
|
|
@ -1,122 +0,0 @@
|
||||||
//@ compile-flags: -Z unstable-options
|
|
||||||
//@ ignore-stage1
|
|
||||||
|
|
||||||
#![crate_type = "lib"]
|
|
||||||
#![feature(rustc_attrs)]
|
|
||||||
#![feature(rustc_private)]
|
|
||||||
|
|
||||||
extern crate rustc_errors;
|
|
||||||
extern crate rustc_fluent_macro;
|
|
||||||
extern crate rustc_macros;
|
|
||||||
extern crate rustc_session;
|
|
||||||
extern crate rustc_span;
|
|
||||||
|
|
||||||
use rustc_errors::{
|
|
||||||
Diag, DiagCtxtHandle, DiagInner, DiagMessage, Diagnostic, EmissionGuarantee, Level,
|
|
||||||
LintDiagnostic, SubdiagMessage, Subdiagnostic,
|
|
||||||
};
|
|
||||||
use rustc_macros::{Diagnostic, Subdiagnostic};
|
|
||||||
use rustc_span::Span;
|
|
||||||
|
|
||||||
rustc_fluent_macro::fluent_messages! { "./diagnostics.ftl" }
|
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
|
||||||
#[diag(no_crate_example)]
|
|
||||||
struct DeriveDiagnostic {
|
|
||||||
#[primary_span]
|
|
||||||
span: Span,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Subdiagnostic)]
|
|
||||||
#[note(no_crate_example)]
|
|
||||||
struct Note {
|
|
||||||
#[primary_span]
|
|
||||||
span: Span,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct UntranslatableInDiagnostic;
|
|
||||||
|
|
||||||
impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for UntranslatableInDiagnostic {
|
|
||||||
fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
|
|
||||||
Diag::new(dcx, level, "untranslatable diagnostic")
|
|
||||||
//~^ ERROR diagnostics should be created using translatable messages
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct TranslatableInDiagnostic;
|
|
||||||
|
|
||||||
impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for TranslatableInDiagnostic {
|
|
||||||
fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
|
|
||||||
Diag::new(dcx, level, crate::fluent_generated::no_crate_example)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct UntranslatableInAddtoDiag;
|
|
||||||
|
|
||||||
impl Subdiagnostic for UntranslatableInAddtoDiag {
|
|
||||||
fn add_to_diag<G: EmissionGuarantee>(
|
|
||||||
self,
|
|
||||||
diag: &mut Diag<'_, G>,
|
|
||||||
) {
|
|
||||||
diag.note("untranslatable diagnostic");
|
|
||||||
//~^ ERROR diagnostics should be created using translatable messages
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct TranslatableInAddtoDiag;
|
|
||||||
|
|
||||||
impl Subdiagnostic for TranslatableInAddtoDiag {
|
|
||||||
fn add_to_diag<G: EmissionGuarantee>(
|
|
||||||
self,
|
|
||||||
diag: &mut Diag<'_, G>,
|
|
||||||
) {
|
|
||||||
diag.note(crate::fluent_generated::no_crate_note);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct UntranslatableInLintDiagnostic;
|
|
||||||
|
|
||||||
impl<'a> LintDiagnostic<'a, ()> for UntranslatableInLintDiagnostic {
|
|
||||||
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
|
||||||
diag.note("untranslatable diagnostic");
|
|
||||||
//~^ ERROR diagnostics should be created using translatable messages
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct TranslatableInLintDiagnostic;
|
|
||||||
|
|
||||||
impl<'a> LintDiagnostic<'a, ()> for TranslatableInLintDiagnostic {
|
|
||||||
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
|
||||||
diag.note(crate::fluent_generated::no_crate_note);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn make_diagnostics<'a>(dcx: DiagCtxtHandle<'a>) {
|
|
||||||
let _diag = dcx.struct_err(crate::fluent_generated::no_crate_example);
|
|
||||||
//~^ ERROR diagnostics should only be created in `Diagnostic`/`Subdiagnostic`/`LintDiagnostic` impls
|
|
||||||
|
|
||||||
let _diag = dcx.struct_err("untranslatable diagnostic");
|
|
||||||
//~^ ERROR diagnostics should only be created in `Diagnostic`/`Subdiagnostic`/`LintDiagnostic` impls
|
|
||||||
//~^^ ERROR diagnostics should be created using translatable messages
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check that `rustc_lint_diagnostics`-annotated functions aren't themselves linted for
|
|
||||||
// `diagnostic_outside_of_impl`.
|
|
||||||
#[rustc_lint_diagnostics]
|
|
||||||
pub fn skipped_because_of_annotation<'a>(dcx: DiagCtxtHandle<'a>) {
|
|
||||||
let _diag = dcx.struct_err("untranslatable diagnostic"); // okay!
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check that multiple translatable params are allowed in a single function (at one point they
|
|
||||||
// weren't).
|
|
||||||
fn f(_x: impl Into<DiagMessage>, _y: impl Into<SubdiagMessage>) {}
|
|
||||||
fn g() {
|
|
||||||
f(crate::fluent_generated::no_crate_example, crate::fluent_generated::no_crate_example);
|
|
||||||
f("untranslatable diagnostic", crate::fluent_generated::no_crate_example);
|
|
||||||
//~^ ERROR diagnostics should be created using translatable messages
|
|
||||||
f(crate::fluent_generated::no_crate_example, "untranslatable diagnostic");
|
|
||||||
//~^ ERROR diagnostics should be created using translatable messages
|
|
||||||
f("untranslatable diagnostic", "untranslatable diagnostic");
|
|
||||||
//~^ ERROR diagnostics should be created using translatable messages
|
|
||||||
//~^^ ERROR diagnostics should be created using translatable messages
|
|
||||||
}
|
|
||||||
|
|
@ -1,74 +0,0 @@
|
||||||
error: diagnostics should be created using translatable messages
|
|
||||||
--> $DIR/diagnostics.rs:43:31
|
|
||||||
|
|
|
||||||
LL | Diag::new(dcx, level, "untranslatable diagnostic")
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
|
||||||
note: the lint level is defined here
|
|
||||||
--> $DIR/diagnostics.rs:7:9
|
|
||||||
|
|
|
||||||
LL | #![deny(rustc::untranslatable_diagnostic)]
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
error: diagnostics should be created using translatable messages
|
|
||||||
--> $DIR/diagnostics.rs:63:19
|
|
||||||
|
|
|
||||||
LL | diag.note("untranslatable diagnostic");
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
error: diagnostics should be created using translatable messages
|
|
||||||
--> $DIR/diagnostics.rs:83:19
|
|
||||||
|
|
|
||||||
LL | diag.note("untranslatable diagnostic");
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
error: diagnostics should only be created in `Diagnostic`/`Subdiagnostic`/`LintDiagnostic` impls
|
|
||||||
--> $DIR/diagnostics.rs:97:21
|
|
||||||
|
|
|
||||||
LL | let _diag = dcx.struct_err(crate::fluent_generated::no_crate_example);
|
|
||||||
| ^^^^^^^^^^
|
|
||||||
|
|
|
||||||
note: the lint level is defined here
|
|
||||||
--> $DIR/diagnostics.rs:8:9
|
|
||||||
|
|
|
||||||
LL | #![deny(rustc::diagnostic_outside_of_impl)]
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
error: diagnostics should only be created in `Diagnostic`/`Subdiagnostic`/`LintDiagnostic` impls
|
|
||||||
--> $DIR/diagnostics.rs:100:21
|
|
||||||
|
|
|
||||||
LL | let _diag = dcx.struct_err("untranslatable diagnostic");
|
|
||||||
| ^^^^^^^^^^
|
|
||||||
|
|
||||||
error: diagnostics should be created using translatable messages
|
|
||||||
--> $DIR/diagnostics.rs:100:32
|
|
||||||
|
|
|
||||||
LL | let _diag = dcx.struct_err("untranslatable diagnostic");
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
error: diagnostics should be created using translatable messages
|
|
||||||
--> $DIR/diagnostics.rs:118:7
|
|
||||||
|
|
|
||||||
LL | f("untranslatable diagnostic", crate::fluent_generated::no_crate_example);
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
error: diagnostics should be created using translatable messages
|
|
||||||
--> $DIR/diagnostics.rs:120:50
|
|
||||||
|
|
|
||||||
LL | f(crate::fluent_generated::no_crate_example, "untranslatable diagnostic");
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
error: diagnostics should be created using translatable messages
|
|
||||||
--> $DIR/diagnostics.rs:122:7
|
|
||||||
|
|
|
||||||
LL | f("untranslatable diagnostic", "untranslatable diagnostic");
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
error: diagnostics should be created using translatable messages
|
|
||||||
--> $DIR/diagnostics.rs:122:36
|
|
||||||
|
|
|
||||||
LL | f("untranslatable diagnostic", "untranslatable diagnostic");
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
error: aborting due to 10 previous errors
|
|
||||||
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
//@ compile-flags: -Z unstable-options
|
|
||||||
|
|
||||||
#![feature(rustc_attrs)]
|
|
||||||
|
|
||||||
#[rustc_lint_diagnostics]
|
|
||||||
//~^ ERROR `#[rustc_lint_diagnostics]` attribute cannot be used on structs
|
|
||||||
struct Foo;
|
|
||||||
|
|
||||||
impl Foo {
|
|
||||||
#[rustc_lint_diagnostics(a)]
|
|
||||||
//~^ ERROR malformed `rustc_lint_diagnostics`
|
|
||||||
fn bar() {}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {}
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
error: `#[rustc_lint_diagnostics]` attribute cannot be used on structs
|
|
||||||
--> $DIR/diagnostics_incorrect.rs:5:1
|
|
||||||
|
|
|
||||||
LL | #[rustc_lint_diagnostics]
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
|
||||||
= help: `#[rustc_lint_diagnostics]` can only be applied to functions
|
|
||||||
|
|
||||||
error[E0565]: malformed `rustc_lint_diagnostics` attribute input
|
|
||||||
--> $DIR/diagnostics_incorrect.rs:10:5
|
|
||||||
|
|
|
||||||
LL | #[rustc_lint_diagnostics(a)]
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^---^
|
|
||||||
| | |
|
|
||||||
| | didn't expect any arguments here
|
|
||||||
| help: must be of the form: `#[rustc_lint_diagnostics]`
|
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0565`.
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue