Skip to content

Commit

Permalink
Update fulldeps UI tests to the new lint diagnostic API
Browse files Browse the repository at this point in the history
  • Loading branch information
fmease committed Oct 24, 2024
1 parent 870fa29 commit 0f0d42d
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 56 deletions.
10 changes: 9 additions & 1 deletion tests/ui-fulldeps/internal-lints/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ extern crate rustc_session;
extern crate rustc_span;

use rustc_errors::{
Diag, DiagCtxtHandle, DiagInner, DiagMessage, Diagnostic, EmissionGuarantee, Level,
Diag, DiagCtxtHandle, DiagInner, DiagMessage, Diagnostic, EmissionGuarantee, Level, MultiSpan,
LintDiagnostic, SubdiagMessage, SubdiagMessageOp, Subdiagnostic,
};
use rustc_macros::{Diagnostic, Subdiagnostic};
Expand Down Expand Up @@ -85,6 +85,10 @@ impl<'a> LintDiagnostic<'a, ()> for UntranslatableInLintDiagnostic {
diag.note("untranslatable diagnostic");
//~^ ERROR diagnostics should be created using translatable messages
}

fn span(&self) -> Option<MultiSpan> {
None
}
}

pub struct TranslatableInLintDiagnostic;
Expand All @@ -93,6 +97,10 @@ impl<'a> LintDiagnostic<'a, ()> for TranslatableInLintDiagnostic {
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
diag.note(crate::fluent_generated::no_crate_note);
}

fn span(&self) -> Option<MultiSpan> {
None
}
}

pub fn make_diagnostics<'a>(dcx: DiagCtxtHandle<'a>) {
Expand Down
14 changes: 7 additions & 7 deletions tests/ui-fulldeps/internal-lints/diagnostics.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ LL | diag.note("untranslatable diagnostic");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: diagnostics should only be created in `Diagnostic`/`Subdiagnostic`/`LintDiagnostic` impls
--> $DIR/diagnostics.rs:99:21
--> $DIR/diagnostics.rs:107:21
|
LL | let _diag = dcx.struct_err(crate::fluent_generated::no_crate_example);
| ^^^^^^^^^^
Expand All @@ -35,37 +35,37 @@ LL | #![deny(rustc::diagnostic_outside_of_impl)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: diagnostics should only be created in `Diagnostic`/`Subdiagnostic`/`LintDiagnostic` impls
--> $DIR/diagnostics.rs:102:21
--> $DIR/diagnostics.rs:110:21
|
LL | let _diag = dcx.struct_err("untranslatable diagnostic");
| ^^^^^^^^^^

error: diagnostics should be created using translatable messages
--> $DIR/diagnostics.rs:102:32
--> $DIR/diagnostics.rs:110:32
|
LL | let _diag = dcx.struct_err("untranslatable diagnostic");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: diagnostics should be created using translatable messages
--> $DIR/diagnostics.rs:120:7
--> $DIR/diagnostics.rs:128:7
|
LL | f("untranslatable diagnostic", crate::fluent_generated::no_crate_example);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: diagnostics should be created using translatable messages
--> $DIR/diagnostics.rs:122:50
--> $DIR/diagnostics.rs:130:50
|
LL | f(crate::fluent_generated::no_crate_example, "untranslatable diagnostic");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: diagnostics should be created using translatable messages
--> $DIR/diagnostics.rs:124:7
--> $DIR/diagnostics.rs:132:7
|
LL | f("untranslatable diagnostic", "untranslatable diagnostic");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: diagnostics should be created using translatable messages
--> $DIR/diagnostics.rs:124:36
--> $DIR/diagnostics.rs:132:36
|
LL | f("untranslatable diagnostic", "untranslatable diagnostic");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
1 change: 0 additions & 1 deletion tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,6 @@ struct LintsGood {}
#[diag(no_crate_example)]
struct PrimarySpanOnLint {
#[primary_span]
//~^ ERROR `#[primary_span]` is not a valid attribute
span: Span,
}

Expand Down
Loading

0 comments on commit 0f0d42d

Please sign in to comment.