Skip to content

Commit 7075000

Browse files
committed
clarify control flow of check_c_variadic_type
1 parent a093372 commit 7075000

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -697,14 +697,23 @@ impl<'a> AstValidator<'a> {
697697
match fn_ctxt {
698698
FnCtxt::Foreign => return,
699699
FnCtxt::Free => match sig.header.ext {
700-
Extern::Explicit(StrLit { symbol_unescaped: sym::C, .. }, _)
701-
| Extern::Explicit(StrLit { symbol_unescaped: sym::C_dash_unwind, .. }, _)
702-
| Extern::Implicit(_)
703-
if matches!(sig.header.safety, Safety::Unsafe(_)) =>
704-
{
705-
return;
700+
Extern::Implicit(_) => {
701+
if matches!(sig.header.safety, Safety::Unsafe(_)) {
702+
return;
703+
}
704+
705+
self.dcx().emit_err(errors::BadCVariadic { span: variadic_param.span });
706+
}
707+
Extern::Explicit(StrLit { symbol_unescaped, .. }, _) => {
708+
if matches!(symbol_unescaped, sym::C | sym::C_dash_unwind) {
709+
if matches!(sig.header.safety, Safety::Unsafe(_)) {
710+
return;
711+
}
712+
}
713+
714+
self.dcx().emit_err(errors::BadCVariadic { span: variadic_param.span });
706715
}
707-
_ => {
716+
Extern::None => {
708717
self.dcx().emit_err(errors::BadCVariadic { span: variadic_param.span });
709718
}
710719
},

0 commit comments

Comments
 (0)