aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src/diagnostics
diff options
context:
space:
mode:
authorJonas Schievink <[email protected]>2020-07-14 17:23:45 +0100
committerJonas Schievink <[email protected]>2020-07-14 19:27:47 +0100
commita09d48380204fa948a3af397dc2188b93bf5793f (patch)
treee38436638e0987a8ed2d68a646a35080a5e4c6d3 /crates/ra_hir_ty/src/diagnostics
parent3f2ab436f45a4fae32514756736055819ead2baa (diff)
Thread varargs through r-a
Diffstat (limited to 'crates/ra_hir_ty/src/diagnostics')
-rw-r--r--crates/ra_hir_ty/src/diagnostics/expr.rs30
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#"
524extern "C" {
525 fn fixed(fixed: u8);
526 fn varargs(fixed: u8, ...);
527 fn varargs2(...);
528}
529
530fn 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}