diff options
Diffstat (limited to 'crates/ra_hir_ty/src/diagnostics')
-rw-r--r-- | crates/ra_hir_ty/src/diagnostics/expr.rs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/crates/ra_hir_ty/src/diagnostics/expr.rs b/crates/ra_hir_ty/src/diagnostics/expr.rs index 21ff99a8c..557d01cdc 100644 --- a/crates/ra_hir_ty/src/diagnostics/expr.rs +++ b/crates/ra_hir_ty/src/diagnostics/expr.rs | |||
@@ -175,6 +175,10 @@ impl<'a, 'b> ExprValidator<'a, 'b> { | |||
175 | }; | 175 | }; |
176 | 176 | ||
177 | let sig = db.callable_item_signature(callee); | 177 | let sig = db.callable_item_signature(callee); |
178 | if sig.value.is_varargs { | ||
179 | return None; | ||
180 | } | ||
181 | |||
178 | let params = sig.value.params(); | 182 | let params = sig.value.params(); |
179 | 183 | ||
180 | let mut param_count = params.len(); | 184 | let mut param_count = params.len(); |
@@ -512,4 +516,30 @@ impl Foo { | |||
512 | "#, | 516 | "#, |
513 | ); | 517 | ); |
514 | } | 518 | } |
519 | |||
520 | #[test] | ||
521 | fn varargs() { | ||
522 | check_diagnostics( | ||
523 | r#" | ||
524 | extern "C" { | ||
525 | fn fixed(fixed: u8); | ||
526 | fn varargs(fixed: u8, ...); | ||
527 | fn varargs2(...); | ||
528 | } | ||
529 | |||
530 | fn f() { | ||
531 | unsafe { | ||
532 | fixed(0); | ||
533 | fixed(0, 1); | ||
534 | //^^^^^^^^^^^ Expected 1 argument, found 2 | ||
535 | varargs(0); | ||
536 | varargs(0, 1); | ||
537 | varargs2(); | ||
538 | varargs2(0); | ||
539 | varargs2(0, 1); | ||
540 | } | ||
541 | } | ||
542 | "#, | ||
543 | ) | ||
544 | } | ||
515 | } | 545 | } |