Skip to content

Commit

Permalink
Remove unnecessary CVarArgs name skipping logic
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes committed Oct 25, 2023
1 parent 2c1dbed commit 6aead74
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
9 changes: 1 addition & 8 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1737,14 +1737,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
}

fn lower_fn_params_to_names(&mut self, decl: &FnDecl) -> &'hir [Ident] {
// Skip the `...` (`CVarArgs`) trailing arguments from the AST,
// as they are not explicit in HIR/Ty function signatures.
// (instead, the `c_variadic` flag is set to `true`)
let mut inputs = &decl.inputs[..];
if decl.c_variadic() {
inputs = &inputs[..inputs.len() - 1];
}
self.arena.alloc_from_iter(inputs.iter().map(|param| match param.pat.kind {
self.arena.alloc_from_iter(decl.inputs.iter().map(|param| match param.pat.kind {
PatKind::Ident(_, ident, _) => self.lower_ident(ident),
_ => Ident::new(kw::Empty, self.lower_span(param.pat.span)),
}))
Expand Down
2 changes: 1 addition & 1 deletion tests/pretty/hir-fn-variadic.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
extern crate std;

extern "C" {
fn foo(x: i32, ...);
fn foo(x: i32, va1: ...);
}

unsafe extern "C" fn bar(_: i32, mut va2: ...) -> usize { va2.arg::<usize>() }

0 comments on commit 6aead74

Please sign in to comment.