Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf005b45

Browse files
Support C23's Variadics Without a Named Parameter
This PR removes the static check that disallowed extern functionswith ellipsis (varargs) as the only parameter since this is nowvalid in C23.Also, adds a doc comment for `check_decl_cvariadic_pos()` andfixes the name of the function (`varadic` -> `variadic`).
1 parent62a104d commitf005b45

File tree

3 files changed

+5
-17
lines changed

3 files changed

+5
-17
lines changed

‎compiler/rustc_ast_passes/messages.ftl‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,6 @@ ast_passes_fn_body_extern = incorrect function inside `extern` block
9797
ast_passes_fn_param_c_var_args_not_last =
9898
`...` must be the last argument of a C-variadic function
9999
100-
ast_passes_fn_param_c_var_args_only =
101-
C-variadic function must be declared with at least one named argument
102-
103100
ast_passes_fn_param_doc_comment =
104101
documentation comments cannot be applied to function parameters
105102
.label =doc comments are not allowed here

‎compiler/rustc_ast_passes/src/ast_validation.rs‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ impl<'a> AstValidator<'a> {
365365

366366
fncheck_fn_decl(&self,fn_decl:&FnDecl,self_semantic:SelfSemantic){
367367
self.check_decl_num_args(fn_decl);
368-
self.check_decl_cvaradic_pos(fn_decl);
368+
self.check_decl_cvariadic_pos(fn_decl);
369369
self.check_decl_attrs(fn_decl);
370370
self.check_decl_self_param(fn_decl, self_semantic);
371371
}
@@ -380,13 +380,11 @@ impl<'a> AstValidator<'a> {
380380
}
381381
}
382382

383-
fncheck_decl_cvaradic_pos(&self,fn_decl:&FnDecl){
383+
/// Emits an error if a function declaration has a variadic parameter in the
384+
/// beginning or middle of parameter list.
385+
/// Example: `fn foo(..., x: i32)` will emit an error.
386+
fncheck_decl_cvariadic_pos(&self,fn_decl:&FnDecl){
384387
match&*fn_decl.inputs{
385-
[Param{ ty, span, ..}] =>{
386-
ifletTyKind::CVarArgs = ty.kind{
387-
self.dcx().emit_err(errors::FnParamCVarArgsOnly{span:*span});
388-
}
389-
}
390388
[ps @ .., _] =>{
391389
forParam{ ty, span, ..}in ps{
392390
ifletTyKind::CVarArgs = ty.kind{

‎compiler/rustc_ast_passes/src/errors.rs‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,6 @@ pub struct FnParamTooMany {
9292
pubmax_num_args:usize,
9393
}
9494

95-
#[derive(Diagnostic)]
96-
#[diag(ast_passes_fn_param_c_var_args_only)]
97-
pubstructFnParamCVarArgsOnly{
98-
#[primary_span]
99-
pubspan:Span,
100-
}
101-
10295
#[derive(Diagnostic)]
10396
#[diag(ast_passes_fn_param_c_var_args_not_last)]
10497
pubstructFnParamCVarArgsNotLast{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp