diff options
24 files changed, 286 insertions, 232 deletions
diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index 4f2cc8b0351..211bbf4f50e 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -1768,7 +1768,7 @@ impl EmitterWriter { // Render the replacements for each suggestion let suggestions = suggestion.splice_lines(sm); - debug!("emit_suggestion_default: suggestions={:?}", suggestions); + debug!(?suggestions); if suggestions.is_empty() { // Suggestions coming from macros can have malformed spans. This is a heavy handed @@ -1797,6 +1797,7 @@ impl EmitterWriter { for (complete, parts, highlights, only_capitalization) in suggestions.iter().take(MAX_SUGGESTIONS) { + debug!(?complete, ?parts, ?highlights); notice_capitalization |= only_capitalization; let has_deletion = parts.iter().any(|p| p.is_deletion(sm)); diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs index 9c7a84ce198..63b170a3c63 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs @@ -755,15 +755,20 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } errors.drain_filter(|error| { - let Error::Invalid(provided_idx, expected_idx, Compatibility::Incompatible(Some(e))) = error else { return false }; - let (provided_ty, provided_span) = provided_arg_tys[*provided_idx]; - let trace = mk_trace(provided_span, formal_and_expected_inputs[*expected_idx], provided_ty); - if !matches!(trace.cause.as_failure_code(*e), FailureCode::Error0308(_)) { - self.err_ctxt().report_and_explain_type_error(trace, *e).emit(); - return true; - } - false - }); + let Error::Invalid( + provided_idx, + expected_idx, + Compatibility::Incompatible(Some(e)), + ) = error else { return false }; + let (provided_ty, provided_span) = provided_arg_tys[*provided_idx]; + let trace = + mk_trace(provided_span, formal_and_expected_inputs[*expected_idx], provided_ty); + if !matches!(trace.cause.as_failure_code(*e), FailureCode::Error0308(_)) { + self.err_ctxt().report_and_explain_type_error(trace, *e).emit(); + return true; + } + false + }); // We're done if we found errors, but we already emitted them. if errors.is_empty() { @@ -864,7 +869,27 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } let mut suggestion_text = SuggestionText::None; + let ty_to_snippet = |ty: Ty<'tcx>, expected_idx: ExpectedIdx| { + if ty.is_unit() { + "()".to_string() + } else if ty.is_suggestable(tcx, false) { + format!("/* {} */", ty) + } else if let Some(fn_def_id) = fn_def_id + && self.tcx.def_kind(fn_def_id).is_fn_like() + && let self_implicit = + matches!(call_expr.kind, hir::ExprKind::MethodCall(..)) as usize + && let Some(arg) = self.tcx.fn_arg_names(fn_def_id) + .get(expected_idx.as_usize() + self_implicit) + && arg.name != kw::SelfLower + { + format!("/* {} */", arg.name) + } else { + "/* value */".to_string() + } + }; + let mut errors = errors.into_iter().peekable(); + let mut suggestions = vec![]; while let Some(error) = errors.next() { match error { Error::Invalid(provided_idx, expected_idx, compatibility) => { @@ -905,7 +930,22 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { "".to_string() }; labels - .push((provided_span, format!("argument{} unexpected", provided_ty_name))); + .push((provided_span, format!("unexpected argument{}", provided_ty_name))); + let mut span = provided_span; + if arg_idx.index() > 0 + && let Some((_, prev)) = provided_arg_tys + .get(ProvidedIdx::from_usize(arg_idx.index() - 1) + ) { + // Include previous comma + span = span.with_lo(prev.hi()); + } else if let Some((_, next)) = provided_arg_tys.get( + ProvidedIdx::from_usize(arg_idx.index() + 1), + ) { + // Include next comma + span = span.until(*next); + } + suggestions.push((span, String::new())); + suggestion_text = match suggestion_text { SuggestionText::None => SuggestionText::Remove(false), SuggestionText::Remove(_) => SuggestionText::Remove(true), @@ -1095,6 +1135,45 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } + // Incorporate the argument changes in the removal suggestion. + // When a type is *missing*, and the rest are additional, we want to suggest these with a + // multipart suggestion, but in order to do so we need to figure out *where* the arg that + // was provided but had the wrong type should go, because when looking at `expected_idx` + // that is the position in the argument list in the definition, while `provided_idx` will + // not be present. So we have to look at what the *last* provided position was, and point + // one after to suggest the replacement. FIXME(estebank): This is hacky, and there's + // probably a better more involved change we can make to make this work. + // For example, if we have + // ``` + // fn foo(i32, &'static str) {} + // foo((), (), ()); + // ``` + // what should be suggested is + // ``` + // foo(/* i32 */, /* &str */); + // ``` + // which includes the replacement of the first two `()` for the correct type, and the + // removal of the last `()`. + let mut prev = -1; + for (expected_idx, provided_idx) in matched_inputs.iter_enumerated() { + // We want to point not at the *current* argument expression index, but rather at the + // index position where it *should have been*, which is *after* the previous one. + if let Some(provided_idx) = provided_idx { + prev = provided_idx.index() as i64; + } + let idx = ProvidedIdx::from_usize((prev + 1) as usize); + if let None = provided_idx + && let Some((_, arg_span)) = provided_arg_tys.get(idx) + { + // There is a type that was *not* found anywhere, so it isn't a move, but a + // replacement and we look at what type it should have been. This will allow us + // To suggest a multipart suggestion when encountering `foo(1, "")` where the def + // was `fn foo(())`. + let (_, expected_ty) = formal_and_expected_inputs[expected_idx]; + suggestions.push((*arg_span, ty_to_snippet(expected_ty, expected_idx))); + } + } + // If we have less than 5 things to say, it would be useful to call out exactly what's wrong if labels.len() <= 5 { for (span, label) in labels { @@ -1112,7 +1191,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { Some(format!("provide the argument{}", if plural { "s" } else { "" })) } SuggestionText::Remove(plural) => { - Some(format!("remove the extra argument{}", if plural { "s" } else { "" })) + err.multipart_suggestion( + &format!("remove the extra argument{}", if plural { "s" } else { "" }), + suggestions, + Applicability::HasPlaceholders, + ); + None } SuggestionText::Swap => Some("swap these arguments".to_string()), SuggestionText::Reorder => Some("reorder these arguments".to_string()), @@ -1151,20 +1235,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } else { // Propose a placeholder of the correct type let (_, expected_ty) = formal_and_expected_inputs[expected_idx]; - if expected_ty.is_unit() { - "()".to_string() - } else if expected_ty.is_suggestable(tcx, false) { - format!("/* {} */", expected_ty) - } else if let Some(fn_def_id) = fn_def_id - && self.tcx.def_kind(fn_def_id).is_fn_like() - && let self_implicit = matches!(call_expr.kind, hir::ExprKind::MethodCall(..)) as usize - && let Some(arg) = self.tcx.fn_arg_names(fn_def_id).get(expected_idx.as_usize() + self_implicit) - && arg.name != kw::SelfLower - { - format!("/* {} */", arg.name) - } else { - "/* value */".to_string() - } + ty_to_snippet(expected_ty, expected_idx) }; suggestion += &suggestion_text; } diff --git a/tests/ui/alloc-error/alloc-error-handler-bad-signature-3.stderr b/tests/ui/alloc-error/alloc-error-handler-bad-signature-3.stderr index 77ea8ef0520..d1b9d7a40b4 100644 --- a/tests/ui/alloc-error/alloc-error-handler-bad-signature-3.stderr +++ b/tests/ui/alloc-error/alloc-error-handler-bad-signature-3.stderr @@ -7,7 +7,10 @@ LL | fn oom() -> ! { | _-^^^^^^^^^^^^ LL | | loop {} LL | | } - | |_- argument of type `core::alloc::Layout` unexpected + | | - + | | | + | |_unexpected argument of type `core::alloc::Layout` + | help: remove the extra argument | note: function defined here --> $DIR/alloc-error-handler-bad-signature-3.rs:10:4 @@ -15,10 +18,6 @@ note: function defined here LL | fn oom() -> ! { | ^^^ = note: this error originates in the attribute macro `alloc_error_handler` (in Nightly builds, run with -Z macro-backtrace for more info) -help: remove the extra argument - | -LL | fn oom() -> !() { - | ++ error: aborting due to previous error diff --git a/tests/ui/argument-suggestions/basic.stderr b/tests/ui/argument-suggestions/basic.stderr index 062b3768858..c74186285f9 100644 --- a/tests/ui/argument-suggestions/basic.stderr +++ b/tests/ui/argument-suggestions/basic.stderr @@ -16,17 +16,16 @@ error[E0061]: this function takes 0 arguments but 1 argument was supplied --> $DIR/basic.rs:21:5 | LL | extra(""); - | ^^^^^ -- argument of type `&'static str` unexpected + | ^^^^^ -- + | | + | unexpected argument of type `&'static str` + | help: remove the extra argument | note: function defined here --> $DIR/basic.rs:14:4 | LL | fn extra() {} | ^^^^^ -help: remove the extra argument - | -LL | extra(); - | ~~ error[E0061]: this function takes 1 argument but 0 arguments were supplied --> $DIR/basic.rs:22:5 diff --git a/tests/ui/argument-suggestions/exotic-calls.stderr b/tests/ui/argument-suggestions/exotic-calls.stderr index 0580e53c510..ff795b507f2 100644 --- a/tests/ui/argument-suggestions/exotic-calls.stderr +++ b/tests/ui/argument-suggestions/exotic-calls.stderr @@ -2,65 +2,61 @@ error[E0057]: this function takes 0 arguments but 1 argument was supplied --> $DIR/exotic-calls.rs:2:5 | LL | t(1i32); - | ^ ---- argument of type `i32` unexpected + | ^ ---- + | | + | unexpected argument of type `i32` + | help: remove the extra argument | note: callable defined here --> $DIR/exotic-calls.rs:1:11 | LL | fn foo<T: Fn()>(t: T) { | ^^^^ -help: remove the extra argument - | -LL | t(); - | ~~ error[E0057]: this function takes 0 arguments but 1 argument was supplied --> $DIR/exotic-calls.rs:7:5 | LL | t(1i32); - | ^ ---- argument of type `i32` unexpected + | ^ ---- + | | + | unexpected argument of type `i32` + | help: remove the extra argument | note: type parameter defined here --> $DIR/exotic-calls.rs:6:11 | LL | fn bar(t: impl Fn()) { | ^^^^^^^^^ -help: remove the extra argument - | -LL | t(); - | ~~ error[E0057]: this function takes 0 arguments but 1 argument was supplied --> $DIR/exotic-calls.rs:16:5 | LL | baz()(1i32) - | ^^^^^ ---- argument of type `i32` unexpected + | ^^^^^ ---- + | | + | unexpected argument of type `i32` + | help: remove the extra argument | note: opaque type defined here --> $DIR/exotic-calls.rs:11:13 | LL | fn baz() -> impl Fn() { | ^^^^^^^^^ -help: remove the extra argument - | -LL | baz()() - | ~~ error[E0057]: this function takes 0 arguments but 1 argument was supplied --> $DIR/exotic-calls.rs:22:5 | LL | x(1i32); - | ^ ---- argument of type `i32` unexpected + | ^ ---- + | | + | unexpected argument of type `i32` + | help: remove the extra argument | note: closure defined here --> $DIR/exotic-calls.rs:21:13 | LL | let x = || {}; | ^^ -help: remove the extra argument - | -LL | x(); - | ~~ error: aborting due to 4 previous errors diff --git a/tests/ui/argument-suggestions/extra_arguments.stderr b/tests/ui/argument-suggestions/extra_arguments.stderr index 48787b0c352..0911685b428 100644 --- a/tests/ui/argument-suggestions/extra_arguments.stderr +++ b/tests/ui/argument-suggestions/extra_arguments.stderr @@ -2,57 +2,54 @@ error[E0061]: this function takes 0 arguments but 1 argument was supplied --> $DIR/extra_arguments.rs:7:3 | LL | empty(""); - | ^^^^^ -- argument of type `&'static str` unexpected + | ^^^^^ -- + | | + | unexpected argument of type `&'static str` + | help: remove the extra argument | note: function defined here --> $DIR/extra_arguments.rs:1:4 | LL | fn empty() {} | ^^^^^ -help: remove the extra argument - | -LL | empty(); - | ~~ error[E0061]: this function takes 1 argument but 2 arguments were supplied --> $DIR/extra_arguments.rs:9:3 | LL | one_arg(1, 1); - | ^^^^^^^ - argument of type `{integer}` unexpected + | ^^^^^^^ --- + | | | + | | unexpected argument of type `{integer}` + | help: remove the extra argument | note: function defined here --> $DIR/extra_arguments.rs:2:4 | LL | fn one_arg(_a: i32) {} | ^^^^^^^ ------- -help: remove the extra argument - | -LL | one_arg(1); - | ~~~ error[E0061]: this function takes 1 argument but 2 arguments were supplied --> $DIR/extra_arguments.rs:10:3 | LL | one_arg(1, ""); - | ^^^^^^^ -- argument of type `&'static str` unexpected + | ^^^^^^^ ---- + | | | + | | unexpected argument of type `&'static str` + | help: remove the extra argument | note: function defined here --> $DIR/extra_arguments.rs:2:4 | LL | fn one_arg(_a: i32) {} | ^^^^^^^ ------- -help: remove the extra argument - | -LL | one_arg(1); - | ~~~ error[E0061]: this function takes 1 argument but 3 arguments were supplied --> $DIR/extra_arguments.rs:11:3 | LL | one_arg(1, "", 1.0); - | ^^^^^^^ -- --- argument of type `{float}` unexpected + | ^^^^^^^ -- --- unexpected argument of type `{float}` | | - | argument of type `&'static str` unexpected + | unexpected argument of type `&'static str` | note: function defined here --> $DIR/extra_arguments.rs:2:4 @@ -61,80 +58,77 @@ LL | fn one_arg(_a: i32) {} | ^^^^^^^ ------- help: remove the extra arguments | -LL | one_arg(1); - | ~~~ +LL - one_arg(1, "", 1.0); +LL + one_arg(1); + | error[E0061]: this function takes 2 arguments but 3 arguments were supplied --> $DIR/extra_arguments.rs:13:3 | LL | two_arg_same(1, 1, 1); - | ^^^^^^^^^^^^ - argument of type `{integer}` unexpected + | ^^^^^^^^^^^^ --- + | | | + | | unexpected argument of type `{integer}` + | help: remove the extra argument | note: function defined here --> $DIR/extra_arguments.rs:3:4 | LL | fn two_arg_same(_a: i32, _b: i32) {} | ^^^^^^^^^^^^ ------- ------- -help: remove the extra argument - | -LL | two_arg_same(1, 1); - | ~~~~~~ error[E0061]: this function takes 2 arguments but 3 arguments were supplied --> $DIR/extra_arguments.rs:14:3 | LL | two_arg_same(1, 1, 1.0); - | ^^^^^^^^^^^^ --- argument of type `{float}` unexpected + | ^^^^^^^^^^^^ ----- + | | | + | | unexpected argument of type `{float}` + | help: remove the extra argument | note: function defined here --> $DIR/extra_arguments.rs:3:4 | LL | fn two_arg_same(_a: i32, _b: i32) {} | ^^^^^^^^^^^^ ------- ------- -help: remove the extra argument - | -LL | two_arg_same(1, 1); - | ~~~~~~ error[E0061]: this function takes 2 arguments but 3 arguments were supplied --> $DIR/extra_arguments.rs:16:3 | LL | two_arg_diff(1, 1, ""); - | ^^^^^^^^^^^^ - argument of type `{integer}` unexpected + | ^^^^^^^^^^^^ --- + | | | + | | unexpected argument of type `{integer}` + | help: remove the extra argument | note: function defined here --> $DIR/extra_arguments.rs:4:4 | LL | fn two_arg_diff(_a: i32, _b: &str) {} | ^^^^^^^^^^^^ ------- -------- -help: remove the extra argument - | -LL | two_arg_diff(1, ""); - | ~~~~~~~ error[E0061]: this function takes 2 arguments but 3 arguments were supplied --> $DIR/extra_arguments.rs:17:3 | LL | two_arg_diff(1, "", ""); - | ^^^^^^^^^^^^ -- argument of type `&'static str` unexpected + | ^^^^^^^^^^^^ ---- + | | | + | | unexpected argument of type `&'static str` + | help: remove the extra argument | note: function defined here --> $DIR/extra_arguments.rs:4:4 | LL | fn two_arg_diff(_a: i32, _b: &str) {} | ^^^^^^^^^^^^ ------- -------- -help: remove the extra argument - | -LL | two_arg_diff(1, ""); - | ~~~~~~~ error[E0061]: this function takes 2 arguments but 4 arguments were supplied --> $DIR/extra_arguments.rs:18:3 | LL | two_arg_diff(1, 1, "", ""); - | ^^^^^^^^^^^^ - -- argument of type `&'static str` unexpected + | ^^^^^^^^^^^^ - -- unexpected argument of type `&'static str` | | - | argument of type `{integer}` unexpected + | unexpected argument of type `{integer}` | note: function defined here --> $DIR/extra_arguments.rs:4:4 @@ -143,16 +137,17 @@ LL | fn two_arg_diff(_a: i32, _b: &str) {} | ^^^^^^^^^^^^ ------- -------- help: remove the extra arguments | -LL | two_arg_diff(1, ""); - | ~~~~~~~ +LL - two_arg_diff(1, 1, "", ""); +LL + two_arg_diff(1, ""); + | error[E0061]: this function takes 2 arguments but 4 arguments were supplied --> $DIR/extra_arguments.rs:19:3 | LL | two_arg_diff(1, "", 1, ""); - | ^^^^^^^^^^^^ - -- argument of type `&'static str` unexpected + | ^^^^^^^^^^^^ - -- unexpected argument of type `&'static str` | | - | argument of type `{integer}` unexpected + | unexpected argument of type `{integer}` | note: function defined here --> $DIR/extra_arguments.rs:4:4 @@ -161,78 +156,78 @@ LL | fn two_arg_diff(_a: i32, _b: &str) {} | ^^^^^^^^^^^^ ------- -------- help: remove the extra arguments | -LL | two_arg_diff(1, ""); - | ~~~~~~~ +LL - two_arg_diff(1, "", 1, ""); +LL + two_arg_diff(1, ""); + | error[E0061]: this function takes 2 arguments but 3 arguments were supplied --> $DIR/extra_arguments.rs:22:3 | LL | two_arg_same(1, 1, ""); - | ^^^^^^^^^^^^ -- argument of type `&'static str` unexpected + | ^^^^^^^^^^^^ -------- + | | | + | | unexpected argument of type `&'static str` + | help: remove the extra argument | note: function defined here --> $DIR/extra_arguments.rs:3:4 | LL | fn two_arg_same(_a: i32, _b: i32) {} | ^^^^^^^^^^^^ ------- ------- -help: remove the extra argument - | -LL | two_arg_same(1, 1); - | ~~~~~~ error[E0061]: this function takes 2 arguments but 3 arguments were supplied --> $DIR/extra_arguments.rs:23:3 | LL | two_arg_diff(1, 1, ""); - | ^^^^^^^^^^^^ - argument of type `{integer}` unexpected + | ^^^^^^^^^^^^ --- + | | | + | | unexpected argument of type `{integer}` + | help: remove the extra argument | note: function defined here --> $DIR/extra_arguments.rs:4:4 | LL | fn two_arg_diff(_a: i32, _b: &str) {} | ^^^^^^^^^^^^ ------- -------- -help: remove the extra argument - | -LL | two_arg_diff(1, ""); - | ~~~~~~~ error[E0061]: this function takes 2 arguments but 3 arguments were supplied --> $DIR/extra_arguments.rs:24:3 | -LL | two_arg_same( - | ^^^^^^^^^^^^ -... -LL | "" - | -- argument of type `&'static str` unexpected +LL | two_arg_same( + | ^^^^^^^^^^^^ +LL | 1, +LL | 1, + | ______- +LL | | "" + | | -- + | |_____|| + | |help: remove the extra argument + | unexpected argument of type `&'static str` | note: function defined here --> $DIR/extra_arguments.rs:3:4 | LL | fn two_arg_same(_a: i32, _b: i32) {} | ^^^^^^^^^^^^ ------- ------- -help: remove the extra argument - | -LL | two_arg_same(1, 1); - | ~~~~~~ error[E0061]: this function takes 2 arguments but 3 arguments were supplied --> $DIR/extra_arguments.rs:30:3 | -LL | two_arg_diff( - | ^^^^^^^^^^^^ -LL | 1, -LL | 1, - | - argument of type `{integer}` unexpected +LL | two_arg_diff( + | ^^^^^^^^^^^^ +LL | 1, + | ______- +LL | | 1, + | | - + | | | + | |_____unexpected argument of type `{integer}` + | help: remove the extra argument | note: function defined here --> $DIR/extra_arguments.rs:4:4 | LL | fn two_arg_diff(_a: i32, _b: &str) {} | ^^^^^^^^^^^^ ------- -------- -help: remove the extra argument - | -LL | two_arg_diff(1, ""); - | ~~~~~~~ error: aborting due to 14 previous errors diff --git a/tests/ui/argument-suggestions/issue-101097.stderr b/tests/ui/argument-suggestions/issue-101097.stderr index 7582082ac72..061f510144b 100644 --- a/tests/ui/argument-suggestions/issue-101097.stderr +++ b/tests/ui/argument-suggestions/issue-101097.stderr @@ -4,7 +4,7 @@ error[E0061]: this function takes 6 arguments but 7 arguments were supplied LL | f(C, A, A, A, B, B, C); | ^ - - - - expected `C`, found `B` | | | | - | | | argument of type `A` unexpected + | | | unexpected argument of type `A` | | expected `B`, found `A` | expected `A`, found `C` | @@ -64,8 +64,8 @@ error[E0308]: arguments to this function are incorrect LL | f(A, A, D, D, B, B); | ^ - - ---- two arguments of type `C` and `C` are missing | | | - | | argument of type `D` unexpected - | argument of type `D` unexpected + | | unexpected argument of type `D` + | unexpected argument of type `D` | note: function defined here --> $DIR/issue-101097.rs:6:4 diff --git a/tests/ui/argument-suggestions/issue-97484.stderr b/tests/ui/argument-suggestions/issue-97484.stderr index c2e6e001b17..a86cbbf1802 100644 --- a/tests/ui/argument-suggestions/issue-97484.stderr +++ b/tests/ui/argument-suggestions/issue-97484.stderr @@ -2,11 +2,11 @@ error[E0061]: this function takes 4 arguments but 7 arguments were supplied --> $DIR/issue-97484.rs:12:5 | LL | foo(&&A, B, C, D, E, F, G); - | ^^^ - - - - argument of type `F` unexpected + | ^^^ - - - - unexpected argument of type `F` | | | | | | | expected `&E`, found `E` - | | argument of type `C` unexpected - | argument of type `B` unexpected + | | unexpected argument of type `C` + | unexpected argument of type `B` | note: function defined here --> $DIR/issue-97484.rs:9:4 @@ -19,8 +19,9 @@ LL | foo(&&A, B, C, D, &E, F, G); | ~~ help: remove the extra arguments | -LL | foo(&&A, D, /* &E */, G); - | ~~~~~~~~~~~~~~~~~~~~~ +LL - foo(&&A, B, C, D, E, F, G); +LL + foo(&&A, D, /* &E */, G); + | error: aborting due to previous error diff --git a/tests/ui/argument-suggestions/mixed_cases.stderr b/tests/ui/argument-suggestions/mixed_cases.stderr index 8cf48060a63..c645dd38179 100644 --- a/tests/ui/argument-suggestions/mixed_cases.stderr +++ b/tests/ui/argument-suggestions/mixed_cases.stderr @@ -2,7 +2,7 @@ error[E0061]: this function takes 2 arguments but 3 arguments were supplied --> $DIR/mixed_cases.rs:10:3 | LL | two_args(1, "", X {}); - | ^^^^^^^^ -- ---- argument of type `X` unexpected + | ^^^^^^^^ -- ---- unexpected argument of type `X` | | | expected `f32`, found `&str` | @@ -13,16 +13,17 @@ LL | fn two_args(_a: i32, _b: f32) {} | ^^^^^^^^ ------- ------- help: remove the extra argument | -LL | two_args(1, /* f32 */); - | ~~~~~~~~~~~~~~ +LL - two_args(1, "", X {}); +LL + two_args(1, /* f32 */); + | error[E0061]: this function takes 3 arguments but 4 arguments were supplied --> $DIR/mixed_cases.rs:11:3 | LL | three_args(1, "", X {}, ""); - | ^^^^^^^^^^ -- ---- -- argument of type `&'static str` unexpected + | ^^^^^^^^^^ -- ---- -- unexpected argument of type `&'static str` | | | - | | argument of type `X` unexpected + | | unexpected argument of type `X` | an argument of type `f32` is missing | note: function defined here @@ -58,7 +59,7 @@ error[E0308]: arguments to this function are incorrect --> $DIR/mixed_cases.rs:17:3 | LL | three_args(1, "", X {}); - | ^^^^^^^^^^ -- ---- argument of type `X` unexpected + | ^^^^^^^^^^ -- ---- unexpected argument of type `X` | | | an argument of type `f32` is missing | diff --git a/tests/ui/error-codes/E0057.stderr b/tests/ui/error-codes/E0057.stderr index 163737895fe..9b0cf069824 100644 --- a/tests/ui/error-codes/E0057.stderr +++ b/tests/ui/error-codes/E0057.stderr @@ -18,17 +18,16 @@ error[E0057]: this function takes 1 argument but 2 arguments were supplied --> $DIR/E0057.rs:5:13 | LL | let c = f(2, 3); - | ^ - argument of type `{integer}` unexpected + | ^ --- + | | | + | | unexpected argument of type `{integer}` + | help: remove the extra argument | note: closure defined here --> $DIR/E0057.rs:2:13 | LL | let f = |x| x * 3; | ^^^ -help: remove the extra argument - | -LL | let c = f(2); - | ~~~ error: aborting due to 2 previous errors diff --git a/tests/ui/issues/issue-16939.stderr b/tests/ui/issues/issue-16939.stderr index 76645645464..6db29bc61b1 100644 --- a/tests/ui/issues/issue-16939.stderr +++ b/tests/ui/issues/issue-16939.stderr @@ -2,17 +2,16 @@ error[E0057]: this function takes 0 arguments but 1 argument was supplied --> $DIR/issue-16939.rs:5:9 | LL | |t| f(t); - | ^ - argument unexpected + | ^ - + | | + | unexpected argument + | help: remove the extra argument | note: callable defined here --> $DIR/issue-16939.rs:4:12 | LL | fn _foo<F: Fn()> (f: F) { | ^^^^ -help: remove the extra argument - | -LL | |t| f(); - | ~~ error: aborting due to previous error diff --git a/tests/ui/issues/issue-26094.rs b/tests/ui/issues/issue-26094.rs index d3d670aa92a..abf3543ddb9 100644 --- a/tests/ui/issues/issue-26094.rs +++ b/tests/ui/issues/issue-26094.rs @@ -1,6 +1,6 @@ macro_rules! some_macro { ($other: expr) => ({ - $other(None) //~ NOTE argument of type `Option<_>` unexpected + $other(None) //~ NOTE unexpected argument of type `Option<_>` }) } diff --git a/tests/ui/issues/issue-26094.stderr b/tests/ui/issues/issue-26094.stderr index 881a6e538ee..608d2c7aff9 100644 --- a/tests/ui/issues/issue-26094.stderr +++ b/tests/ui/issues/issue-26094.stderr @@ -2,7 +2,10 @@ error[E0061]: this function takes 0 arguments but 1 argument was supplied --> $DIR/issue-26094.rs:10:17 | LL | $other(None) - | ---- argument of type `Option<_>` unexpected + | ---- + | | + | unexpected argument of type `Option<_>` + | help: remove the extra argument ... LL | some_macro!(some_function); | ^^^^^^^^^^^^^ @@ -12,10 +15,6 @@ note: function defined here | LL | fn some_function() {} | ^^^^^^^^^^^^^ -help: remove the extra argument - | -LL | some_function() - | ~~~~~~~~~~~~~~~ error: aborting due to previous error diff --git a/tests/ui/issues/issue-4935.stderr b/tests/ui/issues/issue-4935.stderr index bb45fa08338..e544e424403 100644 --- a/tests/ui/issues/issue-4935.stderr +++ b/tests/ui/issues/issue-4935.stderr @@ -2,17 +2,16 @@ error[E0061]: this function takes 1 argument but 2 arguments were supplied --> $DIR/issue-4935.rs:5:13 | LL | fn main() { foo(5, 6) } - | ^^^ - argument of type `{integer}` unexpected + | ^^^ --- + | | | + | | unexpected argument of type `{integer}` + | help: remove the extra argument | note: function defined here --> $DIR/issue-4935.rs:3:4 | LL | fn foo(a: usize) {} | ^^^ -------- -help: remove the extra argument - | -LL | fn main() { foo(5) } - | ~~~ error: aborting due to previous error diff --git a/tests/ui/methods/method-call-err-msg.stderr b/tests/ui/methods/method-call-err-msg.stderr index 81269b73b9a..0f37e8f09a9 100644 --- a/tests/ui/methods/method-call-err-msg.stderr +++ b/tests/ui/methods/method-call-err-msg.stderr @@ -2,17 +2,16 @@ error[E0061]: this method takes 0 arguments but 1 argument was supplied --> $DIR/method-call-err-msg.rs:13:7 | LL | x.zero(0) - | ^^^^ - argument of type `{integer}` unexpected + | ^^^^ - + | | + | unexpected argument of type `{integer}` + | help: remove the extra argument | note: associated function defined here --> $DIR/method-call-err-msg.rs:5:8 | LL | fn zero(self) -> Foo { self } | ^^^^ -help: remove the extra argument - | -LL | x.zero() - | ~~ error[E0061]: this method takes 1 argument but 0 arguments were supplied --> $DIR/method-call-err-msg.rs:14:7 diff --git a/tests/ui/mismatched_types/overloaded-calls-bad.stderr b/tests/ui/mismatched_types/overloaded-calls-bad.stderr index 3a895acbdb5..cd483e7ad2c 100644 --- a/tests/ui/mismatched_types/overloaded-calls-bad.stderr +++ b/tests/ui/mismatched_types/overloaded-calls-bad.stderr @@ -32,7 +32,7 @@ error[E0057]: this function takes 1 argument but 2 arguments were supplied --> $DIR/overloaded-calls-bad.rs:37:15 | LL | let ans = s("burma", "shave"); - | ^ ------- ------- argument of type `&'static str` unexpected + | ^ ------- ------- unexpected argument of type `&'static str` | | | expected `isize`, found `&str` | @@ -43,8 +43,9 @@ LL | impl FnMut<(isize,)> for S { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove the extra argument | -LL | let ans = s(/* isize */); - | ~~~~~~~~~~~~~ +LL - let ans = s("burma", "shave"); +LL + let ans = s(/* isize */); + | error[E0308]: mismatched types --> $DIR/overloaded-calls-bad.rs:40:7 diff --git a/tests/ui/resolve/resolve-primitive-fallback.stderr b/tests/ui/resolve/resolve-primitive-fallback.stderr index 964302e924c..f803f9da2af 100644 --- a/tests/ui/resolve/resolve-primitive-fallback.stderr +++ b/tests/ui/resolve/resolve-primitive-fallback.stderr @@ -24,14 +24,13 @@ error[E0061]: this function takes 0 arguments but 1 argument was supplied --> $DIR/resolve-primitive-fallback.rs:3:5 | LL | std::mem::size_of(u16); - | ^^^^^^^^^^^^^^^^^ --- argument unexpected + | ^^^^^^^^^^^^^^^^^ --- + | | + | unexpected argument + | help: remove the extra argument | note: function defined here --> $SRC_DIR/core/src/mem/mod.rs:LL:COL -help: remove the extra argument - | -LL | std::mem::size_of(); - | ~~ error: aborting due to 3 previous errors diff --git a/tests/ui/span/issue-34264.stderr b/tests/ui/span/issue-34264.stderr index 15179954adc..f0dea66f612 100644 --- a/tests/ui/span/issue-34264.stderr +++ b/tests/ui/span/issue-34264.stderr @@ -54,17 +54,16 @@ error[E0061]: this function takes 2 arguments but 3 arguments were supplied --> $DIR/issue-34264.rs:7:5 | LL | foo(Some(42), 2, ""); - | ^^^ -- argument of type `&'static str` unexpected + | ^^^ ---- + | | | + | | unexpected argument of type `&'static str` + | help: remove the extra argument | note: function defined here --> $DIR/issue-34264.rs:1:4 | LL | fn foo(Option<i32>, String) {} | ^^^ ----------- ------ -help: remove the extra argument - | -LL | foo(Some(42), 2); - | ~~~~~~~~~~~~~ error[E0308]: mismatched types --> $DIR/issue-34264.rs:8:13 @@ -84,17 +83,16 @@ error[E0061]: this function takes 2 arguments but 3 arguments were supplied --> $DIR/issue-34264.rs:10:5 | LL | bar(1, 2, 3); - | ^^^ - argument of type `{integer}` unexpected + | ^^^ --- + | | | + | | unexpected argument of type `{integer}` + | help: remove the extra argument | note: function defined here --> $DIR/issue-34264.rs:3:4 | LL | fn bar(x, y: usize) {} | ^^^ - -------- -help: remove the extra argument - | -LL | bar(1, 2); - | ~~~~~~ error: aborting due to 6 previous errors diff --git a/tests/ui/suggestions/args-instead-of-tuple-errors.stderr b/tests/ui/suggestions/args-instead-of-tuple-errors.stderr index e9736363816..510b99bb5af 100644 --- a/tests/ui/suggestions/args-instead-of-tuple-errors.stderr +++ b/tests/ui/suggestions/args-instead-of-tuple-errors.stderr @@ -2,7 +2,7 @@ error[E0061]: this enum variant takes 1 argument but 2 arguments were supplied --> $DIR/args-instead-of-tuple-errors.rs:6:34 | LL | let _: Option<(i32, bool)> = Some(1, 2); - | ^^^^ - argument of type `{integer}` unexpected + | ^^^^ - unexpected argument of type `{integer}` | note: expected `(i32, bool)`, found integer --> $DIR/args-instead-of-tuple-errors.rs:6:39 @@ -22,14 +22,15 @@ note: tuple variant defined here --> $SRC_DIR/core/src/option.rs:LL:COL help: remove the extra argument | -LL | let _: Option<(i32, bool)> = Some(/* (i32, bool) */); - | ~~~~~~~~~~~~~~~~~~~ +LL - let _: Option<(i32, bool)> = Some(1, 2); +LL + let _: Option<(i32, bool)> = Some(/* (i32, bool) */); + | error[E0061]: this function takes 1 argument but 2 arguments were supplied --> $DIR/args-instead-of-tuple-errors.rs:8:5 | LL | int_bool(1, 2); - | ^^^^^^^^ - argument of type `{integer}` unexpected + | ^^^^^^^^ - unexpected argument of type `{integer}` | note: expected `(i32, bool)`, found integer --> $DIR/args-instead-of-tuple-errors.rs:8:14 @@ -45,8 +46,9 @@ LL | fn int_bool(_: (i32, bool)) { | ^^^^^^^^ -------------- help: remove the extra argument | -LL | int_bool(/* (i32, bool) */); - | ~~~~~~~~~~~~~~~~~~~ +LL - int_bool(1, 2); +LL + int_bool(/* (i32, bool) */); + | error[E0061]: this enum variant takes 1 argument but 0 arguments were supplied --> $DIR/args-instead-of-tuple-errors.rs:11:28 diff --git a/tests/ui/tuple/wrong_argument_ice-3.stderr b/tests/ui/tuple/wrong_argument_ice-3.stderr index 75dfe716395..7143c959478 100644 --- a/tests/ui/tuple/wrong_argument_ice-3.stderr +++ b/tests/ui/tuple/wrong_argument_ice-3.stderr @@ -2,7 +2,7 @@ error[E0061]: this method takes 1 argument but 2 arguments were supplied --> $DIR/wrong_argument_ice-3.rs:9:16 | LL | groups.push(new_group, vec![process]); - | ^^^^ ------------- argument of type `Vec<&Process>` unexpected + | ^^^^ ------------- unexpected argument of type `Vec<&Process>` | note: expected `(Vec<String>, Vec<Process>)`, found `Vec<String>` --> $DIR/wrong_argument_ice-3.rs:9:21 @@ -15,8 +15,9 @@ note: associated function defined here --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL help: remove the extra argument | -LL | groups.push(/* (Vec<String>, Vec<Process>) */); - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +LL - groups.push(new_group, vec![process]); +LL + groups.push(/* (Vec<String>, Vec<Process>) */); + | error: aborting due to previous error diff --git a/tests/ui/tuple/wrong_argument_ice-4.stderr b/tests/ui/tuple/wrong_argument_ice-4.stderr index a2686ab9440..d8569ebf6b6 100644 --- a/tests/ui/tuple/wrong_argument_ice-4.stderr +++ b/tests/ui/tuple/wrong_argument_ice-4.stderr @@ -6,17 +6,16 @@ LL | (|| {})(|| { LL | | LL | | let b = 1; LL | | }); - | |_____- argument of type `[closure@$DIR/wrong_argument_ice-4.rs:2:13: 2:15]` unexpected + | | - + | | | + | |_____unexpected argument of type `[closure@$DIR/wrong_argument_ice-4.rs:2:13: 2:15]` + | help: remove the extra argument | note: closure defined here --> $DIR/wrong_argument_ice-4.rs:2:6 | LL | (|| {})(|| { | ^^ -help: remove the extra argument - | -LL | (|| {})(); - | ~~ error: aborting due to previous error diff --git a/tests/ui/type/type-ascription-instead-of-initializer.stderr b/tests/ui/type/type-ascription-instead-of-initializer.stderr index ba8d15d0b73..429501c2762 100644 --- a/tests/ui/type/type-ascription-instead-of-initializer.stderr +++ b/tests/ui/type/type-ascription-instead-of-initializer.stderr @@ -11,14 +11,13 @@ error[E0061]: this function takes 1 argument but 2 arguments were supplied --> $DIR/type-ascription-instead-of-initializer.rs:2:12 | LL | let x: Vec::with_capacity(10, 20); - | ^^^^^^^^^^^^^^^^^^ -- argument of type `{integer}` unexpected + | ^^^^^^^^^^^^^^^^^^ ---- + | | | + | | unexpected argument of type `{integer}` + | help: remove the extra argument | note: associated function defined here --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL -help: remove the extra argument - | -LL | let x: Vec::with_capacity(10); - | ~~~~ error: aborting due to 2 previous errors diff --git a/tests/ui/typeck/remove-extra-argument.stderr b/tests/ui/typeck/remove-extra-argument.stderr index b734bcd4eb0..72ddebab486 100644 --- a/tests/ui/typeck/remove-extra-argument.stderr +++ b/tests/ui/typeck/remove-extra-argument.stderr @@ -2,17 +2,16 @@ error[E0061]: this function takes 1 argument but 2 arguments were supplied --> $DIR/remove-extra-argument.rs:6:5 | LL | l(vec![], vec![]) - | ^ ------ argument of type `Vec<_>` unexpected + | ^ -------- + | | | + | | unexpected argument of type `Vec<_>` + | help: remove the extra argument | note: function defined here --> $DIR/remove-extra-argument.rs:3:4 | LL | fn l(_a: Vec<u8>) {} | ^ ----------- -help: remove the extra argument - | -LL | l(vec![]) - | ~~~~~~~~ error: aborting due to previous error diff --git a/tests/ui/typeck/struct-enum-wrong-args.stderr b/tests/ui/typeck/struct-enum-wrong-args.stderr index fbced928a8a..57cbd1d2005 100644 --- a/tests/ui/typeck/struct-enum-wrong-args.stderr +++ b/tests/ui/typeck/struct-enum-wrong-args.stderr @@ -2,29 +2,29 @@ error[E0061]: this enum variant takes 1 argument but 2 arguments were supplied --> $DIR/struct-enum-wrong-args.rs:6:13 | LL | let _ = Some(3, 2); - | ^^^^ - argument of type `{integer}` unexpected + | ^^^^ --- + | | | + | | unexpected argument of type `{integer}` + | help: remove the extra argument | note: tuple variant defined here --> $SRC_DIR/core/src/option.rs:LL:COL -help: remove the extra argument - | -LL | let _ = Some(3); - | ~~~ error[E0061]: this enum variant takes 1 argument but 3 arguments were supplied --> $DIR/struct-enum-wrong-args.rs:7:13 | LL | let _ = Ok(3, 6, 2); - | ^^ - - argument of type `{integer}` unexpected + | ^^ - - unexpected argument of type `{integer}` | | - | argument of type `{integer}` unexpected + | unexpected argument of type `{integer}` | note: tuple variant defined here --> $SRC_DIR/core/src/result.rs:LL:COL help: remove the extra arguments | -LL | let _ = Ok(3); - | ~~~ +LL - let _ = Ok(3, 6, 2); +LL + let _ = Ok(3); + | error[E0061]: this enum variant takes 1 argument but 0 arguments were supplied --> $DIR/struct-enum-wrong-args.rs:8:13 @@ -59,17 +59,16 @@ error[E0061]: this struct takes 1 argument but 2 arguments were supplied --> $DIR/struct-enum-wrong-args.rs:10:13 | LL | let _ = Wrapper(5, 2); - | ^^^^^^^ - argument of type `{integer}` unexpected + | ^^^^^^^ --- + | | | + | | unexpected argument of type `{integer}` + | help: remove the extra argument | note: tuple struct defined here --> $DIR/struct-enum-wrong-args.rs:2:8 | LL | struct Wrapper(i32); | ^^^^^^^ -help: remove the extra argument - | -LL | let _ = Wrapper(5); - | ~~~ error[E0061]: this struct takes 2 arguments but 0 arguments were supplied --> $DIR/struct-enum-wrong-args.rs:11:13 @@ -107,17 +106,16 @@ error[E0061]: this struct takes 2 arguments but 3 arguments were supplied --> $DIR/struct-enum-wrong-args.rs:13:13 | LL | let _ = DoubleWrapper(5, 2, 7); - | ^^^^^^^^^^^^^ - argument of type `{integer}` unexpected + | ^^^^^^^^^^^^^ --- + | | | + | | unexpected argument of type `{integer}` + | help: remove the extra argument | note: tuple struct defined here --> $DIR/struct-enum-wrong-args.rs:3:8 | LL | struct DoubleWrapper(i32, i32); | ^^^^^^^^^^^^^ -help: remove the extra argument - | -LL | let _ = DoubleWrapper(5, 2); - | ~~~~~~ error: aborting due to 8 previous errors |