Skip to content

Commit b317ec1

Browse files
committed
Feature-gate do yeet inside cfgs too
1 parent 9b5766c commit b317ec1

File tree

3 files changed

+41
-8
lines changed

3 files changed

+41
-8
lines changed

compiler/rustc_ast_passes/src/feature_gate.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -619,14 +619,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
619619
ast::ExprKind::TryBlock(_) => {
620620
gate_feature_post!(&self, try_blocks, e.span, "`try` expression is experimental");
621621
}
622-
ast::ExprKind::Yeet(_) => {
623-
gate_feature_post!(
624-
&self,
625-
yeet_expr,
626-
e.span,
627-
"`do yeet` expression is experimental"
628-
);
629-
}
630622
ast::ExprKind::Block(_, Some(label)) => {
631623
gate_feature_post!(
632624
&self,
@@ -791,6 +783,7 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session) {
791783
gate_all!(inline_const, "inline-const is experimental");
792784
gate_all!(inline_const_pat, "inline-const in pattern position is experimental");
793785
gate_all!(associated_const_equality, "associated const equality is incomplete");
786+
gate_all!(yeet_expr, "`do yeet` expression is experimental");
794787

795788
// All uses of `gate_all!` below this point were added in #65742,
796789
// and subsequently disabled (with the non-early gating readded).
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// compile-flags: --edition 2021
2+
3+
pub fn demo() -> Option<i32> {
4+
#[cfg(nope)]
5+
{
6+
do yeet //~ ERROR `do yeet` expression is experimental
7+
}
8+
9+
Some(1)
10+
}
11+
12+
#[cfg(nope)]
13+
pub fn alternative() -> Result<(), String> {
14+
do yeet "hello"; //~ ERROR `do yeet` expression is experimental
15+
}
16+
17+
fn main() {
18+
demo();
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
error[E0658]: `do yeet` expression is experimental
2+
--> $DIR/feature-gate-yeet_expr-in-cfg.rs:6:9
3+
|
4+
LL | do yeet
5+
| ^^^^^^^
6+
|
7+
= note: see issue #96373 <https://github.com/rust-lang/rust/issues/96373> for more information
8+
= help: add `#![feature(yeet_expr)]` to the crate attributes to enable
9+
10+
error[E0658]: `do yeet` expression is experimental
11+
--> $DIR/feature-gate-yeet_expr-in-cfg.rs:14:5
12+
|
13+
LL | do yeet "hello";
14+
| ^^^^^^^^^^^^^^^
15+
|
16+
= note: see issue #96373 <https://github.com/rust-lang/rust/issues/96373> for more information
17+
= help: add `#![feature(yeet_expr)]` to the crate attributes to enable
18+
19+
error: aborting due to 2 previous errors
20+
21+
For more information about this error, try `rustc --explain E0658`.

0 commit comments

Comments
 (0)