Skip to content

Commit e07731c

Browse files
Correctly check never_type feature gating
1 parent 11f32b7 commit e07731c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,16 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
362362
}
363363
}
364364

365+
fn visit_generic_args(&mut self, args: &'a ast::GenericArgs) {
366+
if let ast::GenericArgs::Parenthesized(generic_args) = args
367+
&& let ast::FnRetTy::Ty(ref ty) = generic_args.output
368+
&& matches!(ty.kind, ast::TyKind::Never)
369+
{
370+
gate!(&self, never_type, ty.span, "the `!` type is experimental");
371+
}
372+
visit::walk_generic_args(self, args);
373+
}
374+
365375
fn visit_expr(&mut self, e: &'a ast::Expr) {
366376
match e.kind {
367377
ast::ExprKind::TryBlock(_) => {

0 commit comments

Comments
 (0)