diff --git a/compiler/rustc_ast_lowering/src/stability.rs b/compiler/rustc_ast_lowering/src/stability.rs index 6752218fa0d4b..9acdd672178a1 100644 --- a/compiler/rustc_ast_lowering/src/stability.rs +++ b/compiler/rustc_ast_lowering/src/stability.rs @@ -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(_) => (), diff --git a/compiler/rustc_ast_passes/src/feature_gate.rs b/compiler/rustc_ast_passes/src/feature_gate.rs index 028a5048d5438..dd0e27948bec6 100644 --- a/compiler/rustc_ast_passes/src/feature_gate.rs +++ b/compiler/rustc_ast_passes/src/feature_gate.rs @@ -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 { diff --git a/compiler/rustc_attr_parsing/src/attributes/cfg.rs b/compiler/rustc_attr_parsing/src/attributes/cfg.rs index ccf0a394afd0e..6cf3018a034d1 100644 --- a/compiler/rustc_attr_parsing/src/attributes/cfg.rs +++ b/compiler/rustc_attr_parsing/src/attributes/cfg.rs @@ -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) { diff --git a/compiler/rustc_attr_parsing/src/attributes/link_attrs.rs b/compiler/rustc_attr_parsing/src/attributes/link_attrs.rs index 61f975555884e..d5fb743494ead 100644 --- a/compiler/rustc_attr_parsing/src/attributes/link_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/link_attrs.rs @@ -141,8 +141,6 @@ impl CombineAttributeParser for LinkParser { macro report_unstable_modifier($feature: ident) { if !features.$feature() { - // FIXME: make this translatable - #[expect(rustc::untranslatable_diagnostic)] feature_err( sess, sym::$feature, diff --git a/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs b/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs index 922a5bd297ace..17106b7c51f58 100644 --- a/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs +++ b/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs @@ -164,21 +164,6 @@ impl SingleAttributeParser for RustcLegacyConstGenericsParser { } } -pub(crate) struct RustcLintDiagnosticsParser; - -impl NoArgsAttributeParser for RustcLintDiagnosticsParser { - const PATH: &[Symbol] = &[sym::rustc_lint_diagnostics]; - const ON_DUPLICATE: OnDuplicate = OnDuplicate::Error; - const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[ - Allow(Target::Fn), - Allow(Target::Method(MethodKind::Inherent)), - Allow(Target::Method(MethodKind::Trait { body: false })), - Allow(Target::Method(MethodKind::Trait { body: true })), - Allow(Target::Method(MethodKind::TraitImpl)), - ]); - const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcLintDiagnostics; -} - pub(crate) struct RustcLintOptDenyFieldAccessParser; impl SingleAttributeParser for RustcLintOptDenyFieldAccessParser { diff --git a/compiler/rustc_attr_parsing/src/attributes/transparency.rs b/compiler/rustc_attr_parsing/src/attributes/transparency.rs index 52aa42b1085a3..c7feb3fb5f225 100644 --- a/compiler/rustc_attr_parsing/src/attributes/transparency.rs +++ b/compiler/rustc_attr_parsing/src/attributes/transparency.rs @@ -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 SingleAttributeParser for TransparencyParser { const PATH: &[Symbol] = &[sym::rustc_macro_transparency]; const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepInnermost; diff --git a/compiler/rustc_attr_parsing/src/context.rs b/compiler/rustc_attr_parsing/src/context.rs index b85bb6c6c89d4..130227e11e7e2 100644 --- a/compiler/rustc_attr_parsing/src/context.rs +++ b/compiler/rustc_attr_parsing/src/context.rs @@ -63,11 +63,10 @@ use crate::attributes::prototype::CustomMirParser; use crate::attributes::repr::{AlignParser, AlignStaticParser, ReprParser}; use crate::attributes::rustc_internal::{ RustcLayoutScalarValidRangeEndParser, RustcLayoutScalarValidRangeStartParser, - RustcLegacyConstGenericsParser, RustcLintDiagnosticsParser, RustcLintOptDenyFieldAccessParser, - RustcLintOptTyParser, RustcLintQueryInstabilityParser, - RustcLintUntrackedQueryInformationParser, RustcMainParser, RustcMustImplementOneOfParser, - RustcNeverReturnsNullPointerParser, RustcNoImplicitAutorefsParser, - RustcObjectLifetimeDefaultParser, RustcScalableVectorParser, + RustcLegacyConstGenericsParser, RustcLintOptDenyFieldAccessParser, RustcLintOptTyParser, + RustcLintQueryInstabilityParser, RustcLintUntrackedQueryInformationParser, RustcMainParser, + RustcMustImplementOneOfParser, RustcNeverReturnsNullPointerParser, + RustcNoImplicitAutorefsParser, RustcObjectLifetimeDefaultParser, RustcScalableVectorParser, RustcSimdMonomorphizeLaneLimitParser, }; use crate::attributes::semantics::MayDangleParser; @@ -264,7 +263,6 @@ attribute_parsers!( Single>, Single>, Single>, - Single>, Single>, Single>, Single>, diff --git a/compiler/rustc_borrowck/src/borrowck_errors.rs b/compiler/rustc_borrowck/src/borrowck_errors.rs index 7c9011505d64c..0d3c554e41765 100644 --- a/compiler/rustc_borrowck/src/borrowck_errors.rs +++ b/compiler/rustc_borrowck/src/borrowck_errors.rs @@ -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; diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs index 5cfe9db009bff..caf6a86af098a 100644 --- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs @@ -1,8 +1,5 @@ // ignore-tidy-filelength -#![allow(rustc::diagnostic_outside_of_impl)] -#![allow(rustc::untranslatable_diagnostic)] - use std::iter; use std::ops::ControlFlow; diff --git a/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs b/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs index 743a28822eb97..fb67d3fb0f9ff 100644 --- a/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs +++ b/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs @@ -1,8 +1,5 @@ //! Print diagnostics to explain why values are borrowed. -#![allow(rustc::diagnostic_outside_of_impl)] -#![allow(rustc::untranslatable_diagnostic)] - use std::assert_matches::assert_matches; use rustc_errors::{Applicability, Diag, EmissionGuarantee}; diff --git a/compiler/rustc_borrowck/src/diagnostics/mod.rs b/compiler/rustc_borrowck/src/diagnostics/mod.rs index e725b13434a1f..c15e7041c94d3 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mod.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mod.rs @@ -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>, diff --git a/compiler/rustc_borrowck/src/diagnostics/move_errors.rs b/compiler/rustc_borrowck/src/diagnostics/move_errors.rs index 3322c590a6cee..f83931d375996 100644 --- a/compiler/rustc_borrowck/src/diagnostics/move_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/move_errors.rs @@ -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; diff --git a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs index e9039d4311b66..4fb739403cede 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs @@ -1,6 +1,3 @@ -#![allow(rustc::diagnostic_outside_of_impl)] -#![allow(rustc::untranslatable_diagnostic)] - use core::ops::ControlFlow; use either::Either; diff --git a/compiler/rustc_borrowck/src/diagnostics/opaque_types.rs b/compiler/rustc_borrowck/src/diagnostics/opaque_types.rs index 9991362641847..62ba4d172a3f4 100644 --- a/compiler/rustc_borrowck/src/diagnostics/opaque_types.rs +++ b/compiler/rustc_borrowck/src/diagnostics/opaque_types.rs @@ -1,6 +1,3 @@ -#![allow(rustc::diagnostic_outside_of_impl)] -#![allow(rustc::untranslatable_diagnostic)] - use std::ops::ControlFlow; use either::Either; diff --git a/compiler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs b/compiler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs index bd0cf3578c2bb..b1e16717466b5 100644 --- a/compiler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs +++ b/compiler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs @@ -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; diff --git a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs index 9c2b9139367a9..17f1988a17c40 100644 --- a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs @@ -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 + '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(); diff --git a/compiler/rustc_borrowck/src/diagnostics/region_name.rs b/compiler/rustc_borrowck/src/diagnostics/region_name.rs index 517f9e88cd9bd..fba0879e81337 100644 --- a/compiler/rustc_borrowck/src/diagnostics/region_name.rs +++ b/compiler/rustc_borrowck/src/diagnostics/region_name.rs @@ -1,6 +1,3 @@ -#![allow(rustc::diagnostic_outside_of_impl)] -#![allow(rustc::untranslatable_diagnostic)] - use std::fmt::{self, Display}; use std::iter; diff --git a/compiler/rustc_borrowck/src/nll.rs b/compiler/rustc_borrowck/src/nll.rs index 5537d90e297aa..64e3b59acfff9 100644 --- a/compiler/rustc_borrowck/src/nll.rs +++ b/compiler/rustc_borrowck/src/nll.rs @@ -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>, diff --git a/compiler/rustc_borrowck/src/universal_regions.rs b/compiler/rustc_borrowck/src/universal_regions.rs index fda4719fc3f5e..7ebfb4683bf96 100644 --- a/compiler/rustc_borrowck/src/universal_regions.rs +++ b/compiler/rustc_borrowck/src/universal_regions.rs @@ -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; diff --git a/compiler/rustc_builtin_macros/src/compile_error.rs b/compiler/rustc_builtin_macros/src/compile_error.rs index 7fc4b437c1d8d..35a587eeb2fc8 100644 --- a/compiler/rustc_builtin_macros/src/compile_error.rs +++ b/compiler/rustc_builtin_macros/src/compile_error.rs @@ -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()); ExpandResult::Ready(DummyResult::any(sp, guar)) diff --git a/compiler/rustc_builtin_macros/src/errors.rs b/compiler/rustc_builtin_macros/src/errors.rs index ad31eae10f60c..d0c63ebff9034 100644 --- a/compiler/rustc_builtin_macros/src/errors.rs +++ b/compiler/rustc_builtin_macros/src/errors.rs @@ -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 diff --git a/compiler/rustc_builtin_macros/src/lib.rs b/compiler/rustc_builtin_macros/src/lib.rs index 89ac8db760638..1c7f9abb347f0 100644 --- a/compiler/rustc_builtin_macros/src/lib.rs +++ b/compiler/rustc_builtin_macros/src/lib.rs @@ -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)] diff --git a/compiler/rustc_builtin_macros/src/util.rs b/compiler/rustc_builtin_macros/src/util.rs index e26f31dce67bd..9ac3d0e7eac12 100644 --- a/compiler/rustc_builtin_macros/src/util.rs +++ b/compiler/rustc_builtin_macros/src/util.rs @@ -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, diff --git a/compiler/rustc_codegen_cranelift/src/lib.rs b/compiler/rustc_codegen_cranelift/src/lib.rs index 5fdecd014ac05..7361a6af41784 100644 --- a/compiler/rustc_codegen_cranelift/src/lib.rs +++ b/compiler/rustc_codegen_cranelift/src/lib.rs @@ -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`. diff --git a/compiler/rustc_codegen_ssa/src/lib.rs b/compiler/rustc_codegen_ssa/src/lib.rs index d7461c76ff03e..dc7f463d21403 100644 --- a/compiler/rustc_codegen_ssa/src/lib.rs +++ b/compiler/rustc_codegen_ssa/src/lib.rs @@ -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)] diff --git a/compiler/rustc_const_eval/src/check_consts/ops.rs b/compiler/rustc_const_eval/src/check_consts/ops.rs index f606158e40180..a9366bf29fbef 100644 --- a/compiler/rustc_const_eval/src/check_consts/ops.rs +++ b/compiler/rustc_const_eval/src/check_consts/ops.rs @@ -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(); diff --git a/compiler/rustc_const_eval/src/interpret/eval_context.rs b/compiler/rustc_const_eval/src/interpret/eval_context.rs index d23369caffa42..212ac36f223c9 100644 --- a/compiler/rustc_const_eval/src/interpret/eval_context.rs +++ b/compiler/rustc_const_eval/src/interpret/eval_context.rs @@ -233,7 +233,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); diff --git a/compiler/rustc_const_eval/src/lib.rs b/compiler/rustc_const_eval/src/lib.rs index 2fce4b8c0566e..76b33b3dc7191 100644 --- a/compiler/rustc_const_eval/src/lib.rs +++ b/compiler/rustc_const_eval/src/lib.rs @@ -1,5 +1,4 @@ // tidy-alphabetical-start -#![allow(rustc::diagnostic_outside_of_impl)] #![feature(array_try_map)] #![feature(assert_matches)] #![feature(box_patterns)] diff --git a/compiler/rustc_driver_impl/src/args.rs b/compiler/rustc_driver_impl/src/args.rs index b0970144c421e..d8d55ce141257 100644 --- a/compiler/rustc_driver_impl/src/args.rs +++ b/compiler/rustc_driver_impl/src/args.rs @@ -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 { let mut expander = Expander::default(); let mut result = Ok(()); diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs index 7820198f2dcf2..df2cdfc1dafc5 100644 --- a/compiler/rustc_driver_impl/src/lib.rs +++ b/compiler/rustc_driver_impl/src/lib.rs @@ -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)] @@ -296,7 +295,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 } @@ -608,7 +606,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"); } } @@ -830,7 +827,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") } } diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs index 96a4ed3218fbf..4365ceaff22d4 100644 --- a/compiler/rustc_errors/src/diagnostic.rs +++ b/compiler/rustc_errors/src/diagnostic.rs @@ -538,7 +538,6 @@ macro_rules! with_fn { } impl<'a, G: EmissionGuarantee> Diag<'a, G> { - #[rustc_lint_diagnostics] #[track_caller] pub fn new(dcx: DiagCtxtHandle<'a>, level: Level, message: impl Into) -> Self { Self::new_diagnostic(dcx, DiagInner::new(level, message)) @@ -566,7 +565,6 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> { /// /// In the meantime, though, callsites are required to deal with the "bug" /// locally in whichever way makes the most sense. - #[rustc_lint_diagnostics] #[track_caller] pub fn downgrade_to_delayed_bug(&mut self) { assert!( @@ -584,7 +582,6 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> { /// This function still gives an emission guarantee, the guarantee is now just that it exits fatally. /// For delayed bugs this is different, since those are buffered. If we upgrade one to fatal, another /// might now be ignored. - #[rustc_lint_diagnostics] #[track_caller] pub fn upgrade_to_fatal(mut self) -> Diag<'a, FatalAbort> { assert!( @@ -613,7 +610,6 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> { /// the diagnostic was constructed. However, the label span is *not* considered a /// ["primary span"][`MultiSpan`]; only the `Span` supplied when creating the diagnostic is /// primary. - #[rustc_lint_diagnostics] pub fn span_label(&mut self, span: Span, label: impl Into) -> &mut Self { let msg = self.subdiagnostic_message_to_diagnostic_message(label); self.span.push_span_label(span, msg); @@ -623,7 +619,6 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> { with_fn! { with_span_labels, /// Labels all the given spans with the provided label. /// See [`Self::span_label()`] for more information. - #[rustc_lint_diagnostics] pub fn span_labels(&mut self, spans: impl IntoIterator, label: &str) -> &mut Self { for span in spans { self.span_label(span, label.to_string()); @@ -631,7 +626,6 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> { self } } - #[rustc_lint_diagnostics] pub fn replace_span_with(&mut self, after: Span, keep_label: bool) -> &mut Self { let before = self.span.clone(); self.span(after); @@ -647,7 +641,6 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> { self } - #[rustc_lint_diagnostics] pub fn note_expected_found( &mut self, expected_label: &str, @@ -665,7 +658,6 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> { ) } - #[rustc_lint_diagnostics] pub fn note_expected_found_extra( &mut self, expected_label: &str, @@ -711,7 +703,6 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> { self } - #[rustc_lint_diagnostics] pub fn note_trait_signature(&mut self, name: Symbol, signature: String) -> &mut Self { self.highlighted_note(vec![ StringPart::normal(format!("`{name}` from trait: `")), @@ -723,19 +714,16 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> { with_fn! { with_note, /// Add a note attached to this diagnostic. - #[rustc_lint_diagnostics] pub fn note(&mut self, msg: impl Into) -> &mut Self { self.sub(Level::Note, msg, MultiSpan::new()); self } } - #[rustc_lint_diagnostics] pub fn highlighted_note(&mut self, msg: Vec) -> &mut Self { self.sub_with_highlights(Level::Note, msg, MultiSpan::new()); self } - #[rustc_lint_diagnostics] pub fn highlighted_span_note( &mut self, span: impl Into, @@ -746,7 +734,6 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> { } /// This is like [`Diag::note()`], but it's only printed once. - #[rustc_lint_diagnostics] pub fn note_once(&mut self, msg: impl Into) -> &mut Self { self.sub(Level::OnceNote, msg, MultiSpan::new()); self @@ -755,7 +742,6 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> { with_fn! { with_span_note, /// Prints the span with a note above it. /// This is like [`Diag::note()`], but it gets its own span. - #[rustc_lint_diagnostics] pub fn span_note( &mut self, sp: impl Into, @@ -767,7 +753,6 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> { /// Prints the span with a note above it. /// This is like [`Diag::note_once()`], but it gets its own span. - #[rustc_lint_diagnostics] pub fn span_note_once>( &mut self, sp: S, @@ -779,7 +764,6 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> { with_fn! { with_warn, /// Add a warning attached to this diagnostic. - #[rustc_lint_diagnostics] pub fn warn(&mut self, msg: impl Into) -> &mut Self { self.sub(Level::Warning, msg, MultiSpan::new()); self @@ -787,7 +771,6 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> { /// Prints the span with a warning above it. /// This is like [`Diag::warn()`], but it gets its own span. - #[rustc_lint_diagnostics] pub fn span_warn>( &mut self, sp: S, @@ -799,28 +782,24 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> { with_fn! { with_help, /// Add a help message attached to this diagnostic. - #[rustc_lint_diagnostics] pub fn help(&mut self, msg: impl Into) -> &mut Self { self.sub(Level::Help, msg, MultiSpan::new()); self } } /// This is like [`Diag::help()`], but it's only printed once. - #[rustc_lint_diagnostics] pub fn help_once(&mut self, msg: impl Into) -> &mut Self { self.sub(Level::OnceHelp, msg, MultiSpan::new()); self } /// Add a help message attached to this diagnostic with a customizable highlighted message. - #[rustc_lint_diagnostics] pub fn highlighted_help(&mut self, msg: Vec) -> &mut Self { self.sub_with_highlights(Level::Help, msg, MultiSpan::new()); self } /// Add a help message attached to this diagnostic with a customizable highlighted message. - #[rustc_lint_diagnostics] pub fn highlighted_span_help( &mut self, span: impl Into, @@ -833,7 +812,6 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> { with_fn! { with_span_help, /// Prints the span with some help above it. /// This is like [`Diag::help()`], but it gets its own span. - #[rustc_lint_diagnostics] pub fn span_help( &mut self, sp: impl Into, @@ -846,7 +824,6 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> { /// Disallow attaching suggestions to this diagnostic. /// Any suggestions attached e.g. with the `span_suggestion_*` methods /// (before and after the call to `disable_suggestions`) will be ignored. - #[rustc_lint_diagnostics] pub fn disable_suggestions(&mut self) -> &mut Self { self.suggestions = Suggestions::Disabled; self @@ -856,7 +833,6 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> { /// /// Suggestions added before the call to `.seal_suggestions()` will be preserved /// and new suggestions will be ignored. - #[rustc_lint_diagnostics] pub fn seal_suggestions(&mut self) -> &mut Self { if let Suggestions::Enabled(suggestions) = &mut self.suggestions { let suggestions_slice = std::mem::take(suggestions).into_boxed_slice(); @@ -869,7 +845,6 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> { /// /// A new suggestion is added if suggestions are enabled for this diagnostic. /// Otherwise, they are ignored. - #[rustc_lint_diagnostics] fn push_suggestion(&mut self, suggestion: CodeSuggestion) { for subst in &suggestion.substitutions { for part in &subst.parts { @@ -890,7 +865,6 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> { with_fn! { with_multipart_suggestion, /// Show a suggestion that has multiple parts to it. /// In other words, multiple changes need to be applied as part of this suggestion. - #[rustc_lint_diagnostics] pub fn multipart_suggestion( &mut self, msg: impl Into, @@ -907,7 +881,6 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> { /// Show a suggestion that has multiple parts to it, always as its own subdiagnostic. /// In other words, multiple changes need to be applied as part of this suggestion. - #[rustc_lint_diagnostics] pub fn multipart_suggestion_verbose( &mut self, msg: impl Into, @@ -923,7 +896,6 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> { } /// [`Diag::multipart_suggestion()`] but you can set the [`SuggestionStyle`]. - #[rustc_lint_diagnostics] pub fn multipart_suggestion_with_style( &mut self, msg: impl Into, @@ -966,7 +938,6 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> { /// be from the message, showing the span label inline would be visually unpleasant /// (marginally overlapping spans or multiline spans) and showing the snippet window wouldn't /// improve understandability. - #[rustc_lint_diagnostics] pub fn tool_only_multipart_suggestion( &mut self, msg: impl Into, @@ -999,7 +970,6 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> { /// * may contain a name of a function, variable, or type, but not whole expressions /// /// See [`CodeSuggestion`] for more information. - #[rustc_lint_diagnostics] pub fn span_suggestion( &mut self, sp: Span, @@ -1018,7 +988,6 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> { } } /// [`Diag::span_suggestion()`] but you can set the [`SuggestionStyle`]. - #[rustc_lint_diagnostics] pub fn span_suggestion_with_style( &mut self, sp: Span, @@ -1044,7 +1013,6 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> { with_fn! { with_span_suggestion_verbose, /// Always show the suggested change. - #[rustc_lint_diagnostics] pub fn span_suggestion_verbose( &mut self, sp: Span, @@ -1065,7 +1033,6 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> { with_fn! { with_span_suggestions, /// Prints out a message with multiple suggested edits of the code. /// See also [`Diag::span_suggestion()`]. - #[rustc_lint_diagnostics] pub fn span_suggestions( &mut self, sp: Span, @@ -1082,7 +1049,6 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> { ) } } - #[rustc_lint_diagnostics] pub fn span_suggestions_with_style( &mut self, sp: Span, @@ -1113,7 +1079,6 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> { /// Prints out a message with multiple suggested edits of the code, where each edit consists of /// multiple parts. /// See also [`Diag::multipart_suggestion()`]. - #[rustc_lint_diagnostics] pub fn multipart_suggestions( &mut self, msg: impl Into, @@ -1160,7 +1125,6 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> { /// inline, it will only show the message and not the suggestion. /// /// See [`CodeSuggestion`] for more information. - #[rustc_lint_diagnostics] pub fn span_suggestion_short( &mut self, sp: Span, @@ -1184,7 +1148,6 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> { /// be from the message, showing the span label inline would be visually unpleasant /// (marginally overlapping spans or multiline spans) and showing the snippet window wouldn't /// improve understandability. - #[rustc_lint_diagnostics] pub fn span_suggestion_hidden( &mut self, sp: Span, @@ -1207,7 +1170,6 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> { /// /// This is intended to be used for suggestions that are *very* obvious in what the changes /// need to be from the message, but we still want other tools to be able to apply them. - #[rustc_lint_diagnostics] pub fn tool_only_span_suggestion( &mut self, sp: Span, @@ -1229,7 +1191,6 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> { /// [rustc_macros::Subdiagnostic]). Performs eager translation of any translatable messages /// used in the subdiagnostic, so suitable for use with repeated messages (i.e. re-use of /// interpolated variables). - #[rustc_lint_diagnostics] pub fn subdiagnostic(&mut self, subdiagnostic: impl Subdiagnostic) -> &mut Self { subdiagnostic.add_to_diag(self); self @@ -1248,7 +1209,6 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> { with_fn! { with_span, /// Add a span. - #[rustc_lint_diagnostics] pub fn span(&mut self, sp: impl Into) -> &mut Self { self.span = sp.into(); if let Some(span) = self.span.primary_span() { @@ -1257,7 +1217,6 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> { self } } - #[rustc_lint_diagnostics] pub fn is_lint(&mut self, name: String, has_future_breakage: bool) -> &mut Self { self.is_lint = Some(IsLint { name, has_future_breakage }); self @@ -1265,7 +1224,6 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> { with_fn! { with_code, /// Add an error code. - #[rustc_lint_diagnostics] pub fn code(&mut self, code: ErrCode) -> &mut Self { self.code = Some(code); self @@ -1273,7 +1231,6 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> { with_fn! { with_lint_id, /// Add an argument. - #[rustc_lint_diagnostics] pub fn lint_id( &mut self, id: LintExpectationId, @@ -1284,7 +1241,6 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> { with_fn! { with_primary_message, /// Add a primary message. - #[rustc_lint_diagnostics] pub fn primary_message(&mut self, msg: impl Into) -> &mut Self { self.messages[0] = (msg.into(), Style::NoStyle); self @@ -1292,7 +1248,6 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> { with_fn! { with_arg, /// Add an argument. - #[rustc_lint_diagnostics] pub fn arg( &mut self, name: impl Into, diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index 148368045f4f5..d317361781083 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -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)] @@ -1217,22 +1215,16 @@ impl<'a> DiagCtxtHandle<'a> { // Functions beginning with `struct_`/`create_` create a diagnostic. Other // functions create and emit a diagnostic all in one go. impl<'a> DiagCtxtHandle<'a> { - // No `#[rustc_lint_diagnostics]` and no `impl Into` because bug messages aren't - // user-facing. #[track_caller] pub fn struct_bug(self, msg: impl Into>) -> Diag<'a, BugAbort> { Diag::new(self, Bug, msg.into()) } - // No `#[rustc_lint_diagnostics]` and no `impl Into` because bug messages aren't - // user-facing. #[track_caller] pub fn bug(self, msg: impl Into>) -> ! { self.struct_bug(msg).emit() } - // No `#[rustc_lint_diagnostics]` and no `impl Into` because bug messages aren't - // user-facing. #[track_caller] pub fn struct_span_bug( self, @@ -1242,8 +1234,6 @@ impl<'a> DiagCtxtHandle<'a> { self.struct_bug(msg).with_span(span) } - // No `#[rustc_lint_diagnostics]` and no `impl Into` because bug messages aren't - // user-facing. #[track_caller] pub fn span_bug(self, span: impl Into, msg: impl Into>) -> ! { self.struct_span_bug(span, msg.into()).emit() @@ -1259,19 +1249,16 @@ impl<'a> DiagCtxtHandle<'a> { self.create_bug(bug).emit() } - #[rustc_lint_diagnostics] #[track_caller] pub fn struct_fatal(self, msg: impl Into) -> Diag<'a, FatalAbort> { Diag::new(self, Fatal, msg) } - #[rustc_lint_diagnostics] #[track_caller] pub fn fatal(self, msg: impl Into) -> ! { self.struct_fatal(msg).emit() } - #[rustc_lint_diagnostics] #[track_caller] pub fn struct_span_fatal( self, @@ -1281,7 +1268,6 @@ impl<'a> DiagCtxtHandle<'a> { self.struct_fatal(msg).with_span(span) } - #[rustc_lint_diagnostics] #[track_caller] pub fn span_fatal(self, span: impl Into, msg: impl Into) -> ! { self.struct_span_fatal(span, msg).emit() @@ -1311,19 +1297,16 @@ impl<'a> DiagCtxtHandle<'a> { } // FIXME: This method should be removed (every error should have an associated error code). - #[rustc_lint_diagnostics] #[track_caller] pub fn struct_err(self, msg: impl Into) -> Diag<'a> { Diag::new(self, Error, msg) } - #[rustc_lint_diagnostics] #[track_caller] pub fn err(self, msg: impl Into) -> ErrorGuaranteed { self.struct_err(msg).emit() } - #[rustc_lint_diagnostics] #[track_caller] pub fn struct_span_err( self, @@ -1333,7 +1316,6 @@ impl<'a> DiagCtxtHandle<'a> { self.struct_err(msg).with_span(span) } - #[rustc_lint_diagnostics] #[track_caller] pub fn span_err( self, @@ -1354,9 +1336,6 @@ impl<'a> DiagCtxtHandle<'a> { } /// Ensures that an error is printed. See [`Level::DelayedBug`]. - // - // No `#[rustc_lint_diagnostics]` and no `impl Into` because bug messages aren't - // user-facing. #[track_caller] pub fn delayed_bug(self, msg: impl Into>) -> ErrorGuaranteed { Diag::::new(self, DelayedBug, msg.into()).emit() @@ -1366,9 +1345,6 @@ impl<'a> DiagCtxtHandle<'a> { /// /// Note: this function used to be called `delay_span_bug`. It was renamed /// to match similar functions like `span_err`, `span_warn`, etc. - // - // No `#[rustc_lint_diagnostics]` and no `impl Into` because bug messages aren't - // user-facing. #[track_caller] pub fn span_delayed_bug( self, @@ -1378,19 +1354,16 @@ impl<'a> DiagCtxtHandle<'a> { Diag::::new(self, DelayedBug, msg.into()).with_span(sp).emit() } - #[rustc_lint_diagnostics] #[track_caller] pub fn struct_warn(self, msg: impl Into) -> Diag<'a, ()> { Diag::new(self, Warning, msg) } - #[rustc_lint_diagnostics] #[track_caller] pub fn warn(self, msg: impl Into) { self.struct_warn(msg).emit() } - #[rustc_lint_diagnostics] #[track_caller] pub fn struct_span_warn( self, @@ -1400,7 +1373,6 @@ impl<'a> DiagCtxtHandle<'a> { self.struct_warn(msg).with_span(span) } - #[rustc_lint_diagnostics] #[track_caller] pub fn span_warn(self, span: impl Into, msg: impl Into) { self.struct_span_warn(span, msg).emit() @@ -1416,19 +1388,16 @@ impl<'a> DiagCtxtHandle<'a> { self.create_warn(warning).emit() } - #[rustc_lint_diagnostics] #[track_caller] pub fn struct_note(self, msg: impl Into) -> Diag<'a, ()> { Diag::new(self, Note, msg) } - #[rustc_lint_diagnostics] #[track_caller] pub fn note(&self, msg: impl Into) { self.struct_note(msg).emit() } - #[rustc_lint_diagnostics] #[track_caller] pub fn struct_span_note( self, @@ -1438,7 +1407,6 @@ impl<'a> DiagCtxtHandle<'a> { self.struct_note(msg).with_span(span) } - #[rustc_lint_diagnostics] #[track_caller] pub fn span_note(self, span: impl Into, msg: impl Into) { self.struct_span_note(span, msg).emit() @@ -1454,25 +1422,21 @@ impl<'a> DiagCtxtHandle<'a> { self.create_note(note).emit() } - #[rustc_lint_diagnostics] #[track_caller] pub fn struct_help(self, msg: impl Into) -> Diag<'a, ()> { Diag::new(self, Help, msg) } - #[rustc_lint_diagnostics] #[track_caller] pub fn struct_failure_note(self, msg: impl Into) -> Diag<'a, ()> { Diag::new(self, FailureNote, msg) } - #[rustc_lint_diagnostics] #[track_caller] pub fn struct_allow(self, msg: impl Into) -> Diag<'a, ()> { Diag::new(self, Allow, msg) } - #[rustc_lint_diagnostics] #[track_caller] pub fn struct_expect(self, msg: impl Into, id: LintExpectationId) -> Diag<'a, ()> { Diag::new(self, Expect, msg).with_lint_id(id) diff --git a/compiler/rustc_expand/src/base.rs b/compiler/rustc_expand/src/base.rs index 946f17943fe3d..b391f857e2203 100644 --- a/compiler/rustc_expand/src/base.rs +++ b/compiler/rustc_expand/src/base.rs @@ -1378,8 +1378,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(); diff --git a/compiler/rustc_expand/src/expand.rs b/compiler/rustc_expand/src/expand.rs index c130d9f599401..c4035bc839c5e 100644 --- a/compiler/rustc_expand/src/expand.rs +++ b/compiler/rustc_expand/src/expand.rs @@ -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(_) diff --git a/compiler/rustc_expand/src/lib.rs b/compiler/rustc_expand/src/lib.rs index 5eefa4bcdf6be..2aca6ef648a4e 100644 --- a/compiler/rustc_expand/src/lib.rs +++ b/compiler/rustc_expand/src/lib.rs @@ -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; rustc_fluent_macro::fluent_messages! { "../messages.ftl" } diff --git a/compiler/rustc_expand/src/proc_macro_server.rs b/compiler/rustc_expand/src/proc_macro_server.rs index 0e063011eea49..7688df2d3a55d 100644 --- a/compiler/rustc_expand/src/proc_macro_server.rs +++ b/compiler/rustc_expand/src/proc_macro_server.rs @@ -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(); diff --git a/compiler/rustc_feature/src/builtin_attrs.rs b/compiler/rustc_feature/src/builtin_attrs.rs index a7e8515e415f0..c71123a25bdf9 100644 --- a/compiler/rustc_feature/src/builtin_attrs.rs +++ b/compiler/rustc_feature/src/builtin_attrs.rs @@ -1182,12 +1182,6 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ rustc_lint_untracked_query_information, Normal, template!(Word), WarnFollowing, EncodeCrossCrate::Yes, ), - // Used by the `rustc::diagnostic_outside_of_impl` lints to assist in changes to diagnostic - // APIs. Any function with this attribute will be checked by that lint. - rustc_attr!( - rustc_lint_diagnostics, Normal, template!(Word), - WarnFollowing, EncodeCrossCrate::Yes, - ), // Used by the `rustc::bad_opt_access` lint to identify `DebuggingOptions` and `CodegenOptions` // types (as well as any others in future). rustc_attr!( diff --git a/compiler/rustc_hir/src/attrs/data_structures.rs b/compiler/rustc_hir/src/attrs/data_structures.rs index fa8998f0546d1..f2389f1e5b3eb 100644 --- a/compiler/rustc_hir/src/attrs/data_structures.rs +++ b/compiler/rustc_hir/src/attrs/data_structures.rs @@ -876,9 +876,6 @@ pub enum AttributeKind { /// Represents `#[rustc_legacy_const_generics]` RustcLegacyConstGenerics { fn_indexes: ThinVec<(usize, Span)>, attr_span: Span }, - /// Represents `#[rustc_lint_diagnostics]` - RustcLintDiagnostics, - /// Represents `#[rustc_lint_opt_deny_field_access]` RustcLintOptDenyFieldAccess { lint_message: Symbol }, diff --git a/compiler/rustc_hir/src/attrs/encode_cross_crate.rs b/compiler/rustc_hir/src/attrs/encode_cross_crate.rs index 3efa876ed6a9b..0e1d64ebdd659 100644 --- a/compiler/rustc_hir/src/attrs/encode_cross_crate.rs +++ b/compiler/rustc_hir/src/attrs/encode_cross_crate.rs @@ -98,7 +98,6 @@ impl AttributeKind { RustcLayoutScalarValidRangeEnd(..) => Yes, RustcLayoutScalarValidRangeStart(..) => Yes, RustcLegacyConstGenerics { .. } => Yes, - RustcLintDiagnostics => Yes, RustcLintOptDenyFieldAccess { .. } => Yes, RustcLintOptTy => Yes, RustcLintQueryInstability => Yes, diff --git a/compiler/rustc_hir_analysis/src/lib.rs b/compiler/rustc_hir_analysis/src/lib.rs index 7296ba6f964a4..ee9b0fb7e9734 100644 --- a/compiler/rustc_hir_analysis/src/lib.rs +++ b/compiler/rustc_hir_analysis/src/lib.rs @@ -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)] diff --git a/compiler/rustc_hir_typeck/src/callee.rs b/compiler/rustc_hir_typeck/src/callee.rs index b60d053957a9b..4594b9217f830 100644 --- a/compiler/rustc_hir_typeck/src/callee.rs +++ b/compiler/rustc_hir_typeck/src/callee.rs @@ -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) { diff --git a/compiler/rustc_interface/src/interface.rs b/compiler/rustc_interface/src/interface.rs index b2c4a91581979..b952e280cb0a0 100644 --- a/compiler/rustc_interface/src/interface.rs +++ b/compiler/rustc_interface/src/interface.rs @@ -66,8 +66,6 @@ pub(crate) fn parse_cfg(dcx: DiagCtxtHandle<'_>, cfgs: Vec) -> 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) -> Ch "visit 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() + ($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")); } - }; - (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}`")); - - 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() - } - }; + 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") @@ -475,11 +459,7 @@ pub fn run_compiler(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; diff --git a/compiler/rustc_interface/src/util.rs b/compiler/rustc_interface/src/util.rs index 7e9c135661630..94f3b056266ee 100644 --- a/compiler/rustc_interface/src/util.rs +++ b/compiler/rustc_interface/src/util.rs @@ -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::().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::(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, diff --git a/compiler/rustc_lint/messages.ftl b/compiler/rustc_lint/messages.ftl index b49b090272d45..c3592e2aad57a 100644 --- a/compiler/rustc_lint/messages.ftl +++ b/compiler/rustc_lint/messages.ftl @@ -232,9 +232,6 @@ lint_deprecated_where_clause_location = where clause not allowed here .suggestion_move_to_end = move it to the end of the type declaration .suggestion_remove_where = remove this `where` -lint_diag_out_of_impl = - diagnostics should only be created in `Diagnostic`/`Subdiagnostic`/`LintDiagnostic` impls - lint_doc_alias_duplicated = doc alias is duplicated .label = first defined here @@ -984,8 +981,6 @@ lint_unsafe_attr_outside_unsafe_suggestion = wrap the attribute in `unsafe(...)` lint_unsupported_group = `{$lint_group}` lint group is not supported with ´--force-warn´ -lint_untranslatable_diag = diagnostics should be created using translatable messages - lint_unused_allocation = unnecessary allocation, use `&` instead lint_unused_allocation_mut = unnecessary allocation, use `&mut` instead diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs index 68fcf73cec51a..19f3a9b4c062e 100644 --- a/compiler/rustc_lint/src/context.rs +++ b/compiler/rustc_lint/src/context.rs @@ -509,7 +509,6 @@ pub trait LintContext { /// Emit a lint at the appropriate level, with an optional associated span. /// /// [`lint_level`]: rustc_middle::lint::lint_level#decorate-signature - #[rustc_lint_diagnostics] #[track_caller] fn opt_span_lint>( &self, @@ -548,7 +547,6 @@ pub trait LintContext { /// Emit a lint at the appropriate level, with an associated span. /// /// [`lint_level`]: rustc_middle::lint::lint_level#decorate-signature - #[rustc_lint_diagnostics] #[track_caller] fn span_lint>( &self, @@ -570,7 +568,6 @@ pub trait LintContext { /// Emit a lint at the appropriate level, with no associated span. /// /// [`lint_level`]: rustc_middle::lint::lint_level#decorate-signature - #[rustc_lint_diagnostics] fn lint(&self, lint: &'static Lint, decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>)) { self.opt_span_lint(lint, None as Option, decorate); } @@ -590,8 +587,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( @@ -630,7 +625,6 @@ impl<'tcx> LintContext for LateContext<'tcx> { self.tcx.sess } - #[rustc_lint_diagnostics] fn opt_span_lint>( &self, lint: &'static Lint, @@ -656,7 +650,6 @@ impl LintContext for EarlyContext<'_> { self.builder.sess() } - #[rustc_lint_diagnostics] fn opt_span_lint>( &self, lint: &'static Lint, diff --git a/compiler/rustc_lint/src/early.rs b/compiler/rustc_lint/src/early.rs index 6cb5aea798407..0295df2feca56 100644 --- a/compiler/rustc_lint/src/early.rs +++ b/compiler/rustc_lint/src/early.rs @@ -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; diff --git a/compiler/rustc_lint/src/errors.rs b/compiler/rustc_lint/src/errors.rs index 586e55c8055c9..8f2f3594161ac 100644 --- a/compiler/rustc_lint/src/errors.rs +++ b/compiler/rustc_lint/src/errors.rs @@ -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()); } } diff --git a/compiler/rustc_lint/src/internal.rs b/compiler/rustc_lint/src/internal.rs index 68885e14f40d2..37eb375c7a6c2 100644 --- a/compiler/rustc_lint/src/internal.rs +++ b/compiler/rustc_lint/src/internal.rs @@ -5,18 +5,17 @@ use rustc_hir::attrs::AttributeKind; use rustc_hir::def::Res; use rustc_hir::def_id::DefId; use rustc_hir::{Expr, ExprKind, HirId, find_attr}; -use rustc_middle::ty::{self, GenericArgsRef, PredicatePolarity, Ty}; +use rustc_middle::ty::{self, GenericArgsRef, PredicatePolarity}; use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::hygiene::{ExpnKind, MacroKind}; use rustc_span::{Span, sym}; -use tracing::debug; use {rustc_ast as ast, rustc_hir as hir}; use crate::lints::{ - BadOptAccessDiag, DefaultHashTypesDiag, DiagOutOfImpl, ImplicitSysrootCrateImportDiag, - LintPassByHand, NonGlobImportTypeIrInherent, QueryInstability, QueryUntracked, - SpanUseEqCtxtDiag, SymbolInternStringLiteralDiag, TyQualified, TykindDiag, TykindKind, - TypeIrDirectUse, TypeIrInherentUsage, TypeIrTraitUsage, UntranslatableDiag, + BadOptAccessDiag, DefaultHashTypesDiag, ImplicitSysrootCrateImportDiag, LintPassByHand, + NonGlobImportTypeIrInherent, QueryInstability, QueryUntracked, SpanUseEqCtxtDiag, + SymbolInternStringLiteralDiag, TyQualified, TykindDiag, TykindKind, TypeIrDirectUse, + TypeIrInherentUsage, TypeIrTraitUsage, }; use crate::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext}; @@ -492,162 +491,6 @@ impl EarlyLintPass for LintPassImpl { } } -declare_tool_lint! { - /// The `untranslatable_diagnostic` lint detects messages passed to functions with `impl - /// Into<{D,Subd}iagMessage` parameters without using translatable Fluent strings. - /// - /// More details on translatable diagnostics can be found - /// [here](https://rustc-dev-guide.rust-lang.org/diagnostics/translation.html). - pub rustc::UNTRANSLATABLE_DIAGNOSTIC, - Allow, - "prevent creation of diagnostics which cannot be translated", - report_in_external_macro: true, - @eval_always = true -} - -declare_tool_lint! { - /// The `diagnostic_outside_of_impl` lint detects calls to functions annotated with - /// `#[rustc_lint_diagnostics]` that are outside an `Diagnostic`, `Subdiagnostic`, or - /// `LintDiagnostic` impl (either hand-written or derived). - /// - /// More details on diagnostics implementations can be found - /// [here](https://rustc-dev-guide.rust-lang.org/diagnostics/diagnostic-structs.html). - pub rustc::DIAGNOSTIC_OUTSIDE_OF_IMPL, - Allow, - "prevent diagnostic creation outside of `Diagnostic`/`Subdiagnostic`/`LintDiagnostic` impls", - report_in_external_macro: true, - @eval_always = true -} - -declare_lint_pass!(Diagnostics => [UNTRANSLATABLE_DIAGNOSTIC, DIAGNOSTIC_OUTSIDE_OF_IMPL]); - -impl LateLintPass<'_> for Diagnostics { - fn check_expr<'tcx>(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'tcx>) { - let collect_args_tys_and_spans = |args: &[hir::Expr<'_>], reserve_one_extra: bool| { - let mut result = Vec::with_capacity(args.len() + usize::from(reserve_one_extra)); - result.extend(args.iter().map(|arg| (cx.typeck_results().expr_ty(arg), arg.span))); - result - }; - // Only check function calls and method calls. - let Some((def_id, span, fn_gen_args, recv, args)) = - get_callee_span_generic_args_and_args(cx, expr) - else { - return; - }; - let mut arg_tys_and_spans = collect_args_tys_and_spans(args, recv.is_some()); - if let Some(recv) = recv { - arg_tys_and_spans.insert(0, (cx.tcx.types.self_param, recv.span)); // dummy inserted for `self` - } - - Self::diagnostic_outside_of_impl(cx, span, expr.hir_id, def_id, fn_gen_args); - Self::untranslatable_diagnostic(cx, def_id, &arg_tys_and_spans); - } -} - -impl Diagnostics { - // Is the type `{D,Subd}iagMessage`? - fn is_diag_message<'cx>(cx: &LateContext<'cx>, ty: Ty<'cx>) -> bool { - if let Some(adt_def) = ty.ty_adt_def() - && let Some(name) = cx.tcx.get_diagnostic_name(adt_def.did()) - && matches!(name, sym::DiagMessage | sym::SubdiagMessage) - { - true - } else { - false - } - } - - fn untranslatable_diagnostic<'cx>( - cx: &LateContext<'cx>, - def_id: DefId, - arg_tys_and_spans: &[(Ty<'cx>, Span)], - ) { - let fn_sig = cx.tcx.fn_sig(def_id).instantiate_identity().skip_binder(); - let predicates = cx.tcx.predicates_of(def_id).instantiate_identity(cx.tcx).predicates; - for (i, ¶m_ty) in fn_sig.inputs().iter().enumerate() { - if let ty::Param(sig_param) = param_ty.kind() { - // It is a type parameter. Check if it is `impl Into<{D,Subd}iagMessage>`. - for pred in predicates.iter() { - if let Some(trait_pred) = pred.as_trait_clause() - && let trait_ref = trait_pred.skip_binder().trait_ref - && trait_ref.self_ty() == param_ty // correct predicate for the param? - && cx.tcx.is_diagnostic_item(sym::Into, trait_ref.def_id) - && let ty1 = trait_ref.args.type_at(1) - && Self::is_diag_message(cx, ty1) - { - // Calls to methods with an `impl Into<{D,Subd}iagMessage>` parameter must be passed an arg - // with type `{D,Subd}iagMessage` or `impl Into<{D,Subd}iagMessage>`. Otherwise, emit an - // `UNTRANSLATABLE_DIAGNOSTIC` lint. - let (arg_ty, arg_span) = arg_tys_and_spans[i]; - - // Is the arg type `{Sub,D}iagMessage`or `impl Into<{Sub,D}iagMessage>`? - let is_translatable = Self::is_diag_message(cx, arg_ty) - || matches!(arg_ty.kind(), ty::Param(arg_param) if arg_param.name == sig_param.name); - if !is_translatable { - cx.emit_span_lint( - UNTRANSLATABLE_DIAGNOSTIC, - arg_span, - UntranslatableDiag, - ); - } - } - } - } - } - } - - fn diagnostic_outside_of_impl<'cx>( - cx: &LateContext<'cx>, - span: Span, - current_id: HirId, - def_id: DefId, - fn_gen_args: GenericArgsRef<'cx>, - ) { - // Is the callee marked with `#[rustc_lint_diagnostics]`? - let Some(inst) = - ty::Instance::try_resolve(cx.tcx, cx.typing_env(), def_id, fn_gen_args).ok().flatten() - else { - return; - }; - - if !find_attr!(cx.tcx.get_all_attrs(inst.def_id()), AttributeKind::RustcLintDiagnostics) { - return; - }; - - for (hir_id, _parent) in cx.tcx.hir_parent_iter(current_id) { - if let Some(owner_did) = hir_id.as_owner() - && find_attr!(cx.tcx.get_all_attrs(owner_did), AttributeKind::RustcLintDiagnostics) - { - // The parent method is marked with `#[rustc_lint_diagnostics]` - return; - } - } - - // Calls to `#[rustc_lint_diagnostics]`-marked functions should only occur: - // - inside an impl of `Diagnostic`, `Subdiagnostic`, or `LintDiagnostic`, or - // - inside a parent function that is itself marked with `#[rustc_lint_diagnostics]`. - // - // Otherwise, emit a `DIAGNOSTIC_OUTSIDE_OF_IMPL` lint. - let mut is_inside_appropriate_impl = false; - for (_hir_id, parent) in cx.tcx.hir_parent_iter(current_id) { - debug!(?parent); - if let hir::Node::Item(hir::Item { kind: hir::ItemKind::Impl(impl_), .. }) = parent - && let Some(of_trait) = impl_.of_trait - && let Some(def_id) = of_trait.trait_ref.trait_def_id() - && let Some(name) = cx.tcx.get_diagnostic_name(def_id) - && matches!(name, sym::Diagnostic | sym::Subdiagnostic | sym::LintDiagnostic) - { - is_inside_appropriate_impl = true; - break; - } - } - debug!(?is_inside_appropriate_impl); - if !is_inside_appropriate_impl { - cx.emit_span_lint(DIAGNOSTIC_OUTSIDE_OF_IMPL, span, DiagOutOfImpl); - } - } -} - declare_tool_lint! { /// The `bad_opt_access` lint detects accessing options by field instead of /// the wrapper function. diff --git a/compiler/rustc_lint/src/levels.rs b/compiler/rustc_lint/src/levels.rs index 0f6452a2bc995..57dacbc11e054 100644 --- a/compiler/rustc_lint/src/levels.rs +++ b/compiler/rustc_lint/src/levels.rs @@ -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()); @@ -970,7 +968,6 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> { /// this lint context. /// /// [`lint_level`]: rustc_middle::lint::lint_level#decorate-signature - #[rustc_lint_diagnostics] #[track_caller] pub(crate) fn opt_span_lint( &self, diff --git a/compiler/rustc_lint/src/lib.rs b/compiler/rustc_lint/src/lib.rs index ec7ce1ade9290..0105446b545d5 100644 --- a/compiler/rustc_lint/src/lib.rs +++ b/compiler/rustc_lint/src/lib.rs @@ -655,8 +655,6 @@ fn register_internals(store: &mut LintStore) { store.register_late_mod_pass(|_| Box::new(TyTyKind)); store.register_lints(&TypeIr::lint_vec()); store.register_late_mod_pass(|_| Box::new(TypeIr)); - store.register_lints(&Diagnostics::lint_vec()); - store.register_late_mod_pass(|_| Box::new(Diagnostics)); store.register_lints(&BadOptAccess::lint_vec()); store.register_late_mod_pass(|_| Box::new(BadOptAccess)); store.register_lints(&PassByValue::lint_vec()); @@ -667,10 +665,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", diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index 841b11c996872..c7ab0dc1fa7bd 100644 --- a/compiler/rustc_lint/src/lints.rs +++ b/compiler/rustc_lint/src/lints.rs @@ -1,6 +1,5 @@ // ignore-tidy-filelength -#![allow(rustc::untranslatable_diagnostic)] use std::num::NonZero; use rustc_errors::codes::*; @@ -944,14 +943,6 @@ pub(crate) struct NonGlobImportTypeIrInherent { #[help] pub(crate) struct LintPassByHand; -#[derive(LintDiagnostic)] -#[diag(lint_diag_out_of_impl)] -pub(crate) struct DiagOutOfImpl; - -#[derive(LintDiagnostic)] -#[diag(lint_untranslatable_diag)] -pub(crate) struct UntranslatableDiag; - #[derive(LintDiagnostic)] #[diag(lint_bad_opt_access)] pub(crate) struct BadOptAccessDiag<'a> { @@ -2869,7 +2860,6 @@ pub(crate) struct AmbiguousGlobReexports { pub duplicate_reexport: Span, pub name: String, - // FIXME: make this translatable pub namespace: String, } @@ -2882,7 +2872,6 @@ pub(crate) struct HiddenGlobReexports { pub private_item: Span, pub name: String, - // FIXME: make this translatable pub namespace: String, } diff --git a/compiler/rustc_lint/src/non_fmt_panic.rs b/compiler/rustc_lint/src/non_fmt_panic.rs index f6295698b2813..a07c3b372d347 100644 --- a/compiler/rustc_lint/src/non_fmt_panic.rs +++ b/compiler/rustc_lint/src/non_fmt_panic.rs @@ -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); diff --git a/compiler/rustc_lint/src/non_local_def.rs b/compiler/rustc_lint/src/non_local_def.rs index b10be22dc389d..bcf4d9ec3b295 100644 --- a/compiler/rustc_lint/src/non_local_def.rs +++ b/compiler/rustc_lint/src/non_local_def.rs @@ -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)), diff --git a/compiler/rustc_metadata/src/errors.rs b/compiler/rustc_metadata/src/errors.rs index 2702c4498df6f..8eb4fad078fe8 100644 --- a/compiler/rustc_metadata/src/errors.rs +++ b/compiler/rustc_metadata/src/errors.rs @@ -338,8 +338,6 @@ impl 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 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 diff --git a/compiler/rustc_middle/src/lib.rs b/compiler/rustc_middle/src/lib.rs index 5f62d44df6b61..412e1896fb87b 100644 --- a/compiler/rustc_middle/src/lib.rs +++ b/compiler/rustc_middle/src/lib.rs @@ -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)] diff --git a/compiler/rustc_middle/src/middle/stability.rs b/compiler/rustc_middle/src/middle/stability.rs index 18520089e3ea3..eed3e5c631953 100644 --- a/compiler/rustc_middle/src/middle/stability.rs +++ b/compiler/rustc_middle/src/middle/stability.rs @@ -119,7 +119,6 @@ pub struct DeprecationSuggestion { pub struct Deprecated { pub sub: Option, - // FIXME: make this translatable pub kind: String, pub path: String, pub note: Option, diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index a2f4714d1b2c2..2b9d43b1bdb2b 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -3276,7 +3276,6 @@ impl<'tcx> TyCtxt<'tcx> { /// Emit a lint at the appropriate level for a hir node, with an associated span. /// /// [`lint_level`]: rustc_middle::lint::lint_level#decorate-signature - #[rustc_lint_diagnostics] #[track_caller] pub fn node_span_lint( self, @@ -3336,7 +3335,6 @@ impl<'tcx> TyCtxt<'tcx> { /// Emit a lint at the appropriate level for a hir node. /// /// [`lint_level`]: rustc_middle::lint::lint_level#decorate-signature - #[rustc_lint_diagnostics] #[track_caller] pub fn node_lint( self, diff --git a/compiler/rustc_mir_build/src/lib.rs b/compiler/rustc_mir_build/src/lib.rs index 8c7003b778761..7979ddf23da8c 100644 --- a/compiler/rustc_mir_build/src/lib.rs +++ b/compiler/rustc_mir_build/src/lib.rs @@ -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)] diff --git a/compiler/rustc_mir_transform/src/pass_manager.rs b/compiler/rustc_mir_transform/src/pass_manager.rs index ab09cdf787ee7..e225c31881f83 100644 --- a/compiler/rustc_mir_transform/src/pass_manager.rs +++ b/compiler/rustc_mir_transform/src/pass_manager.rs @@ -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(); diff --git a/compiler/rustc_parse/src/lib.rs b/compiler/rustc_parse/src/lib.rs index 1fb44df65347e..c836d52a71e48 100644 --- a/compiler/rustc_parse/src/lib.rs +++ b/compiler/rustc_parse/src/lib.rs @@ -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)] diff --git a/compiler/rustc_parse/src/parser/pat.rs b/compiler/rustc_parse/src/parser/pat.rs index d7f3a36122e59..b6608779787b5 100644 --- a/compiler/rustc_parse/src/parser/pat.rs +++ b/compiler/rustc_parse/src/parser/pat.rs @@ -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); diff --git a/compiler/rustc_parse/src/parser/tests.rs b/compiler/rustc_parse/src/parser/tests.rs index 62e97c0c308c1..01d319b0f7095 100644 --- a/compiler/rustc_parse/src/parser/tests.rs +++ b/compiler/rustc_parse/src/parser/tests.rs @@ -184,7 +184,6 @@ impl Write for Shared { } } -#[allow(rustc::untranslatable_diagnostic)] // no translation needed for tests fn test_harness( file_text: &str, span_labels: Vec, diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index f1cbb72554d2f..859fdbd33f2bc 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -264,7 +264,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> { | AttributeKind::RustcNoImplicitAutorefs | AttributeKind::RustcLayoutScalarValidRangeStart(..) | AttributeKind::RustcLayoutScalarValidRangeEnd(..) - | AttributeKind::RustcLintDiagnostics | AttributeKind::RustcLintOptDenyFieldAccess { .. } | AttributeKind::RustcLintOptTy | AttributeKind::RustcLintQueryInstability @@ -1724,7 +1723,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) { diff --git a/compiler/rustc_pattern_analysis/src/lib.rs b/compiler/rustc_pattern_analysis/src/lib.rs index f3308086ddc64..364ffc7bace0d 100644 --- a/compiler/rustc_pattern_analysis/src/lib.rs +++ b/compiler/rustc_pattern_analysis/src/lib.rs @@ -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 diff --git a/compiler/rustc_query_system/src/query/job.rs b/compiler/rustc_query_system/src/query/job.rs index 7d9b594d501ff..6107b05a11922 100644 --- a/compiler/rustc_query_system/src/query/job.rs +++ b/compiler/rustc_query_system/src/query/job.rs @@ -631,9 +631,6 @@ pub fn print_query_stack( let query_extra = qcx.lift_query_info(&query_info.query.info); 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_extra.description diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index 063b6b4058f05..f506e71ef712c 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -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)] diff --git a/compiler/rustc_resolve/src/macros.rs b/compiler/rustc_resolve/src/macros.rs index c9c754374c87c..303038ae72a3b 100644 --- a/compiler/rustc_resolve/src/macros.rs +++ b/compiler/rustc_resolve/src/macros.rs @@ -1131,7 +1131,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { errors::OutOfScopeMacroCalls { span: path.span, path: pprust::path_to_string(path), - // FIXME: Make this translatable. location, }, ); diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 8c492fcf8f15d..e64f7e54c8da8 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -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, }; diff --git a/compiler/rustc_session/src/config/externs.rs b/compiler/rustc_session/src/config/externs.rs index 1420ee38bf214..d668d8b4203db 100644 --- a/compiler/rustc_session/src/config/externs.rs +++ b/compiler/rustc_session/src/config/externs.rs @@ -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}`")); } diff --git a/compiler/rustc_session/src/config/print_request.rs b/compiler/rustc_session/src/config/print_request.rs index 395f7a4fab71f..dc53fcc6955f7 100644 --- a/compiler/rustc_session/src/config/print_request.rs +++ b/compiler/rustc_session/src/config/print_request.rs @@ -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" { diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index 21fa3321a30ad..fe39b2cf744ef 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -723,7 +723,6 @@ impl OptionDesc { } } -#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable fn build_options( early_dcx: &EarlyDiagCtxt, matches: &getopts::Matches, diff --git a/compiler/rustc_session/src/parse.rs b/compiler/rustc_session/src/parse.rs index edc5ae9e6f634..4242b184cc98c 100644 --- a/compiler/rustc_session/src/parse.rs +++ b/compiler/rustc_session/src/parse.rs @@ -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( /// 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( err: &mut Diag<'_, G>, sess: &Session, diff --git a/compiler/rustc_session/src/search_paths.rs b/compiler/rustc_session/src/search_paths.rs index 2ca390b50dd0e..3e1fb4df4c3a5 100644 --- a/compiler/rustc_session/src/search_paths.rs +++ b/compiler/rustc_session/src/search_paths.rs @@ -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`"); } diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index 1a0ec600af47d..8773d58361663 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -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, @@ -1393,45 +1391,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) { self.dcx.handle().note(msg) } - #[allow(rustc::untranslatable_diagnostic)] - #[allow(rustc::diagnostic_outside_of_impl)] pub fn early_help(&self, msg: impl Into) { 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) -> ErrorGuaranteed { self.dcx.handle().err(msg) } - #[allow(rustc::untranslatable_diagnostic)] - #[allow(rustc::diagnostic_outside_of_impl)] pub fn early_fatal(&self, msg: impl Into) -> ! { self.dcx.handle().fatal(msg) } - #[allow(rustc::untranslatable_diagnostic)] - #[allow(rustc::diagnostic_outside_of_impl)] pub fn early_struct_fatal(&self, msg: impl Into) -> 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) { self.dcx.handle().warn(msg) } - #[allow(rustc::untranslatable_diagnostic)] - #[allow(rustc::diagnostic_outside_of_impl)] pub fn early_struct_warn(&self, msg: impl Into) -> Diag<'_, ()> { self.dcx.handle().struct_warn(msg) } diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index c7ff28ccaffb7..aa7338a106768 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -1963,7 +1963,6 @@ symbols! { rustc_layout_scalar_valid_range_end, rustc_layout_scalar_valid_range_start, rustc_legacy_const_generics, - rustc_lint_diagnostics, rustc_lint_opt_deny_field_access, rustc_lint_opt_ty, rustc_lint_query_instability, diff --git a/compiler/rustc_symbol_mangling/src/errors.rs b/compiler/rustc_symbol_mangling/src/errors.rs index 775f3112ed5f7..ada9e3fb15624 100644 --- a/compiler/rustc_symbol_mangling/src/errors.rs +++ b/compiler/rustc_symbol_mangling/src/errors.rs @@ -18,7 +18,6 @@ impl 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) } } diff --git a/compiler/rustc_trait_selection/src/lib.rs b/compiler/rustc_trait_selection/src/lib.rs index 6705d271bc7d9..561a95bad50c3 100644 --- a/compiler/rustc_trait_selection/src/lib.rs +++ b/compiler/rustc_trait_selection/src/lib.rs @@ -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)] diff --git a/src/tools/clippy/clippy_config/src/lib.rs b/src/tools/clippy/clippy_config/src/lib.rs index 67904b4fcdc85..a565a21a0e77b 100644 --- a/src/tools/clippy/clippy_config/src/lib.rs +++ b/src/tools/clippy/clippy_config/src/lib.rs @@ -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)] diff --git a/src/tools/clippy/clippy_lints/src/lib.rs b/src/tools/clippy/clippy_lints/src/lib.rs index a957afdb19103..ae236ac25de79 100644 --- a/src/tools/clippy/clippy_lints/src/lib.rs +++ b/src/tools/clippy/clippy_lints/src/lib.rs @@ -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( diff --git a/src/tools/clippy/clippy_lints_internal/src/lib.rs b/src/tools/clippy/clippy_lints_internal/src/lib.rs index cca5608fa6be2..e009f263f11f6 100644 --- a/src/tools/clippy/clippy_lints_internal/src/lib.rs +++ b/src/tools/clippy/clippy_lints_internal/src/lib.rs @@ -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, diff --git a/src/tools/clippy/clippy_utils/src/lib.rs b/src/tools/clippy/clippy_utils/src/lib.rs index 38e1542cd758f..7d7b5afe4e155 100644 --- a/src/tools/clippy/clippy_utils/src/lib.rs +++ b/src/tools/clippy/clippy_utils/src/lib.rs @@ -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, diff --git a/src/tools/clippy/src/driver.rs b/src/tools/clippy/src/driver.rs index 8693973ef78c7..c9ca6335de6ed 100644 --- a/src/tools/clippy/src/driver.rs +++ b/src/tools/clippy/src/driver.rs @@ -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)] diff --git a/src/tools/miri/src/bin/miri.rs b/src/tools/miri/src/bin/miri.rs index 19fbf90246c93..c7a7941e548c5 100644 --- a/src/tools/miri/src/bin/miri.rs +++ b/src/tools/miri/src/bin/miri.rs @@ -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 diff --git a/src/tools/miri/src/lib.rs b/src/tools/miri/src/lib.rs index 7ce2ab3b3a434..5722969a31bf9 100644 --- a/src/tools/miri/src/lib.rs +++ b/src/tools/miri/src/lib.rs @@ -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, diff --git a/src/tools/rust-analyzer/crates/hir-expand/src/inert_attr_macro.rs b/src/tools/rust-analyzer/crates/hir-expand/src/inert_attr_macro.rs index 385c98ef87784..55539220a7680 100644 --- a/src/tools/rust-analyzer/crates/hir-expand/src/inert_attr_macro.rs +++ b/src/tools/rust-analyzer/crates/hir-expand/src/inert_attr_macro.rs @@ -467,9 +467,6 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[ // Used by the `rustc::untracked_query_information` lint to warn methods which // might break incremental compilation. rustc_attr!(rustc_lint_untracked_query_information, Normal, template!(Word), WarnFollowing, INTERNAL_UNSTABLE), - // Used by the `rustc::untranslatable_diagnostic` and `rustc::diagnostic_outside_of_impl` lints - // to assist in changes to diagnostic APIs. - rustc_attr!(rustc_lint_diagnostics, Normal, template!(Word), WarnFollowing, INTERNAL_UNSTABLE), // Used by the `rustc::bad_opt_access` lint to identify `DebuggingOptions` and `CodegenOptions` // types (as well as any others in future). rustc_attr!(rustc_lint_opt_ty, Normal, template!(Word), WarnFollowing, INTERNAL_UNSTABLE), diff --git a/src/tools/rustfmt/src/parse/session.rs b/src/tools/rustfmt/src/parse/session.rs index 2fd8bfdaf3e11..d3ff27c51eabb 100644 --- a/src/tools/rustfmt/src/parse/session.rs +++ b/src/tools/rustfmt/src/parse/session.rs @@ -349,7 +349,6 @@ mod tests { } fn build_diagnostic(level: DiagnosticLevel, span: Option) -> 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 { diff --git a/tests/ui-fulldeps/internal-lints/diagnostics.ftl b/tests/ui-fulldeps/internal-lints/diagnostics.ftl deleted file mode 100644 index cb2d476d815d2..0000000000000 --- a/tests/ui-fulldeps/internal-lints/diagnostics.ftl +++ /dev/null @@ -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 diff --git a/tests/ui-fulldeps/internal-lints/diagnostics.rs b/tests/ui-fulldeps/internal-lints/diagnostics.rs deleted file mode 100644 index 1238fefd5bc03..0000000000000 --- a/tests/ui-fulldeps/internal-lints/diagnostics.rs +++ /dev/null @@ -1,125 +0,0 @@ -//@ compile-flags: -Z unstable-options -//@ ignore-stage1 - -#![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; -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( - 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( - 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>) { - #[allow(rustc::untranslatable_diagnostic)] - 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, _y: impl Into) {} -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 -} diff --git a/tests/ui-fulldeps/internal-lints/diagnostics.stderr b/tests/ui-fulldeps/internal-lints/diagnostics.stderr deleted file mode 100644 index b260c4b7afefb..0000000000000 --- a/tests/ui-fulldeps/internal-lints/diagnostics.stderr +++ /dev/null @@ -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 - diff --git a/tests/ui/internal-lints/diagnostics_incorrect.rs b/tests/ui/internal-lints/diagnostics_incorrect.rs deleted file mode 100644 index 787acdad38842..0000000000000 --- a/tests/ui/internal-lints/diagnostics_incorrect.rs +++ /dev/null @@ -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() {} diff --git a/tests/ui/internal-lints/diagnostics_incorrect.stderr b/tests/ui/internal-lints/diagnostics_incorrect.stderr deleted file mode 100644 index 4d509acec7900..0000000000000 --- a/tests/ui/internal-lints/diagnostics_incorrect.stderr +++ /dev/null @@ -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`.