Skip to content

Commit

Permalink
Fix up some ui-fulldeps tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
nnethercote committed Dec 18, 2023
1 parent e56fb98 commit 9449218
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
20 changes: 10 additions & 10 deletions tests/ui-fulldeps/internal-lints/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ extern crate rustc_session;
extern crate rustc_span;

use rustc_errors::{
AddToDiagnostic, Diagnostic, DiagnosticBuilder, DiagnosticMessage, ErrorGuaranteed, Handler,
AddToDiagnostic, DiagCtxt, Diagnostic, DiagnosticBuilder, DiagnosticMessage, ErrorGuaranteed,
IntoDiagnostic, SubdiagnosticMessage,
};
use rustc_macros::{Diagnostic, Subdiagnostic};
Expand All @@ -38,17 +38,17 @@ struct Note {
pub struct UntranslatableInIntoDiagnostic;

impl<'a> IntoDiagnostic<'a, ErrorGuaranteed> for UntranslatableInIntoDiagnostic {
fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
handler.struct_err("untranslatable diagnostic")
fn into_diagnostic(self, dcx: &'a DiagCtxt) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
dcx.struct_err("untranslatable diagnostic")
//~^ ERROR diagnostics should be created using translatable messages
}
}

pub struct TranslatableInIntoDiagnostic;

impl<'a> IntoDiagnostic<'a, ErrorGuaranteed> for TranslatableInIntoDiagnostic {
fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
handler.struct_err(crate::fluent_generated::no_crate_example)
fn into_diagnostic(self, dcx: &'a DiagCtxt) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
dcx.struct_err(crate::fluent_generated::no_crate_example)
}
}

Expand All @@ -75,18 +75,18 @@ impl AddToDiagnostic for TranslatableInAddToDiagnostic {
}
}

pub fn make_diagnostics<'a>(handler: &'a Handler) {
let _diag = handler.struct_err(crate::fluent_generated::no_crate_example);
pub fn make_diagnostics<'a>(dcx: &'a DiagCtxt) {
let _diag = dcx.struct_err(crate::fluent_generated::no_crate_example);
//~^ ERROR diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls

let _diag = handler.struct_err("untranslatable diagnostic");
let _diag = dcx.struct_err("untranslatable diagnostic");
//~^ ERROR diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls
//~^^ ERROR diagnostics should be created using translatable messages
}

// Check that `rustc_lint_diagnostics`-annotated functions aren't themselves linted.

#[rustc_lint_diagnostics]
pub fn skipped_because_of_annotation<'a>(handler: &'a Handler) {
let _diag = handler.struct_err("untranslatable diagnostic"); // okay!
pub fn skipped_because_of_annotation<'a>(dcx: &'a DiagCtxt) {
let _diag = dcx.struct_err("untranslatable diagnostic"); // okay!
}
24 changes: 12 additions & 12 deletions tests/ui-fulldeps/internal-lints/diagnostics.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error: diagnostics should be created using translatable messages
--> $DIR/diagnostics.rs:42:17
--> $DIR/diagnostics.rs:42:13
|
LL | handler.struct_err("untranslatable diagnostic")
| ^^^^^^^^^^
LL | dcx.struct_err("untranslatable diagnostic")
| ^^^^^^^^^^
|
note: the lint level is defined here
--> $DIR/diagnostics.rs:6:9
Expand All @@ -17,10 +17,10 @@ LL | diag.note("untranslatable diagnostic");
| ^^^^

error: diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls
--> $DIR/diagnostics.rs:79:25
--> $DIR/diagnostics.rs:79:21
|
LL | let _diag = handler.struct_err(crate::fluent_generated::no_crate_example);
| ^^^^^^^^^^
LL | let _diag = dcx.struct_err(crate::fluent_generated::no_crate_example);
| ^^^^^^^^^^
|
note: the lint level is defined here
--> $DIR/diagnostics.rs:7:9
Expand All @@ -29,16 +29,16 @@ LL | #![deny(rustc::diagnostic_outside_of_impl)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls
--> $DIR/diagnostics.rs:82:25
--> $DIR/diagnostics.rs:82:21
|
LL | let _diag = handler.struct_err("untranslatable diagnostic");
| ^^^^^^^^^^
LL | let _diag = dcx.struct_err("untranslatable diagnostic");
| ^^^^^^^^^^

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

error: aborting due to 5 previous errors

0 comments on commit 9449218

Please sign in to comment.