Rollup merge of #128886 - GrigorenkoPV:untranslatable-diagnostic, r=nnethercote

Get rid of some `#[allow(rustc::untranslatable_diagnostic)]`

`@rustbot` label +A-translation
cc https://github.com/rust-lang/rust/issues/100717
This commit is contained in:
Guillaume Gomez 2024-08-12 17:09:17 +02:00 committed by GitHub
commit ea74eff55c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
23 changed files with 125 additions and 77 deletions

View File

@ -167,11 +167,23 @@ ast_lowering_template_modifier = template modifier
ast_lowering_this_not_async = this is not `async` ast_lowering_this_not_async = this is not `async`
ast_lowering_underscore_array_length_unstable =
using `_` for array lengths is unstable
ast_lowering_underscore_expr_lhs_assign = ast_lowering_underscore_expr_lhs_assign =
in expressions, `_` can only be used on the left-hand side of an assignment in expressions, `_` can only be used on the left-hand side of an assignment
.label = `_` not allowed here .label = `_` not allowed here
ast_lowering_unstable_inline_assembly = inline assembly is not stable yet on this architecture
ast_lowering_unstable_inline_assembly_const_operands =
const operands for inline assembly are unstable
ast_lowering_unstable_inline_assembly_label_operands =
label operands for inline assembly are unstable
ast_lowering_unstable_may_unwind = the `may_unwind` option is unstable
ast_lowering_use_angle_brackets = use angle brackets instead ast_lowering_use_angle_brackets = use angle brackets instead
ast_lowering_yield = yield syntax is experimental
ast_lowering_yield_in_closure = ast_lowering_yield_in_closure =
`yield` can only be used in `#[coroutine]` closures, or `gen` blocks `yield` can only be used in `#[coroutine]` closures, or `gen` blocks
.suggestion = use `#[coroutine]` to make this closure a coroutine .suggestion = use `#[coroutine]` to make this closure a coroutine

View File

@ -19,10 +19,12 @@
InvalidRegisterClass, RegisterClassOnlyClobber, RegisterConflict, InvalidRegisterClass, RegisterClassOnlyClobber, RegisterConflict,
}; };
use super::LoweringContext; use super::LoweringContext;
use crate::{ImplTraitContext, ImplTraitPosition, ParamMode, ResolverAstLoweringExt}; use crate::{
fluent_generated as fluent, ImplTraitContext, ImplTraitPosition, ParamMode,
ResolverAstLoweringExt,
};
impl<'a, 'hir> LoweringContext<'a, 'hir> { impl<'a, 'hir> LoweringContext<'a, 'hir> {
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
pub(crate) fn lower_inline_asm( pub(crate) fn lower_inline_asm(
&mut self, &mut self,
sp: Span, sp: Span,
@ -52,7 +54,7 @@ pub(crate) fn lower_inline_asm(
&self.tcx.sess, &self.tcx.sess,
sym::asm_experimental_arch, sym::asm_experimental_arch,
sp, sp,
"inline assembly is not stable yet on this architecture", fluent::ast_lowering_unstable_inline_assembly,
) )
.emit(); .emit();
} }
@ -64,7 +66,12 @@ pub(crate) fn lower_inline_asm(
self.dcx().emit_err(AttSyntaxOnlyX86 { span: sp }); self.dcx().emit_err(AttSyntaxOnlyX86 { span: sp });
} }
if asm.options.contains(InlineAsmOptions::MAY_UNWIND) && !self.tcx.features().asm_unwind { if asm.options.contains(InlineAsmOptions::MAY_UNWIND) && !self.tcx.features().asm_unwind {
feature_err(&self.tcx.sess, sym::asm_unwind, sp, "the `may_unwind` option is unstable") feature_err(
&self.tcx.sess,
sym::asm_unwind,
sp,
fluent::ast_lowering_unstable_may_unwind,
)
.emit(); .emit();
} }
@ -182,7 +189,7 @@ pub(crate) fn lower_inline_asm(
sess, sess,
sym::asm_const, sym::asm_const,
*op_sp, *op_sp,
"const operands for inline assembly are unstable", fluent::ast_lowering_unstable_inline_assembly_const_operands,
) )
.emit(); .emit();
} }
@ -246,7 +253,7 @@ pub(crate) fn lower_inline_asm(
sess, sess,
sym::asm_goto, sym::asm_goto,
*op_sp, *op_sp,
"label operands for inline assembly are unstable", fluent::ast_lowering_unstable_inline_assembly_label_operands,
) )
.emit(); .emit();
} }

View File

@ -23,7 +23,7 @@
ImplTraitContext, LoweringContext, ParamMode, ParenthesizedGenericArgs, ResolverAstLoweringExt, ImplTraitContext, LoweringContext, ParamMode, ParenthesizedGenericArgs, ResolverAstLoweringExt,
}; };
use crate::errors::YieldInClosure; use crate::errors::YieldInClosure;
use crate::{FnDeclKind, ImplTraitPosition}; use crate::{fluent_generated, FnDeclKind, ImplTraitPosition};
impl<'hir> LoweringContext<'_, 'hir> { impl<'hir> LoweringContext<'_, 'hir> {
fn lower_exprs(&mut self, exprs: &[AstP<Expr>]) -> &'hir [hir::Expr<'hir>] { fn lower_exprs(&mut self, exprs: &[AstP<Expr>]) -> &'hir [hir::Expr<'hir>] {
@ -1540,7 +1540,6 @@ fn lower_expr_field(&mut self, f: &ExprField) -> hir::ExprField<'hir> {
} }
} }
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
fn lower_expr_yield(&mut self, span: Span, opt_expr: Option<&Expr>) -> hir::ExprKind<'hir> { fn lower_expr_yield(&mut self, span: Span, opt_expr: Option<&Expr>) -> hir::ExprKind<'hir> {
let yielded = let yielded =
opt_expr.as_ref().map(|x| self.lower_expr(x)).unwrap_or_else(|| self.expr_unit(span)); opt_expr.as_ref().map(|x| self.lower_expr(x)).unwrap_or_else(|| self.expr_unit(span));
@ -1575,7 +1574,7 @@ fn lower_expr_yield(&mut self, span: Span, opt_expr: Option<&Expr>) -> hir::Expr
&self.tcx.sess, &self.tcx.sess,
sym::coroutines, sym::coroutines,
span, span,
"yield syntax is experimental", fluent_generated::ast_lowering_yield,
) )
.emit(); .emit();
} }
@ -1587,7 +1586,7 @@ fn lower_expr_yield(&mut self, span: Span, opt_expr: Option<&Expr>) -> hir::Expr
&self.tcx.sess, &self.tcx.sess,
sym::coroutines, sym::coroutines,
span, span,
"yield syntax is experimental", fluent_generated::ast_lowering_yield,
) )
.emit(); .emit();
} }

View File

@ -2326,7 +2326,6 @@ fn lower_block_expr(&mut self, b: &Block) -> hir::Expr<'hir> {
self.expr_block(block) self.expr_block(block)
} }
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
fn lower_array_length(&mut self, c: &AnonConst) -> hir::ArrayLen<'hir> { fn lower_array_length(&mut self, c: &AnonConst) -> hir::ArrayLen<'hir> {
match c.value.kind { match c.value.kind {
ExprKind::Underscore => { ExprKind::Underscore => {
@ -2340,7 +2339,7 @@ fn lower_array_length(&mut self, c: &AnonConst) -> hir::ArrayLen<'hir> {
&self.tcx.sess, &self.tcx.sess,
sym::generic_arg_infer, sym::generic_arg_infer,
c.value.span, c.value.span,
"using `_` for array lengths is unstable", fluent_generated::ast_lowering_underscore_array_length_unstable,
) )
.stash(c.value.span, StashKey::UnderscoreForArrayLengths); .stash(c.value.span, StashKey::UnderscoreForArrayLengths);
hir::ArrayLen::Body(self.lower_anon_const_to_const_arg(c)) hir::ArrayLen::Body(self.lower_anon_const_to_const_arg(c))

View File

@ -104,6 +104,9 @@ attr_unknown_meta_item =
attr_unknown_version_literal = attr_unknown_version_literal =
unknown version literal format, assuming it refers to a future version unknown version literal format, assuming it refers to a future version
attr_unstable_cfg_target_compact =
compact `cfg(target(..))` is experimental and subject to change
attr_unsupported_literal_cfg_string = attr_unsupported_literal_cfg_string =
literal in `cfg` predicate value must be a string literal in `cfg` predicate value must be a string
attr_unsupported_literal_deprecated_kv_pair = attr_unsupported_literal_deprecated_kv_pair =

View File

@ -20,6 +20,7 @@
use rustc_span::symbol::{sym, Symbol}; use rustc_span::symbol::{sym, Symbol};
use rustc_span::Span; use rustc_span::Span;
use crate::fluent_generated;
use crate::session_diagnostics::{self, IncorrectReprFormatGenericCause}; use crate::session_diagnostics::{self, IncorrectReprFormatGenericCause};
/// The version placeholder that recently stabilized features contain inside the /// The version placeholder that recently stabilized features contain inside the
@ -521,7 +522,6 @@ pub struct Condition {
} }
/// Tests if a cfg-pattern matches the cfg set /// Tests if a cfg-pattern matches the cfg set
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
pub fn cfg_matches( pub fn cfg_matches(
cfg: &ast::MetaItem, cfg: &ast::MetaItem,
sess: &Session, sess: &Session,
@ -593,7 +593,6 @@ pub fn parse_version(s: Symbol) -> Option<RustcVersion> {
/// Evaluate a cfg-like condition (with `any` and `all`), using `eval` to /// Evaluate a cfg-like condition (with `any` and `all`), using `eval` to
/// evaluate individual items. /// evaluate individual items.
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
pub fn eval_condition( pub fn eval_condition(
cfg: &ast::MetaItem, cfg: &ast::MetaItem,
sess: &Session, sess: &Session,
@ -680,7 +679,7 @@ pub fn eval_condition(
sess, sess,
sym::cfg_target_compact, sym::cfg_target_compact,
cfg.span, cfg.span,
"compact `cfg(target(..))` is experimental and subject to change", fluent_generated::attr_unstable_cfg_target_compact,
) )
.emit(); .emit();
} }

View File

@ -62,6 +62,9 @@ borrowck_could_not_normalize =
borrowck_could_not_prove = borrowck_could_not_prove =
could not prove `{$predicate}` could not prove `{$predicate}`
borrowck_dereference_suggestion =
dereference the return value
borrowck_func_take_self_moved_place = borrowck_func_take_self_moved_place =
`{$func}` takes ownership of the receiver `self`, which moves {$place_name} `{$func}` takes ownership of the receiver `self`, which moves {$place_name}
@ -74,9 +77,24 @@ borrowck_higher_ranked_lifetime_error =
borrowck_higher_ranked_subtype_error = borrowck_higher_ranked_subtype_error =
higher-ranked subtype error higher-ranked subtype error
borrowck_implicit_static =
this has an implicit `'static` lifetime requirement
borrowck_implicit_static_introduced =
calling this method introduces the `impl`'s `'static` requirement
borrowck_implicit_static_relax =
consider relaxing the implicit `'static` requirement
borrowck_lifetime_constraints_error = borrowck_lifetime_constraints_error =
lifetime may not live long enough lifetime may not live long enough
borrowck_limitations_implies_static =
due to current limitations in the borrow checker, this implies a `'static` lifetime
borrowck_move_closure_suggestion =
consider adding 'move' keyword before the nested closure
borrowck_move_out_place_here = borrowck_move_out_place_here =
{$place} is moved here {$place} is moved here
@ -163,6 +181,9 @@ borrowck_partial_var_move_by_use_in_coroutine =
*[false] moved *[false] moved
} due to use in coroutine } due to use in coroutine
borrowck_restrict_to_static =
consider restricting the type parameter to the `'static` lifetime
borrowck_returned_async_block_escaped = borrowck_returned_async_block_escaped =
returns an `async` block that contains a reference to a captured variable, which then escapes the closure body returns an `async` block that contains a reference to a captured variable, which then escapes the closure body

View File

@ -35,7 +35,7 @@
LifetimeReturnCategoryErr, RequireStaticErr, VarHereDenote, LifetimeReturnCategoryErr, RequireStaticErr, VarHereDenote,
}; };
use crate::universal_regions::DefiningTy; use crate::universal_regions::DefiningTy;
use crate::{borrowck_errors, MirBorrowckCtxt}; use crate::{borrowck_errors, fluent_generated as fluent, MirBorrowckCtxt};
impl<'tcx> ConstraintDescription for ConstraintCategory<'tcx> { impl<'tcx> ConstraintDescription for ConstraintCategory<'tcx> {
fn description(&self) -> &'static str { fn description(&self) -> &'static str {
@ -198,7 +198,6 @@ fn is_closure_fn_mut(&self, fr: RegionVid) -> bool {
// from higher-ranked trait bounds (HRTB). Try to locate span of the trait // 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 // and the span which bounded to the trait for adding 'static lifetime suggestion
#[allow(rustc::diagnostic_outside_of_impl)] #[allow(rustc::diagnostic_outside_of_impl)]
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
fn suggest_static_lifetime_for_gat_from_hrtb( fn suggest_static_lifetime_for_gat_from_hrtb(
&self, &self,
diag: &mut Diag<'_>, diag: &mut Diag<'_>,
@ -251,23 +250,28 @@ fn suggest_static_lifetime_for_gat_from_hrtb(
debug!(?hrtb_bounds); debug!(?hrtb_bounds);
hrtb_bounds.iter().for_each(|bound| { hrtb_bounds.iter().for_each(|bound| {
let Trait(PolyTraitRef { trait_ref, span: trait_span, .. }, _) = bound else { return; }; let Trait(PolyTraitRef { trait_ref, span: trait_span, .. }, _) = bound else {
diag.span_note( return;
*trait_span, };
"due to current limitations in the borrow checker, this implies a `'static` lifetime" diag.span_note(*trait_span, fluent::borrowck_limitations_implies_static);
); let Some(generics_fn) = hir.get_generics(self.body.source.def_id().expect_local())
let Some(generics_fn) = hir.get_generics(self.body.source.def_id().expect_local()) else { return; }; else {
let Def(_, trait_res_defid) = trait_ref.path.res else { return; }; return;
};
let Def(_, trait_res_defid) = trait_ref.path.res else {
return;
};
debug!(?generics_fn); debug!(?generics_fn);
generics_fn.predicates.iter().for_each(|predicate| { generics_fn.predicates.iter().for_each(|predicate| {
let BoundPredicate( let BoundPredicate(WhereBoundPredicate {
WhereBoundPredicate {
span: bounded_span, span: bounded_span,
bounded_ty, bounded_ty,
bounds, bounds,
.. ..
} }) = predicate
) = predicate else { return; }; else {
return;
};
bounds.iter().for_each(|bd| { bounds.iter().for_each(|bd| {
if let Trait(PolyTraitRef { trait_ref: tr_ref, .. }, _) = bd if let Trait(PolyTraitRef { trait_ref: tr_ref, .. }, _) = bd
&& let Def(_, res_defid) = tr_ref.path.res && let Def(_, res_defid) = tr_ref.path.res
@ -277,7 +281,8 @@ fn suggest_static_lifetime_for_gat_from_hrtb(
&& generics_fn.params && generics_fn.params
.iter() .iter()
.rfind(|param| param.def_id.to_def_id() == defid) .rfind(|param| param.def_id.to_def_id() == defid)
.is_some() { .is_some()
{
suggestions.push((bounded_span.shrink_to_hi(), " + 'static".to_string())); suggestions.push((bounded_span.shrink_to_hi(), " + 'static".to_string()));
} }
}); });
@ -286,7 +291,7 @@ fn suggest_static_lifetime_for_gat_from_hrtb(
if suggestions.len() > 0 { if suggestions.len() > 0 {
suggestions.dedup(); suggestions.dedup();
diag.multipart_suggestion_verbose( diag.multipart_suggestion_verbose(
"consider restricting the type parameter to the `'static` lifetime", fluent::borrowck_restrict_to_static,
suggestions, suggestions,
Applicability::MaybeIncorrect, Applicability::MaybeIncorrect,
); );
@ -976,7 +981,6 @@ fn maybe_suggest_constrain_dyn_trait_impl(
} }
#[allow(rustc::diagnostic_outside_of_impl)] #[allow(rustc::diagnostic_outside_of_impl)]
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
#[instrument(skip(self, err), level = "debug")] #[instrument(skip(self, err), level = "debug")]
fn suggest_constrain_dyn_trait_in_impl( fn suggest_constrain_dyn_trait_in_impl(
&self, &self,
@ -994,16 +998,12 @@ fn suggest_constrain_dyn_trait_in_impl(
debug!("trait spans found: {:?}", traits); debug!("trait spans found: {:?}", traits);
for span in &traits { for span in &traits {
let mut multi_span: MultiSpan = vec![*span].into(); let mut multi_span: MultiSpan = vec![*span].into();
multi_span multi_span.push_span_label(*span, fluent::borrowck_implicit_static);
.push_span_label(*span, "this has an implicit `'static` lifetime requirement"); multi_span.push_span_label(ident.span, fluent::borrowck_implicit_static_introduced);
multi_span.push_span_label(
ident.span,
"calling this method introduces the `impl`'s `'static` requirement",
);
err.subdiagnostic(RequireStaticErr::UsedImpl { multi_span }); err.subdiagnostic(RequireStaticErr::UsedImpl { multi_span });
err.span_suggestion_verbose( err.span_suggestion_verbose(
span.shrink_to_hi(), span.shrink_to_hi(),
"consider relaxing the implicit `'static` requirement", fluent::borrowck_implicit_static_relax,
" + '_", " + '_",
Applicability::MaybeIncorrect, Applicability::MaybeIncorrect,
); );
@ -1045,7 +1045,6 @@ fn suggest_adding_lifetime_params(&self, diag: &mut Diag<'_>, sub: RegionVid, su
} }
#[allow(rustc::diagnostic_outside_of_impl)] #[allow(rustc::diagnostic_outside_of_impl)]
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
/// When encountering a lifetime error caused by the return type of a closure, check the /// 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 /// corresponding trait bound and see if dereferencing the closure return value would satisfy
/// them. If so, we produce a structured suggestion. /// them. If so, we produce a structured suggestion.
@ -1166,7 +1165,7 @@ fn suggest_deref_closure_return(&self, diag: &mut Diag<'_>) {
if ocx.select_all_or_error().is_empty() && count > 0 { if ocx.select_all_or_error().is_empty() && count > 0 {
diag.span_suggestion_verbose( diag.span_suggestion_verbose(
tcx.hir().body(*body).value.peel_blocks().span.shrink_to_lo(), tcx.hir().body(*body).value.peel_blocks().span.shrink_to_lo(),
"dereference the return value", fluent::borrowck_dereference_suggestion,
"*".repeat(count), "*".repeat(count),
Applicability::MachineApplicable, Applicability::MachineApplicable,
); );
@ -1174,7 +1173,6 @@ fn suggest_deref_closure_return(&self, diag: &mut Diag<'_>) {
} }
#[allow(rustc::diagnostic_outside_of_impl)] #[allow(rustc::diagnostic_outside_of_impl)]
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
fn suggest_move_on_borrowing_closure(&self, diag: &mut Diag<'_>) { fn suggest_move_on_borrowing_closure(&self, diag: &mut Diag<'_>) {
let map = self.infcx.tcx.hir(); let map = self.infcx.tcx.hir();
let body = map.body_owned_by(self.mir_def_id()); let body = map.body_owned_by(self.mir_def_id());
@ -1213,7 +1211,7 @@ fn suggest_move_on_borrowing_closure(&self, diag: &mut Diag<'_>) {
if let Some(closure_span) = closure_span { if let Some(closure_span) = closure_span {
diag.span_suggestion_verbose( diag.span_suggestion_verbose(
closure_span, closure_span,
"consider adding 'move' keyword before the nested closure", fluent::borrowck_move_closure_suggestion,
"move ", "move ",
Applicability::MaybeIncorrect, Applicability::MaybeIncorrect,
); );

View File

@ -41,6 +41,8 @@ const_eval_const_context = {$kind ->
*[other] {""} *[other] {""}
} }
const_eval_const_stable = const-stable functions can only call other const-stable functions
const_eval_copy_nonoverlapping_overlapping = const_eval_copy_nonoverlapping_overlapping =
`copy_nonoverlapping` called on overlapping ranges `copy_nonoverlapping` called on overlapping ranges
@ -201,6 +203,9 @@ const_eval_invalid_vtable_pointer =
const_eval_invalid_vtable_trait = const_eval_invalid_vtable_trait =
using vtable for trait `{$vtable_trait}` but trait `{$expected_trait}` was expected using vtable for trait `{$vtable_trait}` but trait `{$expected_trait}` was expected
const_eval_lazy_lock =
consider wrapping this expression in `std::sync::LazyLock::new(|| ...)`
const_eval_live_drop = const_eval_live_drop =
destructor of `{$dropped_ty}` cannot be evaluated at compile-time destructor of `{$dropped_ty}` cannot be evaluated at compile-time
.label = the destructor for this type cannot be evaluated in {const_eval_const_context}s .label = the destructor for this type cannot be evaluated in {const_eval_const_context}s

View File

@ -23,7 +23,7 @@
use tracing::debug; use tracing::debug;
use super::ConstCx; use super::ConstCx;
use crate::errors; use crate::{errors, fluent_generated};
#[derive(Clone, Copy, Debug, PartialEq, Eq)] #[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Status { pub enum Status {
@ -310,7 +310,7 @@ macro_rules! error {
} }
if let ConstContext::Static(_) = ccx.const_kind() { if let ConstContext::Static(_) = ccx.const_kind() {
err.note("consider wrapping this expression in `std::sync::LazyLock::new(|| ...)`"); err.note(fluent_generated::const_eval_lazy_lock);
} }
err err
@ -334,7 +334,7 @@ fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> {
// FIXME: make this translatable // FIXME: make this translatable
#[allow(rustc::untranslatable_diagnostic)] #[allow(rustc::untranslatable_diagnostic)]
if ccx.is_const_stable_const_fn() { if ccx.is_const_stable_const_fn() {
err.help("const-stable functions can only call other const-stable functions"); err.help(fluent_generated::const_eval_const_stable);
} else if ccx.tcx.sess.is_nightly_build() { } else if ccx.tcx.sess.is_nightly_build() {
if let Some(feature) = feature { if let Some(feature) = feature {
err.help(format!("add `#![feature({feature})]` to the crate attributes to enable")); err.help(format!("add `#![feature({feature})]` to the crate attributes to enable"));
@ -605,8 +605,6 @@ fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> {
span, span,
format!("referencing statics in {}s is unstable", ccx.const_kind(),), format!("referencing statics in {}s is unstable", ccx.const_kind(),),
); );
// FIXME: make this translatable
#[allow(rustc::untranslatable_diagnostic)]
err err
.note("`static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable.") .note("`static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable.")
.help("to fix this, the value can be extracted to a `const` and then used."); .help("to fix this, the value can be extracted to a `const` and then used.");

View File

@ -129,6 +129,9 @@ expand_module_multiple_candidates =
expand_must_repeat_once = expand_must_repeat_once =
this must repeat at least once this must repeat at least once
expand_non_inline_modules_in_proc_macro_input_are_unstable =
non-inline modules in proc macro input are unstable
expand_not_a_meta_item = expand_not_a_meta_item =
not a meta item not a meta item

View File

@ -1398,8 +1398,6 @@ fn pretty_printing_compatibility_hack(item: &Item, sess: &Session) {
}; };
if crate_matches { if crate_matches {
// FIXME: make this translatable
#[allow(rustc::untranslatable_diagnostic)]
sess.dcx().emit_fatal(errors::ProcMacroBackCompat { sess.dcx().emit_fatal(errors::ProcMacroBackCompat {
crate_name: "rental".to_string(), crate_name: "rental".to_string(),
fixed_version: "0.5.6".to_string(), fixed_version: "0.5.6".to_string(),

View File

@ -39,6 +39,7 @@
RecursionLimitReached, RemoveExprNotSupported, RemoveNodeNotSupported, UnsupportedKeyValue, RecursionLimitReached, RemoveExprNotSupported, RemoveNodeNotSupported, UnsupportedKeyValue,
WrongFragmentKind, WrongFragmentKind,
}; };
use crate::fluent_generated;
use crate::mbe::diagnostics::annotate_err_with_kind; use crate::mbe::diagnostics::annotate_err_with_kind;
use crate::module::{mod_dir_path, parse_external_mod, DirOwnership, ParsedExternalMod}; use crate::module::{mod_dir_path, parse_external_mod, DirOwnership, ParsedExternalMod};
use crate::placeholders::{placeholder, PlaceholderExpander}; use crate::placeholders::{placeholder, PlaceholderExpander};
@ -882,7 +883,6 @@ struct GateProcMacroInput<'a> {
} }
impl<'ast, 'a> Visitor<'ast> for GateProcMacroInput<'a> { impl<'ast, 'a> Visitor<'ast> for GateProcMacroInput<'a> {
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
fn visit_item(&mut self, item: &'ast ast::Item) { fn visit_item(&mut self, item: &'ast ast::Item) {
match &item.kind { match &item.kind {
ItemKind::Mod(_, mod_kind) ItemKind::Mod(_, mod_kind)
@ -892,7 +892,7 @@ fn visit_item(&mut self, item: &'ast ast::Item) {
self.sess, self.sess,
sym::proc_macro_hygiene, sym::proc_macro_hygiene,
item.span, item.span,
"non-inline modules in proc macro input are unstable", fluent_generated::expand_non_inline_modules_in_proc_macro_input_are_unstable,
) )
.emit(); .emit();
} }
@ -1876,7 +1876,6 @@ fn take_first_attr(
// Detect use of feature-gated or invalid attributes on macro invocations // Detect use of feature-gated or invalid attributes on macro invocations
// since they will not be detected after macro expansion. // since they will not be detected after macro expansion.
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
fn check_attributes(&self, attrs: &[ast::Attribute], call: &ast::MacCall) { fn check_attributes(&self, attrs: &[ast::Attribute], call: &ast::MacCall) {
let features = self.cx.ecfg.features; let features = self.cx.ecfg.features;
let mut attrs = attrs.iter().peekable(); let mut attrs = attrs.iter().peekable();

View File

@ -386,7 +386,6 @@ fn get_codegen_sysroot(
} }
} }
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
pub(crate) fn check_attr_crate_type( pub(crate) fn check_attr_crate_type(
sess: &Session, sess: &Session,
attrs: &[ast::Attribute], attrs: &[ast::Attribute],

View File

@ -717,7 +717,6 @@ fn insert_spec(&mut self, id: LintId, (mut level, src): LevelAndSource) {
}; };
} }
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
fn add(&mut self, attrs: &[ast::Attribute], is_crate_node: bool, source_hir_id: Option<HirId>) { fn add(&mut self, attrs: &[ast::Attribute], is_crate_node: bool, source_hir_id: Option<HirId>) {
let sess = self.sess; let sess = self.sess;
for (attr_index, attr) in attrs.iter().enumerate() { for (attr_index, attr) in attrs.iter().enumerate() {
@ -1039,7 +1038,6 @@ fn check_gated_lint(&self, lint_id: LintId, span: Span, lint_from_cli: bool) ->
let (level, src) = self.lint_level(builtin::UNKNOWN_LINTS); let (level, src) = self.lint_level(builtin::UNKNOWN_LINTS);
// FIXME: make this translatable // FIXME: make this translatable
#[allow(rustc::diagnostic_outside_of_impl)] #[allow(rustc::diagnostic_outside_of_impl)]
#[allow(rustc::untranslatable_diagnostic)]
lint_level(self.sess, lint, level, src, Some(span.into()), |lint| { lint_level(self.sess, lint, level, src, Some(span.into()), |lint| {
lint.primary_message(fluent::lint_unknown_gated_lint); lint.primary_message(fluent::lint_unknown_gated_lint);
lint.arg("name", lint_id.lint.name_lower()); lint.arg("name", lint_id.lint.name_lower());

View File

@ -134,12 +134,18 @@ metadata_lib_framework_apple =
metadata_lib_required = metadata_lib_required =
crate `{$crate_name}` required to be available in {$kind} format, but was not found in this form crate `{$crate_name}` required to be available in {$kind} format, but was not found in this form
metadata_link_arg_unstable =
link kind `link-arg` is unstable
metadata_link_cfg_form = metadata_link_cfg_form =
link cfg must be of the form `cfg(/* predicate */)` link cfg must be of the form `cfg(/* predicate */)`
metadata_link_cfg_single_predicate = metadata_link_cfg_single_predicate =
link cfg must have a single predicate argument link cfg must have a single predicate argument
metadata_link_cfg_unstable =
link cfg is unstable
metadata_link_framework_apple = metadata_link_framework_apple =
link kind `framework` is only supported on Apple targets link kind `framework` is only supported on Apple targets

View File

@ -949,7 +949,6 @@ fn inject_dependency_if(
} }
} }
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
fn report_unused_deps(&mut self, krate: &ast::Crate) { fn report_unused_deps(&mut self, krate: &ast::Crate) {
// Make a point span rather than covering the whole file // Make a point span rather than covering the whole file
let span = krate.spans.inner_span.shrink_to_lo(); let span = krate.spans.inner_span.shrink_to_lo();

View File

@ -17,7 +17,7 @@
use rustc_span::symbol::{sym, Symbol}; use rustc_span::symbol::{sym, Symbol};
use rustc_target::spec::abi::Abi; use rustc_target::spec::abi::Abi;
use crate::errors; use crate::{errors, fluent_generated};
pub fn find_native_static_library(name: &str, verbatim: bool, sess: &Session) -> PathBuf { pub fn find_native_static_library(name: &str, verbatim: bool, sess: &Session) -> PathBuf {
let formats = if verbatim { let formats = if verbatim {
@ -87,7 +87,6 @@ struct Collector<'tcx> {
} }
impl<'tcx> Collector<'tcx> { impl<'tcx> Collector<'tcx> {
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
fn process_module(&mut self, module: &ForeignModule) { fn process_module(&mut self, module: &ForeignModule) {
let ForeignModule { def_id, abi, ref foreign_items } = *module; let ForeignModule { def_id, abi, ref foreign_items } = *module;
let def_id = def_id.expect_local(); let def_id = def_id.expect_local();
@ -161,7 +160,7 @@ fn process_module(&mut self, module: &ForeignModule) {
sess, sess,
sym::link_arg_attribute, sym::link_arg_attribute,
span, span,
"link kind `link-arg` is unstable", fluent_generated::metadata_link_arg_unstable,
) )
.emit(); .emit();
} }
@ -201,7 +200,12 @@ fn process_module(&mut self, module: &ForeignModule) {
continue; continue;
}; };
if !features.link_cfg { if !features.link_cfg {
feature_err(sess, sym::link_cfg, item.span(), "link cfg is unstable") feature_err(
sess,
sym::link_cfg,
item.span(),
fluent_generated::metadata_link_cfg_unstable,
)
.emit(); .emit();
} }
cfg = Some(link_cfg.clone()); cfg = Some(link_cfg.clone());
@ -266,6 +270,8 @@ fn process_module(&mut self, module: &ForeignModule) {
macro report_unstable_modifier($feature: ident) { macro report_unstable_modifier($feature: ident) {
if !features.$feature { if !features.$feature {
// FIXME: make this translatable
#[expect(rustc::untranslatable_diagnostic)]
feature_err( feature_err(
sess, sess,
sym::$feature, sym::$feature,

View File

@ -223,6 +223,9 @@ passes_doc_masked_only_extern_crate =
.not_an_extern_crate_label = not an `extern crate` item .not_an_extern_crate_label = not an `extern crate` item
.note = read <https://doc.rust-lang.org/unstable-book/language-features/doc-masked.html> for more information .note = read <https://doc.rust-lang.org/unstable-book/language-features/doc-masked.html> for more information
passes_doc_rust_logo =
the `#[doc(rust_logo)]` attribute is used for Rust branding
passes_doc_test_literal = `#![doc(test(...)]` does not take a literal passes_doc_test_literal = `#![doc(test(...)]` does not take a literal
passes_doc_test_takes_list = passes_doc_test_takes_list =
@ -595,6 +598,9 @@ passes_remove_fields =
*[other] fields *[other] fields
} }
passes_repr_align_function =
`repr(align)` attributes on functions are unstable
passes_repr_conflicting = passes_repr_conflicting =
conflicting representation hints conflicting representation hints

View File

@ -1142,7 +1142,6 @@ fn check_doc_cfg_hide(&self, meta: &NestedMetaItem, hir_id: HirId) {
/// of one item. Read the documentation of [`check_doc_inline`] for more information. /// of one item. Read the documentation of [`check_doc_inline`] for more information.
/// ///
/// [`check_doc_inline`]: Self::check_doc_inline /// [`check_doc_inline`]: Self::check_doc_inline
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
fn check_doc_attrs( fn check_doc_attrs(
&self, &self,
attr: &Attribute, attr: &Attribute,
@ -1220,7 +1219,7 @@ fn check_doc_attrs(
&self.tcx.sess, &self.tcx.sess,
sym::rustdoc_internals, sym::rustdoc_internals,
meta.span(), meta.span(),
"the `#[doc(rust_logo)]` attribute is used for Rust branding", fluent::passes_doc_rust_logo,
) )
.emit(); .emit();
} }
@ -1736,7 +1735,6 @@ fn check_no_mangle(&self, hir_id: HirId, attr: &Attribute, span: Span, target: T
} }
/// Checks if the `#[repr]` attributes on `item` are valid. /// Checks if the `#[repr]` attributes on `item` are valid.
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
fn check_repr( fn check_repr(
&self, &self,
attrs: &[Attribute], attrs: &[Attribute],
@ -1793,7 +1791,7 @@ fn check_repr(
&self.tcx.sess, &self.tcx.sess,
sym::fn_align, sym::fn_align,
hint.span(), hint.span(),
"`repr(align)` attributes on functions are unstable", fluent::passes_repr_align_function,
) )
.emit(); .emit();
} }

View File

@ -106,7 +106,6 @@ fn check_and_search_item(id: ItemId, ctxt: &mut EntryContext<'_>) {
} }
} }
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
fn configure_main(tcx: TyCtxt<'_>, visitor: &EntryContext<'_>) -> Option<(DefId, EntryFnType)> { fn configure_main(tcx: TyCtxt<'_>, visitor: &EntryContext<'_>) -> Option<(DefId, EntryFnType)> {
if let Some((def_id, _)) = visitor.start_fn { if let Some((def_id, _)) = visitor.start_fn {
Some((def_id.to_def_id(), EntryFnType::Start)) Some((def_id.to_def_id(), EntryFnType::Start))

View File

@ -73,7 +73,6 @@ LL | let _ = || yield true;
= note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information
= help: add `#![feature(coroutines)]` to the crate attributes to enable = help: add `#![feature(coroutines)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: `yield` can only be used in `#[coroutine]` closures, or `gen` blocks error: `yield` can only be used in `#[coroutine]` closures, or `gen` blocks
--> $DIR/gen_block.rs:16:16 --> $DIR/gen_block.rs:16:16
@ -95,7 +94,6 @@ LL | let _ = #[coroutine] || yield true;
= note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information
= help: add `#![feature(coroutines)]` to the crate attributes to enable = help: add `#![feature(coroutines)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: aborting due to 11 previous errors error: aborting due to 11 previous errors

View File

@ -47,7 +47,6 @@ LL | yield true;
= note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information
= help: add `#![feature(coroutines)]` to the crate attributes to enable = help: add `#![feature(coroutines)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: `yield` can only be used in `#[coroutine]` closures, or `gen` blocks error: `yield` can only be used in `#[coroutine]` closures, or `gen` blocks
--> $DIR/feature-gate-coroutines.rs:5:5 --> $DIR/feature-gate-coroutines.rs:5:5
@ -69,7 +68,6 @@ LL | let _ = || yield true;
= note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information
= help: add `#![feature(coroutines)]` to the crate attributes to enable = help: add `#![feature(coroutines)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: `yield` can only be used in `#[coroutine]` closures, or `gen` blocks error: `yield` can only be used in `#[coroutine]` closures, or `gen` blocks
--> $DIR/feature-gate-coroutines.rs:10:16 --> $DIR/feature-gate-coroutines.rs:10:16