Rollup merge of #150879 - remove_diag_lints, r=Kivooeo
Remove the diagnostic lints Removes the `untranslatable_diagnostic` and `diagnostic_outside_of_impl` lints These lints are allowed for a while already. Per https://github.com/rust-lang/compiler-team/issues/959, we no longer want to enforce struct diagnostics for all usecases, so this is no longer useful. r? @Kivooeo I recommend reviewing commit by commit (also feel free to wait with reviewing until the MCP is accepted) @rustbot +S-blocked Blocked by https://github.com/rust-lang/compiler-team/issues/959
This commit is contained in:
commit
958d1f907b
91 changed files with 33 additions and 790 deletions
|
|
@ -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(_) => (),
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -141,8 +141,6 @@ impl<S: Stage> CombineAttributeParser<S> for LinkParser {
|
|||
|
||||
macro report_unstable_modifier($feature: ident) {
|
||||
if !features.$feature() {
|
||||
// FIXME: make this translatable
|
||||
#[expect(rustc::untranslatable_diagnostic)]
|
||||
feature_err(
|
||||
sess,
|
||||
sym::$feature,
|
||||
|
|
|
|||
|
|
@ -164,21 +164,6 @@ impl<S: Stage> SingleAttributeParser<S> for RustcLegacyConstGenericsParser {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) struct RustcLintDiagnosticsParser;
|
||||
|
||||
impl<S: Stage> NoArgsAttributeParser<S> for RustcLintDiagnosticsParser {
|
||||
const PATH: &[Symbol] = &[sym::rustc_lint_diagnostics];
|
||||
const ON_DUPLICATE: OnDuplicate<S> = 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<S: Stage> SingleAttributeParser<S> for RustcLintOptDenyFieldAccessParser {
|
||||
|
|
|
|||
|
|
@ -4,9 +4,6 @@ use super::prelude::*;
|
|||
|
||||
pub(crate) struct TransparencyParser;
|
||||
|
||||
// FIXME(jdonszelmann): make these proper diagnostics
|
||||
#[allow(rustc::untranslatable_diagnostic)]
|
||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
||||
impl<S: Stage> SingleAttributeParser<S> for TransparencyParser {
|
||||
const PATH: &[Symbol] = &[sym::rustc_macro_transparency];
|
||||
const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepInnermost;
|
||||
|
|
|
|||
|
|
@ -75,11 +75,11 @@ use crate::attributes::rustc_dump::{
|
|||
use crate::attributes::rustc_internal::{
|
||||
RustcHasIncoherentInherentImplsParser, RustcLayoutScalarValidRangeEndParser,
|
||||
RustcLayoutScalarValidRangeStartParser, RustcLegacyConstGenericsParser,
|
||||
RustcLintDiagnosticsParser, RustcLintOptDenyFieldAccessParser, RustcLintOptTyParser,
|
||||
RustcLintQueryInstabilityParser, RustcLintUntrackedQueryInformationParser, RustcMainParser,
|
||||
RustcMustImplementOneOfParser, RustcNeverReturnsNullPointerParser,
|
||||
RustcNoImplicitAutorefsParser, RustcNounwindParser, RustcObjectLifetimeDefaultParser,
|
||||
RustcOffloadKernelParser, RustcScalableVectorParser, RustcSimdMonomorphizeLaneLimitParser,
|
||||
RustcLintOptDenyFieldAccessParser, RustcLintOptTyParser, RustcLintQueryInstabilityParser,
|
||||
RustcLintUntrackedQueryInformationParser, RustcMainParser, RustcMustImplementOneOfParser,
|
||||
RustcNeverReturnsNullPointerParser, RustcNoImplicitAutorefsParser, RustcNounwindParser,
|
||||
RustcObjectLifetimeDefaultParser, RustcOffloadKernelParser, RustcScalableVectorParser,
|
||||
RustcSimdMonomorphizeLaneLimitParser,
|
||||
};
|
||||
use crate::attributes::semantics::MayDangleParser;
|
||||
use crate::attributes::stability::{
|
||||
|
|
@ -289,7 +289,6 @@ attribute_parsers!(
|
|||
Single<WithoutArgs<RustcDumpUserArgs>>,
|
||||
Single<WithoutArgs<RustcDumpVtable>>,
|
||||
Single<WithoutArgs<RustcHasIncoherentInherentImplsParser>>,
|
||||
Single<WithoutArgs<RustcLintDiagnosticsParser>>,
|
||||
Single<WithoutArgs<RustcLintOptTyParser>>,
|
||||
Single<WithoutArgs<RustcLintQueryInstabilityParser>>,
|
||||
Single<WithoutArgs<RustcLintUntrackedQueryInformationParser>>,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
// ignore-tidy-filelength
|
||||
|
||||
#![allow(rustc::diagnostic_outside_of_impl)]
|
||||
#![allow(rustc::untranslatable_diagnostic)]
|
||||
|
||||
use std::iter;
|
||||
use std::ops::ControlFlow;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
//! Print diagnostics to explain why values are borrowed.
|
||||
|
||||
#![allow(rustc::diagnostic_outside_of_impl)]
|
||||
#![allow(rustc::untranslatable_diagnostic)]
|
||||
|
||||
use rustc_data_structures::assert_matches;
|
||||
use rustc_errors::{Applicability, Diag, EmissionGuarantee};
|
||||
use rustc_hir as hir;
|
||||
|
|
|
|||
|
|
@ -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>,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,3 @@
|
|||
#![allow(rustc::diagnostic_outside_of_impl)]
|
||||
#![allow(rustc::untranslatable_diagnostic)]
|
||||
|
||||
use core::ops::ControlFlow;
|
||||
|
||||
use either::Either;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,3 @@
|
|||
#![allow(rustc::diagnostic_outside_of_impl)]
|
||||
#![allow(rustc::untranslatable_diagnostic)]
|
||||
|
||||
use std::ops::ControlFlow;
|
||||
|
||||
use either::Either;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -196,7 +196,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
|
|||
// For generic associated types (GATs) which implied 'static requirement
|
||||
// from higher-ranked trait bounds (HRTB). Try to locate span of the trait
|
||||
// and the span which bounded to the trait for adding 'static lifetime suggestion
|
||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
||||
fn suggest_static_lifetime_for_gat_from_hrtb(
|
||||
&self,
|
||||
diag: &mut Diag<'_>,
|
||||
|
|
@ -421,9 +420,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
|
|||
/// ```
|
||||
///
|
||||
/// Here we would be invoked with `fr = 'a` and `outlived_fr = 'b`.
|
||||
// FIXME: make this translatable
|
||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
||||
#[allow(rustc::untranslatable_diagnostic)]
|
||||
pub(crate) fn report_region_error(
|
||||
&mut self,
|
||||
fr: RegionVid,
|
||||
|
|
@ -577,7 +573,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
|
|||
/// executing...
|
||||
/// = note: ...therefore, returned references to captured variables will escape the closure
|
||||
/// ```
|
||||
#[allow(rustc::diagnostic_outside_of_impl)] // FIXME
|
||||
fn report_fnmut_error(
|
||||
&self,
|
||||
errci: &ErrorConstraintInfo<'tcx>,
|
||||
|
|
@ -686,18 +681,12 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
|
|||
borrowck_errors::borrowed_data_escapes_closure(self.infcx.tcx, *span, escapes_from);
|
||||
|
||||
if let Some((Some(outlived_fr_name), outlived_fr_span)) = outlived_fr_name_and_span {
|
||||
// FIXME: make this translatable
|
||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
||||
#[allow(rustc::untranslatable_diagnostic)]
|
||||
diag.span_label(
|
||||
outlived_fr_span,
|
||||
format!("`{outlived_fr_name}` declared here, outside of the {escapes_from} body",),
|
||||
);
|
||||
}
|
||||
|
||||
// FIXME: make this translatable
|
||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
||||
#[allow(rustc::untranslatable_diagnostic)]
|
||||
if let Some((Some(fr_name), fr_span)) = fr_name_and_span {
|
||||
diag.span_label(
|
||||
fr_span,
|
||||
|
|
@ -732,9 +721,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
|
|||
let outlived_fr_region_name = self.give_region_a_name(errci.outlived_fr).unwrap();
|
||||
outlived_fr_region_name.highlight_region_name(&mut diag);
|
||||
|
||||
// FIXME: make this translatable
|
||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
||||
#[allow(rustc::untranslatable_diagnostic)]
|
||||
diag.span_label(
|
||||
*span,
|
||||
format!(
|
||||
|
|
@ -766,7 +752,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
|
|||
/// | ^^^^^^^^^^^^^^ function was supposed to return data with lifetime `'a` but it
|
||||
/// | is returning data with lifetime `'b`
|
||||
/// ```
|
||||
#[allow(rustc::diagnostic_outside_of_impl)] // FIXME
|
||||
fn report_general_error(&self, errci: &ErrorConstraintInfo<'tcx>) -> Diag<'infcx> {
|
||||
let ErrorConstraintInfo { fr, outlived_fr, span, category, .. } = errci;
|
||||
|
||||
|
|
@ -824,8 +809,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
|
|||
/// LL | fn iter_values_anon(&self) -> impl Iterator<Item=u32> + 'a {
|
||||
/// | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
/// ```
|
||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
||||
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
|
||||
fn add_static_impl_trait_suggestion(
|
||||
&self,
|
||||
diag: &mut Diag<'_>,
|
||||
|
|
@ -966,7 +949,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
|
|||
self.suggest_constrain_dyn_trait_in_impl(diag, &visitor.0, ident, self_ty);
|
||||
}
|
||||
|
||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
||||
#[instrument(skip(self, err), level = "debug")]
|
||||
fn suggest_constrain_dyn_trait_in_impl(
|
||||
&self,
|
||||
|
|
@ -1032,7 +1014,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
|
|||
);
|
||||
}
|
||||
|
||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
||||
/// When encountering a lifetime error caused by the return type of a closure, check the
|
||||
/// corresponding trait bound and see if dereferencing the closure return value would satisfy
|
||||
/// them. If so, we produce a structured suggestion.
|
||||
|
|
@ -1160,7 +1141,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
||||
fn suggest_move_on_borrowing_closure(&self, diag: &mut Diag<'_>) {
|
||||
let body = self.infcx.tcx.hir_body_owned_by(self.mir_def_id());
|
||||
let expr = &body.value.peel_blocks();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,3 @@
|
|||
#![allow(rustc::diagnostic_outside_of_impl)]
|
||||
#![allow(rustc::untranslatable_diagnostic)]
|
||||
|
||||
use std::fmt::{self, Display};
|
||||
use std::iter;
|
||||
|
||||
|
|
|
|||
|
|
@ -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>,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -19,8 +19,6 @@ pub(crate) fn expand_compile_error<'cx>(
|
|||
Err(guar) => return ExpandResult::Ready(DummyResult::any(sp, guar)),
|
||||
};
|
||||
|
||||
#[expect(rustc::diagnostic_outside_of_impl, reason = "diagnostic message is specified by user")]
|
||||
#[expect(rustc::untranslatable_diagnostic, reason = "diagnostic message is specified by user")]
|
||||
let guar = cx.dcx().span_err(sp, var.to_string());
|
||||
cx.resolver.mark_scope_with_compile_error(cx.current_expansion.lint_node_id);
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)]
|
||||
|
|
|
|||
|
|
@ -78,8 +78,6 @@ type UnexpectedExprKind<'a> = Result<(Diag<'a>, bool /* has_suggestions */), Err
|
|||
/// The returned bool indicates whether an applicable suggestion has already been
|
||||
/// added to the diagnostic to avoid emitting multiple suggestions. `Err(Err(ErrorGuaranteed))`
|
||||
/// indicates that an ast error was encountered.
|
||||
// FIXME(Nilstrieb) Make this function setup translatable
|
||||
#[allow(rustc::untranslatable_diagnostic)]
|
||||
pub(crate) fn expr_to_spanned_string<'a>(
|
||||
cx: &'a mut ExtCtxt<'_>,
|
||||
expr: Box<ast::Expr>,
|
||||
|
|
|
|||
|
|
@ -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`.
|
||||
|
|
|
|||
|
|
@ -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)]
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -232,7 +232,6 @@ pub fn format_interp_error<'tcx>(dcx: DiagCtxtHandle<'_>, e: InterpErrorInfo<'tc
|
|||
backtrace.print_backtrace();
|
||||
// FIXME(fee1-dead), HACK: we want to use the error as title therefore we can just extract the
|
||||
// label and arguments from the InterpError.
|
||||
#[allow(rustc::untranslatable_diagnostic)]
|
||||
let mut diag = dcx.struct_allow("");
|
||||
let msg = e.diagnostic_message();
|
||||
e.add_args(&mut diag);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
// tidy-alphabetical-start
|
||||
#![allow(rustc::diagnostic_outside_of_impl)]
|
||||
#![feature(array_try_map)]
|
||||
#![feature(assert_matches)]
|
||||
#![feature(box_patterns)]
|
||||
|
|
|
|||
|
|
@ -97,7 +97,6 @@ impl Expander {
|
|||
/// **Note:** This function doesn't interpret argument 0 in any special way.
|
||||
/// If this function is intended to be used with command line arguments,
|
||||
/// `argv[0]` must be removed prior to calling it manually.
|
||||
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
|
||||
pub fn arg_expand_all(early_dcx: &EarlyDiagCtxt, at_args: &[String]) -> Vec<String> {
|
||||
let mut expander = Expander::default();
|
||||
let mut result = Ok(());
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
//! This API is completely unstable and subject to change.
|
||||
|
||||
// tidy-alphabetical-start
|
||||
#![allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
|
||||
#![feature(decl_macro)]
|
||||
#![feature(panic_backtrace_config)]
|
||||
#![feature(panic_update_hook)]
|
||||
|
|
@ -303,7 +302,6 @@ pub fn run_compiler(at_args: &[String], callbacks: &mut (dyn Callbacks + Send))
|
|||
}
|
||||
|
||||
if !has_input {
|
||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
||||
sess.dcx().fatal("no input filename given"); // this is fatal
|
||||
}
|
||||
|
||||
|
|
@ -615,7 +613,6 @@ fn list_metadata(sess: &Session, metadata_loader: &dyn MetadataLoader) {
|
|||
safe_println!("{}", String::from_utf8(v).unwrap());
|
||||
}
|
||||
Input::Str { .. } => {
|
||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
||||
sess.dcx().fatal("cannot list metadata for stdin");
|
||||
}
|
||||
}
|
||||
|
|
@ -842,7 +839,6 @@ fn print_crate_info(
|
|||
sess.apple_deployment_target().fmt_pretty(),
|
||||
)
|
||||
} else {
|
||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
||||
sess.dcx().fatal("only Apple targets currently support deployment version info")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<DiagMessage>) -> 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<SubdiagMessage>) -> &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<Item = Span>, 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<SubdiagMessage>) -> &mut Self {
|
||||
self.sub(Level::Note, msg, MultiSpan::new());
|
||||
self
|
||||
} }
|
||||
|
||||
#[rustc_lint_diagnostics]
|
||||
pub fn highlighted_note(&mut self, msg: Vec<StringPart>) -> &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<MultiSpan>,
|
||||
|
|
@ -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<SubdiagMessage>) -> &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<MultiSpan>,
|
||||
|
|
@ -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<S: Into<MultiSpan>>(
|
||||
&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<SubdiagMessage>) -> &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<S: Into<MultiSpan>>(
|
||||
&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<SubdiagMessage>) -> &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<SubdiagMessage>) -> &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<StringPart>) -> &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<MultiSpan>,
|
||||
|
|
@ -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<MultiSpan>,
|
||||
|
|
@ -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<SubdiagMessage>,
|
||||
|
|
@ -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<SubdiagMessage>,
|
||||
|
|
@ -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<SubdiagMessage>,
|
||||
|
|
@ -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<SubdiagMessage>,
|
||||
|
|
@ -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<SubdiagMessage>,
|
||||
|
|
@ -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<MultiSpan>) -> &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<DiagMessage>) -> &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<DiagArgName>,
|
||||
|
|
|
|||
|
|
@ -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)]
|
||||
|
|
@ -1216,22 +1214,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<DiagMessage>` because bug messages aren't
|
||||
// user-facing.
|
||||
#[track_caller]
|
||||
pub fn struct_bug(self, msg: impl Into<Cow<'static, str>>) -> Diag<'a, BugAbort> {
|
||||
Diag::new(self, Bug, msg.into())
|
||||
}
|
||||
|
||||
// No `#[rustc_lint_diagnostics]` and no `impl Into<DiagMessage>` because bug messages aren't
|
||||
// user-facing.
|
||||
#[track_caller]
|
||||
pub fn bug(self, msg: impl Into<Cow<'static, str>>) -> ! {
|
||||
self.struct_bug(msg).emit()
|
||||
}
|
||||
|
||||
// No `#[rustc_lint_diagnostics]` and no `impl Into<DiagMessage>` because bug messages aren't
|
||||
// user-facing.
|
||||
#[track_caller]
|
||||
pub fn struct_span_bug(
|
||||
self,
|
||||
|
|
@ -1241,8 +1233,6 @@ impl<'a> DiagCtxtHandle<'a> {
|
|||
self.struct_bug(msg).with_span(span)
|
||||
}
|
||||
|
||||
// No `#[rustc_lint_diagnostics]` and no `impl Into<DiagMessage>` because bug messages aren't
|
||||
// user-facing.
|
||||
#[track_caller]
|
||||
pub fn span_bug(self, span: impl Into<MultiSpan>, msg: impl Into<Cow<'static, str>>) -> ! {
|
||||
self.struct_span_bug(span, msg.into()).emit()
|
||||
|
|
@ -1258,19 +1248,16 @@ impl<'a> DiagCtxtHandle<'a> {
|
|||
self.create_bug(bug).emit()
|
||||
}
|
||||
|
||||
#[rustc_lint_diagnostics]
|
||||
#[track_caller]
|
||||
pub fn struct_fatal(self, msg: impl Into<DiagMessage>) -> Diag<'a, FatalAbort> {
|
||||
Diag::new(self, Fatal, msg)
|
||||
}
|
||||
|
||||
#[rustc_lint_diagnostics]
|
||||
#[track_caller]
|
||||
pub fn fatal(self, msg: impl Into<DiagMessage>) -> ! {
|
||||
self.struct_fatal(msg).emit()
|
||||
}
|
||||
|
||||
#[rustc_lint_diagnostics]
|
||||
#[track_caller]
|
||||
pub fn struct_span_fatal(
|
||||
self,
|
||||
|
|
@ -1280,7 +1267,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<MultiSpan>, msg: impl Into<DiagMessage>) -> ! {
|
||||
self.struct_span_fatal(span, msg).emit()
|
||||
|
|
@ -1310,19 +1296,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<DiagMessage>) -> Diag<'a> {
|
||||
Diag::new(self, Error, msg)
|
||||
}
|
||||
|
||||
#[rustc_lint_diagnostics]
|
||||
#[track_caller]
|
||||
pub fn err(self, msg: impl Into<DiagMessage>) -> ErrorGuaranteed {
|
||||
self.struct_err(msg).emit()
|
||||
}
|
||||
|
||||
#[rustc_lint_diagnostics]
|
||||
#[track_caller]
|
||||
pub fn struct_span_err(
|
||||
self,
|
||||
|
|
@ -1332,7 +1315,6 @@ impl<'a> DiagCtxtHandle<'a> {
|
|||
self.struct_err(msg).with_span(span)
|
||||
}
|
||||
|
||||
#[rustc_lint_diagnostics]
|
||||
#[track_caller]
|
||||
pub fn span_err(
|
||||
self,
|
||||
|
|
@ -1353,9 +1335,6 @@ impl<'a> DiagCtxtHandle<'a> {
|
|||
}
|
||||
|
||||
/// Ensures that an error is printed. See [`Level::DelayedBug`].
|
||||
//
|
||||
// No `#[rustc_lint_diagnostics]` and no `impl Into<DiagMessage>` because bug messages aren't
|
||||
// user-facing.
|
||||
#[track_caller]
|
||||
pub fn delayed_bug(self, msg: impl Into<Cow<'static, str>>) -> ErrorGuaranteed {
|
||||
Diag::<ErrorGuaranteed>::new(self, DelayedBug, msg.into()).emit()
|
||||
|
|
@ -1365,9 +1344,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<DiagMessage>` because bug messages aren't
|
||||
// user-facing.
|
||||
#[track_caller]
|
||||
pub fn span_delayed_bug(
|
||||
self,
|
||||
|
|
@ -1377,19 +1353,16 @@ impl<'a> DiagCtxtHandle<'a> {
|
|||
Diag::<ErrorGuaranteed>::new(self, DelayedBug, msg.into()).with_span(sp).emit()
|
||||
}
|
||||
|
||||
#[rustc_lint_diagnostics]
|
||||
#[track_caller]
|
||||
pub fn struct_warn(self, msg: impl Into<DiagMessage>) -> Diag<'a, ()> {
|
||||
Diag::new(self, Warning, msg)
|
||||
}
|
||||
|
||||
#[rustc_lint_diagnostics]
|
||||
#[track_caller]
|
||||
pub fn warn(self, msg: impl Into<DiagMessage>) {
|
||||
self.struct_warn(msg).emit()
|
||||
}
|
||||
|
||||
#[rustc_lint_diagnostics]
|
||||
#[track_caller]
|
||||
pub fn struct_span_warn(
|
||||
self,
|
||||
|
|
@ -1399,7 +1372,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<MultiSpan>, msg: impl Into<DiagMessage>) {
|
||||
self.struct_span_warn(span, msg).emit()
|
||||
|
|
@ -1415,19 +1387,16 @@ impl<'a> DiagCtxtHandle<'a> {
|
|||
self.create_warn(warning).emit()
|
||||
}
|
||||
|
||||
#[rustc_lint_diagnostics]
|
||||
#[track_caller]
|
||||
pub fn struct_note(self, msg: impl Into<DiagMessage>) -> Diag<'a, ()> {
|
||||
Diag::new(self, Note, msg)
|
||||
}
|
||||
|
||||
#[rustc_lint_diagnostics]
|
||||
#[track_caller]
|
||||
pub fn note(&self, msg: impl Into<DiagMessage>) {
|
||||
self.struct_note(msg).emit()
|
||||
}
|
||||
|
||||
#[rustc_lint_diagnostics]
|
||||
#[track_caller]
|
||||
pub fn struct_span_note(
|
||||
self,
|
||||
|
|
@ -1437,7 +1406,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<MultiSpan>, msg: impl Into<DiagMessage>) {
|
||||
self.struct_span_note(span, msg).emit()
|
||||
|
|
@ -1453,25 +1421,21 @@ impl<'a> DiagCtxtHandle<'a> {
|
|||
self.create_note(note).emit()
|
||||
}
|
||||
|
||||
#[rustc_lint_diagnostics]
|
||||
#[track_caller]
|
||||
pub fn struct_help(self, msg: impl Into<DiagMessage>) -> Diag<'a, ()> {
|
||||
Diag::new(self, Help, msg)
|
||||
}
|
||||
|
||||
#[rustc_lint_diagnostics]
|
||||
#[track_caller]
|
||||
pub fn struct_failure_note(self, msg: impl Into<DiagMessage>) -> Diag<'a, ()> {
|
||||
Diag::new(self, FailureNote, msg)
|
||||
}
|
||||
|
||||
#[rustc_lint_diagnostics]
|
||||
#[track_caller]
|
||||
pub fn struct_allow(self, msg: impl Into<DiagMessage>) -> Diag<'a, ()> {
|
||||
Diag::new(self, Allow, msg)
|
||||
}
|
||||
|
||||
#[rustc_lint_diagnostics]
|
||||
#[track_caller]
|
||||
pub fn struct_expect(self, msg: impl Into<DiagMessage>, id: LintExpectationId) -> Diag<'a, ()> {
|
||||
Diag::new(self, Expect, msg).with_lint_id(id)
|
||||
|
|
|
|||
|
|
@ -1355,8 +1355,6 @@ impl<'a> ExtCtxt<'a> {
|
|||
for (span, notes) in self.expansions.iter() {
|
||||
let mut db = self.dcx().create_note(errors::TraceMacro { span: *span });
|
||||
for note in notes {
|
||||
// FIXME: make this translatable
|
||||
#[allow(rustc::untranslatable_diagnostic)]
|
||||
db.note(note.clone());
|
||||
}
|
||||
db.emit();
|
||||
|
|
|
|||
|
|
@ -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(_)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
// tidy-alphabetical-start
|
||||
#![allow(internal_features)]
|
||||
#![allow(rustc::diagnostic_outside_of_impl)]
|
||||
#![cfg_attr(bootstrap, feature(array_windows))]
|
||||
#![feature(associated_type_defaults)]
|
||||
#![feature(if_let_guard)]
|
||||
|
|
@ -13,8 +12,6 @@
|
|||
|
||||
mod build;
|
||||
mod errors;
|
||||
// FIXME(Nilstrieb) Translate macro_rules diagnostics
|
||||
#[allow(rustc::untranslatable_diagnostic)]
|
||||
mod mbe;
|
||||
mod placeholders;
|
||||
mod proc_macro_server;
|
||||
|
|
@ -25,8 +22,6 @@ pub mod base;
|
|||
pub mod config;
|
||||
pub mod expand;
|
||||
pub mod module;
|
||||
// FIXME(Nilstrieb) Translate proc_macro diagnostics
|
||||
#[allow(rustc::untranslatable_diagnostic)]
|
||||
pub mod proc_macro;
|
||||
|
||||
pub fn provide(providers: &mut rustc_middle::query::Providers) {
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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!(
|
||||
|
|
|
|||
|
|
@ -954,9 +954,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 },
|
||||
|
||||
|
|
|
|||
|
|
@ -113,7 +113,6 @@ impl AttributeKind {
|
|||
RustcLayoutScalarValidRangeEnd(..) => Yes,
|
||||
RustcLayoutScalarValidRangeStart(..) => Yes,
|
||||
RustcLegacyConstGenerics { .. } => Yes,
|
||||
RustcLintDiagnostics => Yes,
|
||||
RustcLintOptDenyFieldAccess { .. } => Yes,
|
||||
RustcLintOptTy => Yes,
|
||||
RustcLintQueryInstability => Yes,
|
||||
|
|
|
|||
|
|
@ -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)]
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -66,8 +66,6 @@ pub(crate) fn parse_cfg(dcx: DiagCtxtHandle<'_>, cfgs: Vec<String>) -> Cfg {
|
|||
|
||||
macro_rules! error {
|
||||
($reason: expr) => {
|
||||
#[allow(rustc::untranslatable_diagnostic)]
|
||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
||||
dcx.fatal(format!("invalid `--cfg` argument: `{s}` ({})", $reason));
|
||||
};
|
||||
}
|
||||
|
|
@ -146,42 +144,30 @@ pub(crate) fn parse_check_cfg(dcx: DiagCtxtHandle<'_>, specs: Vec<String>) -> Ch
|
|||
"visit <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more details";
|
||||
|
||||
macro_rules! error {
|
||||
($reason:expr) => {
|
||||
#[allow(rustc::untranslatable_diagnostic)]
|
||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
||||
{
|
||||
let mut diag =
|
||||
dcx.struct_fatal(format!("invalid `--check-cfg` argument: `{s}`"));
|
||||
diag.note($reason);
|
||||
diag.note(VISIT);
|
||||
diag.emit()
|
||||
}
|
||||
};
|
||||
(in $arg:expr, $reason:expr) => {
|
||||
#[allow(rustc::untranslatable_diagnostic)]
|
||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
||||
{
|
||||
let mut diag =
|
||||
dcx.struct_fatal(format!("invalid `--check-cfg` argument: `{s}`"));
|
||||
($reason:expr) => {{
|
||||
let mut diag = dcx.struct_fatal(format!("invalid `--check-cfg` argument: `{s}`"));
|
||||
diag.note($reason);
|
||||
diag.note(VISIT);
|
||||
diag.emit()
|
||||
}};
|
||||
(in $arg:expr, $reason:expr) => {{
|
||||
let mut diag = dcx.struct_fatal(format!("invalid `--check-cfg` argument: `{s}`"));
|
||||
|
||||
let pparg = rustc_ast_pretty::pprust::meta_list_item_to_string($arg);
|
||||
if let Some(lit) = $arg.lit() {
|
||||
let (lit_kind_article, lit_kind_descr) = {
|
||||
let lit_kind = lit.as_token_lit().kind;
|
||||
(lit_kind.article(), lit_kind.descr())
|
||||
};
|
||||
diag.note(format!(
|
||||
"`{pparg}` is {lit_kind_article} {lit_kind_descr} literal"
|
||||
));
|
||||
} else {
|
||||
diag.note(format!("`{pparg}` is invalid"));
|
||||
}
|
||||
|
||||
diag.note($reason);
|
||||
diag.note(VISIT);
|
||||
diag.emit()
|
||||
let pparg = rustc_ast_pretty::pprust::meta_list_item_to_string($arg);
|
||||
if let Some(lit) = $arg.lit() {
|
||||
let (lit_kind_article, lit_kind_descr) = {
|
||||
let lit_kind = lit.as_token_lit().kind;
|
||||
(lit_kind.article(), lit_kind.descr())
|
||||
};
|
||||
diag.note(format!("`{pparg}` is {lit_kind_article} {lit_kind_descr} literal"));
|
||||
} else {
|
||||
diag.note(format!("`{pparg}` is invalid"));
|
||||
}
|
||||
};
|
||||
|
||||
diag.note($reason);
|
||||
diag.note(VISIT);
|
||||
diag.emit()
|
||||
}};
|
||||
}
|
||||
|
||||
let expected_error = || -> ! {
|
||||
|
|
@ -408,8 +394,6 @@ pub struct Config {
|
|||
/// Initialize jobserver before getting `jobserver::client` and `build_session`.
|
||||
pub(crate) fn initialize_checked_jobserver(early_dcx: &EarlyDiagCtxt) {
|
||||
jobserver::initialize_checked(|err| {
|
||||
#[allow(rustc::untranslatable_diagnostic)]
|
||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
||||
early_dcx
|
||||
.early_struct_warn(err)
|
||||
.with_note("the build environment is likely misconfigured")
|
||||
|
|
@ -476,11 +460,7 @@ pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Se
|
|||
config.opts.unstable_opts.translate_directionality_markers,
|
||||
) {
|
||||
Ok(bundle) => bundle,
|
||||
Err(e) => {
|
||||
// We can't translate anything if we failed to load translations
|
||||
#[allow(rustc::untranslatable_diagnostic)]
|
||||
early_dcx.early_fatal(format!("failed to load fluent bundle: {e}"))
|
||||
}
|
||||
Err(e) => early_dcx.early_fatal(format!("failed to load fluent bundle: {e}")),
|
||||
};
|
||||
|
||||
let mut locale_resources = config.locale_resources;
|
||||
|
|
|
|||
|
|
@ -119,8 +119,6 @@ fn init_stack_size(early_dcx: &EarlyDiagCtxt) -> usize {
|
|||
// FIXME: we could accept `RUST_MIN_STACK=64MB`, perhaps?
|
||||
.map(|s| {
|
||||
let s = s.trim();
|
||||
// FIXME(workingjubilee): add proper diagnostics when we factor out "pre-run" setup
|
||||
#[allow(rustc::untranslatable_diagnostic, rustc::diagnostic_outside_of_impl)]
|
||||
s.parse::<usize>().unwrap_or_else(|_| {
|
||||
let mut err = early_dcx.early_struct_fatal(format!(
|
||||
r#"`RUST_MIN_STACK` should be a number of bytes, but was "{s}""#,
|
||||
|
|
@ -301,7 +299,6 @@ pub(crate) fn run_in_thread_pool_with_globals<
|
|||
})
|
||||
}
|
||||
|
||||
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
|
||||
fn load_backend_from_dylib(early_dcx: &EarlyDiagCtxt, path: &Path) -> MakeBackendFn {
|
||||
match unsafe { load_symbol_from_dylib::<MakeBackendFn>(path, "__rustc_codegen_backend") } {
|
||||
Ok(backend_sym) => backend_sym,
|
||||
|
|
@ -434,8 +431,6 @@ impl CodegenBackend for DummyCodegenBackend {
|
|||
.find(|&&crate_type| crate_type != CrateType::Rlib)
|
||||
&& outputs.outputs.should_link()
|
||||
{
|
||||
#[allow(rustc::untranslatable_diagnostic)]
|
||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
||||
sess.dcx().fatal(format!(
|
||||
"crate type {crate_type} not supported by the dummy codegen backend"
|
||||
));
|
||||
|
|
@ -491,7 +486,6 @@ pub fn rustc_path<'a>(sysroot: &Sysroot) -> Option<&'a Path> {
|
|||
.as_deref()
|
||||
}
|
||||
|
||||
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
|
||||
fn get_codegen_sysroot(
|
||||
early_dcx: &EarlyDiagCtxt,
|
||||
sysroot: &Sysroot,
|
||||
|
|
|
|||
|
|
@ -237,9 +237,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
|
||||
|
||||
|
|
@ -992,8 +989,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
|
||||
|
||||
|
|
|
|||
|
|
@ -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<S: Into<MultiSpan>>(
|
||||
&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<S: Into<MultiSpan>>(
|
||||
&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<Span>, 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<S: Into<MultiSpan>>(
|
||||
&self,
|
||||
lint: &'static Lint,
|
||||
|
|
@ -656,7 +650,6 @@ impl LintContext for EarlyContext<'_> {
|
|||
self.builder.sess()
|
||||
}
|
||||
|
||||
#[rustc_lint_diagnostics]
|
||||
fn opt_span_lint<S: Into<MultiSpan>>(
|
||||
&self,
|
||||
lint: &'static Lint,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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)),
|
||||
|
|
|
|||
|
|
@ -338,8 +338,6 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for MultipleCandidates {
|
|||
diag.code(E0464);
|
||||
diag.span(self.span);
|
||||
for (i, candidate) in self.candidates.iter().enumerate() {
|
||||
// FIXME: make this translatable
|
||||
#[allow(rustc::untranslatable_diagnostic)]
|
||||
diag.note(format!("candidate #{}: {}", i + 1, candidate.display()));
|
||||
}
|
||||
diag
|
||||
|
|
@ -446,8 +444,6 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for InvalidMetadataFiles {
|
|||
diag.code(E0786);
|
||||
diag.span(self.span);
|
||||
for crate_rejection in self.crate_rejections {
|
||||
// FIXME: make this translatable
|
||||
#[allow(rustc::untranslatable_diagnostic)]
|
||||
diag.note(crate_rejection);
|
||||
}
|
||||
diag
|
||||
|
|
|
|||
|
|
@ -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)]
|
||||
|
|
|
|||
|
|
@ -119,7 +119,6 @@ pub struct DeprecationSuggestion {
|
|||
pub struct Deprecated {
|
||||
pub sub: Option<DeprecationSuggestion>,
|
||||
|
||||
// FIXME: make this translatable
|
||||
pub kind: String,
|
||||
pub path: String,
|
||||
pub note: Option<Symbol>,
|
||||
|
|
|
|||
|
|
@ -3281,7 +3281,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,
|
||||
|
|
@ -3341,7 +3340,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,
|
||||
|
|
|
|||
|
|
@ -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)]
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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)]
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -184,7 +184,6 @@ impl<T: Write> Write for Shared<T> {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(rustc::untranslatable_diagnostic)] // no translation needed for tests
|
||||
fn test_harness(
|
||||
file_text: &str,
|
||||
span_labels: Vec<SpanLabel>,
|
||||
|
|
|
|||
|
|
@ -266,7 +266,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
|
|||
| AttributeKind::RustcNoImplicitAutorefs
|
||||
| AttributeKind::RustcLayoutScalarValidRangeStart(..)
|
||||
| AttributeKind::RustcLayoutScalarValidRangeEnd(..)
|
||||
| AttributeKind::RustcLintDiagnostics
|
||||
| AttributeKind::RustcLintOptDenyFieldAccess { .. }
|
||||
| AttributeKind::RustcLintOptTy
|
||||
| AttributeKind::RustcLintQueryInstability
|
||||
|
|
@ -1692,7 +1691,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) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -612,9 +612,6 @@ pub fn print_query_stack<Qcx: QueryContext>(
|
|||
};
|
||||
if Some(count_printed) < limit_frames || limit_frames.is_none() {
|
||||
// Only print to stderr as many stack frames as `num_frames` when present.
|
||||
// FIXME: needs translation
|
||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
||||
#[allow(rustc::untranslatable_diagnostic)]
|
||||
dcx.struct_failure_note(format!(
|
||||
"#{} [{:?}] {}",
|
||||
count_printed, query_info.query.dep_kind, query_info.query.description
|
||||
|
|
|
|||
|
|
@ -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)]
|
||||
|
|
|
|||
|
|
@ -1138,7 +1138,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
|||
errors::OutOfScopeMacroCalls {
|
||||
span: path.span,
|
||||
path: pprust::path_to_string(path),
|
||||
// FIXME: Make this translatable.
|
||||
location,
|
||||
},
|
||||
);
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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}`"));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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" {
|
||||
|
|
|
|||
|
|
@ -724,7 +724,6 @@ impl<O> OptionDesc<O> {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
|
||||
fn build_options<O: Default>(
|
||||
early_dcx: &EarlyDiagCtxt,
|
||||
matches: &getopts::Matches,
|
||||
|
|
|
|||
|
|
@ -132,8 +132,6 @@ pub fn feature_warn(sess: &Session, feature: Symbol, span: Span, explain: &'stat
|
|||
///
|
||||
/// This variant allows you to control whether it is a library or language feature.
|
||||
/// Almost always, you want to use this for a language feature. If so, prefer `feature_warn`.
|
||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
||||
#[allow(rustc::untranslatable_diagnostic)]
|
||||
#[track_caller]
|
||||
pub fn feature_warn_issue(
|
||||
sess: &Session,
|
||||
|
|
@ -171,7 +169,6 @@ pub fn add_feature_diagnostics<G: EmissionGuarantee>(
|
|||
/// This variant allows you to control whether it is a library or language feature.
|
||||
/// Almost always, you want to use this for a language feature. If so, prefer
|
||||
/// `add_feature_diagnostics`.
|
||||
#[allow(rustc::diagnostic_outside_of_impl)] // FIXME
|
||||
pub fn add_feature_diagnostics_for_issue<G: EmissionGuarantee>(
|
||||
err: &mut Diag<'_, G>,
|
||||
sess: &Session,
|
||||
|
|
|
|||
|
|
@ -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`");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -246,7 +246,6 @@ impl Session {
|
|||
pub fn create_feature_err<'a>(&'a self, err: impl Diagnostic<'a>, feature: Symbol) -> Diag<'a> {
|
||||
let mut err = self.dcx().create_err(err);
|
||||
if err.code.is_none() {
|
||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
||||
err.code(E0658);
|
||||
}
|
||||
add_feature_diagnostics(&mut err, self, feature);
|
||||
|
|
@ -960,7 +959,6 @@ fn default_emitter(
|
|||
|
||||
// JUSTIFICATION: literally session construction
|
||||
#[allow(rustc::bad_opt_access)]
|
||||
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
|
||||
pub fn build_session(
|
||||
sopts: config::Options,
|
||||
io: CompilerIO,
|
||||
|
|
@ -1396,45 +1394,31 @@ impl EarlyDiagCtxt {
|
|||
self.dcx = DiagCtxt::new(emitter);
|
||||
}
|
||||
|
||||
#[allow(rustc::untranslatable_diagnostic)]
|
||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
||||
pub fn early_note(&self, msg: impl Into<DiagMessage>) {
|
||||
self.dcx.handle().note(msg)
|
||||
}
|
||||
|
||||
#[allow(rustc::untranslatable_diagnostic)]
|
||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
||||
pub fn early_help(&self, msg: impl Into<DiagMessage>) {
|
||||
self.dcx.handle().struct_help(msg).emit()
|
||||
}
|
||||
|
||||
#[allow(rustc::untranslatable_diagnostic)]
|
||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
||||
#[must_use = "raise_fatal must be called on the returned ErrorGuaranteed in order to exit with a non-zero status code"]
|
||||
pub fn early_err(&self, msg: impl Into<DiagMessage>) -> ErrorGuaranteed {
|
||||
self.dcx.handle().err(msg)
|
||||
}
|
||||
|
||||
#[allow(rustc::untranslatable_diagnostic)]
|
||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
||||
pub fn early_fatal(&self, msg: impl Into<DiagMessage>) -> ! {
|
||||
self.dcx.handle().fatal(msg)
|
||||
}
|
||||
|
||||
#[allow(rustc::untranslatable_diagnostic)]
|
||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
||||
pub fn early_struct_fatal(&self, msg: impl Into<DiagMessage>) -> Diag<'_, FatalAbort> {
|
||||
self.dcx.handle().struct_fatal(msg)
|
||||
}
|
||||
|
||||
#[allow(rustc::untranslatable_diagnostic)]
|
||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
||||
pub fn early_warn(&self, msg: impl Into<DiagMessage>) {
|
||||
self.dcx.handle().warn(msg)
|
||||
}
|
||||
|
||||
#[allow(rustc::untranslatable_diagnostic)]
|
||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
||||
pub fn early_struct_warn(&self, msg: impl Into<DiagMessage>) -> Diag<'_, ()> {
|
||||
self.dcx.handle().struct_warn(msg)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1975,7 +1975,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,
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for TestOutput {
|
|||
fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> {
|
||||
let TestOutput { span, kind, content } = self;
|
||||
|
||||
#[allow(rustc::untranslatable_diagnostic)]
|
||||
Diag::new(dcx, level, format!("{kind}({content})")).with_span(span)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)]
|
||||
|
|
|
|||
|
|
@ -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)]
|
||||
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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)]
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
|
|
|
|||
|
|
@ -349,7 +349,6 @@ mod tests {
|
|||
}
|
||||
|
||||
fn build_diagnostic(level: DiagnosticLevel, span: Option<MultiSpan>) -> DiagInner {
|
||||
#[allow(rustc::untranslatable_diagnostic)] // no translation needed for empty string
|
||||
let mut diag = DiagInner::new(level, "");
|
||||
diag.messages.clear();
|
||||
if let Some(span) = span {
|
||||
|
|
|
|||
|
|
@ -1,5 +0,0 @@
|
|||
no_crate_example = this is an example message used in testing
|
||||
.note = with a note
|
||||
.help = with a help
|
||||
.suggestion = with a suggestion
|
||||
.label = with a label
|
||||
|
|
@ -1,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<G: EmissionGuarantee>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
) {
|
||||
diag.note("untranslatable diagnostic");
|
||||
//~^ ERROR diagnostics should be created using translatable messages
|
||||
}
|
||||
}
|
||||
|
||||
pub struct TranslatableInAddtoDiag;
|
||||
|
||||
impl Subdiagnostic for TranslatableInAddtoDiag {
|
||||
fn add_to_diag<G: EmissionGuarantee>(
|
||||
self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
) {
|
||||
diag.note(crate::fluent_generated::no_crate_note);
|
||||
}
|
||||
}
|
||||
|
||||
pub struct UntranslatableInLintDiagnostic;
|
||||
|
||||
impl<'a> LintDiagnostic<'a, ()> for UntranslatableInLintDiagnostic {
|
||||
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
||||
diag.note("untranslatable diagnostic");
|
||||
//~^ ERROR diagnostics should be created using translatable messages
|
||||
}
|
||||
}
|
||||
|
||||
pub struct TranslatableInLintDiagnostic;
|
||||
|
||||
impl<'a> LintDiagnostic<'a, ()> for TranslatableInLintDiagnostic {
|
||||
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
||||
diag.note(crate::fluent_generated::no_crate_note);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn make_diagnostics<'a>(dcx: DiagCtxtHandle<'a>) {
|
||||
let _diag = dcx.struct_err(crate::fluent_generated::no_crate_example);
|
||||
//~^ ERROR diagnostics should only be created in `Diagnostic`/`Subdiagnostic`/`LintDiagnostic` impls
|
||||
|
||||
let _diag = dcx.struct_err("untranslatable diagnostic");
|
||||
//~^ ERROR diagnostics should only be created in `Diagnostic`/`Subdiagnostic`/`LintDiagnostic` impls
|
||||
//~^^ ERROR diagnostics should be created using translatable messages
|
||||
}
|
||||
|
||||
// Check that `rustc_lint_diagnostics`-annotated functions aren't themselves linted for
|
||||
// `diagnostic_outside_of_impl`.
|
||||
#[rustc_lint_diagnostics]
|
||||
pub fn skipped_because_of_annotation<'a>(dcx: DiagCtxtHandle<'a>) {
|
||||
#[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<DiagMessage>, _y: impl Into<SubdiagMessage>) {}
|
||||
fn g() {
|
||||
f(crate::fluent_generated::no_crate_example, crate::fluent_generated::no_crate_example);
|
||||
f("untranslatable diagnostic", crate::fluent_generated::no_crate_example);
|
||||
//~^ ERROR diagnostics should be created using translatable messages
|
||||
f(crate::fluent_generated::no_crate_example, "untranslatable diagnostic");
|
||||
//~^ ERROR diagnostics should be created using translatable messages
|
||||
f("untranslatable diagnostic", "untranslatable diagnostic");
|
||||
//~^ ERROR diagnostics should be created using translatable messages
|
||||
//~^^ ERROR diagnostics should be created using translatable messages
|
||||
}
|
||||
|
|
@ -1,74 +0,0 @@
|
|||
error: diagnostics should be created using translatable messages
|
||||
--> $DIR/diagnostics.rs:43:31
|
||||
|
|
||||
LL | Diag::new(dcx, level, "untranslatable diagnostic")
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/diagnostics.rs:7:9
|
||||
|
|
||||
LL | #![deny(rustc::untranslatable_diagnostic)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: diagnostics should be created using translatable messages
|
||||
--> $DIR/diagnostics.rs:63:19
|
||||
|
|
||||
LL | diag.note("untranslatable diagnostic");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: diagnostics should be created using translatable messages
|
||||
--> $DIR/diagnostics.rs:83:19
|
||||
|
|
||||
LL | diag.note("untranslatable diagnostic");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: diagnostics should only be created in `Diagnostic`/`Subdiagnostic`/`LintDiagnostic` impls
|
||||
--> $DIR/diagnostics.rs:97:21
|
||||
|
|
||||
LL | let _diag = dcx.struct_err(crate::fluent_generated::no_crate_example);
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/diagnostics.rs:8:9
|
||||
|
|
||||
LL | #![deny(rustc::diagnostic_outside_of_impl)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: diagnostics should only be created in `Diagnostic`/`Subdiagnostic`/`LintDiagnostic` impls
|
||||
--> $DIR/diagnostics.rs:100:21
|
||||
|
|
||||
LL | let _diag = dcx.struct_err("untranslatable diagnostic");
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: diagnostics should be created using translatable messages
|
||||
--> $DIR/diagnostics.rs:100:32
|
||||
|
|
||||
LL | let _diag = dcx.struct_err("untranslatable diagnostic");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: diagnostics should be created using translatable messages
|
||||
--> $DIR/diagnostics.rs:118:7
|
||||
|
|
||||
LL | f("untranslatable diagnostic", crate::fluent_generated::no_crate_example);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: diagnostics should be created using translatable messages
|
||||
--> $DIR/diagnostics.rs:120:50
|
||||
|
|
||||
LL | f(crate::fluent_generated::no_crate_example, "untranslatable diagnostic");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: diagnostics should be created using translatable messages
|
||||
--> $DIR/diagnostics.rs:122:7
|
||||
|
|
||||
LL | f("untranslatable diagnostic", "untranslatable diagnostic");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: diagnostics should be created using translatable messages
|
||||
--> $DIR/diagnostics.rs:122:36
|
||||
|
|
||||
LL | f("untranslatable diagnostic", "untranslatable diagnostic");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 10 previous errors
|
||||
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
//@ compile-flags: -Z unstable-options
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
#[rustc_lint_diagnostics]
|
||||
//~^ ERROR `#[rustc_lint_diagnostics]` attribute cannot be used on structs
|
||||
struct Foo;
|
||||
|
||||
impl Foo {
|
||||
#[rustc_lint_diagnostics(a)]
|
||||
//~^ ERROR malformed `rustc_lint_diagnostics`
|
||||
fn bar() {}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
error: `#[rustc_lint_diagnostics]` attribute cannot be used on structs
|
||||
--> $DIR/diagnostics_incorrect.rs:5:1
|
||||
|
|
||||
LL | #[rustc_lint_diagnostics]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: `#[rustc_lint_diagnostics]` can only be applied to functions
|
||||
|
||||
error[E0565]: malformed `rustc_lint_diagnostics` attribute input
|
||||
--> $DIR/diagnostics_incorrect.rs:10:5
|
||||
|
|
||||
LL | #[rustc_lint_diagnostics(a)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^---^
|
||||
| | |
|
||||
| | didn't expect any arguments here
|
||||
| help: must be of the form: `#[rustc_lint_diagnostics]`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0565`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue