diff options
| author | Folkert de Vries <folkert@folkertdev.nl> | 2025-09-06 17:23:34 +0200 |
|---|---|---|
| committer | Folkert de Vries <folkert@folkertdev.nl> | 2025-09-08 19:18:21 +0200 |
| commit | 2b9fce8c8cf4373ee9da938ad5eeb97e85ca2739 (patch) | |
| tree | 154eb55dcef1f2a9b791ef4d42e7f77fbad1f279 /compiler/rustc_ast_passes | |
| parent | 7075000ae72c3ead855dc660a37c6bf263b7b452 (diff) | |
| download | rust-2b9fce8c8cf4373ee9da938ad5eeb97e85ca2739.tar.gz rust-2b9fce8c8cf4373ee9da938ad5eeb97e85ca2739.zip | |
c-variadic: reject non-extern functions
Diffstat (limited to 'compiler/rustc_ast_passes')
| -rw-r--r-- | compiler/rustc_ast_passes/messages.ftl | 2 | ||||
| -rw-r--r-- | compiler/rustc_ast_passes/src/ast_validation.rs | 3 | ||||
| -rw-r--r-- | compiler/rustc_ast_passes/src/errors.rs | 7 |
3 files changed, 11 insertions, 1 deletions
diff --git a/compiler/rustc_ast_passes/messages.ftl b/compiler/rustc_ast_passes/messages.ftl index 6eb4e4bc452..958797a6089 100644 --- a/compiler/rustc_ast_passes/messages.ftl +++ b/compiler/rustc_ast_passes/messages.ftl @@ -68,6 +68,8 @@ ast_passes_bound_in_context = bounds on `type`s in {$ctx} have no effect ast_passes_c_variadic_associated_function = associated functions cannot have a C variable argument list +ast_passes_c_variadic_no_extern = `...` is not supported for non-extern functions + ast_passes_const_and_c_variadic = functions cannot be both `const` and C-variadic .const = `const` because of this .variadic = C-variadic because of this diff --git a/compiler/rustc_ast_passes/src/ast_validation.rs b/compiler/rustc_ast_passes/src/ast_validation.rs index 79947b514b1..bbba235a6d1 100644 --- a/compiler/rustc_ast_passes/src/ast_validation.rs +++ b/compiler/rustc_ast_passes/src/ast_validation.rs @@ -714,7 +714,8 @@ impl<'a> AstValidator<'a> { self.dcx().emit_err(errors::BadCVariadic { span: variadic_param.span }); } Extern::None => { - self.dcx().emit_err(errors::BadCVariadic { span: variadic_param.span }); + let err = errors::CVariadicNoExtern { span: variadic_param.span }; + self.dcx().emit_err(err); } }, FnCtxt::Assoc(_) => { diff --git a/compiler/rustc_ast_passes/src/errors.rs b/compiler/rustc_ast_passes/src/errors.rs index a085e09fe94..6b57e5ef376 100644 --- a/compiler/rustc_ast_passes/src/errors.rs +++ b/compiler/rustc_ast_passes/src/errors.rs @@ -326,6 +326,13 @@ pub(crate) struct CVariadicAssociatedFunction { } #[derive(Diagnostic)] +#[diag(ast_passes_c_variadic_no_extern)] +pub(crate) struct CVariadicNoExtern { + #[primary_span] + pub span: Span, +} + +#[derive(Diagnostic)] #[diag(ast_passes_bad_c_variadic)] pub(crate) struct BadCVariadic { #[primary_span] |
