Skip to content

Commit 290df4f

Browse files
committed
rustc_ast_lowering: make "yield syntax is experimental" translatable
1 parent 334a097 commit 290df4f

File tree

4 files changed

+5
-8
lines changed

4 files changed

+5
-8
lines changed

compiler/rustc_ast_lowering/messages.ftl

+2
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ ast_lowering_underscore_expr_lhs_assign =
175175
.label = `_` not allowed here
176176
177177
ast_lowering_use_angle_brackets = use angle brackets instead
178+
179+
ast_lowering_yield = yield syntax is experimental
178180
ast_lowering_yield_in_closure =
179181
`yield` can only be used in `#[coroutine]` closures, or `gen` blocks
180182
.suggestion = use `#[coroutine]` to make this closure a coroutine

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
}

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)