Rollup merge of #75023 - euclio:argument-span, r=estebank

ensure arguments are included in count mismatch span

The current diagnostic isn't very helpful if the function header spans multiple lines. Lines comprising the function signature may be elided to keep the diagnostic short, but these lines are essential to fixing the error. This is made worse when the function has a body, because the last two lines of the span are then dedicated to showing the end of the body, which is irrelevant.

This PR changes the span to be a multispan made up of the header and the the arguments, ensuring they won't be elided. It also discards the function body from the span.

[Old](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=f92d9f81a8c9416f0f04e4e09923b6d4):

```
error[E0061]: this function takes 6 arguments but 1 argument was supplied
  --> src/main.rs:18:5
   |
1  | / fn bar(
2  | |     a: i32,
3  | |     b: i32,
4  | |     c: i32,
...  |
14 | |     println!("{}", f);
15 | | }
   | |_- defined here
...
18 |       bar(1);
   |       ^^^ - supplied 1 argument
   |       |
   |       expected 6 arguments
```

New:

```
error[E0061]: this function takes 6 arguments but 1 argument was supplied
  --> $DIR/not-enough-arguments.rs:28:3
   |
LL |   bar(1);
   |   ^^^ - supplied 1 argument
   |   |
   |   expected 6 arguments
   |
note: function defined here
  --> $DIR/not-enough-arguments.rs:9:1
   |
LL | / fn bar(
LL | |     a: i32,
   | |     ^^^^^^^
LL | |     b: i32,
   | |     ^^^^^^^
LL | |     c: i32,
   | |     ^^^^^^^
LL | |     d: i32,
   | |     ^^^^^^^
LL | |     e: i32,
   | |     ^^^^^^^
LL | |     f: i32,
   | |     ^^^^^^^
LL | | ) {
   | |_^
```
This commit is contained in:
Dylan DPC 2020-10-16 02:09:58 +02:00 committed by GitHub
commit 075f2bfc39
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 276 additions and 125 deletions

View File

@ -2742,4 +2742,32 @@ impl<'hir> Node<'hir> {
_ => None, _ => None,
} }
} }
pub fn hir_id(&self) -> Option<HirId> {
match self {
Node::Item(Item { hir_id, .. })
| Node::ForeignItem(ForeignItem { hir_id, .. })
| Node::TraitItem(TraitItem { hir_id, .. })
| Node::ImplItem(ImplItem { hir_id, .. })
| Node::Field(StructField { hir_id, .. })
| Node::AnonConst(AnonConst { hir_id, .. })
| Node::Expr(Expr { hir_id, .. })
| Node::Stmt(Stmt { hir_id, .. })
| Node::Ty(Ty { hir_id, .. })
| Node::Binding(Pat { hir_id, .. })
| Node::Pat(Pat { hir_id, .. })
| Node::Arm(Arm { hir_id, .. })
| Node::Block(Block { hir_id, .. })
| Node::Local(Local { hir_id, .. })
| Node::MacroDef(MacroDef { hir_id, .. })
| Node::Lifetime(Lifetime { hir_id, .. })
| Node::Param(Param { hir_id, .. })
| Node::GenericParam(GenericParam { hir_id, .. }) => Some(*hir_id),
Node::TraitRef(TraitRef { hir_ref_id, .. }) => Some(*hir_ref_id),
Node::PathSegment(PathSegment { hir_id, .. }) => *hir_id,
Node::Variant(Variant { id, .. }) => Some(*id),
Node::Ctor(variant) => variant.ctor_hir_id(),
Node::Crate(_) | Node::Visibility(_) => None,
}
}
} }

View File

@ -1744,7 +1744,7 @@ impl<'a> Parser<'a> {
} }
}; };
let span = lo.to(self.token.span); let span = lo.until(self.token.span);
Ok(Param { Ok(Param {
attrs: attrs.into(), attrs: attrs.into(),

View File

@ -285,10 +285,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
arg_exprs: &'tcx [hir::Expr<'tcx>], arg_exprs: &'tcx [hir::Expr<'tcx>],
expected: Expectation<'tcx>, expected: Expectation<'tcx>,
) -> Ty<'tcx> { ) -> Ty<'tcx> {
let (fn_sig, def_span) = match *callee_ty.kind() { let (fn_sig, def_id) = match *callee_ty.kind() {
ty::FnDef(def_id, _) => { ty::FnDef(def_id, _) => (callee_ty.fn_sig(self.tcx), Some(def_id)),
(callee_ty.fn_sig(self.tcx), self.tcx.hir().span_if_local(def_id))
}
ty::FnPtr(sig) => (sig, None), ty::FnPtr(sig) => (sig, None),
ref t => { ref t => {
let mut unit_variant = None; let mut unit_variant = None;
@ -427,7 +425,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
arg_exprs, arg_exprs,
fn_sig.c_variadic, fn_sig.c_variadic,
TupleArgumentsFlag::DontTupleArguments, TupleArgumentsFlag::DontTupleArguments,
def_span, def_id,
); );
fn_sig.output() fn_sig.output()

View File

@ -19,7 +19,7 @@ use rustc_middle::ty::fold::TypeFoldable;
use rustc_middle::ty::{self, Ty}; use rustc_middle::ty::{self, Ty};
use rustc_session::Session; use rustc_session::Session;
use rustc_span::symbol::{sym, Ident}; use rustc_span::symbol::{sym, Ident};
use rustc_span::{self, Span}; use rustc_span::{self, MultiSpan, Span};
use rustc_trait_selection::traits::{self, ObligationCauseCode}; use rustc_trait_selection::traits::{self, ObligationCauseCode};
use std::mem::replace; use std::mem::replace;
@ -83,7 +83,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
args_no_rcvr, args_no_rcvr,
method.sig.c_variadic, method.sig.c_variadic,
tuple_arguments, tuple_arguments,
self.tcx.hir().span_if_local(method.def_id), Some(method.def_id),
); );
method.sig.output() method.sig.output()
} }
@ -99,7 +99,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
args: &'tcx [hir::Expr<'tcx>], args: &'tcx [hir::Expr<'tcx>],
c_variadic: bool, c_variadic: bool,
tuple_arguments: TupleArgumentsFlag, tuple_arguments: TupleArgumentsFlag,
def_span: Option<Span>, def_id: Option<DefId>,
) { ) {
let tcx = self.tcx; let tcx = self.tcx;
// Grab the argument types, supplying fresh type variables // Grab the argument types, supplying fresh type variables
@ -172,9 +172,26 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
); );
} }
if let Some(def_s) = def_span.map(|sp| tcx.sess.source_map().guess_head_span(sp)) { if let Some(def_id) = def_id {
err.span_label(def_s, "defined here"); if let Some(node) = tcx.hir().get_if_local(def_id) {
let mut spans: MultiSpan = node
.ident()
.map(|ident| ident.span)
.unwrap_or_else(|| tcx.hir().span(node.hir_id().unwrap()))
.into();
if let Some(id) = node.body_id() {
let body = tcx.hir().body(id);
for param in body.params {
spans.push_span_label(param.span, String::new());
}
}
let def_kind = tcx.def_kind(def_id);
err.span_note(spans, &format!("{} defined here", def_kind.descr(def_id)));
}
} }
if sugg_unit { if sugg_unit {
let sugg_span = tcx.sess.source_map().end_point(expr.span); let sugg_span = tcx.sess.source_map().end_point(expr.span);
// remove closing `)` from the span // remove closing `)` from the span

View File

@ -1,13 +1,16 @@
error[E0061]: this function takes 1 argument but 0 arguments were supplied error[E0061]: this function takes 1 argument but 0 arguments were supplied
--> $DIR/arg-count-mismatch.rs:5:28 --> $DIR/arg-count-mismatch.rs:5:28
| |
LL | fn f(x: isize) { }
| -------------- defined here
LL |
LL | fn main() { let i: (); i = f(); } LL | fn main() { let i: (); i = f(); }
| ^-- supplied 0 arguments | ^-- supplied 0 arguments
| | | |
| expected 1 argument | expected 1 argument
|
note: function defined here
--> $DIR/arg-count-mismatch.rs:3:4
|
LL | fn f(x: isize) { }
| ^ --------
error: aborting due to previous error error: aborting due to previous error

View File

@ -7,24 +7,30 @@ LL | fn printf(_: *const u8, ...);
error[E0060]: this function takes at least 2 arguments but 0 arguments were supplied error[E0060]: this function takes at least 2 arguments but 0 arguments were supplied
--> $DIR/variadic-ffi-1.rs:17:9 --> $DIR/variadic-ffi-1.rs:17:9
| |
LL | fn foo(f: isize, x: u8, ...);
| ----------------------------- defined here
...
LL | foo(); LL | foo();
| ^^^-- supplied 0 arguments | ^^^-- supplied 0 arguments
| | | |
| expected at least 2 arguments | expected at least 2 arguments
|
note: function defined here
--> $DIR/variadic-ffi-1.rs:10:8
|
LL | fn foo(f: isize, x: u8, ...);
| ^^^
error[E0060]: this function takes at least 2 arguments but 1 argument was supplied error[E0060]: this function takes at least 2 arguments but 1 argument was supplied
--> $DIR/variadic-ffi-1.rs:18:9 --> $DIR/variadic-ffi-1.rs:18:9
| |
LL | fn foo(f: isize, x: u8, ...);
| ----------------------------- defined here
...
LL | foo(1); LL | foo(1);
| ^^^ - supplied 1 argument | ^^^ - supplied 1 argument
| | | |
| expected at least 2 arguments | expected at least 2 arguments
|
note: function defined here
--> $DIR/variadic-ffi-1.rs:10:8
|
LL | fn foo(f: isize, x: u8, ...);
| ^^^
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/variadic-ffi-1.rs:20:56 --> $DIR/variadic-ffi-1.rs:20:56

View File

@ -2,7 +2,7 @@ error: C-variadic function must be declared with at least one named argument
--> $DIR/variadic-ffi-no-fixed-args.rs:2:12 --> $DIR/variadic-ffi-no-fixed-args.rs:2:12
| |
LL | fn foo(...); LL | fn foo(...);
| ^^^^ | ^^^
error: aborting due to previous error error: aborting due to previous error

View File

@ -1,13 +1,16 @@
error[E0060]: this function takes at least 1 argument but 0 arguments were supplied error[E0060]: this function takes at least 1 argument but 0 arguments were supplied
--> $DIR/E0060.rs:6:14 --> $DIR/E0060.rs:6:14
| |
LL | fn printf(_: *const u8, ...) -> u32;
| ------------------------------------ defined here
...
LL | unsafe { printf(); } LL | unsafe { printf(); }
| ^^^^^^-- supplied 0 arguments | ^^^^^^-- supplied 0 arguments
| | | |
| expected at least 1 argument | expected at least 1 argument
|
note: function defined here
--> $DIR/E0060.rs:2:8
|
LL | fn printf(_: *const u8, ...) -> u32;
| ^^^^^^
error: aborting due to previous error error: aborting due to previous error

View File

@ -1,24 +1,30 @@
error[E0061]: this function takes 2 arguments but 1 argument was supplied error[E0061]: this function takes 2 arguments but 1 argument was supplied
--> $DIR/E0061.rs:6:5 --> $DIR/E0061.rs:6:5
| |
LL | fn f(a: u16, b: &str) {}
| --------------------- defined here
...
LL | f(0); LL | f(0);
| ^ - supplied 1 argument | ^ - supplied 1 argument
| | | |
| expected 2 arguments | expected 2 arguments
|
note: function defined here
--> $DIR/E0061.rs:1:4
|
LL | fn f(a: u16, b: &str) {}
| ^ ------ -------
error[E0061]: this function takes 1 argument but 0 arguments were supplied error[E0061]: this function takes 1 argument but 0 arguments were supplied
--> $DIR/E0061.rs:10:5 --> $DIR/E0061.rs:10:5
| |
LL | fn f2(a: u16) {}
| ------------- defined here
...
LL | f2(); LL | f2();
| ^^-- supplied 0 arguments | ^^-- supplied 0 arguments
| | | |
| expected 1 argument | expected 1 argument
|
note: function defined here
--> $DIR/E0061.rs:3:4
|
LL | fn f2(a: u16) {}
| ^^ ------
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View File

@ -1,16 +1,16 @@
error[E0061]: this function takes 1 argument but 0 arguments were supplied error[E0061]: this function takes 1 argument but 0 arguments were supplied
--> $DIR/issue-58451.rs:12:9 --> $DIR/issue-58451.rs:12:9
| |
LL | / fn f<I>(i: I) LL | f(&[f()]);
LL | | where | ^-- supplied 0 arguments
LL | | I: IntoIterator, | |
LL | | I::Item: for<'a> Into<&'a ()>, | expected 1 argument
| |__________________________________- defined here |
... note: function defined here
LL | f(&[f()]); --> $DIR/issue-58451.rs:5:4
| ^-- supplied 0 arguments |
| | LL | fn f<I>(i: I)
| expected 1 argument | ^ ----
error: aborting due to previous error error: aborting due to previous error

View File

@ -1,13 +1,16 @@
error[E0061]: this function takes 2 arguments but 1 argument was supplied error[E0061]: this function takes 2 arguments but 1 argument was supplied
--> $DIR/issue-18819.rs:16:5 --> $DIR/issue-18819.rs:16:5
| |
LL | fn print_x(_: &dyn Foo<Item=bool>, extra: &str) {
| ----------------------------------------------- defined here
...
LL | print_x(X); LL | print_x(X);
| ^^^^^^^ - supplied 1 argument | ^^^^^^^ - supplied 1 argument
| | | |
| expected 2 arguments | expected 2 arguments
|
note: function defined here
--> $DIR/issue-18819.rs:11:4
|
LL | fn print_x(_: &dyn Foo<Item=bool>, extra: &str) {
| ^^^^^^^ ---------------------- -----------
error: aborting due to previous error error: aborting due to previous error

View File

@ -4,11 +4,14 @@ error[E0061]: this function takes 0 arguments but 1 argument was supplied
LL | $other(None) LL | $other(None)
| ---- supplied 1 argument | ---- supplied 1 argument
... ...
LL | fn some_function() {}
| ------------------ defined here
...
LL | some_macro!(some_function); LL | some_macro!(some_function);
| ^^^^^^^^^^^^^ expected 0 arguments | ^^^^^^^^^^^^^ expected 0 arguments
|
note: function defined here
--> $DIR/issue-26094.rs:7:4
|
LL | fn some_function() {}
| ^^^^^^^^^^^^^
error: aborting due to previous error error: aborting due to previous error

View File

@ -1,13 +1,16 @@
error[E0061]: this function takes 1 argument but 2 arguments were supplied error[E0061]: this function takes 1 argument but 2 arguments were supplied
--> $DIR/issue-4935.rs:5:13 --> $DIR/issue-4935.rs:5:13
| |
LL | fn foo(a: usize) {}
| ---------------- defined here
LL |
LL | fn main() { foo(5, 6) } LL | fn main() { foo(5, 6) }
| ^^^ - - supplied 2 arguments | ^^^ - - supplied 2 arguments
| | | |
| expected 1 argument | expected 1 argument
|
note: function defined here
--> $DIR/issue-4935.rs:3:4
|
LL | fn foo(a: usize) {}
| ^^^ --------
error: aborting due to previous error error: aborting due to previous error

View File

@ -1,35 +1,44 @@
error[E0061]: this function takes 0 arguments but 1 argument was supplied error[E0061]: this function takes 0 arguments but 1 argument was supplied
--> $DIR/method-call-err-msg.rs:13:7 --> $DIR/method-call-err-msg.rs:13:7
| |
LL | fn zero(self) -> Foo { self }
| -------------------- defined here
...
LL | x.zero(0) LL | x.zero(0)
| ^^^^ - supplied 1 argument | ^^^^ - supplied 1 argument
| | | |
| expected 0 arguments | expected 0 arguments
|
note: associated function defined here
--> $DIR/method-call-err-msg.rs:5:8
|
LL | fn zero(self) -> Foo { self }
| ^^^^ ----
error[E0061]: this function takes 1 argument but 0 arguments were supplied error[E0061]: this function takes 1 argument but 0 arguments were supplied
--> $DIR/method-call-err-msg.rs:14:7 --> $DIR/method-call-err-msg.rs:14:7
| |
LL | fn one(self, _: isize) -> Foo { self }
| ----------------------------- defined here
...
LL | .one() LL | .one()
| ^^^- supplied 0 arguments | ^^^- supplied 0 arguments
| | | |
| expected 1 argument | expected 1 argument
|
note: associated function defined here
--> $DIR/method-call-err-msg.rs:6:8
|
LL | fn one(self, _: isize) -> Foo { self }
| ^^^ ---- --------
error[E0061]: this function takes 2 arguments but 1 argument was supplied error[E0061]: this function takes 2 arguments but 1 argument was supplied
--> $DIR/method-call-err-msg.rs:15:7 --> $DIR/method-call-err-msg.rs:15:7
| |
LL | fn two(self, _: isize, _: isize) -> Foo { self }
| --------------------------------------- defined here
...
LL | .two(0); LL | .two(0);
| ^^^ - supplied 1 argument | ^^^ - supplied 1 argument
| | | |
| expected 2 arguments | expected 2 arguments
|
note: associated function defined here
--> $DIR/method-call-err-msg.rs:7:8
|
LL | fn two(self, _: isize, _: isize) -> Foo { self }
| ^^^ ---- -------- --------
error[E0599]: no method named `take` found for struct `Foo` in the current scope error[E0599]: no method named `take` found for struct `Foo` in the current scope
--> $DIR/method-call-err-msg.rs:19:7 --> $DIR/method-call-err-msg.rs:19:7
@ -53,13 +62,16 @@ LL | .take()
error[E0061]: this function takes 3 arguments but 0 arguments were supplied error[E0061]: this function takes 3 arguments but 0 arguments were supplied
--> $DIR/method-call-err-msg.rs:21:7 --> $DIR/method-call-err-msg.rs:21:7
| |
LL | fn three<T>(self, _: T, _: T, _: T) -> Foo { self }
| ------------------------------------------ defined here
...
LL | y.three::<usize>(); LL | y.three::<usize>();
| ^^^^^--------- supplied 0 arguments | ^^^^^--------- supplied 0 arguments
| | | |
| expected 3 arguments | expected 3 arguments
|
note: associated function defined here
--> $DIR/method-call-err-msg.rs:8:8
|
LL | fn three<T>(self, _: T, _: T, _: T) -> Foo { self }
| ^^^^^ ---- ---- ---- ----
error: aborting due to 5 previous errors error: aborting due to 5 previous errors

View File

@ -2,7 +2,7 @@ error[E0308]: mismatched types
--> $DIR/issue-38371.rs:4:8 --> $DIR/issue-38371.rs:4:8
| |
LL | fn foo(&foo: Foo) { LL | fn foo(&foo: Foo) {
| ^^^^------ | ^^^^-----
| | | | | |
| | expected due to this | | expected due to this
| expected struct `Foo`, found reference | expected struct `Foo`, found reference

View File

@ -6,7 +6,26 @@ fn foo(a: isize, b: isize, c: isize, d:isize) {
panic!(); panic!();
} }
// Check that all arguments are shown in the error message, even if they're across multiple lines.
fn bar(
a: i32,
b: i32,
c: i32,
d: i32,
e: i32,
f: i32,
) {
println!("{}", a);
println!("{}", b);
println!("{}", c);
println!("{}", d);
println!("{}", e);
println!("{}", f);
}
fn main() { fn main() {
foo(1, 2, 3); foo(1, 2, 3);
//~^ ERROR this function takes 4 arguments but 3 //~^ ERROR this function takes 4 arguments but 3
bar(1, 2, 3);
//~^ ERROR this function takes 6 arguments but 3
} }

View File

@ -1,14 +1,43 @@
error[E0061]: this function takes 4 arguments but 3 arguments were supplied error[E0061]: this function takes 4 arguments but 3 arguments were supplied
--> $DIR/not-enough-arguments.rs:10:3 --> $DIR/not-enough-arguments.rs:27:3
| |
LL | fn foo(a: isize, b: isize, c: isize, d:isize) {
| --------------------------------------------- defined here
...
LL | foo(1, 2, 3); LL | foo(1, 2, 3);
| ^^^ - - - supplied 3 arguments | ^^^ - - - supplied 3 arguments
| | | |
| expected 4 arguments | expected 4 arguments
|
note: function defined here
--> $DIR/not-enough-arguments.rs:5:4
|
LL | fn foo(a: isize, b: isize, c: isize, d:isize) {
| ^^^ -------- -------- -------- -------
error: aborting due to previous error error[E0061]: this function takes 6 arguments but 3 arguments were supplied
--> $DIR/not-enough-arguments.rs:29:3
|
LL | bar(1, 2, 3);
| ^^^ - - - supplied 3 arguments
| |
| expected 6 arguments
|
note: function defined here
--> $DIR/not-enough-arguments.rs:10:4
|
LL | fn bar(
| ^^^
LL | a: i32,
| ------
LL | b: i32,
| ------
LL | c: i32,
| ------
LL | d: i32,
| ------
LL | e: i32,
| ------
LL | f: i32,
| ------
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0061`. For more information about this error, try `rustc --explain E0061`.

View File

@ -2,205 +2,205 @@ error: only foreign or `unsafe extern "C" functions may be C-variadic
--> $DIR/variadic-ffi-semantic-restrictions.rs:5:19 --> $DIR/variadic-ffi-semantic-restrictions.rs:5:19
| |
LL | fn f1_1(x: isize, ...) {} LL | fn f1_1(x: isize, ...) {}
| ^^^^ | ^^^
error: C-variadic function must be declared with at least one named argument error: C-variadic function must be declared with at least one named argument
--> $DIR/variadic-ffi-semantic-restrictions.rs:8:9 --> $DIR/variadic-ffi-semantic-restrictions.rs:8:9
| |
LL | fn f1_2(...) {} LL | fn f1_2(...) {}
| ^^^^ | ^^^
error: only foreign or `unsafe extern "C" functions may be C-variadic error: only foreign or `unsafe extern "C" functions may be C-variadic
--> $DIR/variadic-ffi-semantic-restrictions.rs:8:9 --> $DIR/variadic-ffi-semantic-restrictions.rs:8:9
| |
LL | fn f1_2(...) {} LL | fn f1_2(...) {}
| ^^^^ | ^^^
error: only foreign or `unsafe extern "C" functions may be C-variadic error: only foreign or `unsafe extern "C" functions may be C-variadic
--> $DIR/variadic-ffi-semantic-restrictions.rs:12:30 --> $DIR/variadic-ffi-semantic-restrictions.rs:12:30
| |
LL | extern "C" fn f2_1(x: isize, ...) {} LL | extern "C" fn f2_1(x: isize, ...) {}
| ^^^^ | ^^^
error: C-variadic function must be declared with at least one named argument error: C-variadic function must be declared with at least one named argument
--> $DIR/variadic-ffi-semantic-restrictions.rs:15:20 --> $DIR/variadic-ffi-semantic-restrictions.rs:15:20
| |
LL | extern "C" fn f2_2(...) {} LL | extern "C" fn f2_2(...) {}
| ^^^^ | ^^^
error: only foreign or `unsafe extern "C" functions may be C-variadic error: only foreign or `unsafe extern "C" functions may be C-variadic
--> $DIR/variadic-ffi-semantic-restrictions.rs:15:20 --> $DIR/variadic-ffi-semantic-restrictions.rs:15:20
| |
LL | extern "C" fn f2_2(...) {} LL | extern "C" fn f2_2(...) {}
| ^^^^ | ^^^
error: `...` must be the last argument of a C-variadic function error: `...` must be the last argument of a C-variadic function
--> $DIR/variadic-ffi-semantic-restrictions.rs:19:20 --> $DIR/variadic-ffi-semantic-restrictions.rs:19:20
| |
LL | extern "C" fn f2_3(..., x: isize) {} LL | extern "C" fn f2_3(..., x: isize) {}
| ^^^^ | ^^^
error: only foreign or `unsafe extern "C" functions may be C-variadic error: only foreign or `unsafe extern "C" functions may be C-variadic
--> $DIR/variadic-ffi-semantic-restrictions.rs:19:20 --> $DIR/variadic-ffi-semantic-restrictions.rs:19:20
| |
LL | extern "C" fn f2_3(..., x: isize) {} LL | extern "C" fn f2_3(..., x: isize) {}
| ^^^^ | ^^^
error: only foreign or `unsafe extern "C" functions may be C-variadic error: only foreign or `unsafe extern "C" functions may be C-variadic
--> $DIR/variadic-ffi-semantic-restrictions.rs:23:26 --> $DIR/variadic-ffi-semantic-restrictions.rs:23:26
| |
LL | extern fn f3_1(x: isize, ...) {} LL | extern fn f3_1(x: isize, ...) {}
| ^^^^ | ^^^
error: C-variadic function must be declared with at least one named argument error: C-variadic function must be declared with at least one named argument
--> $DIR/variadic-ffi-semantic-restrictions.rs:26:16 --> $DIR/variadic-ffi-semantic-restrictions.rs:26:16
| |
LL | extern fn f3_2(...) {} LL | extern fn f3_2(...) {}
| ^^^^ | ^^^
error: only foreign or `unsafe extern "C" functions may be C-variadic error: only foreign or `unsafe extern "C" functions may be C-variadic
--> $DIR/variadic-ffi-semantic-restrictions.rs:26:16 --> $DIR/variadic-ffi-semantic-restrictions.rs:26:16
| |
LL | extern fn f3_2(...) {} LL | extern fn f3_2(...) {}
| ^^^^ | ^^^
error: `...` must be the last argument of a C-variadic function error: `...` must be the last argument of a C-variadic function
--> $DIR/variadic-ffi-semantic-restrictions.rs:30:16 --> $DIR/variadic-ffi-semantic-restrictions.rs:30:16
| |
LL | extern fn f3_3(..., x: isize) {} LL | extern fn f3_3(..., x: isize) {}
| ^^^^ | ^^^
error: only foreign or `unsafe extern "C" functions may be C-variadic error: only foreign or `unsafe extern "C" functions may be C-variadic
--> $DIR/variadic-ffi-semantic-restrictions.rs:30:16 --> $DIR/variadic-ffi-semantic-restrictions.rs:30:16
| |
LL | extern fn f3_3(..., x: isize) {} LL | extern fn f3_3(..., x: isize) {}
| ^^^^ | ^^^
error: C-variadic function must be declared with at least one named argument error: C-variadic function must be declared with at least one named argument
--> $DIR/variadic-ffi-semantic-restrictions.rs:35:13 --> $DIR/variadic-ffi-semantic-restrictions.rs:35:13
| |
LL | fn e_f1(...); LL | fn e_f1(...);
| ^^^^ | ^^^
error: `...` must be the last argument of a C-variadic function error: `...` must be the last argument of a C-variadic function
--> $DIR/variadic-ffi-semantic-restrictions.rs:37:13 --> $DIR/variadic-ffi-semantic-restrictions.rs:37:13
| |
LL | fn e_f2(..., x: isize); LL | fn e_f2(..., x: isize);
| ^^^^ | ^^^
error: only foreign or `unsafe extern "C" functions may be C-variadic error: only foreign or `unsafe extern "C" functions may be C-variadic
--> $DIR/variadic-ffi-semantic-restrictions.rs:44:23 --> $DIR/variadic-ffi-semantic-restrictions.rs:44:23
| |
LL | fn i_f1(x: isize, ...) {} LL | fn i_f1(x: isize, ...) {}
| ^^^^ | ^^^
error: C-variadic function must be declared with at least one named argument error: C-variadic function must be declared with at least one named argument
--> $DIR/variadic-ffi-semantic-restrictions.rs:46:13 --> $DIR/variadic-ffi-semantic-restrictions.rs:46:13
| |
LL | fn i_f2(...) {} LL | fn i_f2(...) {}
| ^^^^ | ^^^
error: only foreign or `unsafe extern "C" functions may be C-variadic error: only foreign or `unsafe extern "C" functions may be C-variadic
--> $DIR/variadic-ffi-semantic-restrictions.rs:46:13 --> $DIR/variadic-ffi-semantic-restrictions.rs:46:13
| |
LL | fn i_f2(...) {} LL | fn i_f2(...) {}
| ^^^^ | ^^^
error: `...` must be the last argument of a C-variadic function error: `...` must be the last argument of a C-variadic function
--> $DIR/variadic-ffi-semantic-restrictions.rs:49:13 --> $DIR/variadic-ffi-semantic-restrictions.rs:49:13
| |
LL | fn i_f3(..., x: isize, ...) {} LL | fn i_f3(..., x: isize, ...) {}
| ^^^^ | ^^^
error: only foreign or `unsafe extern "C" functions may be C-variadic error: only foreign or `unsafe extern "C" functions may be C-variadic
--> $DIR/variadic-ffi-semantic-restrictions.rs:49:13 --> $DIR/variadic-ffi-semantic-restrictions.rs:49:13
| |
LL | fn i_f3(..., x: isize, ...) {} LL | fn i_f3(..., x: isize, ...) {}
| ^^^^ | ^^^
error: only foreign or `unsafe extern "C" functions may be C-variadic error: only foreign or `unsafe extern "C" functions may be C-variadic
--> $DIR/variadic-ffi-semantic-restrictions.rs:49:28 --> $DIR/variadic-ffi-semantic-restrictions.rs:49:28
| |
LL | fn i_f3(..., x: isize, ...) {} LL | fn i_f3(..., x: isize, ...) {}
| ^^^^ | ^^^
error: `...` must be the last argument of a C-variadic function error: `...` must be the last argument of a C-variadic function
--> $DIR/variadic-ffi-semantic-restrictions.rs:53:13 --> $DIR/variadic-ffi-semantic-restrictions.rs:53:13
| |
LL | fn i_f4(..., x: isize, ...) {} LL | fn i_f4(..., x: isize, ...) {}
| ^^^^ | ^^^
error: only foreign or `unsafe extern "C" functions may be C-variadic error: only foreign or `unsafe extern "C" functions may be C-variadic
--> $DIR/variadic-ffi-semantic-restrictions.rs:53:13 --> $DIR/variadic-ffi-semantic-restrictions.rs:53:13
| |
LL | fn i_f4(..., x: isize, ...) {} LL | fn i_f4(..., x: isize, ...) {}
| ^^^^ | ^^^
error: only foreign or `unsafe extern "C" functions may be C-variadic error: only foreign or `unsafe extern "C" functions may be C-variadic
--> $DIR/variadic-ffi-semantic-restrictions.rs:53:28 --> $DIR/variadic-ffi-semantic-restrictions.rs:53:28
| |
LL | fn i_f4(..., x: isize, ...) {} LL | fn i_f4(..., x: isize, ...) {}
| ^^^^ | ^^^
error: only foreign or `unsafe extern "C" functions may be C-variadic error: only foreign or `unsafe extern "C" functions may be C-variadic
--> $DIR/variadic-ffi-semantic-restrictions.rs:60:23 --> $DIR/variadic-ffi-semantic-restrictions.rs:60:23
| |
LL | fn t_f1(x: isize, ...) {} LL | fn t_f1(x: isize, ...) {}
| ^^^^ | ^^^
error: only foreign or `unsafe extern "C" functions may be C-variadic error: only foreign or `unsafe extern "C" functions may be C-variadic
--> $DIR/variadic-ffi-semantic-restrictions.rs:62:23 --> $DIR/variadic-ffi-semantic-restrictions.rs:62:23
| |
LL | fn t_f2(x: isize, ...); LL | fn t_f2(x: isize, ...);
| ^^^^ | ^^^
error: C-variadic function must be declared with at least one named argument error: C-variadic function must be declared with at least one named argument
--> $DIR/variadic-ffi-semantic-restrictions.rs:64:13 --> $DIR/variadic-ffi-semantic-restrictions.rs:64:13
| |
LL | fn t_f3(...) {} LL | fn t_f3(...) {}
| ^^^^ | ^^^
error: only foreign or `unsafe extern "C" functions may be C-variadic error: only foreign or `unsafe extern "C" functions may be C-variadic
--> $DIR/variadic-ffi-semantic-restrictions.rs:64:13 --> $DIR/variadic-ffi-semantic-restrictions.rs:64:13
| |
LL | fn t_f3(...) {} LL | fn t_f3(...) {}
| ^^^^ | ^^^
error: C-variadic function must be declared with at least one named argument error: C-variadic function must be declared with at least one named argument
--> $DIR/variadic-ffi-semantic-restrictions.rs:67:13 --> $DIR/variadic-ffi-semantic-restrictions.rs:67:13
| |
LL | fn t_f4(...); LL | fn t_f4(...);
| ^^^^ | ^^^
error: only foreign or `unsafe extern "C" functions may be C-variadic error: only foreign or `unsafe extern "C" functions may be C-variadic
--> $DIR/variadic-ffi-semantic-restrictions.rs:67:13 --> $DIR/variadic-ffi-semantic-restrictions.rs:67:13
| |
LL | fn t_f4(...); LL | fn t_f4(...);
| ^^^^ | ^^^
error: `...` must be the last argument of a C-variadic function error: `...` must be the last argument of a C-variadic function
--> $DIR/variadic-ffi-semantic-restrictions.rs:70:13 --> $DIR/variadic-ffi-semantic-restrictions.rs:70:13
| |
LL | fn t_f5(..., x: isize) {} LL | fn t_f5(..., x: isize) {}
| ^^^^ | ^^^
error: only foreign or `unsafe extern "C" functions may be C-variadic error: only foreign or `unsafe extern "C" functions may be C-variadic
--> $DIR/variadic-ffi-semantic-restrictions.rs:70:13 --> $DIR/variadic-ffi-semantic-restrictions.rs:70:13
| |
LL | fn t_f5(..., x: isize) {} LL | fn t_f5(..., x: isize) {}
| ^^^^ | ^^^
error: `...` must be the last argument of a C-variadic function error: `...` must be the last argument of a C-variadic function
--> $DIR/variadic-ffi-semantic-restrictions.rs:73:13 --> $DIR/variadic-ffi-semantic-restrictions.rs:73:13
| |
LL | fn t_f6(..., x: isize); LL | fn t_f6(..., x: isize);
| ^^^^ | ^^^
error: only foreign or `unsafe extern "C" functions may be C-variadic error: only foreign or `unsafe extern "C" functions may be C-variadic
--> $DIR/variadic-ffi-semantic-restrictions.rs:73:13 --> $DIR/variadic-ffi-semantic-restrictions.rs:73:13
| |
LL | fn t_f6(..., x: isize); LL | fn t_f6(..., x: isize);
| ^^^^ | ^^^
error: aborting due to 34 previous errors error: aborting due to 34 previous errors

View File

@ -53,13 +53,16 @@ LL | fn bar(_: x, y: usize) {}
error[E0061]: this function takes 2 arguments but 3 arguments were supplied error[E0061]: this function takes 2 arguments but 3 arguments were supplied
--> $DIR/issue-34264.rs:7:5 --> $DIR/issue-34264.rs:7:5
| |
LL | fn foo(Option<i32>, String) {}
| --------------------------- defined here
...
LL | foo(Some(42), 2, ""); LL | foo(Some(42), 2, "");
| ^^^ -------- - -- supplied 3 arguments | ^^^ -------- - -- supplied 3 arguments
| | | |
| expected 2 arguments | expected 2 arguments
|
note: function defined here
--> $DIR/issue-34264.rs:1:4
|
LL | fn foo(Option<i32>, String) {}
| ^^^ ----------- ------
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/issue-34264.rs:8:13 --> $DIR/issue-34264.rs:8:13
@ -70,13 +73,16 @@ LL | bar("", "");
error[E0061]: this function takes 2 arguments but 3 arguments were supplied error[E0061]: this function takes 2 arguments but 3 arguments were supplied
--> $DIR/issue-34264.rs:10:5 --> $DIR/issue-34264.rs:10:5
| |
LL | fn bar(x, y: usize) {}
| ------------------- defined here
...
LL | bar(1, 2, 3); LL | bar(1, 2, 3);
| ^^^ - - - supplied 3 arguments | ^^^ - - - supplied 3 arguments
| | | |
| expected 2 arguments | expected 2 arguments
|
note: function defined here
--> $DIR/issue-34264.rs:3:4
|
LL | fn bar(x, y: usize) {}
| ^^^ - --------
error: aborting due to 6 previous errors error: aborting due to 6 previous errors

View File

@ -12,34 +12,42 @@ LL | let _: Result<(), String> = Ok(());
error[E0061]: this function takes 2 arguments but 0 arguments were supplied error[E0061]: this function takes 2 arguments but 0 arguments were supplied
--> $DIR/missing-unit-argument.rs:12:5 --> $DIR/missing-unit-argument.rs:12:5
| |
LL | fn foo(():(), ():()) {}
| -------------------- defined here
...
LL | foo(); LL | foo();
| ^^^-- supplied 0 arguments | ^^^-- supplied 0 arguments
| | | |
| expected 2 arguments | expected 2 arguments
|
note: function defined here
--> $DIR/missing-unit-argument.rs:1:4
|
LL | fn foo(():(), ():()) {}
| ^^^ ----- -----
error[E0061]: this function takes 2 arguments but 1 argument was supplied error[E0061]: this function takes 2 arguments but 1 argument was supplied
--> $DIR/missing-unit-argument.rs:13:5 --> $DIR/missing-unit-argument.rs:13:5
| |
LL | fn foo(():(), ():()) {}
| -------------------- defined here
...
LL | foo(()); LL | foo(());
| ^^^ -- supplied 1 argument | ^^^ -- supplied 1 argument
| | | |
| expected 2 arguments | expected 2 arguments
|
note: function defined here
--> $DIR/missing-unit-argument.rs:1:4
|
LL | fn foo(():(), ():()) {}
| ^^^ ----- -----
error[E0061]: this function takes 1 argument but 0 arguments were supplied error[E0061]: this function takes 1 argument but 0 arguments were supplied
--> $DIR/missing-unit-argument.rs:14:5 --> $DIR/missing-unit-argument.rs:14:5
| |
LL | fn bar(():()) {}
| ------------- defined here
...
LL | bar(); LL | bar();
| ^^^-- supplied 0 arguments | ^^^-- supplied 0 arguments
| |
note: function defined here
--> $DIR/missing-unit-argument.rs:2:4
|
LL | fn bar(():()) {}
| ^^^ -----
help: expected the unit value `()`; create it with empty parentheses help: expected the unit value `()`; create it with empty parentheses
| |
LL | bar(()); LL | bar(());
@ -48,12 +56,14 @@ LL | bar(());
error[E0061]: this function takes 1 argument but 0 arguments were supplied error[E0061]: this function takes 1 argument but 0 arguments were supplied
--> $DIR/missing-unit-argument.rs:15:7 --> $DIR/missing-unit-argument.rs:15:7
| |
LL | fn baz(self, (): ()) { }
| -------------------- defined here
...
LL | S.baz(); LL | S.baz();
| ^^^- supplied 0 arguments | ^^^- supplied 0 arguments
| |
note: associated function defined here
--> $DIR/missing-unit-argument.rs:6:8
|
LL | fn baz(self, (): ()) { }
| ^^^ ---- ------
help: expected the unit value `()`; create it with empty parentheses help: expected the unit value `()`; create it with empty parentheses
| |
LL | S.baz(()); LL | S.baz(());
@ -62,12 +72,14 @@ LL | S.baz(());
error[E0061]: this function takes 1 argument but 0 arguments were supplied error[E0061]: this function takes 1 argument but 0 arguments were supplied
--> $DIR/missing-unit-argument.rs:16:7 --> $DIR/missing-unit-argument.rs:16:7
| |
LL | fn generic<T>(self, _: T) { }
| ------------------------- defined here
...
LL | S.generic::<()>(); LL | S.generic::<()>();
| ^^^^^^^------ supplied 0 arguments | ^^^^^^^------ supplied 0 arguments
| |
note: associated function defined here
--> $DIR/missing-unit-argument.rs:7:8
|
LL | fn generic<T>(self, _: T) { }
| ^^^^^^^ ---- ----
help: expected the unit value `()`; create it with empty parentheses help: expected the unit value `()`; create it with empty parentheses
| |
LL | S.generic::<()>(()); LL | S.generic::<()>(());

View File

@ -1,13 +1,16 @@
error[E0061]: this function takes 1 argument but 0 arguments were supplied error[E0061]: this function takes 1 argument but 0 arguments were supplied
--> $DIR/enum-variant-priority-higher-than-other-inherent.rs:21:5 --> $DIR/enum-variant-priority-higher-than-other-inherent.rs:21:5
| |
LL | V(u8)
| ----- defined here
...
LL | <E>::V(); LL | <E>::V();
| ^^^^^^-- supplied 0 arguments | ^^^^^^-- supplied 0 arguments
| | | |
| expected 1 argument | expected 1 argument
|
note: tuple variant defined here
--> $DIR/enum-variant-priority-higher-than-other-inherent.rs:5:5
|
LL | V(u8)
| ^^^^^
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/enum-variant-priority-higher-than-other-inherent.rs:22:17 --> $DIR/enum-variant-priority-higher-than-other-inherent.rs:22:17