Remove all allows for diagnostic_outside_of_impl and untranslatable_diagnostic throughout the codebase

This PR was mostly made by search&replacing
This commit is contained in:
Jonathan Brouwer 2026-01-09 15:47:02 +01:00
parent d940e56841
commit 0ee7d96253
No known key found for this signature in database
GPG key ID: 13619B051B673C52
76 changed files with 23 additions and 254 deletions

View file

@ -29,7 +29,6 @@ pub(crate) fn extern_abi_enabled(
})
}
#[allow(rustc::untranslatable_diagnostic)]
pub(crate) fn gate_unstable_abi(sess: &Session, features: &Features, span: Span, abi: ExternAbi) {
match extern_abi_enabled(features, span, abi) {
Ok(_) => (),

View file

@ -13,15 +13,11 @@ use crate::errors;
macro_rules! gate {
($visitor:expr, $feature:ident, $span:expr, $explain:expr) => {{
if !$visitor.features.$feature() && !$span.allows_unstable(sym::$feature) {
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
feature_err(&$visitor.sess, sym::$feature, $span, $explain).emit();
}
}};
($visitor:expr, $feature:ident, $span:expr, $explain:expr, $help:expr) => {{
if !$visitor.features.$feature() && !$span.allows_unstable(sym::$feature) {
// FIXME: make this translatable
#[allow(rustc::diagnostic_outside_of_impl)]
#[allow(rustc::untranslatable_diagnostic)]
feature_err(&$visitor.sess, sym::$feature, $span, $explain).with_help($help).emit();
}
}};
@ -31,13 +27,11 @@ macro_rules! gate {
macro_rules! gate_alt {
($visitor:expr, $has_feature:expr, $name:expr, $span:expr, $explain:expr) => {{
if !$has_feature && !$span.allows_unstable($name) {
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
feature_err(&$visitor.sess, $name, $span, $explain).emit();
}
}};
($visitor:expr, $has_feature:expr, $name:expr, $span:expr, $explain:expr, $notes: expr) => {{
if !$has_feature && !$span.allows_unstable($name) {
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
let mut diag = feature_err(&$visitor.sess, $name, $span, $explain);
for note in $notes {
diag.note(*note);
@ -491,7 +485,6 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
&& (!visitor.features.gen_blocks() && !span.allows_unstable(sym::gen_blocks))
&& (!visitor.features.yield_expr() && !span.allows_unstable(sym::yield_expr))
{
#[allow(rustc::untranslatable_diagnostic)]
// Emit yield_expr as the error, since that will be sufficient. You can think of it
// as coroutines and gen_blocks imply yield_expr.
feature_err(&visitor.sess, sym::yield_expr, *span, "yield syntax is experimental")
@ -523,7 +516,6 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
if !visitor.features.min_generic_const_args()
&& !span.allows_unstable(sym::min_generic_const_args)
{
#[allow(rustc::untranslatable_diagnostic)]
feature_err(
&visitor.sess,
sym::min_generic_const_args,
@ -559,7 +551,6 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
if let Ok(snippet) = sm.span_to_snippet(span)
&& snippet == "!"
{
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
feature_err(sess, sym::never_patterns, span, "`!` patterns are experimental")
.emit();
} else {

View file

@ -412,7 +412,6 @@ fn try_gate_cfg(name: Symbol, span: Span, sess: &Session, features: Option<&Feat
}
}
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
fn gate_cfg(gated_cfg: &GatedCfg, cfg_span: Span, sess: &Session, features: &Features) {
let (cfg, feature, has_feature) = gated_cfg;
if !has_feature(features) && !cfg_span.allows_unstable(*feature) {

View file

@ -141,8 +141,6 @@ impl<S: Stage> CombineAttributeParser<S> for LinkParser {
macro report_unstable_modifier($feature: ident) {
if !features.$feature() {
// FIXME: make this translatable
#[expect(rustc::untranslatable_diagnostic)]
feature_err(
sess,
sym::$feature,

View file

@ -4,9 +4,6 @@ use super::prelude::*;
pub(crate) struct TransparencyParser;
// FIXME(jdonszelmann): make these proper diagnostics
#[allow(rustc::untranslatable_diagnostic)]
#[allow(rustc::diagnostic_outside_of_impl)]
impl<S: Stage> SingleAttributeParser<S> for TransparencyParser {
const PATH: &[Symbol] = &[sym::rustc_macro_transparency];
const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepInnermost;

View file

@ -1,6 +1,3 @@
#![allow(rustc::diagnostic_outside_of_impl)]
#![allow(rustc::untranslatable_diagnostic)]
use rustc_errors::codes::*;
use rustc_errors::{Applicability, Diag, DiagCtxtHandle, struct_span_code_err};
use rustc_hir as hir;

View file

@ -1,8 +1,5 @@
// ignore-tidy-filelength
#![allow(rustc::diagnostic_outside_of_impl)]
#![allow(rustc::untranslatable_diagnostic)]
use std::iter;
use std::ops::ControlFlow;

View file

@ -1,8 +1,5 @@
//! Print diagnostics to explain why values are borrowed.
#![allow(rustc::diagnostic_outside_of_impl)]
#![allow(rustc::untranslatable_diagnostic)]
use rustc_data_structures::assert_matches;
use rustc_errors::{Applicability, Diag, EmissionGuarantee};
use rustc_hir as hir;

View file

@ -162,8 +162,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
}
for (_, (mut diag, count)) in std::mem::take(&mut self.diags_buffer.buffered_mut_errors) {
if count > 10 {
#[allow(rustc::diagnostic_outside_of_impl)]
#[allow(rustc::untranslatable_diagnostic)]
diag.note(format!("...and {} other attempted mutable borrows", count - 10));
}
self.buffer_error(diag);
@ -236,7 +234,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
/// LL | for (key, value) in dict {
/// | ^^^^
/// ```
#[allow(rustc::diagnostic_outside_of_impl)] // FIXME
pub(super) fn add_moved_or_invoked_closure_note(
&self,
location: Location,
@ -820,7 +817,6 @@ impl UseSpans<'_> {
}
/// Add a span label to the arguments of the closure, if it exists.
#[allow(rustc::diagnostic_outside_of_impl)]
pub(super) fn args_subdiag(self, err: &mut Diag<'_>, f: impl FnOnce(Span) -> CaptureArgLabel) {
if let UseSpans::ClosureUse { args_span, .. } = self {
err.subdiagnostic(f(args_span));
@ -829,7 +825,6 @@ impl UseSpans<'_> {
/// Add a span label to the use of the captured variable, if it exists.
/// only adds label to the `path_span`
#[allow(rustc::diagnostic_outside_of_impl)]
pub(super) fn var_path_only_subdiag(
self,
err: &mut Diag<'_>,
@ -861,7 +856,6 @@ impl UseSpans<'_> {
}
/// Add a subdiagnostic to the use of the captured variable, if it exists.
#[allow(rustc::diagnostic_outside_of_impl)]
pub(super) fn var_subdiag(
self,
err: &mut Diag<'_>,
@ -1225,8 +1219,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
self.borrow_spans(span, borrow.reserve_location)
}
#[allow(rustc::diagnostic_outside_of_impl)]
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
fn explain_captures(
&mut self,
err: &mut Diag<'infcx>,

View file

@ -1,6 +1,3 @@
#![allow(rustc::diagnostic_outside_of_impl)]
#![allow(rustc::untranslatable_diagnostic)]
use rustc_data_structures::fx::FxHashSet;
use rustc_errors::{Applicability, Diag};
use rustc_hir::intravisit::Visitor;

View file

@ -1,6 +1,3 @@
#![allow(rustc::diagnostic_outside_of_impl)]
#![allow(rustc::untranslatable_diagnostic)]
use core::ops::ControlFlow;
use either::Either;

View file

@ -1,6 +1,3 @@
#![allow(rustc::diagnostic_outside_of_impl)]
#![allow(rustc::untranslatable_diagnostic)]
use std::ops::ControlFlow;
use either::Either;

View file

@ -1,9 +1,6 @@
//! Contains utilities for generating suggestions for borrowck errors related to unsatisfied
//! outlives constraints.
#![allow(rustc::diagnostic_outside_of_impl)]
#![allow(rustc::untranslatable_diagnostic)]
use std::collections::BTreeMap;
use rustc_data_structures::fx::FxIndexSet;

View file

@ -196,7 +196,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
// For generic associated types (GATs) which implied 'static requirement
// from higher-ranked trait bounds (HRTB). Try to locate span of the trait
// and the span which bounded to the trait for adding 'static lifetime suggestion
#[allow(rustc::diagnostic_outside_of_impl)]
fn suggest_static_lifetime_for_gat_from_hrtb(
&self,
diag: &mut Diag<'_>,
@ -421,9 +420,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
/// ```
///
/// Here we would be invoked with `fr = 'a` and `outlived_fr = 'b`.
// FIXME: make this translatable
#[allow(rustc::diagnostic_outside_of_impl)]
#[allow(rustc::untranslatable_diagnostic)]
pub(crate) fn report_region_error(
&mut self,
fr: RegionVid,
@ -577,7 +573,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
/// executing...
/// = note: ...therefore, returned references to captured variables will escape the closure
/// ```
#[allow(rustc::diagnostic_outside_of_impl)] // FIXME
fn report_fnmut_error(
&self,
errci: &ErrorConstraintInfo<'tcx>,
@ -686,18 +681,12 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
borrowck_errors::borrowed_data_escapes_closure(self.infcx.tcx, *span, escapes_from);
if let Some((Some(outlived_fr_name), outlived_fr_span)) = outlived_fr_name_and_span {
// FIXME: make this translatable
#[allow(rustc::diagnostic_outside_of_impl)]
#[allow(rustc::untranslatable_diagnostic)]
diag.span_label(
outlived_fr_span,
format!("`{outlived_fr_name}` declared here, outside of the {escapes_from} body",),
);
}
// FIXME: make this translatable
#[allow(rustc::diagnostic_outside_of_impl)]
#[allow(rustc::untranslatable_diagnostic)]
if let Some((Some(fr_name), fr_span)) = fr_name_and_span {
diag.span_label(
fr_span,
@ -732,9 +721,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
let outlived_fr_region_name = self.give_region_a_name(errci.outlived_fr).unwrap();
outlived_fr_region_name.highlight_region_name(&mut diag);
// FIXME: make this translatable
#[allow(rustc::diagnostic_outside_of_impl)]
#[allow(rustc::untranslatable_diagnostic)]
diag.span_label(
*span,
format!(
@ -766,7 +752,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
/// | ^^^^^^^^^^^^^^ function was supposed to return data with lifetime `'a` but it
/// | is returning data with lifetime `'b`
/// ```
#[allow(rustc::diagnostic_outside_of_impl)] // FIXME
fn report_general_error(&self, errci: &ErrorConstraintInfo<'tcx>) -> Diag<'infcx> {
let ErrorConstraintInfo { fr, outlived_fr, span, category, .. } = errci;
@ -824,8 +809,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
/// LL | fn iter_values_anon(&self) -> impl Iterator<Item=u32> + 'a {
/// | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/// ```
#[allow(rustc::diagnostic_outside_of_impl)]
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
fn add_static_impl_trait_suggestion(
&self,
diag: &mut Diag<'_>,
@ -966,7 +949,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
self.suggest_constrain_dyn_trait_in_impl(diag, &visitor.0, ident, self_ty);
}
#[allow(rustc::diagnostic_outside_of_impl)]
#[instrument(skip(self, err), level = "debug")]
fn suggest_constrain_dyn_trait_in_impl(
&self,
@ -1032,7 +1014,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
);
}
#[allow(rustc::diagnostic_outside_of_impl)]
/// When encountering a lifetime error caused by the return type of a closure, check the
/// corresponding trait bound and see if dereferencing the closure return value would satisfy
/// them. If so, we produce a structured suggestion.
@ -1160,7 +1141,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
}
}
#[allow(rustc::diagnostic_outside_of_impl)]
fn suggest_move_on_borrowing_closure(&self, diag: &mut Diag<'_>) {
let body = self.infcx.tcx.hir_body_owned_by(self.mir_def_id());
let expr = &body.value.peel_blocks();

View file

@ -1,6 +1,3 @@
#![allow(rustc::diagnostic_outside_of_impl)]
#![allow(rustc::untranslatable_diagnostic)]
use std::fmt::{self, Display};
use std::iter;

View file

@ -287,8 +287,6 @@ pub(crate) fn emit_nll_mir<'tcx>(
Ok(())
}
#[allow(rustc::diagnostic_outside_of_impl)]
#[allow(rustc::untranslatable_diagnostic)]
pub(super) fn dump_annotation<'tcx, 'infcx>(
infcx: &'infcx BorrowckInferCtxt<'tcx>,
body: &Body<'tcx>,

View file

@ -11,9 +11,6 @@
//! The code in this file doesn't *do anything* with those results; it
//! just returns them for other code to use.
#![allow(rustc::diagnostic_outside_of_impl)]
#![allow(rustc::untranslatable_diagnostic)]
use std::cell::Cell;
use std::iter;

View file

@ -19,8 +19,6 @@ pub(crate) fn expand_compile_error<'cx>(
Err(guar) => return ExpandResult::Ready(DummyResult::any(sp, guar)),
};
#[expect(rustc::diagnostic_outside_of_impl, reason = "diagnostic message is specified by user")]
#[expect(rustc::untranslatable_diagnostic, reason = "diagnostic message is specified by user")]
let guar = cx.dcx().span_err(sp, var.to_string());
cx.resolver.mark_scope_with_compile_error(cx.current_expansion.lint_node_id);

View file

@ -503,10 +503,6 @@ pub(crate) struct EnvNotDefinedWithUserMessage {
impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for EnvNotDefinedWithUserMessage {
#[track_caller]
fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
#[expect(
rustc::untranslatable_diagnostic,
reason = "cannot translate user-provided messages"
)]
let mut diag = Diag::new(dcx, level, self.msg_from_user.to_string());
diag.span(self.span);
diag

View file

@ -3,8 +3,6 @@
// tidy-alphabetical-start
#![allow(internal_features)]
#![allow(rustc::diagnostic_outside_of_impl)]
#![allow(rustc::untranslatable_diagnostic)]
#![feature(assert_matches)]
#![feature(box_patterns)]
#![feature(decl_macro)]

View file

@ -78,8 +78,6 @@ type UnexpectedExprKind<'a> = Result<(Diag<'a>, bool /* has_suggestions */), Err
/// The returned bool indicates whether an applicable suggestion has already been
/// added to the diagnostic to avoid emitting multiple suggestions. `Err(Err(ErrorGuaranteed))`
/// indicates that an ast error was encountered.
// FIXME(Nilstrieb) Make this function setup translatable
#[allow(rustc::untranslatable_diagnostic)]
pub(crate) fn expr_to_spanned_string<'a>(
cx: &'a mut ExtCtxt<'_>,
expr: Box<ast::Expr>,

View file

@ -1,6 +1,4 @@
// tidy-alphabetical-start
#![allow(rustc::diagnostic_outside_of_impl)]
#![allow(rustc::untranslatable_diagnostic)]
// Note: please avoid adding other feature gates where possible
#![feature(rustc_private)]
// Only used to define intrinsics in `compiler_builtins.rs`.

View file

@ -1,6 +1,4 @@
// tidy-alphabetical-start
#![allow(rustc::diagnostic_outside_of_impl)]
#![allow(rustc::untranslatable_diagnostic)]
#![feature(assert_matches)]
#![feature(box_patterns)]
#![feature(file_buffered)]

View file

@ -125,9 +125,6 @@ pub(crate) struct FnCallNonConst<'tcx> {
}
impl<'tcx> NonConstOp<'tcx> for FnCallNonConst<'tcx> {
// FIXME: make this translatable
#[allow(rustc::diagnostic_outside_of_impl)]
#[allow(rustc::untranslatable_diagnostic)]
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, _: Span) -> Diag<'tcx> {
let tcx = ccx.tcx;
let caller = ccx.def_id();

View file

@ -232,7 +232,6 @@ pub fn format_interp_error<'tcx>(dcx: DiagCtxtHandle<'_>, e: InterpErrorInfo<'tc
backtrace.print_backtrace();
// FIXME(fee1-dead), HACK: we want to use the error as title therefore we can just extract the
// label and arguments from the InterpError.
#[allow(rustc::untranslatable_diagnostic)]
let mut diag = dcx.struct_allow("");
let msg = e.diagnostic_message();
e.add_args(&mut diag);

View file

@ -1,5 +1,4 @@
// tidy-alphabetical-start
#![allow(rustc::diagnostic_outside_of_impl)]
#![feature(array_try_map)]
#![feature(assert_matches)]
#![feature(box_patterns)]

View file

@ -97,7 +97,6 @@ impl Expander {
/// **Note:** This function doesn't interpret argument 0 in any special way.
/// If this function is intended to be used with command line arguments,
/// `argv[0]` must be removed prior to calling it manually.
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
pub fn arg_expand_all(early_dcx: &EarlyDiagCtxt, at_args: &[String]) -> Vec<String> {
let mut expander = Expander::default();
let mut result = Ok(());

View file

@ -5,7 +5,6 @@
//! This API is completely unstable and subject to change.
// tidy-alphabetical-start
#![allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
#![feature(decl_macro)]
#![feature(panic_backtrace_config)]
#![feature(panic_update_hook)]
@ -303,7 +302,6 @@ pub fn run_compiler(at_args: &[String], callbacks: &mut (dyn Callbacks + Send))
}
if !has_input {
#[allow(rustc::diagnostic_outside_of_impl)]
sess.dcx().fatal("no input filename given"); // this is fatal
}
@ -615,7 +613,6 @@ fn list_metadata(sess: &Session, metadata_loader: &dyn MetadataLoader) {
safe_println!("{}", String::from_utf8(v).unwrap());
}
Input::Str { .. } => {
#[allow(rustc::diagnostic_outside_of_impl)]
sess.dcx().fatal("cannot list metadata for stdin");
}
}
@ -842,7 +839,6 @@ fn print_crate_info(
sess.apple_deployment_target().fmt_pretty(),
)
} else {
#[allow(rustc::diagnostic_outside_of_impl)]
sess.dcx().fatal("only Apple targets currently support deployment version info")
}
}

View file

@ -4,9 +4,7 @@
// tidy-alphabetical-start
#![allow(internal_features)]
#![allow(rustc::diagnostic_outside_of_impl)]
#![allow(rustc::direct_use_of_rustc_type_ir)]
#![allow(rustc::untranslatable_diagnostic)]
#![cfg_attr(bootstrap, feature(array_windows))]
#![feature(assert_matches)]
#![feature(associated_type_defaults)]

View file

@ -1355,8 +1355,6 @@ impl<'a> ExtCtxt<'a> {
for (span, notes) in self.expansions.iter() {
let mut db = self.dcx().create_note(errors::TraceMacro { span: *span });
for note in notes {
// FIXME: make this translatable
#[allow(rustc::untranslatable_diagnostic)]
db.note(note.clone());
}
db.emit();

View file

@ -999,7 +999,6 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
})
}
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
fn gate_proc_macro_attr_item(&self, span: Span, item: &Annotatable) {
let kind = match item {
Annotatable::Item(_)

View file

@ -1,6 +1,5 @@
// tidy-alphabetical-start
#![allow(internal_features)]
#![allow(rustc::diagnostic_outside_of_impl)]
#![cfg_attr(bootstrap, feature(array_windows))]
#![feature(associated_type_defaults)]
#![feature(if_let_guard)]
@ -13,8 +12,6 @@
mod build;
mod errors;
// FIXME(Nilstrieb) Translate macro_rules diagnostics
#[allow(rustc::untranslatable_diagnostic)]
mod mbe;
mod placeholders;
mod proc_macro_server;
@ -25,8 +22,6 @@ pub mod base;
pub mod config;
pub mod expand;
pub mod module;
// FIXME(Nilstrieb) Translate proc_macro diagnostics
#[allow(rustc::untranslatable_diagnostic)]
pub mod proc_macro;
pub fn provide(providers: &mut rustc_middle::query::Providers) {

View file

@ -548,9 +548,6 @@ impl server::FreeFunctions for Rustc<'_, '_> {
Diag::new(self.psess().dcx(), diagnostic.level.to_internal(), message);
diag.span(MultiSpan::from_spans(diagnostic.spans));
for child in diagnostic.children {
// This message comes from another diagnostic, and we are just reconstructing the
// diagnostic, so there's no need for translation.
#[allow(rustc::untranslatable_diagnostic)]
diag.sub(child.level.to_internal(), child.message, MultiSpan::from_spans(child.spans));
}
diag.emit();

View file

@ -56,8 +56,6 @@ This API is completely unstable and subject to change.
*/
// tidy-alphabetical-start
#![allow(rustc::diagnostic_outside_of_impl)]
#![allow(rustc::untranslatable_diagnostic)]
#![feature(assert_matches)]
#![feature(gen_blocks)]
#![feature(if_let_guard)]

View file

@ -524,9 +524,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// Unit testing: function items annotated with
// `#[rustc_evaluate_where_clauses]` trigger special output
// to let us test the trait evaluation system.
// Untranslatable diagnostics are okay for rustc internals
#[allow(rustc::untranslatable_diagnostic)]
#[allow(rustc::diagnostic_outside_of_impl)]
if self.has_rustc_attrs
&& self.tcx.has_attr(def_id, sym::rustc_evaluate_where_clauses)
{

View file

@ -66,8 +66,6 @@ pub(crate) fn parse_cfg(dcx: DiagCtxtHandle<'_>, cfgs: Vec<String>) -> Cfg {
macro_rules! error {
($reason: expr) => {
#[allow(rustc::untranslatable_diagnostic)]
#[allow(rustc::diagnostic_outside_of_impl)]
dcx.fatal(format!("invalid `--cfg` argument: `{s}` ({})", $reason));
};
}
@ -146,42 +144,30 @@ pub(crate) fn parse_check_cfg(dcx: DiagCtxtHandle<'_>, specs: Vec<String>) -> Ch
"visit <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more details";
macro_rules! error {
($reason:expr) => {
#[allow(rustc::untranslatable_diagnostic)]
#[allow(rustc::diagnostic_outside_of_impl)]
{
let mut diag =
dcx.struct_fatal(format!("invalid `--check-cfg` argument: `{s}`"));
diag.note($reason);
diag.note(VISIT);
diag.emit()
}
};
(in $arg:expr, $reason:expr) => {
#[allow(rustc::untranslatable_diagnostic)]
#[allow(rustc::diagnostic_outside_of_impl)]
{
let mut diag =
dcx.struct_fatal(format!("invalid `--check-cfg` argument: `{s}`"));
($reason:expr) => {{
let mut diag = dcx.struct_fatal(format!("invalid `--check-cfg` argument: `{s}`"));
diag.note($reason);
diag.note(VISIT);
diag.emit()
}};
(in $arg:expr, $reason:expr) => {{
let mut diag = dcx.struct_fatal(format!("invalid `--check-cfg` argument: `{s}`"));
let pparg = rustc_ast_pretty::pprust::meta_list_item_to_string($arg);
if let Some(lit) = $arg.lit() {
let (lit_kind_article, lit_kind_descr) = {
let lit_kind = lit.as_token_lit().kind;
(lit_kind.article(), lit_kind.descr())
};
diag.note(format!(
"`{pparg}` is {lit_kind_article} {lit_kind_descr} literal"
));
} else {
diag.note(format!("`{pparg}` is invalid"));
}
diag.note($reason);
diag.note(VISIT);
diag.emit()
let pparg = rustc_ast_pretty::pprust::meta_list_item_to_string($arg);
if let Some(lit) = $arg.lit() {
let (lit_kind_article, lit_kind_descr) = {
let lit_kind = lit.as_token_lit().kind;
(lit_kind.article(), lit_kind.descr())
};
diag.note(format!("`{pparg}` is {lit_kind_article} {lit_kind_descr} literal"));
} else {
diag.note(format!("`{pparg}` is invalid"));
}
};
diag.note($reason);
diag.note(VISIT);
diag.emit()
}};
}
let expected_error = || -> ! {
@ -408,8 +394,6 @@ pub struct Config {
/// Initialize jobserver before getting `jobserver::client` and `build_session`.
pub(crate) fn initialize_checked_jobserver(early_dcx: &EarlyDiagCtxt) {
jobserver::initialize_checked(|err| {
#[allow(rustc::untranslatable_diagnostic)]
#[allow(rustc::diagnostic_outside_of_impl)]
early_dcx
.early_struct_warn(err)
.with_note("the build environment is likely misconfigured")
@ -476,11 +460,7 @@ pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Se
config.opts.unstable_opts.translate_directionality_markers,
) {
Ok(bundle) => bundle,
Err(e) => {
// We can't translate anything if we failed to load translations
#[allow(rustc::untranslatable_diagnostic)]
early_dcx.early_fatal(format!("failed to load fluent bundle: {e}"))
}
Err(e) => early_dcx.early_fatal(format!("failed to load fluent bundle: {e}")),
};
let mut locale_resources = config.locale_resources;

View file

@ -119,8 +119,6 @@ fn init_stack_size(early_dcx: &EarlyDiagCtxt) -> usize {
// FIXME: we could accept `RUST_MIN_STACK=64MB`, perhaps?
.map(|s| {
let s = s.trim();
// FIXME(workingjubilee): add proper diagnostics when we factor out "pre-run" setup
#[allow(rustc::untranslatable_diagnostic, rustc::diagnostic_outside_of_impl)]
s.parse::<usize>().unwrap_or_else(|_| {
let mut err = early_dcx.early_struct_fatal(format!(
r#"`RUST_MIN_STACK` should be a number of bytes, but was "{s}""#,
@ -301,7 +299,6 @@ pub(crate) fn run_in_thread_pool_with_globals<
})
}
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
fn load_backend_from_dylib(early_dcx: &EarlyDiagCtxt, path: &Path) -> MakeBackendFn {
match unsafe { load_symbol_from_dylib::<MakeBackendFn>(path, "__rustc_codegen_backend") } {
Ok(backend_sym) => backend_sym,
@ -434,8 +431,6 @@ impl CodegenBackend for DummyCodegenBackend {
.find(|&&crate_type| crate_type != CrateType::Rlib)
&& outputs.outputs.should_link()
{
#[allow(rustc::untranslatable_diagnostic)]
#[allow(rustc::diagnostic_outside_of_impl)]
sess.dcx().fatal(format!(
"crate type {crate_type} not supported by the dummy codegen backend"
));
@ -491,7 +486,6 @@ pub fn rustc_path<'a>(sysroot: &Sysroot) -> Option<&'a Path> {
.as_deref()
}
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
fn get_codegen_sysroot(
early_dcx: &EarlyDiagCtxt,
sysroot: &Sysroot,

View file

@ -590,8 +590,6 @@ pub trait LintContext {
// and stored between compilation sessions. To not manually do these steps, we simply create
// a dummy diagnostic and emit it as usual, which will be suppressed and stored like a
// normal expected lint diagnostic.
#[allow(rustc::diagnostic_outside_of_impl)]
#[allow(rustc::untranslatable_diagnostic)]
self.sess()
.dcx()
.struct_expect(

View file

@ -33,7 +33,6 @@ pub struct EarlyContextAndPass<'ecx, 'tcx, T: EarlyLintPass> {
}
impl<'ecx, 'tcx, T: EarlyLintPass> EarlyContextAndPass<'ecx, 'tcx, T> {
#[allow(rustc::diagnostic_outside_of_impl)]
fn check_id(&mut self, id: ast::NodeId) {
for early_lint in self.context.buffered.take(id) {
let BufferedEarlyLint { span, node_id: _, lint_id, diagnostic } = early_lint;

View file

@ -35,7 +35,6 @@ impl Subdiagnostic for OverruledAttributeSub {
OverruledAttributeSub::NodeSource { span, reason } => {
diag.span_label(span, fluent::lint_node_source);
if let Some(rationale) = reason {
#[allow(rustc::untranslatable_diagnostic)]
diag.note(rationale.to_string());
}
}

View file

@ -941,8 +941,6 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
if self.lint_added_lints {
let lint = builtin::UNKNOWN_LINTS;
let level = self.lint_level(builtin::UNKNOWN_LINTS);
// FIXME: make this translatable
#[allow(rustc::diagnostic_outside_of_impl)]
lint_level(self.sess, lint, level, Some(span.into()), |lint| {
lint.primary_message(fluent::lint_unknown_gated_lint);
lint.arg("name", lint_id.lint.name_lower());

View file

@ -667,10 +667,6 @@ fn register_internals(store: &mut LintStore) {
store.register_late_mod_pass(|_| Box::new(SymbolInternStringLiteral));
store.register_lints(&ImplicitSysrootCrateImport::lint_vec());
store.register_early_pass(|| Box::new(ImplicitSysrootCrateImport));
// FIXME(davidtwco): deliberately do not include `UNTRANSLATABLE_DIAGNOSTIC` and
// `DIAGNOSTIC_OUTSIDE_OF_IMPL` here because `-Wrustc::internal` is provided to every crate and
// these lints will trigger all of the time - change this once migration to diagnostic structs
// and translation is completed
store.register_group(
false,
"rustc::internal",

View file

@ -1,6 +1,5 @@
// ignore-tidy-filelength
#![allow(rustc::untranslatable_diagnostic)]
use std::num::NonZero;
use rustc_errors::codes::*;
@ -2869,7 +2868,6 @@ pub(crate) struct AmbiguousGlobReexports {
pub duplicate_reexport: Span,
pub name: String,
// FIXME: make this translatable
pub namespace: String,
}
@ -2882,7 +2880,6 @@ pub(crate) struct HiddenGlobReexports {
pub private_item: Span,
pub name: String,
// FIXME: make this translatable
pub namespace: String,
}

View file

@ -120,7 +120,6 @@ fn check_panic<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>, arg: &'tc
arg_span = expn.call_site;
}
#[allow(rustc::diagnostic_outside_of_impl)]
cx.span_lint(NON_FMT_PANICS, arg_span, |lint| {
lint.primary_message(fluent::lint_non_fmt_panic);
lint.arg("name", symbol);

View file

@ -199,10 +199,6 @@ impl<'tcx> LateLintPass<'tcx> for NonLocalDefinitions {
let mut ms = MultiSpan::from_span(impl_span);
for path in &collector.paths {
// FIXME: While a translatable diagnostic message can have an argument
// we (currently) have no way to set different args per diag msg with
// `MultiSpan::push_span_label`.
#[allow(rustc::untranslatable_diagnostic)]
ms.push_span_label(
path_span_without_args(path),
format!("`{}` is not local", path_name_to_string(path)),

View file

@ -338,8 +338,6 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for MultipleCandidates {
diag.code(E0464);
diag.span(self.span);
for (i, candidate) in self.candidates.iter().enumerate() {
// FIXME: make this translatable
#[allow(rustc::untranslatable_diagnostic)]
diag.note(format!("candidate #{}: {}", i + 1, candidate.display()));
}
diag
@ -446,8 +444,6 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for InvalidMetadataFiles {
diag.code(E0786);
diag.span(self.span);
for crate_rejection in self.crate_rejections {
// FIXME: make this translatable
#[allow(rustc::untranslatable_diagnostic)]
diag.note(crate_rejection);
}
diag

View file

@ -26,9 +26,7 @@
// tidy-alphabetical-start
#![allow(internal_features)]
#![allow(rustc::diagnostic_outside_of_impl)]
#![allow(rustc::direct_use_of_rustc_type_ir)]
#![allow(rustc::untranslatable_diagnostic)]
#![cfg_attr(bootstrap, feature(array_windows))]
#![feature(allocator_api)]
#![feature(assert_matches)]

View file

@ -119,7 +119,6 @@ pub struct DeprecationSuggestion {
pub struct Deprecated {
pub sub: Option<DeprecationSuggestion>,
// FIXME: make this translatable
pub kind: String,
pub path: String,
pub note: Option<Symbol>,

View file

@ -1,8 +1,6 @@
//! Construction of MIR from HIR.
// tidy-alphabetical-start
#![allow(rustc::diagnostic_outside_of_impl)]
#![allow(rustc::untranslatable_diagnostic)]
#![feature(assert_matches)]
#![feature(box_patterns)]
#![feature(if_let_guard)]

View file

@ -258,8 +258,6 @@ fn run_passes_inner<'tcx>(
// Verify that no passes are missing from the `declare_passes` invocation
#[cfg(debug_assertions)]
#[allow(rustc::diagnostic_outside_of_impl)]
#[allow(rustc::untranslatable_diagnostic)]
{
let used_passes: FxIndexSet<_> = passes.iter().map(|p| p.name()).collect();

View file

@ -1,8 +1,6 @@
//! The main parser interface.
// tidy-alphabetical-start
#![allow(rustc::diagnostic_outside_of_impl)]
#![allow(rustc::untranslatable_diagnostic)]
#![feature(assert_matches)]
#![feature(box_patterns)]
#![feature(debug_closure_helpers)]

View file

@ -1669,7 +1669,6 @@ impl<'a> Parser<'a> {
Ok((fields, etc))
}
#[deny(rustc::untranslatable_diagnostic)]
fn report_misplaced_at_in_struct_pat(&self, prev_field: Ident) -> Diag<'a> {
debug_assert_eq!(self.token, token::At);
let span = prev_field.span.to(self.token.span);

View file

@ -184,7 +184,6 @@ impl<T: Write> Write for Shared<T> {
}
}
#[allow(rustc::untranslatable_diagnostic)] // no translation needed for tests
fn test_harness(
file_text: &str,
span_labels: Vec<SpanLabel>,

View file

@ -1692,7 +1692,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
let hir_sig = tcx.hir_fn_sig_by_hir_id(hir_id);
if let Some(hir_sig) = hir_sig {
#[allow(rustc::diagnostic_outside_of_impl)] // FIXME
match terr {
TypeError::ArgumentMutability(idx) | TypeError::ArgumentSorts(_, idx) => {
if let Some(ty) = hir_sig.decl.inputs.get(idx) {

View file

@ -3,8 +3,6 @@
//! [`rustc`] module.
// tidy-alphabetical-start
#![allow(rustc::diagnostic_outside_of_impl)]
#![allow(rustc::untranslatable_diagnostic)]
#![allow(unused_crate_dependencies)]
// tidy-alphabetical-end

View file

@ -612,9 +612,6 @@ pub fn print_query_stack<Qcx: QueryContext>(
};
if Some(count_printed) < limit_frames || limit_frames.is_none() {
// Only print to stderr as many stack frames as `num_frames` when present.
// FIXME: needs translation
#[allow(rustc::diagnostic_outside_of_impl)]
#[allow(rustc::untranslatable_diagnostic)]
dcx.struct_failure_note(format!(
"#{} [{:?}] {}",
count_printed, query_info.query.dep_kind, query_info.query.description

View file

@ -8,8 +8,6 @@
// tidy-alphabetical-start
#![allow(internal_features)]
#![allow(rustc::diagnostic_outside_of_impl)]
#![allow(rustc::untranslatable_diagnostic)]
#![feature(arbitrary_self_types)]
#![feature(assert_matches)]
#![feature(box_patterns)]

View file

@ -1138,7 +1138,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
errors::OutOfScopeMacroCalls {
span: path.span,
path: pprust::path_to_string(path),
// FIXME: Make this translatable.
location,
},
);

View file

@ -1,8 +1,6 @@
//! Contains infrastructure for configuring the compiler, including parsing
//! command-line options.
#![allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
use std::collections::btree_map::{
Iter as BTreeMapIter, Keys as BTreeMapKeysIter, Values as BTreeMapValuesIter,
};

View file

@ -49,7 +49,6 @@ pub(crate) fn split_extern_opt<'a>(
));
let adjusted_name = crate_name.replace('-', "_");
if is_ascii_ident(&adjusted_name) {
#[allow(rustc::diagnostic_outside_of_impl)] // FIXME
error
.help(format!("consider replacing the dashes with underscores: `{adjusted_name}`"));
}

View file

@ -213,7 +213,6 @@ fn emit_unknown_print_request_help(early_dcx: &EarlyDiagCtxt, req: &str, is_nigh
.join(", ");
let mut diag = early_dcx.early_struct_fatal(format!("unknown print request: `{req}`"));
#[allow(rustc::diagnostic_outside_of_impl)]
diag.help(format!("valid print requests are: {prints}"));
if req == "lints" {

View file

@ -724,7 +724,6 @@ impl<O> OptionDesc<O> {
}
}
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
fn build_options<O: Default>(
early_dcx: &EarlyDiagCtxt,
matches: &getopts::Matches,

View file

@ -132,8 +132,6 @@ pub fn feature_warn(sess: &Session, feature: Symbol, span: Span, explain: &'stat
///
/// This variant allows you to control whether it is a library or language feature.
/// Almost always, you want to use this for a language feature. If so, prefer `feature_warn`.
#[allow(rustc::diagnostic_outside_of_impl)]
#[allow(rustc::untranslatable_diagnostic)]
#[track_caller]
pub fn feature_warn_issue(
sess: &Session,
@ -171,7 +169,6 @@ pub fn add_feature_diagnostics<G: EmissionGuarantee>(
/// This variant allows you to control whether it is a library or language feature.
/// Almost always, you want to use this for a language feature. If so, prefer
/// `add_feature_diagnostics`.
#[allow(rustc::diagnostic_outside_of_impl)] // FIXME
pub fn add_feature_diagnostics_for_issue<G: EmissionGuarantee>(
err: &mut Diag<'_, G>,
sess: &Session,

View file

@ -107,7 +107,6 @@ impl SearchPath {
let dir = match path.strip_prefix("@RUSTC_BUILTIN") {
Some(stripped) => {
if !is_unstable_enabled {
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
early_dcx.early_fatal(
"the `-Z unstable-options` flag must also be passed to \
enable the use of `@RUSTC_BUILTIN`",
@ -119,7 +118,6 @@ impl SearchPath {
None => PathBuf::from(path),
};
if dir.as_os_str().is_empty() {
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
early_dcx.early_fatal("empty search path given via `-L`");
}

View file

@ -246,7 +246,6 @@ impl Session {
pub fn create_feature_err<'a>(&'a self, err: impl Diagnostic<'a>, feature: Symbol) -> Diag<'a> {
let mut err = self.dcx().create_err(err);
if err.code.is_none() {
#[allow(rustc::diagnostic_outside_of_impl)]
err.code(E0658);
}
add_feature_diagnostics(&mut err, self, feature);
@ -960,7 +959,6 @@ fn default_emitter(
// JUSTIFICATION: literally session construction
#[allow(rustc::bad_opt_access)]
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
pub fn build_session(
sopts: config::Options,
io: CompilerIO,
@ -1396,45 +1394,31 @@ impl EarlyDiagCtxt {
self.dcx = DiagCtxt::new(emitter);
}
#[allow(rustc::untranslatable_diagnostic)]
#[allow(rustc::diagnostic_outside_of_impl)]
pub fn early_note(&self, msg: impl Into<DiagMessage>) {
self.dcx.handle().note(msg)
}
#[allow(rustc::untranslatable_diagnostic)]
#[allow(rustc::diagnostic_outside_of_impl)]
pub fn early_help(&self, msg: impl Into<DiagMessage>) {
self.dcx.handle().struct_help(msg).emit()
}
#[allow(rustc::untranslatable_diagnostic)]
#[allow(rustc::diagnostic_outside_of_impl)]
#[must_use = "raise_fatal must be called on the returned ErrorGuaranteed in order to exit with a non-zero status code"]
pub fn early_err(&self, msg: impl Into<DiagMessage>) -> ErrorGuaranteed {
self.dcx.handle().err(msg)
}
#[allow(rustc::untranslatable_diagnostic)]
#[allow(rustc::diagnostic_outside_of_impl)]
pub fn early_fatal(&self, msg: impl Into<DiagMessage>) -> ! {
self.dcx.handle().fatal(msg)
}
#[allow(rustc::untranslatable_diagnostic)]
#[allow(rustc::diagnostic_outside_of_impl)]
pub fn early_struct_fatal(&self, msg: impl Into<DiagMessage>) -> Diag<'_, FatalAbort> {
self.dcx.handle().struct_fatal(msg)
}
#[allow(rustc::untranslatable_diagnostic)]
#[allow(rustc::diagnostic_outside_of_impl)]
pub fn early_warn(&self, msg: impl Into<DiagMessage>) {
self.dcx.handle().warn(msg)
}
#[allow(rustc::untranslatable_diagnostic)]
#[allow(rustc::diagnostic_outside_of_impl)]
pub fn early_struct_warn(&self, msg: impl Into<DiagMessage>) -> Diag<'_, ()> {
self.dcx.handle().struct_warn(msg)
}

View file

@ -18,7 +18,6 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for TestOutput {
fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> {
let TestOutput { span, kind, content } = self;
#[allow(rustc::untranslatable_diagnostic)]
Diag::new(dcx, level, format!("{kind}({content})")).with_span(span)
}
}

View file

@ -11,8 +11,6 @@
//! This API is completely unstable and subject to change.
// tidy-alphabetical-start
#![allow(rustc::diagnostic_outside_of_impl)]
#![allow(rustc::untranslatable_diagnostic)]
#![feature(assert_matches)]
#![feature(associated_type_defaults)]
#![feature(box_patterns)]

View file

@ -9,8 +9,6 @@
#![allow(
clippy::must_use_candidate,
clippy::missing_panics_doc,
rustc::diagnostic_outside_of_impl,
rustc::untranslatable_diagnostic
)]
#![deny(clippy::derive_deserialize_allowing_unknown)]

View file

@ -14,8 +14,6 @@
#![allow(
clippy::missing_docs_in_private_items,
clippy::must_use_candidate,
rustc::diagnostic_outside_of_impl,
rustc::untranslatable_diagnostic,
clippy::literal_string_with_formatting_args
)]
#![warn(

View file

@ -3,8 +3,6 @@
clippy::missing_docs_in_private_items,
clippy::must_use_candidate,
clippy::symbol_as_str,
rustc::diagnostic_outside_of_impl,
rustc::untranslatable_diagnostic
)]
#![warn(
trivial_casts,

View file

@ -11,8 +11,6 @@
clippy::missing_errors_doc,
clippy::missing_panics_doc,
clippy::must_use_candidate,
rustc::diagnostic_outside_of_impl,
rustc::untranslatable_diagnostic
)]
#![warn(
trivial_casts,

View file

@ -1,5 +1,3 @@
#![allow(rustc::diagnostic_outside_of_impl)]
#![allow(rustc::untranslatable_diagnostic)]
#![feature(rustc_private)]
// warn on lints, that are included in `rust-lang/rust`s bootstrap
#![warn(rust_2018_idioms, unused_lifetimes)]

View file

@ -4,8 +4,6 @@
clippy::useless_format,
clippy::field_reassign_with_default,
clippy::needless_lifetimes,
rustc::diagnostic_outside_of_impl,
rustc::untranslatable_diagnostic
)]
// The rustc crates we need

View file

@ -39,11 +39,8 @@
clippy::needless_lifetimes,
clippy::too_long_first_doc_paragraph,
clippy::len_zero,
// We don't use translatable diagnostics
rustc::diagnostic_outside_of_impl,
// We are not implementing queries here so it's fine
rustc::potential_query_instability,
rustc::untranslatable_diagnostic,
)]
#![warn(
rust_2018_idioms,

View file

@ -349,7 +349,6 @@ mod tests {
}
fn build_diagnostic(level: DiagnosticLevel, span: Option<MultiSpan>) -> DiagInner {
#[allow(rustc::untranslatable_diagnostic)] // no translation needed for empty string
let mut diag = DiagInner::new(level, "");
diag.messages.clear();
if let Some(span) = span {

View file

@ -4,8 +4,6 @@
#![crate_type = "lib"]
#![feature(rustc_attrs)]
#![feature(rustc_private)]
#![deny(rustc::untranslatable_diagnostic)]
#![deny(rustc::diagnostic_outside_of_impl)]
extern crate rustc_errors;
extern crate rustc_fluent_macro;
@ -106,7 +104,6 @@ pub fn make_diagnostics<'a>(dcx: DiagCtxtHandle<'a>) {
// `diagnostic_outside_of_impl`.
#[rustc_lint_diagnostics]
pub fn skipped_because_of_annotation<'a>(dcx: DiagCtxtHandle<'a>) {
#[allow(rustc::untranslatable_diagnostic)]
let _diag = dcx.struct_err("untranslatable diagnostic"); // okay!
}