Skip to content

Commit ea74eff

Browse files
authoredAug 12, 2024
Rollup merge of rust-lang#128886 - GrigorenkoPV:untranslatable-diagnostic, r=nnethercote
Get rid of some `#[allow(rustc::untranslatable_diagnostic)]` `@rustbot` label +A-translation cc rust-lang#100717
2 parents 355a232 + f09a2b0 commit ea74eff

File tree

23 files changed

+125
-77
lines changed

23 files changed

+125
-77
lines changed
 

‎compiler/rustc_ast_lowering/messages.ftl

+12
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,23 @@ ast_lowering_template_modifier = template modifier
167167
168168
ast_lowering_this_not_async = this is not `async`
169169
170+
ast_lowering_underscore_array_length_unstable =
171+
using `_` for array lengths is unstable
172+
170173
ast_lowering_underscore_expr_lhs_assign =
171174
in expressions, `_` can only be used on the left-hand side of an assignment
172175
.label = `_` not allowed here
173176
177+
ast_lowering_unstable_inline_assembly = inline assembly is not stable yet on this architecture
178+
ast_lowering_unstable_inline_assembly_const_operands =
179+
const operands for inline assembly are unstable
180+
ast_lowering_unstable_inline_assembly_label_operands =
181+
label operands for inline assembly are unstable
182+
ast_lowering_unstable_may_unwind = the `may_unwind` option is unstable
183+
174184
ast_lowering_use_angle_brackets = use angle brackets instead
185+
186+
ast_lowering_yield = yield syntax is experimental
175187
ast_lowering_yield_in_closure =
176188
`yield` can only be used in `#[coroutine]` closures, or `gen` blocks
177189
.suggestion = use `#[coroutine]` to make this closure a coroutine

‎compiler/rustc_ast_lowering/src/asm.rs

+14-7
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@ use super::errors::{
1919
InvalidRegisterClass, RegisterClassOnlyClobber, RegisterConflict,
2020
};
2121
use super::LoweringContext;
22-
use crate::{ImplTraitContext, ImplTraitPosition, ParamMode, ResolverAstLoweringExt};
22+
use crate::{
23+
fluent_generated as fluent, ImplTraitContext, ImplTraitPosition, ParamMode,
24+
ResolverAstLoweringExt,
25+
};
2326

2427
impl<'a, 'hir> LoweringContext<'a, 'hir> {
25-
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
2628
pub(crate) fn lower_inline_asm(
2729
&mut self,
2830
sp: Span,
@@ -52,7 +54,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
5254
&self.tcx.sess,
5355
sym::asm_experimental_arch,
5456
sp,
55-
"inline assembly is not stable yet on this architecture",
57+
fluent::ast_lowering_unstable_inline_assembly,
5658
)
5759
.emit();
5860
}
@@ -64,8 +66,13 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
6466
self.dcx().emit_err(AttSyntaxOnlyX86 { span: sp });
6567
}
6668
if asm.options.contains(InlineAsmOptions::MAY_UNWIND) && !self.tcx.features().asm_unwind {
67-
feature_err(&self.tcx.sess, sym::asm_unwind, sp, "the `may_unwind` option is unstable")
68-
.emit();
69+
feature_err(
70+
&self.tcx.sess,
71+
sym::asm_unwind,
72+
sp,
73+
fluent::ast_lowering_unstable_may_unwind,
74+
)
75+
.emit();
6976
}
7077

7178
let mut clobber_abis = FxIndexMap::default();
@@ -182,7 +189,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
182189
sess,
183190
sym::asm_const,
184191
*op_sp,
185-
"const operands for inline assembly are unstable",
192+
fluent::ast_lowering_unstable_inline_assembly_const_operands,
186193
)
187194
.emit();
188195
}
@@ -246,7 +253,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
246253
sess,
247254
sym::asm_goto,
248255
*op_sp,
249-
"label operands for inline assembly are unstable",
256+
fluent::ast_lowering_unstable_inline_assembly_label_operands,
250257
)
251258
.emit();
252259
}

‎compiler/rustc_ast_lowering/src/expr.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use super::{
2323
ImplTraitContext, LoweringContext, ParamMode, ParenthesizedGenericArgs, ResolverAstLoweringExt,
2424
};
2525
use crate::errors::YieldInClosure;
26-
use crate::{FnDeclKind, ImplTraitPosition};
26+
use crate::{fluent_generated, FnDeclKind, ImplTraitPosition};
2727

2828
impl<'hir> LoweringContext<'_, 'hir> {
2929
fn lower_exprs(&mut self, exprs: &[AstP<Expr>]) -> &'hir [hir::Expr<'hir>] {
@@ -1540,7 +1540,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
15401540
}
15411541
}
15421542

1543-
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
15441543
fn lower_expr_yield(&mut self, span: Span, opt_expr: Option<&Expr>) -> hir::ExprKind<'hir> {
15451544
let yielded =
15461545
opt_expr.as_ref().map(|x| self.lower_expr(x)).unwrap_or_else(|| self.expr_unit(span));
@@ -1575,7 +1574,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
15751574
&self.tcx.sess,
15761575
sym::coroutines,
15771576
span,
1578-
"yield syntax is experimental",
1577+
fluent_generated::ast_lowering_yield,
15791578
)
15801579
.emit();
15811580
}
@@ -1587,7 +1586,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
15871586
&self.tcx.sess,
15881587
sym::coroutines,
15891588
span,
1590-
"yield syntax is experimental",
1589+
fluent_generated::ast_lowering_yield,
15911590
)
15921591
.emit();
15931592
}

‎compiler/rustc_ast_lowering/src/lib.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -2326,7 +2326,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
23262326
self.expr_block(block)
23272327
}
23282328

2329-
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
23302329
fn lower_array_length(&mut self, c: &AnonConst) -> hir::ArrayLen<'hir> {
23312330
match c.value.kind {
23322331
ExprKind::Underscore => {
@@ -2340,7 +2339,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
23402339
&self.tcx.sess,
23412340
sym::generic_arg_infer,
23422341
c.value.span,
2343-
"using `_` for array lengths is unstable",
2342+
fluent_generated::ast_lowering_underscore_array_length_unstable,
23442343
)
23452344
.stash(c.value.span, StashKey::UnderscoreForArrayLengths);
23462345
hir::ArrayLen::Body(self.lower_anon_const_to_const_arg(c))

‎compiler/rustc_attr/messages.ftl

+3
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ attr_unknown_meta_item =
104104
attr_unknown_version_literal =
105105
unknown version literal format, assuming it refers to a future version
106106
107+
attr_unstable_cfg_target_compact =
108+
compact `cfg(target(..))` is experimental and subject to change
109+
107110
attr_unsupported_literal_cfg_string =
108111
literal in `cfg` predicate value must be a string
109112
attr_unsupported_literal_deprecated_kv_pair =

‎compiler/rustc_attr/src/builtin.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use rustc_span::hygiene::Transparency;
2020
use rustc_span::symbol::{sym, Symbol};
2121
use rustc_span::Span;
2222

23+
use crate::fluent_generated;
2324
use crate::session_diagnostics::{self, IncorrectReprFormatGenericCause};
2425

2526
/// The version placeholder that recently stabilized features contain inside the
@@ -521,7 +522,6 @@ pub struct Condition {
521522
}
522523

523524
/// Tests if a cfg-pattern matches the cfg set
524-
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
525525
pub fn cfg_matches(
526526
cfg: &ast::MetaItem,
527527
sess: &Session,
@@ -593,7 +593,6 @@ pub fn parse_version(s: Symbol) -> Option<RustcVersion> {
593593

594594
/// Evaluate a cfg-like condition (with `any` and `all`), using `eval` to
595595
/// evaluate individual items.
596-
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
597596
pub fn eval_condition(
598597
cfg: &ast::MetaItem,
599598
sess: &Session,
@@ -680,7 +679,7 @@ pub fn eval_condition(
680679
sess,
681680
sym::cfg_target_compact,
682681
cfg.span,
683-
"compact `cfg(target(..))` is experimental and subject to change",
682+
fluent_generated::attr_unstable_cfg_target_compact,
684683
)
685684
.emit();
686685
}

‎compiler/rustc_borrowck/messages.ftl

+21
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ borrowck_could_not_normalize =
6262
borrowck_could_not_prove =
6363
could not prove `{$predicate}`
6464
65+
borrowck_dereference_suggestion =
66+
dereference the return value
67+
6568
borrowck_func_take_self_moved_place =
6669
`{$func}` takes ownership of the receiver `self`, which moves {$place_name}
6770
@@ -74,9 +77,24 @@ borrowck_higher_ranked_lifetime_error =
7477
borrowck_higher_ranked_subtype_error =
7578
higher-ranked subtype error
7679
80+
borrowck_implicit_static =
81+
this has an implicit `'static` lifetime requirement
82+
83+
borrowck_implicit_static_introduced =
84+
calling this method introduces the `impl`'s `'static` requirement
85+
86+
borrowck_implicit_static_relax =
87+
consider relaxing the implicit `'static` requirement
88+
7789
borrowck_lifetime_constraints_error =
7890
lifetime may not live long enough
7991
92+
borrowck_limitations_implies_static =
93+
due to current limitations in the borrow checker, this implies a `'static` lifetime
94+
95+
borrowck_move_closure_suggestion =
96+
consider adding 'move' keyword before the nested closure
97+
8098
borrowck_move_out_place_here =
8199
{$place} is moved here
82100
@@ -163,6 +181,9 @@ borrowck_partial_var_move_by_use_in_coroutine =
163181
*[false] moved
164182
} due to use in coroutine
165183
184+
borrowck_restrict_to_static =
185+
consider restricting the type parameter to the `'static` lifetime
186+
166187
borrowck_returned_async_block_escaped =
167188
returns an `async` block that contains a reference to a captured variable, which then escapes the closure body
168189

‎compiler/rustc_borrowck/src/diagnostics/region_errors.rs

+31-33
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use crate::session_diagnostics::{
3535
LifetimeReturnCategoryErr, RequireStaticErr, VarHereDenote,
3636
};
3737
use crate::universal_regions::DefiningTy;
38-
use crate::{borrowck_errors, MirBorrowckCtxt};
38+
use crate::{borrowck_errors, fluent_generated as fluent, MirBorrowckCtxt};
3939

4040
impl<'tcx> ConstraintDescription for ConstraintCategory<'tcx> {
4141
fn description(&self) -> &'static str {
@@ -198,7 +198,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
198198
// from higher-ranked trait bounds (HRTB). Try to locate span of the trait
199199
// and the span which bounded to the trait for adding 'static lifetime suggestion
200200
#[allow(rustc::diagnostic_outside_of_impl)]
201-
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
202201
fn suggest_static_lifetime_for_gat_from_hrtb(
203202
&self,
204203
diag: &mut Diag<'_>,
@@ -251,23 +250,28 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
251250
debug!(?hrtb_bounds);
252251

253252
hrtb_bounds.iter().for_each(|bound| {
254-
let Trait(PolyTraitRef { trait_ref, span: trait_span, .. }, _) = bound else { return; };
255-
diag.span_note(
256-
*trait_span,
257-
"due to current limitations in the borrow checker, this implies a `'static` lifetime"
258-
);
259-
let Some(generics_fn) = hir.get_generics(self.body.source.def_id().expect_local()) else { return; };
260-
let Def(_, trait_res_defid) = trait_ref.path.res else { return; };
253+
let Trait(PolyTraitRef { trait_ref, span: trait_span, .. }, _) = bound else {
254+
return;
255+
};
256+
diag.span_note(*trait_span, fluent::borrowck_limitations_implies_static);
257+
let Some(generics_fn) = hir.get_generics(self.body.source.def_id().expect_local())
258+
else {
259+
return;
260+
};
261+
let Def(_, trait_res_defid) = trait_ref.path.res else {
262+
return;
263+
};
261264
debug!(?generics_fn);
262265
generics_fn.predicates.iter().for_each(|predicate| {
263-
let BoundPredicate(
264-
WhereBoundPredicate {
265-
span: bounded_span,
266-
bounded_ty,
267-
bounds,
268-
..
269-
}
270-
) = predicate else { return; };
266+
let BoundPredicate(WhereBoundPredicate {
267+
span: bounded_span,
268+
bounded_ty,
269+
bounds,
270+
..
271+
}) = predicate
272+
else {
273+
return;
274+
};
271275
bounds.iter().for_each(|bd| {
272276
if let Trait(PolyTraitRef { trait_ref: tr_ref, .. }, _) = bd
273277
&& let Def(_, res_defid) = tr_ref.path.res
@@ -277,16 +281,17 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
277281
&& generics_fn.params
278282
.iter()
279283
.rfind(|param| param.def_id.to_def_id() == defid)
280-
.is_some() {
281-
suggestions.push((bounded_span.shrink_to_hi(), " + 'static".to_string()));
282-
}
284+
.is_some()
285+
{
286+
suggestions.push((bounded_span.shrink_to_hi(), " + 'static".to_string()));
287+
}
283288
});
284289
});
285290
});
286291
if suggestions.len() > 0 {
287292
suggestions.dedup();
288293
diag.multipart_suggestion_verbose(
289-
"consider restricting the type parameter to the `'static` lifetime",
294+
fluent::borrowck_restrict_to_static,
290295
suggestions,
291296
Applicability::MaybeIncorrect,
292297
);
@@ -976,7 +981,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
976981
}
977982

978983
#[allow(rustc::diagnostic_outside_of_impl)]
979-
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
980984
#[instrument(skip(self, err), level = "debug")]
981985
fn suggest_constrain_dyn_trait_in_impl(
982986
&self,
@@ -994,16 +998,12 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
994998
debug!("trait spans found: {:?}", traits);
995999
for span in &traits {
9961000
let mut multi_span: MultiSpan = vec![*span].into();
997-
multi_span
998-
.push_span_label(*span, "this has an implicit `'static` lifetime requirement");
999-
multi_span.push_span_label(
1000-
ident.span,
1001-
"calling this method introduces the `impl`'s `'static` requirement",
1002-
);
1001+
multi_span.push_span_label(*span, fluent::borrowck_implicit_static);
1002+
multi_span.push_span_label(ident.span, fluent::borrowck_implicit_static_introduced);
10031003
err.subdiagnostic(RequireStaticErr::UsedImpl { multi_span });
10041004
err.span_suggestion_verbose(
10051005
span.shrink_to_hi(),
1006-
"consider relaxing the implicit `'static` requirement",
1006+
fluent::borrowck_implicit_static_relax,
10071007
" + '_",
10081008
Applicability::MaybeIncorrect,
10091009
);
@@ -1045,7 +1045,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
10451045
}
10461046

10471047
#[allow(rustc::diagnostic_outside_of_impl)]
1048-
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
10491048
/// When encountering a lifetime error caused by the return type of a closure, check the
10501049
/// corresponding trait bound and see if dereferencing the closure return value would satisfy
10511050
/// them. If so, we produce a structured suggestion.
@@ -1166,15 +1165,14 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
11661165
if ocx.select_all_or_error().is_empty() && count > 0 {
11671166
diag.span_suggestion_verbose(
11681167
tcx.hir().body(*body).value.peel_blocks().span.shrink_to_lo(),
1169-
"dereference the return value",
1168+
fluent::borrowck_dereference_suggestion,
11701169
"*".repeat(count),
11711170
Applicability::MachineApplicable,
11721171
);
11731172
}
11741173
}
11751174

11761175
#[allow(rustc::diagnostic_outside_of_impl)]
1177-
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
11781176
fn suggest_move_on_borrowing_closure(&self, diag: &mut Diag<'_>) {
11791177
let map = self.infcx.tcx.hir();
11801178
let body = map.body_owned_by(self.mir_def_id());
@@ -1213,7 +1211,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
12131211
if let Some(closure_span) = closure_span {
12141212
diag.span_suggestion_verbose(
12151213
closure_span,
1216-
"consider adding 'move' keyword before the nested closure",
1214+
fluent::borrowck_move_closure_suggestion,
12171215
"move ",
12181216
Applicability::MaybeIncorrect,
12191217
);

‎compiler/rustc_const_eval/messages.ftl

+5
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ const_eval_const_context = {$kind ->
4141
*[other] {""}
4242
}
4343
44+
const_eval_const_stable = const-stable functions can only call other const-stable functions
45+
4446
const_eval_copy_nonoverlapping_overlapping =
4547
`copy_nonoverlapping` called on overlapping ranges
4648
@@ -201,6 +203,9 @@ const_eval_invalid_vtable_pointer =
201203
const_eval_invalid_vtable_trait =
202204
using vtable for trait `{$vtable_trait}` but trait `{$expected_trait}` was expected
203205
206+
const_eval_lazy_lock =
207+
consider wrapping this expression in `std::sync::LazyLock::new(|| ...)`
208+
204209
const_eval_live_drop =
205210
destructor of `{$dropped_ty}` cannot be evaluated at compile-time
206211
.label = the destructor for this type cannot be evaluated in {const_eval_const_context}s

‎compiler/rustc_const_eval/src/check_consts/ops.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use rustc_trait_selection::traits::SelectionContext;
2323
use tracing::debug;
2424

2525
use super::ConstCx;
26-
use crate::errors;
26+
use crate::{errors, fluent_generated};
2727

2828
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
2929
pub enum Status {
@@ -310,7 +310,7 @@ impl<'tcx> NonConstOp<'tcx> for FnCallNonConst<'tcx> {
310310
}
311311

312312
if let ConstContext::Static(_) = ccx.const_kind() {
313-
err.note("consider wrapping this expression in `std::sync::LazyLock::new(|| ...)`");
313+
err.note(fluent_generated::const_eval_lazy_lock);
314314
}
315315

316316
err
@@ -334,7 +334,7 @@ impl<'tcx> NonConstOp<'tcx> for FnCallUnstable {
334334
// FIXME: make this translatable
335335
#[allow(rustc::untranslatable_diagnostic)]
336336
if ccx.is_const_stable_const_fn() {
337-
err.help("const-stable functions can only call other const-stable functions");
337+
err.help(fluent_generated::const_eval_const_stable);
338338
} else if ccx.tcx.sess.is_nightly_build() {
339339
if let Some(feature) = feature {
340340
err.help(format!("add `#![feature({feature})]` to the crate attributes to enable"));
@@ -605,8 +605,6 @@ impl<'tcx> NonConstOp<'tcx> for StaticAccess {
605605
span,
606606
format!("referencing statics in {}s is unstable", ccx.const_kind(),),
607607
);
608-
// FIXME: make this translatable
609-
#[allow(rustc::untranslatable_diagnostic)]
610608
err
611609
.note("`static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable.")
612610
.help("to fix this, the value can be extracted to a `const` and then used.");

‎compiler/rustc_expand/messages.ftl

+3
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ expand_module_multiple_candidates =
129129
expand_must_repeat_once =
130130
this must repeat at least once
131131
132+
expand_non_inline_modules_in_proc_macro_input_are_unstable =
133+
non-inline modules in proc macro input are unstable
134+
132135
expand_not_a_meta_item =
133136
not a meta item
134137

‎compiler/rustc_expand/src/base.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1398,8 +1398,6 @@ fn pretty_printing_compatibility_hack(item: &Item, sess: &Session) {
13981398
};
13991399

14001400
if crate_matches {
1401-
// FIXME: make this translatable
1402-
#[allow(rustc::untranslatable_diagnostic)]
14031401
sess.dcx().emit_fatal(errors::ProcMacroBackCompat {
14041402
crate_name: "rental".to_string(),
14051403
fixed_version: "0.5.6".to_string(),

‎compiler/rustc_expand/src/expand.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ use crate::errors::{
3939
RecursionLimitReached, RemoveExprNotSupported, RemoveNodeNotSupported, UnsupportedKeyValue,
4040
WrongFragmentKind,
4141
};
42+
use crate::fluent_generated;
4243
use crate::mbe::diagnostics::annotate_err_with_kind;
4344
use crate::module::{mod_dir_path, parse_external_mod, DirOwnership, ParsedExternalMod};
4445
use crate::placeholders::{placeholder, PlaceholderExpander};
@@ -882,7 +883,6 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
882883
}
883884

884885
impl<'ast, 'a> Visitor<'ast> for GateProcMacroInput<'a> {
885-
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
886886
fn visit_item(&mut self, item: &'ast ast::Item) {
887887
match &item.kind {
888888
ItemKind::Mod(_, mod_kind)
@@ -892,7 +892,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
892892
self.sess,
893893
sym::proc_macro_hygiene,
894894
item.span,
895-
"non-inline modules in proc macro input are unstable",
895+
fluent_generated::expand_non_inline_modules_in_proc_macro_input_are_unstable,
896896
)
897897
.emit();
898898
}
@@ -1876,7 +1876,6 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
18761876

18771877
// Detect use of feature-gated or invalid attributes on macro invocations
18781878
// since they will not be detected after macro expansion.
1879-
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
18801879
fn check_attributes(&self, attrs: &[ast::Attribute], call: &ast::MacCall) {
18811880
let features = self.cx.ecfg.features;
18821881
let mut attrs = attrs.iter().peekable();

‎compiler/rustc_interface/src/util.rs

-1
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,6 @@ fn get_codegen_sysroot(
386386
}
387387
}
388388

389-
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
390389
pub(crate) fn check_attr_crate_type(
391390
sess: &Session,
392391
attrs: &[ast::Attribute],

‎compiler/rustc_lint/src/levels.rs

-2
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,6 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
717717
};
718718
}
719719

720-
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
721720
fn add(&mut self, attrs: &[ast::Attribute], is_crate_node: bool, source_hir_id: Option<HirId>) {
722721
let sess = self.sess;
723722
for (attr_index, attr) in attrs.iter().enumerate() {
@@ -1039,7 +1038,6 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
10391038
let (level, src) = self.lint_level(builtin::UNKNOWN_LINTS);
10401039
// FIXME: make this translatable
10411040
#[allow(rustc::diagnostic_outside_of_impl)]
1042-
#[allow(rustc::untranslatable_diagnostic)]
10431041
lint_level(self.sess, lint, level, src, Some(span.into()), |lint| {
10441042
lint.primary_message(fluent::lint_unknown_gated_lint);
10451043
lint.arg("name", lint_id.lint.name_lower());

‎compiler/rustc_metadata/messages.ftl

+6
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,18 @@ metadata_lib_framework_apple =
134134
metadata_lib_required =
135135
crate `{$crate_name}` required to be available in {$kind} format, but was not found in this form
136136
137+
metadata_link_arg_unstable =
138+
link kind `link-arg` is unstable
139+
137140
metadata_link_cfg_form =
138141
link cfg must be of the form `cfg(/* predicate */)`
139142
140143
metadata_link_cfg_single_predicate =
141144
link cfg must have a single predicate argument
142145
146+
metadata_link_cfg_unstable =
147+
link cfg is unstable
148+
143149
metadata_link_framework_apple =
144150
link kind `framework` is only supported on Apple targets
145151

‎compiler/rustc_metadata/src/creader.rs

-1
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,6 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
949949
}
950950
}
951951

952-
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
953952
fn report_unused_deps(&mut self, krate: &ast::Crate) {
954953
// Make a point span rather than covering the whole file
955954
let span = krate.spans.inner_span.shrink_to_lo();

‎compiler/rustc_metadata/src/native_libs.rs

+11-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use rustc_span::def_id::{DefId, LOCAL_CRATE};
1717
use rustc_span::symbol::{sym, Symbol};
1818
use rustc_target::spec::abi::Abi;
1919

20-
use crate::errors;
20+
use crate::{errors, fluent_generated};
2121

2222
pub fn find_native_static_library(name: &str, verbatim: bool, sess: &Session) -> PathBuf {
2323
let formats = if verbatim {
@@ -87,7 +87,6 @@ struct Collector<'tcx> {
8787
}
8888

8989
impl<'tcx> Collector<'tcx> {
90-
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
9190
fn process_module(&mut self, module: &ForeignModule) {
9291
let ForeignModule { def_id, abi, ref foreign_items } = *module;
9392
let def_id = def_id.expect_local();
@@ -161,7 +160,7 @@ impl<'tcx> Collector<'tcx> {
161160
sess,
162161
sym::link_arg_attribute,
163162
span,
164-
"link kind `link-arg` is unstable",
163+
fluent_generated::metadata_link_arg_unstable,
165164
)
166165
.emit();
167166
}
@@ -201,8 +200,13 @@ impl<'tcx> Collector<'tcx> {
201200
continue;
202201
};
203202
if !features.link_cfg {
204-
feature_err(sess, sym::link_cfg, item.span(), "link cfg is unstable")
205-
.emit();
203+
feature_err(
204+
sess,
205+
sym::link_cfg,
206+
item.span(),
207+
fluent_generated::metadata_link_cfg_unstable,
208+
)
209+
.emit();
206210
}
207211
cfg = Some(link_cfg.clone());
208212
}
@@ -266,6 +270,8 @@ impl<'tcx> Collector<'tcx> {
266270

267271
macro report_unstable_modifier($feature: ident) {
268272
if !features.$feature {
273+
// FIXME: make this translatable
274+
#[expect(rustc::untranslatable_diagnostic)]
269275
feature_err(
270276
sess,
271277
sym::$feature,

‎compiler/rustc_passes/messages.ftl

+6
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,9 @@ passes_doc_masked_only_extern_crate =
223223
.not_an_extern_crate_label = not an `extern crate` item
224224
.note = read <https://doc.rust-lang.org/unstable-book/language-features/doc-masked.html> for more information
225225
226+
passes_doc_rust_logo =
227+
the `#[doc(rust_logo)]` attribute is used for Rust branding
228+
226229
passes_doc_test_literal = `#![doc(test(...)]` does not take a literal
227230
228231
passes_doc_test_takes_list =
@@ -595,6 +598,9 @@ passes_remove_fields =
595598
*[other] fields
596599
}
597600
601+
passes_repr_align_function =
602+
`repr(align)` attributes on functions are unstable
603+
598604
passes_repr_conflicting =
599605
conflicting representation hints
600606

‎compiler/rustc_passes/src/check_attr.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1142,7 +1142,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
11421142
/// of one item. Read the documentation of [`check_doc_inline`] for more information.
11431143
///
11441144
/// [`check_doc_inline`]: Self::check_doc_inline
1145-
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
11461145
fn check_doc_attrs(
11471146
&self,
11481147
attr: &Attribute,
@@ -1220,7 +1219,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
12201219
&self.tcx.sess,
12211220
sym::rustdoc_internals,
12221221
meta.span(),
1223-
"the `#[doc(rust_logo)]` attribute is used for Rust branding",
1222+
fluent::passes_doc_rust_logo,
12241223
)
12251224
.emit();
12261225
}
@@ -1736,7 +1735,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
17361735
}
17371736

17381737
/// Checks if the `#[repr]` attributes on `item` are valid.
1739-
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
17401738
fn check_repr(
17411739
&self,
17421740
attrs: &[Attribute],
@@ -1793,7 +1791,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
17931791
&self.tcx.sess,
17941792
sym::fn_align,
17951793
hint.span(),
1796-
"`repr(align)` attributes on functions are unstable",
1794+
fluent::passes_repr_align_function,
17971795
)
17981796
.emit();
17991797
}

‎compiler/rustc_passes/src/entry.rs

-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ fn check_and_search_item(id: ItemId, ctxt: &mut EntryContext<'_>) {
106106
}
107107
}
108108

109-
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
110109
fn configure_main(tcx: TyCtxt<'_>, visitor: &EntryContext<'_>) -> Option<(DefId, EntryFnType)> {
111110
if let Some((def_id, _)) = visitor.start_fn {
112111
Some((def_id.to_def_id(), EntryFnType::Start))

‎tests/ui/coroutine/gen_block.none.stderr

-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ LL | let _ = || yield true;
7373
= note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information
7474
= help: add `#![feature(coroutines)]` to the crate attributes to enable
7575
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
76-
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
7776

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

10098
error: aborting due to 11 previous errors
10199

‎tests/ui/feature-gates/feature-gate-coroutines.none.stderr

-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ LL | yield true;
4747
= note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information
4848
= help: add `#![feature(coroutines)]` to the crate attributes to enable
4949
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
50-
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
5150

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

7472
error: `yield` can only be used in `#[coroutine]` closures, or `gen` blocks
7573
--> $DIR/feature-gate-coroutines.rs:10:16

0 commit comments

Comments
 (0)
Please sign in to comment.