From acd679c937946df6246364e520ae4fbbd53c6bd2 Mon Sep 17 00:00:00 2001 From: Pi Lanningham Date: Sun, 3 May 2020 04:58:22 +0000 Subject: [PATCH 01/21] Initial implementation for 65853 This attempts to bring better error messages to invalid method calls, by applying some heuristics to identify common mistakes. The algorithm is inspired by Levenshtein distance and longest common sub-sequence. In essence, we treat the types of the function, and the types of the arguments you provided as two "words" and compute the edits to get from one to the other. We then modify that algorithm to detect 4 cases: - A function input is missing - An extra argument was provided - The type of an argument is straight up invalid - Two arguments have been swapped - A subset of the arguments have been shuffled (We detect the last two as separate cases so that we can detect two swaps, instead of 4 parameters permuted.) It helps to understand this argument by paying special attention to terminology: "inputs" refers to the inputs being *expected* by the function, and "arguments" refers to what has been provided at the call site. The basic sketch of the algorithm is as follows: - Construct a boolean grid, with a row for each argument, and a column for each input. The cell [i, j] is true if the i'th argument could satisfy the j'th input. - If we find an argument that could satisfy no inputs, provided for an input that can't be satisfied by any other argument, we consider this an "invalid type". - Extra arguments are those that can't satisfy any input, provided for an input that *could* be satisfied by another argument. - Missing inputs are inputs that can't be satisfied by any argument, where the provided argument could satisfy another input - Swapped / Permuted arguments are identified with a cycle detection algorithm. As each issue is found, we remove the relevant inputs / arguments and check for more issues. If we find no issues, we match up any "valid" arguments, and start again. Note that there's a lot of extra complexity: - We try to stay efficient on the happy path, only computing the diagonal until we find a problem, and then filling in the rest of the matrix. - Closure arguments are wrapped in a tuple and need to be unwrapped - We need to resolve closure types after the rest, to allow the most specific type constraints - We need to handle imported C functions that might be variadic in their inputs. I tried to document a lot of this in comments in the code and keep the naming clear. --- .../rustc_typeck/src/check/fn_ctxt/checks.rs | 813 +++++++++++++----- 1 file changed, 588 insertions(+), 225 deletions(-) diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs index 3e60924d6fcf8..d18393fa56321 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs @@ -4,26 +4,28 @@ use crate::check::method::MethodCallee; use crate::check::Expectation::*; use crate::check::TupleArgumentsFlag::*; use crate::check::{ - potentially_plural_count, struct_span_err, BreakableCtxt, Diverges, Expectation, FnCtxt, + struct_span_err, BreakableCtxt, Diverges, Expectation, FnCtxt, LocalTy, Needs, TupleArgumentsFlag, }; use rustc_ast as ast; -use rustc_errors::{Applicability, DiagnosticBuilder, DiagnosticId}; +use rustc_errors::{Applicability, DiagnosticBuilder}; use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::DefId; use rustc_hir::{ExprKind, Node, QPath}; +use rustc_infer::infer::InferOk; use rustc_middle::ty::adjustment::AllowTwoPhase; use rustc_middle::ty::fold::TypeFoldable; use rustc_middle::ty::{self, Ty}; use rustc_session::Session; -use rustc_span::symbol::{sym, Ident}; +use rustc_span::{BytePos, Pos, symbol::{sym, Ident}}; use rustc_span::{self, MultiSpan, Span}; use rustc_trait_selection::traits::{self, ObligationCauseCode, StatementAsExpression}; use std::mem::replace; use std::slice; +use std::cmp; impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub(in super::super) fn check_casts(&self) { @@ -92,141 +94,42 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// method calls and overloaded operators. pub(in super::super) fn check_argument_types( &self, - sp: Span, - expr: &'tcx hir::Expr<'tcx>, - fn_inputs: &[Ty<'tcx>], - expected_arg_tys: &[Ty<'tcx>], - args: &'tcx [hir::Expr<'tcx>], - c_variadic: bool, - tuple_arguments: TupleArgumentsFlag, - def_id: Option, + call_span: Span, // Span enclosing the call site + call_expr: &'tcx hir::Expr<'tcx>, // Expression of the call site + formal_input_tys: &[Ty<'tcx>], // Types (as defined in the *signature* of the target function) + expected_input_tys: &[Ty<'tcx>], // More specific expected types, after unifying with caller output types + provided_args: &'tcx [hir::Expr<'tcx>], // The expressions for each provided argument + c_variadic: bool, // Whether the function is variadic, for example when imported from C + tuple_arguments: TupleArgumentsFlag, // Whether the arguments have been bundled in a tuple (ex: closures) + fn_def_id: Option, // The DefId for the function being called, for better error messages ) { let tcx = self.tcx; - // Grab the argument types, supplying fresh type variables - // if the wrong number of arguments were supplied - let supplied_arg_count = if tuple_arguments == DontTupleArguments { args.len() } else { 1 }; + + // Conceptually, we've got some number of expected inputs, and some number of provided aguments + // and we can form a grid of whether each argument could satisfy a given input: + // in1 | in2 | in3 | ... + // arg1 ? | | | + // arg2 | ? | | + // arg3 | | ? | + // ... + // Initially, we just check the diagonal, because in the case of correct code + // these are the only checks that matter + // However, in the unhappy path, we'll fill in this whole grid to attempt to provide + // better error messages about invalid method calls. // All the input types from the fn signature must outlive the call // so as to validate implied bounds. - for (&fn_input_ty, arg_expr) in fn_inputs.iter().zip(args.iter()) { + for (&fn_input_ty, arg_expr) in formal_input_tys.iter().zip(provided_args.iter()) { self.register_wf_obligation(fn_input_ty.into(), arg_expr.span, traits::MiscObligation); } - let expected_arg_count = fn_inputs.len(); - - let param_count_error = |expected_count: usize, - arg_count: usize, - error_code: &str, - c_variadic: bool, - sugg_unit: bool| { - let (span, start_span, args) = match &expr.kind { - hir::ExprKind::Call(hir::Expr { span, .. }, args) => (*span, *span, &args[..]), - hir::ExprKind::MethodCall(path_segment, span, args, _) => ( - *span, - // `sp` doesn't point at the whole `foo.bar()`, only at `bar`. - path_segment - .args - .and_then(|args| args.args.iter().last()) - // Account for `foo.bar::()`. - .map(|arg| { - // Skip the closing `>`. - tcx.sess - .source_map() - .next_point(tcx.sess.source_map().next_point(arg.span())) - }) - .unwrap_or(*span), - &args[1..], // Skip the receiver. - ), - k => span_bug!(sp, "checking argument types on a non-call: `{:?}`", k), - }; - let arg_spans = if args.is_empty() { - // foo() - // ^^^-- supplied 0 arguments - // | - // expected 2 arguments - vec![tcx.sess.source_map().next_point(start_span).with_hi(sp.hi())] - } else { - // foo(1, 2, 3) - // ^^^ - - - supplied 3 arguments - // | - // expected 2 arguments - args.iter().map(|arg| arg.span).collect::>() - }; - - let mut err = tcx.sess.struct_span_err_with_code( - span, - &format!( - "this function takes {}{} but {} {} supplied", - if c_variadic { "at least " } else { "" }, - potentially_plural_count(expected_count, "argument"), - potentially_plural_count(arg_count, "argument"), - if arg_count == 1 { "was" } else { "were" } - ), - DiagnosticId::Error(error_code.to_owned()), - ); - let label = format!("supplied {}", potentially_plural_count(arg_count, "argument")); - for (i, span) in arg_spans.into_iter().enumerate() { - err.span_label( - span, - if arg_count == 0 || i + 1 == arg_count { &label } else { "" }, - ); - } - - if let Some(def_id) = def_id { - 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 { - let sugg_span = tcx.sess.source_map().end_point(expr.span); - // remove closing `)` from the span - let sugg_span = sugg_span.shrink_to_lo(); - err.span_suggestion( - sugg_span, - "expected the unit value `()`; create it with empty parentheses", - String::from("()"), - Applicability::MachineApplicable, - ); - } else { - err.span_label( - span, - format!( - "expected {}{}", - if c_variadic { "at least " } else { "" }, - potentially_plural_count(expected_count, "argument") - ), - ); - } - err.emit(); - }; - - let mut expected_arg_tys = expected_arg_tys.to_vec(); - - let formal_tys = if tuple_arguments == TupleArguments { - let tuple_type = self.structurally_resolved_type(sp, fn_inputs[0]); + let mut expected_input_tys = expected_input_tys.to_vec(); + // If the arguments should be wrapped in a tuple (ex: closures), unwrap them here + let formal_input_tys = if tuple_arguments == TupleArguments { + let tuple_type = self.structurally_resolved_type(call_span, formal_input_tys[0]); match tuple_type.kind() { - ty::Tuple(arg_types) if arg_types.len() != args.len() => { - param_count_error(arg_types.len(), args.len(), "E0057", false, false); - expected_arg_tys = vec![]; - self.err_args(args.len()) - } ty::Tuple(arg_types) => { - expected_arg_tys = match expected_arg_tys.get(0) { + expected_input_tys = match expected_input_tys.get(0) { Some(&ty) => match ty.kind() { ty::Tuple(ref tys) => tys.iter().map(|k| k.expect_ty()).collect(), _ => vec![], @@ -236,137 +139,597 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { arg_types.iter().map(|k| k.expect_ty()).collect() } _ => { - struct_span_err!( - tcx.sess, - sp, - E0059, - "cannot use call notation; the first type parameter \ - for the function trait is neither a tuple nor unit" - ) - .emit(); - expected_arg_tys = vec![]; - self.err_args(args.len()) + // Otherwise, there's a mismatch, so clear out what we're expecting, and set + // our input typs to err_args so we don't blow up the error messages + expected_input_tys = vec![]; + self.err_args(provided_args.len()) } } - } else if expected_arg_count == supplied_arg_count { - fn_inputs.to_vec() - } else if c_variadic { - if supplied_arg_count >= expected_arg_count { - fn_inputs.to_vec() - } else { - param_count_error(expected_arg_count, supplied_arg_count, "E0060", true, false); - expected_arg_tys = vec![]; - self.err_args(supplied_arg_count) - } } else { - // is the missing argument of type `()`? - let sugg_unit = if expected_arg_tys.len() == 1 && supplied_arg_count == 0 { - self.resolve_vars_if_possible(expected_arg_tys[0]).is_unit() - } else if fn_inputs.len() == 1 && supplied_arg_count == 0 { - self.resolve_vars_if_possible(fn_inputs[0]).is_unit() - } else { - false - }; - param_count_error(expected_arg_count, supplied_arg_count, "E0061", false, sugg_unit); + formal_input_tys.to_vec() + }; - expected_arg_tys = vec![]; - self.err_args(supplied_arg_count) + // If there are no external expectations at the call site, just use the types from the function defn + let expected_input_tys = if !expected_input_tys.is_empty() { + expected_input_tys + } else { + formal_input_tys.clone() }; - debug!( - "check_argument_types: formal_tys={:?}", - formal_tys.iter().map(|t| self.ty_to_string(*t)).collect::>() - ); + let minimum_input_count = expected_input_tys.len(); + let provided_arg_count: usize = provided_args.len(); + + // Allocate a small grid; + // compatibility_matrix[i][j] will represent whether provided argument i could satisfy input j + let mut compatibility_matrix = vec![vec![false; minimum_input_count]; provided_arg_count]; + + // Keep track of whether we *could possibly* be satisfied, i.e. whether we're on the happy path + // if the wrong number of arguments were supplied, we CAN'T be satisfied, + // and if we're c_variadic, the supplied arguments must be >= the minimum count from the function + // otherwise, they need to be identical, because rust doesn't currently support variadic functions + let mut call_appears_satisfied = if c_variadic { + provided_arg_count >= minimum_input_count + } else { + provided_arg_count == minimum_input_count + }; - // If there is no expectation, expect formal_tys. - let expected_arg_tys = - if !expected_arg_tys.is_empty() { expected_arg_tys } else { formal_tys.clone() }; + // The type of any closure arguments we encounter may be subject to obligations imposed by later arguments, + // so we defer checking any closures until the end, when all of those obligations have been registered + let mut deferred_arguments: Vec = vec![]; + // We'll also want to keep track of the fully coerced argument types, for an awkward hack near the end let mut final_arg_types: Vec<(usize, Ty<'_>, Ty<'_>)> = vec![]; - // Check the arguments. - // We do this in a pretty awful way: first we type-check any arguments - // that are not closures, then we type-check the closures. This is so - // that we have more information about the types of arguments when we - // type-check the functions. This isn't really the right way to do this. - for &check_closures in &[false, true] { - debug!("check_closures={}", check_closures); - - // More awful hacks: before we check argument types, try to do - // an "opportunistic" trait resolution of any trait bounds on - // the call. This helps coercions. - if check_closures { - self.select_obligations_where_possible(false, |errors| { - self.point_at_type_arg_instead_of_call_if_possible(errors, expr); - self.point_at_arg_instead_of_call_if_possible( - errors, - &final_arg_types[..], - sp, - &args, - ); - }) + // We introduce a helper function to demand that a given argument satisfy a given input + // This is more complicated than just checking type equality, as arguments could be coerced + // This version writes those types back so further type checking uses the narrowed types + let demand_compatible = |arg_idx, input_idx| { + let formal_input_ty: Ty<'tcx> = formal_input_tys[input_idx]; + let expected_input_ty: Ty<'tcx> = expected_input_tys[input_idx]; + let provided_arg = &provided_args[arg_idx]; + + // We're on the happy path here, so we'll do a more involved check and write back types + // To check compatibility, we'll do 3 things: + // 1. Unify the provided argument with the expected type + let expectation = Expectation::rvalue_hint(self, expected_input_ty); + let checked_ty = self.check_expr_with_expectation(provided_arg, expectation); + + // 2. Find and check the most detailed coercible type + let coerced_ty = expectation.only_has_type(self).unwrap_or(formal_input_ty); + let coerced_ty = self.resolve_vars_with_obligations(coerced_ty); + + let coerce_error = self.try_coerce(provided_arg, checked_ty, coerced_ty, AllowTwoPhase::Yes); + + // 3. Check if the formal type is a supertype of the checked one + // and register any such obligations for future type checks + let supertype_error = self + .at(&self.misc(provided_arg.span), self.param_env) + .sup(formal_input_ty, coerced_ty); + let is_supertype = match supertype_error { + Ok(InferOk { obligations, value: () }) => { + self.register_predicates(obligations); + true + } + _ => false, + }; + + // If neither check failed, the types are compatible + (coerce_error.is_ok() && is_supertype, checked_ty, coerced_ty) + }; + + // A "softer" version of the hlper above, which checks types without persisting them, + // and treats error types differently + // This will allow us to "probe" for other argument orders that would likely have been correct + let check_compatible = |arg_idx, input_idx| { + let formal_input_ty: Ty<'tcx> = formal_input_tys[input_idx]; + let expected_input_ty: Ty<'tcx> = expected_input_tys[input_idx]; + + // If either is an error type, we defy the usual convention and consider them to *not* be + // coercible. This prevents our error message heuristic from trying to pass errors into + // every argument. + if formal_input_ty.references_error() || expected_input_ty.references_error() { + return false; } - // For C-variadic functions, we don't have a declared type for all of - // the arguments hence we only do our usual type checking with - // the arguments who's types we do know. - let t = if c_variadic { - expected_arg_count - } else if tuple_arguments == TupleArguments { - args.len() + let provided_arg: &hir::Expr<'tcx> = &provided_args[arg_idx]; + let tables = self.in_progress_typeck_results.map(|t| t.borrow()).unwrap(); + let maybe_ty = tables.node_type_opt(provided_arg.hir_id); + if let Some(checked_ty) = maybe_ty { + let expectation = Expectation::rvalue_hint(self, expected_input_ty); + let coerced_ty = expectation.only_has_type(self).unwrap_or(formal_input_ty); + let can_coerce = self.can_coerce(checked_ty, coerced_ty); + + let is_super = self + .at(&self.misc(provided_arg.span), self.param_env) + .sup(formal_input_ty, coerced_ty) + .is_ok(); + // Same as above: if either the coerce type or the checked type is an error type, + // consider them *not* compatible. + return !coerced_ty.references_error() + && !checked_ty.references_error() + && can_coerce + && is_super; + } + return false; + }; + + // Check each argument, to satisfy the input it was provided for + // Visually, we're traveling down the diagonal of the compatibility matrix + for idx in 0..provided_arg_count { + // First, warn if this expression is unreachable + // ex: myFn(panic!(), 2 + 2) + // ^^^^^ + self.warn_if_unreachable( + provided_args[idx].hir_id, + provided_args[idx].span, + "expression" + ); + + // If we're past the end of the expected inputs, we won't have anything to check against + if idx >= minimum_input_count { + break; + } + + // If this argument is a closure, we defer this to a second pass, so we have more type information + if matches!(provided_args[idx].kind, ExprKind::Closure(..)) { + deferred_arguments.push(idx); + continue; + } + + // Demand that this argument satisfies the input in the slot it's in + let (compatible, checked_ty, coerced_ty) = demand_compatible(idx, idx); + // Keep track of these for below + final_arg_types.push((idx, checked_ty, coerced_ty)); + + // If we fail at some point, we'll want to provide better error messages, so hold onto this info + if compatible { + compatibility_matrix[idx][idx] = true; } else { - supplied_arg_count + call_appears_satisfied = false; + } + } + + // Next, check any closures, since we have more type info at this point + // To help with type resolution, we can do an "opportunistic" vtable resolution + // on any trait bounds. This is considered by some to be a pretty awful hack. + self.select_obligations_where_possible(false, |errors| { + // Clean up the error messages a bit + self.point_at_type_arg_instead_of_call_if_possible(errors, call_expr); + self.point_at_arg_instead_of_call_if_possible( + errors, + &final_arg_types[..], + call_span, + &provided_args, + ); + }); + + for idx in deferred_arguments { + let (compatible, _, _) = demand_compatible(idx, idx); + // Note that, unlike the first pass, we ignore the checked/coerced types, + // since we don't plan on running select_obligations_where_possible again + if compatible { + compatibility_matrix[idx][idx] = true; + } else { + call_appears_satisfied = false; + } + } + + // If something above didn't typecheck, we've fallen off the happy path + // and we should make some effort to provide better error messages + if !call_appears_satisfied { + // The algorithm here is inspired by levenshtein distance and longest common subsequence. + // We'll try to detect 4 different types of mistakes: + // - An extra parameter has been provided that doesn't satisfy *any* of the other inputs + // - An input is missing, which isn't satisfied by *any* of the other arguments + // - Some number of arguments have been provided in the wrong order + // - A type is straight up invalid + + // First, fill in the rest of our compatibility matrix + for i in 0..provided_arg_count { + for j in 0..minimum_input_count { + if i == j { continue; } + compatibility_matrix[i][j] = check_compatible(i, j); + } + } + + // Obviously, detecting exact user intention is impossible, so the goal here is to + // come up with as likely of a story as we can to be helpful. + // + // We'll iteratively removed "satisfied" input/argument paris, + // then check for the cases above, until we've eliminated the entire grid + // + // We'll want to know which arguments and inputs these rows and columns correspond to + // even after we delete them, so these lookups will keep track of that + let mut input_indexes: Vec = (0..minimum_input_count).collect(); + let mut arg_indexes: Vec = (0..provided_arg_count).collect(); + + // First, set up some utility functions for the algorithm below + // Remove a given input or argument from consideration + let eliminate_input = |mat: &mut Vec>, ii: &mut Vec, idx| { + if idx >= ii.len() { + return; // FIXME: Should this ICE as a compiler bug? + } + ii.remove(idx); + for row in mat { + row.remove(idx); + } + }; + let eliminate_arg = |mat: &mut Vec>, ai: &mut Vec, idx| { + if idx >= ai.len() { + return; // FIXME: Should this ICE as a compiler bug? + } + ai.remove(idx); + mat.remove(idx); }; - for (i, arg) in args.iter().take(t).enumerate() { - // Warn only for the first loop (the "no closures" one). - // Closure arguments themselves can't be diverging, but - // a previous argument can, e.g., `foo(panic!(), || {})`. - if !check_closures { - self.warn_if_unreachable(arg.hir_id, arg.span, "expression"); + // "satisfy" an input with a given arg, removing both from consideration + let satisfy_input = |mat: &mut Vec>, + ii: &mut Vec, + ai: &mut Vec, + input_idx, + arg_idx| { + eliminate_input(mat, ii, input_idx); + eliminate_arg(mat, ai, arg_idx); + }; + + // A list of the issues we might find + enum Issue { + Invalid(usize), + Missing(usize), + Extra(usize), + Swap(usize, usize), + Permutation(Vec>), + } + // Check for the above mismatch cases + let find_issue = |mat: &Vec>, ii: &Vec, ai: &Vec| { + for i in 0..cmp::max(ai.len(), ii.len()) { + // If we eliminate the last row, any left-over inputs are considered missing + if i >= mat.len() { + return Some(Issue::Missing(i)); + } + // If we eliminate the last column, any left-over arguments are extra + if mat[i].len() == 0 { + return Some(Issue::Extra(i)); + } + + // Make sure we don't pass the bounds of our matrix + let is_arg = i < ai.len(); + let is_input = i < ii.len(); + if is_arg && is_input && mat[i][i] { + // This is a satisfied input, so move along + continue; + } + + let mut useless = true; + let mut unsatisfiable = true; + if is_arg { + for j in 0..ii.len() { + // If we find at least one input this argument could satisfy + // this argument isn't completely useless + if mat[i][j] { + useless = false; + break; + } + } + } + if is_input { + for j in 0..ai.len() { + // If we find at least one argument that could satisfy this input + // this argument isn't unsatisfiable + if mat[j][i] { + unsatisfiable = false; + break; + } + } + } + + match (is_arg, is_input, useless, unsatisfiable) { + // If an input is unsatisfied, and the argument in it's position is useless + // then the most likely explanation is that we just got the types wrong + (true, true, true, true) => return Some(Issue::Invalid(i)), + // Otherwise, if an input is useless, then indicate that this is an extra argument + (true, _, true, _) => return Some(Issue::Extra(i)), + // Otherwise, if an argument is unsatisfiable, indicate that it's missing + (_, true, _, true) => return Some(Issue::Missing(i)), + (true, true, _, _) => { + // The argument isn't useless, and the input isn't unsatisfied, + // so look for a parameter we might swap it with + // We look for swaps explicitly, instead of just falling back on permutations + // so that cases like (A,B,C,D) given (B,A,D,C) show up as two swaps, + // instead of a large permutation of 4 elements. + for j in 0..cmp::min(ai.len(), ii.len()) { + if i == j || mat[j][j] { + continue; + } + if mat[i][j] && mat[j][i] { + return Some(Issue::Swap(i, j)); + } + } + } + _ => { + continue; + } + }; + } + + // We didn't find any of the individual issues above, but + // there might be a larger permutation of parameters, so we now check for that + // by checking for cycles + // We use a double option at position i in this vec to represent: + // - None: We haven't computed anything about this argument yet + // - Some(None): This argument definitely doesn't participate in a cycle + // - Some(Some(x)): the i-th argument could permute to the x-th position + let mut permutation: Vec>> = vec![None; mat.len()]; + let mut permutation_found = false; + for i in 0..mat.len() { + if permutation[i].is_some() { + // We've already decided whether this argument is or is not in a loop + continue; + } + + let mut stack = vec![]; + let mut j = i; + let mut last = i; + let mut is_cycle = true; + loop { + stack.push(j); + // Look for params this one could slot into + let compat: Vec<_> = mat[j] + .iter() + .enumerate() + .filter(|(_, &c)| c) + .map(|(i, _)| i) + .collect(); + if compat.len() != 1 { + // this could go into multipl slots, don't bother exploring both + is_cycle = false; + break; + } + j = compat[0]; + if stack.contains(&j) { + last = j; + break; + } + } + if stack.len() <= 2 { + // If we encounter a cycle of 1 or 2 elements, we'll let the + // "satisfy" and "swap" code above handle those + } + // We've built up some chain, some of which might be a cycle + // ex: [1,2,3,4]; last = 2; j = 2; + // So, we want to mark 4, 3, and 2 as part of a permutation + permutation_found = is_cycle; + while let Some(x) = stack.pop() { + if is_cycle { + permutation[x] = Some(Some(j)); + j = x; + if j == last { + // From here on out, we're a tail leading into a cycle, + // not the cycle itself + is_cycle = false; + } + } else { + // Some(None) ensures we save time by skipping this argument again + permutation[x] = Some(None); + } + } } - let is_closure = matches!(arg.kind, ExprKind::Closure(..)); + if permutation_found { + // Map unwrap to remove the first layer of Some + let final_permutation: Vec> = + permutation.iter().map(|x| x.unwrap()).collect(); + return Some(Issue::Permutation(final_permutation)); + } + return None; + }; - if is_closure != check_closures { - continue; + // As we encounter issues, we'll transcribe them to their actual indices + let mut issues: Vec = vec![]; + // Until we've elimineated / satisfied all arguments/inputs + while input_indexes.len() > 0 || arg_indexes.len() > 0 { + // Check for the first relevant issue + match find_issue(&compatibility_matrix, &input_indexes, &arg_indexes) { + Some(Issue::Invalid(idx)) => { + // Eliminate the input and the arg, while transposing to the original index + issues.push(Issue::Invalid(arg_indexes[idx])); + eliminate_input(&mut compatibility_matrix, &mut input_indexes, idx); + eliminate_arg(&mut compatibility_matrix, &mut arg_indexes, idx); + } + Some(Issue::Extra(idx)) => { + issues.push(Issue::Extra(arg_indexes[idx])); + eliminate_arg(&mut compatibility_matrix, &mut arg_indexes, idx); + } + Some(Issue::Missing(idx)) => { + // FIXME: improve these with help from code reviewers + let input_ty = self.resolve_vars_if_possible(expected_input_tys[input_indexes[idx]]); + if input_ty.is_unit() { + info!("~~~ Issue: Maybe use ()?"); // FIXME + } + issues.push(Issue::Missing(input_indexes[idx])); + eliminate_input(&mut compatibility_matrix, &mut input_indexes, idx); + } + Some(Issue::Swap(idx, other)) => { + issues.push(Issue::Swap(arg_indexes[idx], arg_indexes[other])); + let (min, max) = (cmp::min(idx, other), cmp::max(idx, other)); + satisfy_input( + &mut compatibility_matrix, + &mut input_indexes, + &mut arg_indexes, + min, max, + ); + satisfy_input( + &mut compatibility_matrix, + &mut input_indexes, + &mut arg_indexes, + max - 1, // Subtract 1 because we already removed the "min" row + min, + ); + } + Some(Issue::Permutation(args)) => { + // FIXME: If satisfy_input ever did anything non-trivial (emit obligations to help type checking, for example) + // we'd want to call this function with the correct arg/input pairs, but for now, we just throw them in a bucket. + // This works because they force a cycle, so each row is guaranteed to also be a column + let mut idxs: Vec = args.iter().filter(|a| a.is_some()).map(|a| a.unwrap()).collect(); + // FIXME: Is there a cleaner way to do this? + let mut real_idxs = vec![None; provided_args.len()]; + for (src, dst) in args.iter().enumerate() { + real_idxs[arg_indexes[src]] = dst.map(|dst| arg_indexes[dst]); + } + issues.push(Issue::Permutation(real_idxs)); + idxs.sort(); + idxs.reverse(); + for i in idxs { + satisfy_input( + &mut compatibility_matrix, + &mut input_indexes, + &mut arg_indexes, + i, + i, + ); + } + } + None => { + // We didn't find any issues, so we need to push the algorithm forward + // First, eliminate any arguments that currently satisfy their inputs + let mut i = cmp:: min(arg_indexes.len(), input_indexes.len()); + while i > 0 { + let idx = i - 1; + if compatibility_matrix[idx][idx] { + satisfy_input( + &mut compatibility_matrix, + &mut input_indexes, + &mut arg_indexes, + idx, + idx, + ); + } + i -= 1; + } + } + }; + } + + if issues.len() > 0 { + // We found issues, so lets construct a diagnostic that summarizes the issues we found + // FIXME: This might need some refining in code review + let mut labels = vec![]; + let mut suggestions = vec![]; + let source_map = self.sess().source_map(); + for issue in issues { + match issue { + Issue::Invalid(arg) => { + let span = provided_args[arg].span; + labels.push((span, "expected `TE`, found `TF`")); // FIXME: find actual types + suggestions.push((span, "".to_string())); // FIXME: find actual type + } + Issue::Extra(arg) => { + // FIXME: This could be a lot cleaner, but I dunno how + let span = provided_args[arg].span; + let hungry_span = Span::new( + span.lo(), + BytePos(span.hi().to_u32() + 2u32), + span.ctxt(), + ); // Eat the comma + // FIXME: find the actual types / names + labels.push((span, "no parameter of type `TF` is needed in `fn_name`")); + suggestions.push((hungry_span, "".to_string())); + } + Issue::Missing(arg) => { + // FIXME: do this celaner, if possible. Handle `missing()`, etc + let prev_span = provided_args[arg].span; + let missing_span = Span::new( + BytePos(prev_span.hi().to_u32() + 1u32), + BytePos(prev_span.hi().to_u32() + 1u32), + prev_span.ctxt(), + ); + labels.push((missing_span, "missing argument of type `TE`")); // FIXME: find the type name + suggestions.push((missing_span, " ,".to_string())); // FIXME: find the type name + } + Issue::Swap(arg, other) => { + let first_span = provided_args[arg].span; + let second_span = provided_args[other].span; + let first_snippet = source_map.span_to_snippet(first_span).unwrap(); + let second_snippet = source_map.span_to_snippet(second_span).unwrap(); + labels.push((first_span, "expected `T1`, found `T2`")); // FIXME: Find the type name + suggestions.push((first_span, second_snippet)); + labels.push((second_span, "expected `T2`, found `T1`")); // FIXME: Find the type name + suggestions.push((second_span, first_snippet)); + } + Issue::Permutation(args) => { + for (src, &arg) in args.iter().enumerate() { + if let Some(dst) = arg { + let src_span = provided_args[src].span; + let dst_span = provided_args[dst].span; + let snippet = source_map.span_to_snippet(src_span).unwrap(); + labels.push((dst_span, "expected `{}`, found `{}`")); // FIXME: find the type names + suggestions.push((dst_span, snippet)); + } + } + } + } } - debug!("checking the argument"); - let formal_ty = formal_tys[i]; + // Now construct our error from the various things we've labeled + let highlight_sp = MultiSpan::from_spans(labels.iter().map(|s| s.0).collect()); + let mut err = struct_span_err!( + tcx.sess, + highlight_sp, + E0059, // FIXME: Choose a different code? + "multiple arguments to this function are incorrect" + ); + + // Call out where the function is defined + if let Some(def_id) = fn_def_id { + 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()); + } + } - // The special-cased logic below has three functions: - // 1. Provide as good of an expected type as possible. - let expected = Expectation::rvalue_hint(self, expected_arg_tys[i]); + let def_kind = tcx.def_kind(def_id); + err.span_note(spans, &format!("{} defined here", def_kind.descr(def_id))); + } + } - let checked_ty = self.check_expr_with_expectation(&arg, expected); + // annotate each of the labels + for (span, label) in labels { + err.span_label(span, label); + } - // 2. Coerce to the most detailed type that could be coerced - // to, which is `expected_ty` if `rvalue_hint` returns an - // `ExpectHasType(expected_ty)`, or the `formal_ty` otherwise. - let coerce_ty = expected.only_has_type(self).unwrap_or(formal_ty); - // We're processing function arguments so we definitely want to use - // two-phase borrows. - self.demand_coerce(&arg, checked_ty, coerce_ty, None, AllowTwoPhase::Yes); - final_arg_types.push((i, checked_ty, coerce_ty)); + // And add a series of suggestions + // FIXME: for simpler cases, this might be overkill + err.multipart_suggestion( + "the arguments can be modified to be of the appropriate types in the right positions", + suggestions, + Applicability::MaybeIncorrect, + ); - // 3. Relate the expected type and the formal one, - // if the expected type was used for the coercion. - self.demand_suptype(arg.span, formal_ty, coerce_ty); + err.emit(); } } - // We also need to make sure we at least write the ty of the other - // arguments which we skipped above. + // If the function is c-style variadic, we skipped a bunch of arguments + // so we need to check those, and write out the types + // Ideally this would be folded into the above, for uniform style + // but c-variadic is already a corner case if c_variadic { fn variadic_error<'tcx>(s: &Session, span: Span, t: Ty<'tcx>, cast_ty: &str) { use crate::structured_errors::{StructuredDiagnostic, VariadicError}; VariadicError::new(s, span, t, cast_ty).diagnostic().emit(); } - for arg in args.iter().skip(expected_arg_count) { + for arg in provided_args.iter().skip(minimum_input_count) { let arg_ty = self.check_expr(&arg); - // There are a few types which get autopromoted when passed via varargs + // There are a few types which can get autopromoted when passed via varargs // in C but we just error out instead and require explicit casts. let arg_ty = self.structurally_resolved_type(arg.span, arg_ty); match arg_ty.kind() { From c266c4ce4073d86edb95367c72407d825b03d147 Mon Sep 17 00:00:00 2001 From: Pi Lanningham Date: Sun, 3 May 2020 02:59:37 -0400 Subject: [PATCH 02/21] Adds some basic test cases Much more to come as code review progresses. --- src/test/ui/argument-suggestions/basic.rs | 37 +++++++++++ src/test/ui/argument-suggestions/basic.stderr | 62 +++++++++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 src/test/ui/argument-suggestions/basic.rs create mode 100644 src/test/ui/argument-suggestions/basic.stderr diff --git a/src/test/ui/argument-suggestions/basic.rs b/src/test/ui/argument-suggestions/basic.rs new file mode 100644 index 0000000000000..4495b0d11eb44 --- /dev/null +++ b/src/test/ui/argument-suggestions/basic.rs @@ -0,0 +1,37 @@ +enum E { + X, + Y +} +enum F { + X2, + Y2 +} +struct G { +} +struct H { +} +struct X {} +struct Y {} +struct Z {} + + +fn invalid(_i: u32) {} + +fn extra() {} + +fn missing(_i: u32) {} + +fn swapped(_i: u32, _s: &str) {} + +fn permuted(_x: X, _y: Y, _z: Z) {} + +fn complex(_i: u32, _s: &str, _e: E, _f: F, _g: G, _x: X, _y: Y, _z: Z ) {} + +fn main() { + invalid(1.0); //~ ERROR arguments to this function are incorrect + extra(&""); //~ ERROR arguments to this function are incorrect + missing(); //~ ERROR arguments to this function are incorrect + swapped(&"", 1); //~ ERROR arguments to this function are incorrect + permuted(Y {}, Z {}, X {}); //~ ERROR arguments to this function are incorrect + complex(1.0, H {}, &"", G{}, F::X2, Z {}, X {}, Y {}); //~ ERROR arguments to this function are incorrect +} \ No newline at end of file diff --git a/src/test/ui/argument-suggestions/basic.stderr b/src/test/ui/argument-suggestions/basic.stderr new file mode 100644 index 0000000000000..b4afa6aad450a --- /dev/null +++ b/src/test/ui/argument-suggestions/basic.stderr @@ -0,0 +1,62 @@ +error[E0059]: one or more arguments to this function are incorrect + --> $DIR/basic.rs:31:5 + | +LL | invalid(1.0); + | ^^^^^^^^---^ + | | + | the type of this argument is incorrect + +error[E0059]: one or more arguments to this function are incorrect + --> $DIR/basic.rs:32:5 + | +LL | extra(&""); + | ^^^^^^---^ + | | + | this argument appears to be extra + +error[E0059]: one or more arguments to this function are incorrect + --> $DIR/basic.rs:33:5 + | +LL | missing(); + | ^^^^^^^^^ + | + = note: the 1st parameter appears to be missing + +error[E0059]: one or more arguments to this function are incorrect + --> $DIR/basic.rs:34:5 + | +LL | swapped(&"", 1); + | ^^^^^^^^---^^-^ + | | | + | | these two arguments appear to be swapped + | these two arguments appear to be swapped + +error[E0059]: one or more arguments to this function are incorrect + --> $DIR/basic.rs:35:5 + | +LL | permuted(Y {}, Z {}, X {}); + | ^^^^^^^^^----^^----^^----^ + | | | | + | | | these 3 arguments appear to be in the wrong order + | | these 3 arguments appear to be in the wrong order + | these 3 arguments appear to be in the wrong order + +error[E0059]: one or more arguments to this function are incorrect + --> $DIR/basic.rs:36:5 + | +LL | complex(1.0, H {}, &"", G{}, F::X2, Z {}, X {}, Y {}); + | ^^^^^^^^---^^----^^^^^^^---^^-----^^----^^----^^----^ + | | | | | | | | + | | | | | | | these 3 arguments appear to be in the wrong order + | | | | | | these 3 arguments appear to be in the wrong order + | | | | | these 3 arguments appear to be in the wrong order + | | | | these two arguments appear to be swapped + | | | these two arguments appear to be swapped + | | this argument appears to be extra + | the type of this argument is incorrect + | + = note: the 3rd parameter appears to be missing + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0059`. From 7fc8e3cf381a4a0493cfc6622d00786f556f3f52 Mon Sep 17 00:00:00 2001 From: Pi Lanningham Date: Sun, 3 May 2020 07:42:42 +0000 Subject: [PATCH 03/21] Rust cleanup In a lot of these cases, I prefer the way I formatted the code, but I'll defer to the tidy script :) --- .../rustc_typeck/src/check/fn_ctxt/checks.rs | 57 ++++++++++--------- src/test/ui/argument-suggestions/basic.rs | 28 +++------ 2 files changed, 40 insertions(+), 45 deletions(-) diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs index d18393fa56321..c91fd9215de50 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs @@ -4,8 +4,8 @@ use crate::check::method::MethodCallee; use crate::check::Expectation::*; use crate::check::TupleArgumentsFlag::*; use crate::check::{ - struct_span_err, BreakableCtxt, Diverges, Expectation, FnCtxt, - LocalTy, Needs, TupleArgumentsFlag, + struct_span_err, BreakableCtxt, Diverges, Expectation, FnCtxt, LocalTy, Needs, + TupleArgumentsFlag, }; use rustc_ast as ast; @@ -19,13 +19,16 @@ use rustc_middle::ty::adjustment::AllowTwoPhase; use rustc_middle::ty::fold::TypeFoldable; use rustc_middle::ty::{self, Ty}; use rustc_session::Session; -use rustc_span::{BytePos, Pos, symbol::{sym, Ident}}; use rustc_span::{self, MultiSpan, Span}; +use rustc_span::{ + symbol::{sym, Ident}, + BytePos, Pos, +}; use rustc_trait_selection::traits::{self, ObligationCauseCode, StatementAsExpression}; +use std::cmp; use std::mem::replace; use std::slice; -use std::cmp; impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub(in super::super) fn check_casts(&self) { @@ -96,12 +99,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { &self, call_span: Span, // Span enclosing the call site call_expr: &'tcx hir::Expr<'tcx>, // Expression of the call site - formal_input_tys: &[Ty<'tcx>], // Types (as defined in the *signature* of the target function) - expected_input_tys: &[Ty<'tcx>], // More specific expected types, after unifying with caller output types + formal_input_tys: &[Ty<'tcx>], // Types (as defined in the *signature* of the target function) + expected_input_tys: &[Ty<'tcx>], // More specific expected types, after unifying with caller output types provided_args: &'tcx [hir::Expr<'tcx>], // The expressions for each provided argument - c_variadic: bool, // Whether the function is variadic, for example when imported from C - tuple_arguments: TupleArgumentsFlag, // Whether the arguments have been bundled in a tuple (ex: closures) - fn_def_id: Option, // The DefId for the function being called, for better error messages + c_variadic: bool, // Whether the function is variadic, for example when imported from C + tuple_arguments: TupleArgumentsFlag, // Whether the arguments have been bundled in a tuple (ex: closures) + fn_def_id: Option, // The DefId for the function being called, for better error messages ) { let tcx = self.tcx; @@ -198,7 +201,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let coerced_ty = expectation.only_has_type(self).unwrap_or(formal_input_ty); let coerced_ty = self.resolve_vars_with_obligations(coerced_ty); - let coerce_error = self.try_coerce(provided_arg, checked_ty, coerced_ty, AllowTwoPhase::Yes); + let coerce_error = + self.try_coerce(provided_arg, checked_ty, coerced_ty, AllowTwoPhase::Yes); // 3. Check if the formal type is a supertype of the checked one // and register any such obligations for future type checks @@ -262,7 +266,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.warn_if_unreachable( provided_args[idx].hir_id, provided_args[idx].span, - "expression" + "expression", ); // If we're past the end of the expected inputs, we won't have anything to check against @@ -327,14 +331,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // First, fill in the rest of our compatibility matrix for i in 0..provided_arg_count { for j in 0..minimum_input_count { - if i == j { continue; } + if i == j { + continue; + } compatibility_matrix[i][j] = check_compatible(i, j); } } // Obviously, detecting exact user intention is impossible, so the goal here is to // come up with as likely of a story as we can to be helpful. - // + // // We'll iteratively removed "satisfied" input/argument paris, // then check for the cases above, until we've eliminated the entire grid // @@ -398,7 +404,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // This is a satisfied input, so move along continue; } - + let mut useless = true; let mut unsatisfiable = true; if is_arg { @@ -473,12 +479,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { loop { stack.push(j); // Look for params this one could slot into - let compat: Vec<_> = mat[j] - .iter() - .enumerate() - .filter(|(_, &c)| c) - .map(|(i, _)| i) - .collect(); + let compat: Vec<_> = + mat[j].iter().enumerate().filter(|(_, &c)| c).map(|(i, _)| i).collect(); if compat.len() != 1 { // this could go into multipl slots, don't bother exploring both is_cycle = false; @@ -491,7 +493,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } if stack.len() <= 2 { - // If we encounter a cycle of 1 or 2 elements, we'll let the + // If we encounter a cycle of 1 or 2 elements, we'll let the // "satisfy" and "swap" code above handle those } // We've built up some chain, some of which might be a cycle @@ -541,7 +543,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } Some(Issue::Missing(idx)) => { // FIXME: improve these with help from code reviewers - let input_ty = self.resolve_vars_if_possible(expected_input_tys[input_indexes[idx]]); + let input_ty = + self.resolve_vars_if_possible(expected_input_tys[input_indexes[idx]]); if input_ty.is_unit() { info!("~~~ Issue: Maybe use ()?"); // FIXME } @@ -555,7 +558,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { &mut compatibility_matrix, &mut input_indexes, &mut arg_indexes, - min, max, + min, + max, ); satisfy_input( &mut compatibility_matrix, @@ -569,7 +573,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // FIXME: If satisfy_input ever did anything non-trivial (emit obligations to help type checking, for example) // we'd want to call this function with the correct arg/input pairs, but for now, we just throw them in a bucket. // This works because they force a cycle, so each row is guaranteed to also be a column - let mut idxs: Vec = args.iter().filter(|a| a.is_some()).map(|a| a.unwrap()).collect(); + let mut idxs: Vec = + args.iter().filter(|a| a.is_some()).map(|a| a.unwrap()).collect(); // FIXME: Is there a cleaner way to do this? let mut real_idxs = vec![None; provided_args.len()]; for (src, dst) in args.iter().enumerate() { @@ -591,7 +596,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { None => { // We didn't find any issues, so we need to push the algorithm forward // First, eliminate any arguments that currently satisfy their inputs - let mut i = cmp:: min(arg_indexes.len(), input_indexes.len()); + let mut i = cmp::min(arg_indexes.len(), input_indexes.len()); while i > 0 { let idx = i - 1; if compatibility_matrix[idx][idx] { @@ -677,7 +682,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { E0059, // FIXME: Choose a different code? "multiple arguments to this function are incorrect" ); - + // Call out where the function is defined if let Some(def_id) = fn_def_id { if let Some(node) = tcx.hir().get_if_local(def_id) { diff --git a/src/test/ui/argument-suggestions/basic.rs b/src/test/ui/argument-suggestions/basic.rs index 4495b0d11eb44..aca136a16baae 100644 --- a/src/test/ui/argument-suggestions/basic.rs +++ b/src/test/ui/argument-suggestions/basic.rs @@ -1,30 +1,19 @@ -enum E { - X, - Y -} -enum F { - X2, - Y2 -} -struct G { -} -struct H { -} +// Some basic "obvious" cases for the heuristic error messages added for #65853 + +enum E { X, Y } +enum F { X2, Y2 } +struct G {} +struct H {} struct X {} struct Y {} struct Z {} fn invalid(_i: u32) {} - fn extra() {} - fn missing(_i: u32) {} - fn swapped(_i: u32, _s: &str) {} - fn permuted(_x: X, _y: Y, _z: Z) {} - fn complex(_i: u32, _s: &str, _e: E, _f: F, _g: G, _x: X, _y: Y, _z: Z ) {} fn main() { @@ -33,5 +22,6 @@ fn main() { missing(); //~ ERROR arguments to this function are incorrect swapped(&"", 1); //~ ERROR arguments to this function are incorrect permuted(Y {}, Z {}, X {}); //~ ERROR arguments to this function are incorrect - complex(1.0, H {}, &"", G{}, F::X2, Z {}, X {}, Y {}); //~ ERROR arguments to this function are incorrect -} \ No newline at end of file + complex(1.0, H {}, &"", G{}, F::X2, Z {}, X {}, Y {}); + //~^ ERROR arguments to this function are incorrect +} From 5bf45b3e2d4c4b7187987c330bd748d7193f373d Mon Sep 17 00:00:00 2001 From: Pi Lanningham Date: Thu, 31 Dec 2020 04:44:10 -0500 Subject: [PATCH 04/21] Prevent an ICE on empty params I still need to handle this properly, but I just threw this in to avoid the ICE. I expect I'll have several rounds with code reviewers to refine things. --- compiler/rustc_typeck/src/check/fn_ctxt/checks.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs index c91fd9215de50..f22f0b258b25c 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs @@ -640,8 +640,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { suggestions.push((hungry_span, "".to_string())); } Issue::Missing(arg) => { - // FIXME: do this celaner, if possible. Handle `missing()`, etc - let prev_span = provided_args[arg].span; + // FIXME: do this cleaner, if possible. Handle `missing()`, etc + let prev_span = if arg < provided_args.len() { + provided_args[arg].span + } else { + call_span + }; let missing_span = Span::new( BytePos(prev_span.hi().to_u32() + 1u32), BytePos(prev_span.hi().to_u32() + 1u32), From f1916fa8b5bb7e69f145e70075a837092d38462a Mon Sep 17 00:00:00 2001 From: Pi Lanningham Date: Wed, 13 Jan 2021 00:25:42 -0500 Subject: [PATCH 05/21] Interpolate correct types into error messages For some reason I missed that you could just format!(ty) and get a human readable type for it. There's still lots to work out - What heuristics should we have around when to display the complicated labels? ex: with just one error, it's probably better for the user to provide the error but not the suggestion? Are "missing" parameter suggestions, where we don't have something to stick in there useful? - The semantics around the spans to use; when should we eat a comma, dealing with multiple inserted params, etc. --- .../rustc_typeck/src/check/fn_ctxt/checks.rs | 95 +++++++++----- src/test/ui/argument-suggestions/basic.stderr | 118 ++++++++++++------ 2 files changed, 144 insertions(+), 69 deletions(-) diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs index f22f0b258b25c..91a1d1ee39ec2 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs @@ -22,7 +22,7 @@ use rustc_session::Session; use rustc_span::{self, MultiSpan, Span}; use rustc_span::{ symbol::{sym, Ident}, - BytePos, Pos, + BytePos, }; use rustc_trait_selection::traits::{self, ObligationCauseCode, StatementAsExpression}; @@ -495,6 +495,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if stack.len() <= 2 { // If we encounter a cycle of 1 or 2 elements, we'll let the // "satisfy" and "swap" code above handle those + is_cycle = false; } // We've built up some chain, some of which might be a cycle // ex: [1,2,3,4]; last = 2; j = 2; @@ -614,7 +615,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }; } - if issues.len() > 0 { + let issue_count = issues.len(); + if issue_count > 0 { // We found issues, so lets construct a diagnostic that summarizes the issues we found // FIXME: This might need some refining in code review let mut labels = vec![]; @@ -624,44 +626,75 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { match issue { Issue::Invalid(arg) => { let span = provided_args[arg].span; - labels.push((span, "expected `TE`, found `TF`")); // FIXME: find actual types - suggestions.push((span, "".to_string())); // FIXME: find actual type + let expected_type = expected_input_tys[arg]; + let found_type = final_arg_types.iter().filter(|(i, _, _)| *i == arg).next().unwrap().1; + labels.push((span, format!("expected {}, found {}", expected_type, found_type))); } Issue::Extra(arg) => { - // FIXME: This could be a lot cleaner, but I dunno how + // FIXME: This could probably be a lot cleaner, but I dunno how let span = provided_args[arg].span; - let hungry_span = Span::new( - span.lo(), - BytePos(span.hi().to_u32() + 2u32), - span.ctxt(), - ); // Eat the comma - // FIXME: find the actual types / names - labels.push((span, "no parameter of type `TF` is needed in `fn_name`")); - suggestions.push((hungry_span, "".to_string())); + let hungry_span = if arg < provided_args.len() - 1 { + // Eat the comma + Span::new( + span.lo(), + span.hi() + BytePos(2), + span.ctxt(), + ) + } else { + span + }; + let found_type = self.check_expr(&provided_args[arg]); + let fn_name = fn_def_id + .and_then(|def_id| tcx.hir().get_if_local(def_id)) + .and_then(|node| node.ident()) + .map(|ident| format!("fn {}(..)", ident)) + .unwrap_or("this function".to_string()); + + labels.push((span, format!("no parameter of type {} is needed in {}", found_type, fn_name))); + if issue_count > 1 { + suggestions.push((hungry_span, format!(""))); + } } Issue::Missing(arg) => { - // FIXME: do this cleaner, if possible. Handle `missing()`, etc + // FIXME: The spans here are all kinds of wrong for multiple missing arguments etc. let prev_span = if arg < provided_args.len() { provided_args[arg].span } else { call_span }; - let missing_span = Span::new( - BytePos(prev_span.hi().to_u32() + 1u32), - BytePos(prev_span.hi().to_u32() + 1u32), - prev_span.ctxt(), - ); - labels.push((missing_span, "missing argument of type `TE`")); // FIXME: find the type name - suggestions.push((missing_span, " ,".to_string())); // FIXME: find the type name + // If we're missing something in the middle, shift the span slightly to eat the comma + let missing_span = if arg < provided_args.len() { + Span::new( + prev_span.hi() + BytePos(1), + prev_span.hi() + BytePos(1), + prev_span.ctxt(), + ) + } else { + Span::new( + prev_span.hi() - BytePos(1), + prev_span.hi() - BytePos(1), + prev_span.ctxt(), + ) + }; + let expected_type = expected_input_tys[arg]; + labels.push((missing_span, format!("missing argument of type {}", expected_type))); + if issue_count > 1 { + suggestions.push((missing_span, format!(" {{{}}},", expected_type))); + } } Issue::Swap(arg, other) => { let first_span = provided_args[arg].span; let second_span = provided_args[other].span; let first_snippet = source_map.span_to_snippet(first_span).unwrap(); let second_snippet = source_map.span_to_snippet(second_span).unwrap(); - labels.push((first_span, "expected `T1`, found `T2`")); // FIXME: Find the type name + let expected_types = (expected_input_tys[arg], expected_input_tys[other]); + let found_types = ( + final_arg_types.iter().filter(|(i, _, _)| *i == arg).next().unwrap().1, + final_arg_types.iter().filter(|(i, _, _)| *i == other).next().unwrap().1, + ); + labels.push((first_span, format!("expected {}, found {}", expected_types.0, found_types.0))); suggestions.push((first_span, second_snippet)); - labels.push((second_span, "expected `T2`, found `T1`")); // FIXME: Find the type name + labels.push((second_span, format!("expected {}, found {}", expected_types.1, found_types.1))); suggestions.push((second_span, first_snippet)); } Issue::Permutation(args) => { @@ -670,7 +703,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let src_span = provided_args[src].span; let dst_span = provided_args[dst].span; let snippet = source_map.span_to_snippet(src_span).unwrap(); - labels.push((dst_span, "expected `{}`, found `{}`")); // FIXME: find the type names + let expected_type = expected_input_tys[dst]; + let found_type = final_arg_types.iter().filter(|(i, _, _)| *i == dst).next().unwrap().1; + labels.push((dst_span, format!("expected {}, found {}", expected_type, found_type))); suggestions.push((dst_span, snippet)); } } @@ -715,11 +750,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // And add a series of suggestions // FIXME: for simpler cases, this might be overkill - err.multipart_suggestion( - "the arguments can be modified to be of the appropriate types in the right positions", - suggestions, - Applicability::MaybeIncorrect, - ); + if suggestions.len() > 0 { + err.multipart_suggestion( + "the following changes might help", + suggestions, + Applicability::MaybeIncorrect, + ); + } err.emit(); } diff --git a/src/test/ui/argument-suggestions/basic.stderr b/src/test/ui/argument-suggestions/basic.stderr index b4afa6aad450a..f7fb8bec0111f 100644 --- a/src/test/ui/argument-suggestions/basic.stderr +++ b/src/test/ui/argument-suggestions/basic.stderr @@ -1,61 +1,99 @@ -error[E0059]: one or more arguments to this function are incorrect - --> $DIR/basic.rs:31:5 +error[E0059]: multiple arguments to this function are incorrect + --> $DIR/basic.rs:20:13 | LL | invalid(1.0); - | ^^^^^^^^---^ - | | - | the type of this argument is incorrect + | ^^^ expected u32, found {float} + | +note: function defined here + --> $DIR/basic.rs:12:4 + | +LL | fn invalid(_i: u32) {} + | ^^^^^^^ ------- -error[E0059]: one or more arguments to this function are incorrect - --> $DIR/basic.rs:32:5 +error[E0059]: multiple arguments to this function are incorrect + --> $DIR/basic.rs:21:11 | LL | extra(&""); - | ^^^^^^---^ - | | - | this argument appears to be extra + | ^^^ no parameter of type &&'static str is needed in fn extra(..) + | +note: function defined here + --> $DIR/basic.rs:13:4 + | +LL | fn extra() {} + | ^^^^^ -error[E0059]: one or more arguments to this function are incorrect - --> $DIR/basic.rs:33:5 +error[E0059]: multiple arguments to this function are incorrect + --> $DIR/basic.rs:22:13 | LL | missing(); - | ^^^^^^^^^ + | ^ missing argument of type u32 + | +note: function defined here + --> $DIR/basic.rs:14:4 | - = note: the 1st parameter appears to be missing +LL | fn missing(_i: u32) {} + | ^^^^^^^ ------- -error[E0059]: one or more arguments to this function are incorrect - --> $DIR/basic.rs:34:5 +error[E0059]: multiple arguments to this function are incorrect + --> $DIR/basic.rs:23:13 | LL | swapped(&"", 1); - | ^^^^^^^^---^^-^ - | | | - | | these two arguments appear to be swapped - | these two arguments appear to be swapped + | ^^^ ^ expected &str, found {integer} + | | + | expected u32, found &&'static str + | +note: function defined here + --> $DIR/basic.rs:15:4 + | +LL | fn swapped(_i: u32, _s: &str) {} + | ^^^^^^^ ------- -------- +help: the following changes might help + | +LL | swapped(1, &""); + | ^ ^^^ -error[E0059]: one or more arguments to this function are incorrect - --> $DIR/basic.rs:35:5 +error[E0059]: multiple arguments to this function are incorrect + --> $DIR/basic.rs:24:14 | LL | permuted(Y {}, Z {}, X {}); - | ^^^^^^^^^----^^----^^----^ - | | | | - | | | these 3 arguments appear to be in the wrong order - | | these 3 arguments appear to be in the wrong order - | these 3 arguments appear to be in the wrong order + | ^^^^ ^^^^ ^^^^ expected Z, found X + | | | + | | expected Y, found Z + | expected X, found Y + | +note: function defined here + --> $DIR/basic.rs:16:4 + | +LL | fn permuted(_x: X, _y: Y, _z: Z) {} + | ^^^^^^^^ ----- ----- ----- +help: the following changes might help + | +LL | permuted(X {}, Y {}, Z {}); + | ^^^^ ^^^^ ^^^^ -error[E0059]: one or more arguments to this function are incorrect - --> $DIR/basic.rs:36:5 +error[E0059]: multiple arguments to this function are incorrect + --> $DIR/basic.rs:25:13 | LL | complex(1.0, H {}, &"", G{}, F::X2, Z {}, X {}, Y {}); - | ^^^^^^^^---^^----^^^^^^^---^^-----^^----^^----^^----^ - | | | | | | | | - | | | | | | | these 3 arguments appear to be in the wrong order - | | | | | | these 3 arguments appear to be in the wrong order - | | | | | these 3 arguments appear to be in the wrong order - | | | | these two arguments appear to be swapped - | | | these two arguments appear to be swapped - | | this argument appears to be extra - | the type of this argument is incorrect - | - = note: the 3rd parameter appears to be missing + | ^^^ ^^^^ ^^^^ ^^^^^ ^^^^ ^^^^ ^^^^ expected Z, found Y + | | | || | | | + | | | || | | expected Y, found X + | | | || | expected X, found Z + | | | || expected G, found F + | | | |expected F, found G + | | | missing argument of type E + | | no parameter of type H is needed in fn complex(..) + | expected u32, found {float} + | +note: function defined here + --> $DIR/basic.rs:17:4 + | +LL | fn complex(_i: u32, _s: &str, _e: E, _f: F, _g: G, _x: X, _y: Y, _z: Z ) {} + | ^^^^^^^ ------- -------- ----- ----- ----- ----- ----- ------ +help: the following changes might help + | +LL | complex(1.0, &"", {E}, F::X2, G{}, X {}, Y {}, Z {}); + | -- ^^^^ ^^^^^ ^^^ ^^^^ ^^^^ ^^^^ error: aborting due to 6 previous errors From ae3c859f60abc0021bff58aadb4533e90f112729 Mon Sep 17 00:00:00 2001 From: Pi Lanningham Date: Wed, 13 Jan 2021 10:30:07 -0500 Subject: [PATCH 06/21] Fix a comment typo Co-authored-by: Joshua Nelson --- compiler/rustc_typeck/src/check/fn_ctxt/checks.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs index 91a1d1ee39ec2..1cc58c935eb9e 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs @@ -221,7 +221,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { (coerce_error.is_ok() && is_supertype, checked_ty, coerced_ty) }; - // A "softer" version of the hlper above, which checks types without persisting them, + // A "softer" version of the helper above, which checks types without persisting them, // and treats error types differently // This will allow us to "probe" for other argument orders that would likely have been correct let check_compatible = |arg_idx, input_idx| { From 93ee0af81a309d7318679bd6a97ce07b77da7849 Mon Sep 17 00:00:00 2001 From: Pi Lanningham Date: Thu, 14 Jan 2021 01:01:09 -0500 Subject: [PATCH 07/21] Small tweaks / typos fixed from code review No substantial changes here, just using more idiomatic rust and fixing typos in the comments --- .../rustc_typeck/src/check/fn_ctxt/checks.rs | 58 +++++++++++-------- src/test/ui/argument-suggestions/basic.stderr | 14 ++--- 2 files changed, 41 insertions(+), 31 deletions(-) diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs index 1cc58c935eb9e..f5412604b3f0c 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs @@ -97,14 +97,22 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// method calls and overloaded operators. pub(in super::super) fn check_argument_types( &self, - call_span: Span, // Span enclosing the call site - call_expr: &'tcx hir::Expr<'tcx>, // Expression of the call site - formal_input_tys: &[Ty<'tcx>], // Types (as defined in the *signature* of the target function) - expected_input_tys: &[Ty<'tcx>], // More specific expected types, after unifying with caller output types - provided_args: &'tcx [hir::Expr<'tcx>], // The expressions for each provided argument - c_variadic: bool, // Whether the function is variadic, for example when imported from C - tuple_arguments: TupleArgumentsFlag, // Whether the arguments have been bundled in a tuple (ex: closures) - fn_def_id: Option, // The DefId for the function being called, for better error messages + // Span enclosing the call site + call_span: Span, + // Expression of the call site + call_expr: &'tcx hir::Expr<'tcx>, + // Types (as defined in the *signature* of the target function) + formal_input_tys: &[Ty<'tcx>], + // More specific expected types, after unifying with caller output types + expected_input_tys: &[Ty<'tcx>], + // The expressions for each provided argument + provided_args: &'tcx [hir::Expr<'tcx>], + // Whether the function is variadic, for example when imported from C + c_variadic: bool, + // Whether the arguments have been bundled in a tuple (ex: closures) + tuple_arguments: TupleArgumentsFlag, + // The DefId for the function being called, for better error messages + fn_def_id: Option, ) { let tcx = self.tcx; @@ -429,7 +437,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } match (is_arg, is_input, useless, unsatisfiable) { - // If an input is unsatisfied, and the argument in it's position is useless + // If an input is unsatisfied, and the argument in its position is useless // then the most likely explanation is that we just got the types wrong (true, true, true, true) => return Some(Issue::Invalid(i)), // Otherwise, if an input is useless, then indicate that this is an extra argument @@ -480,9 +488,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { stack.push(j); // Look for params this one could slot into let compat: Vec<_> = - mat[j].iter().enumerate().filter(|(_, &c)| c).map(|(i, _)| i).collect(); + mat[j].iter().enumerate().filter_map(|(i, &c)| if c { Some(i) } else { None }).collect(); if compat.len() != 1 { - // this could go into multipl slots, don't bother exploring both + // this could go into multiple slots, don't bother exploring both is_cycle = false; break; } @@ -520,7 +528,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if permutation_found { // Map unwrap to remove the first layer of Some let final_permutation: Vec> = - permutation.iter().map(|x| x.unwrap()).collect(); + permutation.into_iter().map(|x| x.unwrap()).collect(); return Some(Issue::Permutation(final_permutation)); } return None; @@ -575,7 +583,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // we'd want to call this function with the correct arg/input pairs, but for now, we just throw them in a bucket. // This works because they force a cycle, so each row is guaranteed to also be a column let mut idxs: Vec = - args.iter().filter(|a| a.is_some()).map(|a| a.unwrap()).collect(); + args.iter() + .filter_map(|&a| a) + .collect(); // FIXME: Is there a cleaner way to do this? let mut real_idxs = vec![None; provided_args.len()]; for (src, dst) in args.iter().enumerate() { @@ -617,7 +627,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let issue_count = issues.len(); if issue_count > 0 { - // We found issues, so lets construct a diagnostic that summarizes the issues we found + // We found issues, so let's construct a diagnostic that summarizes the issues we found // FIXME: This might need some refining in code review let mut labels = vec![]; let mut suggestions = vec![]; @@ -627,7 +637,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { Issue::Invalid(arg) => { let span = provided_args[arg].span; let expected_type = expected_input_tys[arg]; - let found_type = final_arg_types.iter().filter(|(i, _, _)| *i == arg).next().unwrap().1; + let found_type = final_arg_types.iter().find(|(i, _, _)| *i == arg).unwrap().1; labels.push((span, format!("expected {}, found {}", expected_type, found_type))); } Issue::Extra(arg) => { @@ -645,10 +655,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }; let found_type = self.check_expr(&provided_args[arg]); let fn_name = fn_def_id - .and_then(|def_id| tcx.hir().get_if_local(def_id)) - .and_then(|node| node.ident()) - .map(|ident| format!("fn {}(..)", ident)) - .unwrap_or("this function".to_string()); + .map(|def_id| (tcx.def_kind(def_id), def_id)) + .map(|(def_kind, def_id)| def_kind.descr(def_id)) + .unwrap_or("this function"); labels.push((span, format!("no parameter of type {} is needed in {}", found_type, fn_name))); if issue_count > 1 { @@ -689,8 +698,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let second_snippet = source_map.span_to_snippet(second_span).unwrap(); let expected_types = (expected_input_tys[arg], expected_input_tys[other]); let found_types = ( - final_arg_types.iter().filter(|(i, _, _)| *i == arg).next().unwrap().1, - final_arg_types.iter().filter(|(i, _, _)| *i == other).next().unwrap().1, + final_arg_types.iter().find(|(i, _, _)| *i == arg).unwrap().1, + final_arg_types.iter().find(|(i, _, _)| *i == other).unwrap().1, ); labels.push((first_span, format!("expected {}, found {}", expected_types.0, found_types.0))); suggestions.push((first_span, second_snippet)); @@ -704,7 +713,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let dst_span = provided_args[dst].span; let snippet = source_map.span_to_snippet(src_span).unwrap(); let expected_type = expected_input_tys[dst]; - let found_type = final_arg_types.iter().filter(|(i, _, _)| *i == dst).next().unwrap().1; + let found_type = final_arg_types.iter().find(|(i, _, _)| *i == dst).unwrap().1; labels.push((dst_span, format!("expected {}, found {}", expected_type, found_type))); suggestions.push((dst_span, snippet)); } @@ -719,7 +728,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { tcx.sess, highlight_sp, E0059, // FIXME: Choose a different code? - "multiple arguments to this function are incorrect" + "{}arguments to this function are incorrect", + if issue_count > 1 { "multiple " } else { "" } ); // Call out where the function is defined @@ -775,7 +785,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { for arg in provided_args.iter().skip(minimum_input_count) { let arg_ty = self.check_expr(&arg); - // There are a few types which can get autopromoted when passed via varargs + // There are a few types which get autopromoted when passed via varargs // in C but we just error out instead and require explicit casts. let arg_ty = self.structurally_resolved_type(arg.span, arg_ty); match arg_ty.kind() { diff --git a/src/test/ui/argument-suggestions/basic.stderr b/src/test/ui/argument-suggestions/basic.stderr index f7fb8bec0111f..541d772ba5509 100644 --- a/src/test/ui/argument-suggestions/basic.stderr +++ b/src/test/ui/argument-suggestions/basic.stderr @@ -1,4 +1,4 @@ -error[E0059]: multiple arguments to this function are incorrect +error[E0059]: arguments to this function are incorrect --> $DIR/basic.rs:20:13 | LL | invalid(1.0); @@ -10,11 +10,11 @@ note: function defined here LL | fn invalid(_i: u32) {} | ^^^^^^^ ------- -error[E0059]: multiple arguments to this function are incorrect +error[E0059]: arguments to this function are incorrect --> $DIR/basic.rs:21:11 | LL | extra(&""); - | ^^^ no parameter of type &&'static str is needed in fn extra(..) + | ^^^ no parameter of type &&'static str is needed in function | note: function defined here --> $DIR/basic.rs:13:4 @@ -22,7 +22,7 @@ note: function defined here LL | fn extra() {} | ^^^^^ -error[E0059]: multiple arguments to this function are incorrect +error[E0059]: arguments to this function are incorrect --> $DIR/basic.rs:22:13 | LL | missing(); @@ -34,7 +34,7 @@ note: function defined here LL | fn missing(_i: u32) {} | ^^^^^^^ ------- -error[E0059]: multiple arguments to this function are incorrect +error[E0059]: arguments to this function are incorrect --> $DIR/basic.rs:23:13 | LL | swapped(&"", 1); @@ -52,7 +52,7 @@ help: the following changes might help LL | swapped(1, &""); | ^ ^^^ -error[E0059]: multiple arguments to this function are incorrect +error[E0059]: arguments to this function are incorrect --> $DIR/basic.rs:24:14 | LL | permuted(Y {}, Z {}, X {}); @@ -82,7 +82,7 @@ LL | complex(1.0, H {}, &"", G{}, F::X2, Z {}, X {}, Y {}); | | | || expected G, found F | | | |expected F, found G | | | missing argument of type E - | | no parameter of type H is needed in fn complex(..) + | | no parameter of type H is needed in function | expected u32, found {float} | note: function defined here From f369af645d258459b0208f50756daa559f51f26f Mon Sep 17 00:00:00 2001 From: Pi Lanningham Date: Thu, 14 Jan 2021 03:02:45 -0500 Subject: [PATCH 08/21] Add a ton of test cases, refine error messages Refined the error messages a bit to be more context sensitive, added quite a few test cases. I'll need help adding cases with trait constraints and other tricky corner cases. --- .../rustc_typeck/src/check/fn_ctxt/checks.rs | 71 +++- src/test/ui/argument-suggestions/basic.rs | 8 +- src/test/ui/argument-suggestions/basic.stderr | 57 +-- src/test/ui/argument-suggestions/complex.rs | 16 + .../ui/argument-suggestions/complex.stderr | 27 ++ .../argument-suggestions/extra_arguments.rs | 20 + .../extra_arguments.stderr | 168 +++++++++ .../argument-suggestions/invalid_arguments.rs | 43 +++ .../invalid_arguments.stderr | 349 ++++++++++++++++++ .../argument-suggestions/missing_arguments.rs | 40 ++ .../missing_arguments.stderr | 314 ++++++++++++++++ .../ui/argument-suggestions/mixed_cases.rs | 24 ++ .../argument-suggestions/mixed_cases.stderr | 114 ++++++ .../permuted_arguments.rs | 13 + .../permuted_arguments.stderr | 43 +++ .../argument-suggestions/swapped_arguments.rs | 14 + .../swapped_arguments.stderr | 95 +++++ 17 files changed, 1357 insertions(+), 59 deletions(-) create mode 100644 src/test/ui/argument-suggestions/complex.rs create mode 100644 src/test/ui/argument-suggestions/complex.stderr create mode 100644 src/test/ui/argument-suggestions/extra_arguments.rs create mode 100644 src/test/ui/argument-suggestions/extra_arguments.stderr create mode 100644 src/test/ui/argument-suggestions/invalid_arguments.rs create mode 100644 src/test/ui/argument-suggestions/invalid_arguments.stderr create mode 100644 src/test/ui/argument-suggestions/missing_arguments.rs create mode 100644 src/test/ui/argument-suggestions/missing_arguments.stderr create mode 100644 src/test/ui/argument-suggestions/mixed_cases.rs create mode 100644 src/test/ui/argument-suggestions/mixed_cases.stderr create mode 100644 src/test/ui/argument-suggestions/permuted_arguments.rs create mode 100644 src/test/ui/argument-suggestions/permuted_arguments.stderr create mode 100644 src/test/ui/argument-suggestions/swapped_arguments.rs create mode 100644 src/test/ui/argument-suggestions/swapped_arguments.stderr diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs index f5412604b3f0c..5e5ada8e8a732 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs @@ -627,10 +627,22 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let issue_count = issues.len(); if issue_count > 0 { + // This represents the kind of wording we want to use on the suggestion + enum SuggestionType { + NoSuggestion, + Remove, // Suggest removing an argument + Provide, // Suggest providing an argument of a given type + Swap, // Suggest swapping a few arguments + Reorder, // Suggest an arbitrary permutation (more complicated than swaps) + Changes // Suggest a mixed bag of generic changes, which may include multiple of the above + } + use SuggestionType::*; + // We found issues, so let's construct a diagnostic that summarizes the issues we found // FIXME: This might need some refining in code review let mut labels = vec![]; let mut suggestions = vec![]; + let mut suggestion_type = NoSuggestion; let source_map = self.sess().source_map(); for issue in issues { match issue { @@ -639,6 +651,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let expected_type = expected_input_tys[arg]; let found_type = final_arg_types.iter().find(|(i, _, _)| *i == arg).unwrap().1; labels.push((span, format!("expected {}, found {}", expected_type, found_type))); + suggestion_type = match suggestion_type { + NoSuggestion | Provide => Provide, + _ => Changes, + }; + suggestions.push((span, format!(" {{{}}},", expected_type))); } Issue::Extra(arg) => { // FIXME: This could probably be a lot cleaner, but I dunno how @@ -655,14 +672,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }; let found_type = self.check_expr(&provided_args[arg]); let fn_name = fn_def_id - .map(|def_id| (tcx.def_kind(def_id), def_id)) - .map(|(def_kind, def_id)| def_kind.descr(def_id)) - .unwrap_or("this function"); + .and_then(|def_id| tcx.hir().get_if_local(def_id)) + .and_then(|node| node.ident()) + .map(|ident| format!("{}", ident)) + .unwrap_or("this function".to_string()); labels.push((span, format!("no parameter of type {} is needed in {}", found_type, fn_name))); - if issue_count > 1 { - suggestions.push((hungry_span, format!(""))); - } + suggestion_type = match suggestion_type { + NoSuggestion | Remove => Remove, + _ => Changes, + }; + suggestions.push((hungry_span, format!(""))); } Issue::Missing(arg) => { // FIXME: The spans here are all kinds of wrong for multiple missing arguments etc. @@ -687,9 +707,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }; let expected_type = expected_input_tys[arg]; labels.push((missing_span, format!("missing argument of type {}", expected_type))); - if issue_count > 1 { - suggestions.push((missing_span, format!(" {{{}}},", expected_type))); - } + suggestion_type = match suggestion_type { + NoSuggestion | Provide => Provide, + _ => Changes, + }; + suggestions.push((missing_span, format!(" {{{}}},", expected_type))); } Issue::Swap(arg, other) => { let first_span = provided_args[arg].span; @@ -705,6 +727,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { suggestions.push((first_span, second_snippet)); labels.push((second_span, format!("expected {}, found {}", expected_types.1, found_types.1))); suggestions.push((second_span, first_snippet)); + suggestion_type = match suggestion_type { + NoSuggestion | Swap => Swap, + _ => Changes, + }; } Issue::Permutation(args) => { for (src, &arg) in args.iter().enumerate() { @@ -716,6 +742,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let found_type = final_arg_types.iter().find(|(i, _, _)| *i == dst).unwrap().1; labels.push((dst_span, format!("expected {}, found {}", expected_type, found_type))); suggestions.push((dst_span, snippet)); + suggestion_type = match suggestion_type { + NoSuggestion | Reorder => Reorder, + _ => Changes, + }; } } } @@ -747,7 +777,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { 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))); } @@ -761,11 +790,23 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // And add a series of suggestions // FIXME: for simpler cases, this might be overkill if suggestions.len() > 0 { - err.multipart_suggestion( - "the following changes might help", - suggestions, - Applicability::MaybeIncorrect, - ); + let suggestion_text = match (suggestion_type, issue_count) { + (Remove, 1) => Some("removing this argument may help"), + (Remove, _) => Some("removing these argument may help"), + (Provide, 1) => None, + (Provide, _) => Some("providing these parameters may help"), + (Swap, 1) => Some("swapping these two arguments might help"), + (Swap, _) => Some("swapping these sets of arguments might help"), + (Reorder, _) => Some("reordering these parameters might help"), + _ => Some("the following changes might help"), + }; + if let Some(suggestion_text) = suggestion_text { + err.multipart_suggestion( + suggestion_text, + suggestions, + Applicability::MaybeIncorrect, + ); + } } err.emit(); diff --git a/src/test/ui/argument-suggestions/basic.rs b/src/test/ui/argument-suggestions/basic.rs index aca136a16baae..6846271ec07cf 100644 --- a/src/test/ui/argument-suggestions/basic.rs +++ b/src/test/ui/argument-suggestions/basic.rs @@ -1,4 +1,5 @@ // Some basic "obvious" cases for the heuristic error messages added for #65853 +// One for each of the detected cases enum E { X, Y } enum F { X2, Y2 } @@ -14,14 +15,11 @@ fn extra() {} fn missing(_i: u32) {} fn swapped(_i: u32, _s: &str) {} fn permuted(_x: X, _y: Y, _z: Z) {} -fn complex(_i: u32, _s: &str, _e: E, _f: F, _g: G, _x: X, _y: Y, _z: Z ) {} fn main() { invalid(1.0); //~ ERROR arguments to this function are incorrect - extra(&""); //~ ERROR arguments to this function are incorrect + extra(""); //~ ERROR arguments to this function are incorrect missing(); //~ ERROR arguments to this function are incorrect - swapped(&"", 1); //~ ERROR arguments to this function are incorrect + swapped("", 1); //~ ERROR arguments to this function are incorrect permuted(Y {}, Z {}, X {}); //~ ERROR arguments to this function are incorrect - complex(1.0, H {}, &"", G{}, F::X2, Z {}, X {}, Y {}); - //~^ ERROR arguments to this function are incorrect } diff --git a/src/test/ui/argument-suggestions/basic.stderr b/src/test/ui/argument-suggestions/basic.stderr index 541d772ba5509..518d2ce5d50ce 100644 --- a/src/test/ui/argument-suggestions/basic.stderr +++ b/src/test/ui/argument-suggestions/basic.stderr @@ -5,7 +5,7 @@ LL | invalid(1.0); | ^^^ expected u32, found {float} | note: function defined here - --> $DIR/basic.rs:12:4 + --> $DIR/basic.rs:13:4 | LL | fn invalid(_i: u32) {} | ^^^^^^^ ------- @@ -13,11 +13,14 @@ LL | fn invalid(_i: u32) {} error[E0059]: arguments to this function are incorrect --> $DIR/basic.rs:21:11 | -LL | extra(&""); - | ^^^ no parameter of type &&'static str is needed in function +LL | extra(""); + | ^^ + | | + | no parameter of type &'static str is needed in extra + | help: removing this argument may help | note: function defined here - --> $DIR/basic.rs:13:4 + --> $DIR/basic.rs:14:4 | LL | fn extra() {} | ^^^^^ @@ -29,7 +32,7 @@ LL | missing(); | ^ missing argument of type u32 | note: function defined here - --> $DIR/basic.rs:14:4 + --> $DIR/basic.rs:15:4 | LL | fn missing(_i: u32) {} | ^^^^^^^ ------- @@ -37,20 +40,20 @@ LL | fn missing(_i: u32) {} error[E0059]: arguments to this function are incorrect --> $DIR/basic.rs:23:13 | -LL | swapped(&"", 1); - | ^^^ ^ expected &str, found {integer} +LL | swapped("", 1); + | ^^ ^ expected &str, found {integer} | | - | expected u32, found &&'static str + | expected u32, found &'static str | note: function defined here - --> $DIR/basic.rs:15:4 + --> $DIR/basic.rs:16:4 | LL | fn swapped(_i: u32, _s: &str) {} | ^^^^^^^ ------- -------- -help: the following changes might help +help: swapping these two arguments might help | -LL | swapped(1, &""); - | ^ ^^^ +LL | swapped(1, ""); + | ^ ^^ error[E0059]: arguments to this function are incorrect --> $DIR/basic.rs:24:14 @@ -62,39 +65,15 @@ LL | permuted(Y {}, Z {}, X {}); | expected X, found Y | note: function defined here - --> $DIR/basic.rs:16:4 + --> $DIR/basic.rs:17:4 | LL | fn permuted(_x: X, _y: Y, _z: Z) {} | ^^^^^^^^ ----- ----- ----- -help: the following changes might help +help: reordering these parameters might help | LL | permuted(X {}, Y {}, Z {}); | ^^^^ ^^^^ ^^^^ -error[E0059]: multiple arguments to this function are incorrect - --> $DIR/basic.rs:25:13 - | -LL | complex(1.0, H {}, &"", G{}, F::X2, Z {}, X {}, Y {}); - | ^^^ ^^^^ ^^^^ ^^^^^ ^^^^ ^^^^ ^^^^ expected Z, found Y - | | | || | | | - | | | || | | expected Y, found X - | | | || | expected X, found Z - | | | || expected G, found F - | | | |expected F, found G - | | | missing argument of type E - | | no parameter of type H is needed in function - | expected u32, found {float} - | -note: function defined here - --> $DIR/basic.rs:17:4 - | -LL | fn complex(_i: u32, _s: &str, _e: E, _f: F, _g: G, _x: X, _y: Y, _z: Z ) {} - | ^^^^^^^ ------- -------- ----- ----- ----- ----- ----- ------ -help: the following changes might help - | -LL | complex(1.0, &"", {E}, F::X2, G{}, X {}, Y {}, Z {}); - | -- ^^^^ ^^^^^ ^^^ ^^^^ ^^^^ ^^^^ - -error: aborting due to 6 previous errors +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0059`. diff --git a/src/test/ui/argument-suggestions/complex.rs b/src/test/ui/argument-suggestions/complex.rs new file mode 100644 index 0000000000000..6e89dc2e6f378 --- /dev/null +++ b/src/test/ui/argument-suggestions/complex.rs @@ -0,0 +1,16 @@ +// A complex case with mixed suggestions from #65853 + +enum E { X, Y } +enum F { X2, Y2 } +struct G {} +struct H {} +struct X {} +struct Y {} +struct Z {} + +fn complex(_i: u32, _s: &str, _e: E, _f: F, _g: G, _x: X, _y: Y, _z: Z ) {} + +fn main() { + complex(1.0, H {}, &"", G{}, F::X2, Z {}, X {}, Y {}); + //~^ ERROR arguments to this function are incorrect +} \ No newline at end of file diff --git a/src/test/ui/argument-suggestions/complex.stderr b/src/test/ui/argument-suggestions/complex.stderr new file mode 100644 index 0000000000000..7f2d1ca2a1155 --- /dev/null +++ b/src/test/ui/argument-suggestions/complex.stderr @@ -0,0 +1,27 @@ +error[E0059]: multiple arguments to this function are incorrect + --> $DIR/complex.rs:14:11 + | +LL | complex(1.0, H {}, &"", G{}, F::X2, Z {}, X {}, Y {}); + | ^^^ ^^^^ ^^^^ ^^^^^ ^^^^ ^^^^ ^^^^ expected Z, found Y + | | | || | | | + | | | || | | expected Y, found X + | | | || | expected X, found Z + | | | || expected G, found F + | | | |expected F, found G + | | | missing argument of type E + | | no parameter of type H is needed in complex + | expected u32, found {float} + | +note: function defined here + --> $DIR/complex.rs:11:4 + | +LL | fn complex(_i: u32, _s: &str, _e: E, _f: F, _g: G, _x: X, _y: Y, _z: Z ) {} + | ^^^^^^^ ------- -------- ----- ----- ----- ----- ----- ------ +help: the following changes might help + | +LL | complex( {u32},, &"", {E}, F::X2, G{}, X {}, Y {}, Z {}); + | ^^^^^^ -- ^^^^ ^^^^^ ^^^ ^^^^ ^^^^ ^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0059`. diff --git a/src/test/ui/argument-suggestions/extra_arguments.rs b/src/test/ui/argument-suggestions/extra_arguments.rs new file mode 100644 index 0000000000000..5f8e192209839 --- /dev/null +++ b/src/test/ui/argument-suggestions/extra_arguments.rs @@ -0,0 +1,20 @@ +fn empty() {} +fn one_arg(_a: i32) {} +fn two_arg_same(_a: i32, _b: i32) {} +fn two_arg_diff(_a: i32, _b: &str) {} + +fn main() { + empty(""); //~ ERROR arguments to this function are incorrect + + one_arg(1, 1); //~ ERROR arguments to this function are incorrect + one_arg(1, ""); //~ ERROR arguments to this function are incorrect + one_arg(1, "", 1.0); //~ ERROR arguments to this function are incorrect + + two_arg_same(1, 1, 1); //~ ERROR arguments to this function are incorrect + two_arg_same(1, 1, 1.0); //~ ERROR arguments to this function are incorrect + + two_arg_diff(1, 1, ""); //~ ERROR arguments to this function are incorrect + two_arg_diff(1, "", ""); //~ ERROR arguments to this function are incorrect + two_arg_diff(1, 1, "", ""); //~ ERROR arguments to this function are incorrect + two_arg_diff(1, "", 1, ""); //~ ERROR arguments to this function are incorrect +} \ No newline at end of file diff --git a/src/test/ui/argument-suggestions/extra_arguments.stderr b/src/test/ui/argument-suggestions/extra_arguments.stderr new file mode 100644 index 0000000000000..2c2ee030e39c7 --- /dev/null +++ b/src/test/ui/argument-suggestions/extra_arguments.stderr @@ -0,0 +1,168 @@ +error[E0059]: arguments to this function are incorrect + --> $DIR/extra_arguments.rs:7:9 + | +LL | empty(""); + | ^^ + | | + | no parameter of type &'static str is needed in empty + | help: removing this argument may help + | +note: function defined here + --> $DIR/extra_arguments.rs:1:4 + | +LL | fn empty() {} + | ^^^^^ + +error[E0059]: arguments to this function are incorrect + --> $DIR/extra_arguments.rs:9:14 + | +LL | one_arg(1, 1); + | ^ + | | + | no parameter of type {integer} is needed in one_arg + | help: removing this argument may help + | +note: function defined here + --> $DIR/extra_arguments.rs:2:4 + | +LL | fn one_arg(_a: i32) {} + | ^^^^^^^ ------- + +error[E0059]: arguments to this function are incorrect + --> $DIR/extra_arguments.rs:10:14 + | +LL | one_arg(1, ""); + | ^^ + | | + | no parameter of type &'static str is needed in one_arg + | help: removing this argument may help + | +note: function defined here + --> $DIR/extra_arguments.rs:2:4 + | +LL | fn one_arg(_a: i32) {} + | ^^^^^^^ ------- + +error[E0059]: multiple arguments to this function are incorrect + --> $DIR/extra_arguments.rs:11:14 + | +LL | one_arg(1, "", 1.0); + | ^^ ^^^ no parameter of type {float} is needed in one_arg + | | + | no parameter of type &'static str is needed in one_arg + | +note: function defined here + --> $DIR/extra_arguments.rs:2:4 + | +LL | fn one_arg(_a: i32) {} + | ^^^^^^^ ------- +help: removing these argument may help + | +LL | one_arg(1, ); + | -- -- + +error[E0059]: arguments to this function are incorrect + --> $DIR/extra_arguments.rs:13:22 + | +LL | two_arg_same(1, 1, 1); + | ^ + | | + | no parameter of type {integer} is needed in two_arg_same + | help: removing this argument may help + | +note: function defined here + --> $DIR/extra_arguments.rs:3:4 + | +LL | fn two_arg_same(_a: i32, _b: i32) {} + | ^^^^^^^^^^^^ ------- ------- + +error[E0059]: arguments to this function are incorrect + --> $DIR/extra_arguments.rs:14:22 + | +LL | two_arg_same(1, 1, 1.0); + | ^^^ + | | + | no parameter of type {float} is needed in two_arg_same + | help: removing this argument may help + | +note: function defined here + --> $DIR/extra_arguments.rs:3:4 + | +LL | fn two_arg_same(_a: i32, _b: i32) {} + | ^^^^^^^^^^^^ ------- ------- + +error[E0059]: multiple arguments to this function are incorrect + --> $DIR/extra_arguments.rs:16:19 + | +LL | two_arg_diff(1, 1, ""); + | ^ ^^^ no parameter of type &'static str is needed in two_arg_diff + | | | + | | missing argument of type &str + | no parameter of type {integer} is needed in two_arg_diff + | +note: function defined here + --> $DIR/extra_arguments.rs:4:4 + | +LL | fn two_arg_diff(_a: i32, _b: &str) {} + | ^^^^^^^^^^^^ ------- -------- +help: the following changes might help + | +LL | two_arg_diff(1, {&str}, ); + | -- ^^^^^^^-- + +error[E0059]: arguments to this function are incorrect + --> $DIR/extra_arguments.rs:17:23 + | +LL | two_arg_diff(1, "", ""); + | ^^ + | | + | no parameter of type &'static str is needed in two_arg_diff + | help: removing this argument may help + | +note: function defined here + --> $DIR/extra_arguments.rs:4:4 + | +LL | fn two_arg_diff(_a: i32, _b: &str) {} + | ^^^^^^^^^^^^ ------- -------- + +error[E0059]: multiple arguments to this function are incorrect + --> $DIR/extra_arguments.rs:18:19 + | +LL | two_arg_diff(1, 1, "", ""); + | ^ ^^^ ^^ no parameter of type &'static str is needed in two_arg_diff + | | || + | | |no parameter of type &'static str is needed in two_arg_diff + | | missing argument of type &str + | no parameter of type {integer} is needed in two_arg_diff + | +note: function defined here + --> $DIR/extra_arguments.rs:4:4 + | +LL | fn two_arg_diff(_a: i32, _b: &str) {} + | ^^^^^^^^^^^^ ------- -------- +help: the following changes might help + | +LL | two_arg_diff(1, {&str}, ); + | -- ^^^^^^^--- + +error[E0059]: multiple arguments to this function are incorrect + --> $DIR/extra_arguments.rs:19:23 + | +LL | two_arg_diff(1, "", 1, ""); + | ^ ^^ no parameter of type &'static str is needed in two_arg_diff + | | + | no parameter of type {integer} is needed in two_arg_diff + | +note: function defined here + --> $DIR/extra_arguments.rs:4:4 + | +LL | fn two_arg_diff(_a: i32, _b: &str) {} + | ^^^^^^^^^^^^ ------- -------- +help: removing these argument may help + | +LL | two_arg_diff(1, "", ); + | -- -- + +error: aborting due to 10 previous errors + +For more information about this error, try `rustc --explain E0059`. diff --git a/src/test/ui/argument-suggestions/invalid_arguments.rs b/src/test/ui/argument-suggestions/invalid_arguments.rs new file mode 100644 index 0000000000000..b42acae62420c --- /dev/null +++ b/src/test/ui/argument-suggestions/invalid_arguments.rs @@ -0,0 +1,43 @@ +// More nuanced test cases for invalid arguments #65853 + +struct X {} + +fn one_arg(_a: i32) {} +fn two_arg_same(_a: i32, _b: i32) {} +fn two_arg_diff(_a: i32, _b: f32) {} +fn three_arg_diff(_a: i32, _b: f32, _c: &str) {} +fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {} + +fn main() { + // Providing an incorrect argument for a single parameter function + one_arg(1.0); //~ ERROR arguments to this function are incorrect + + // Providing one or two invalid arguments to a two parameter function + two_arg_same(1, ""); //~ ERROR arguments to this function are incorrect + two_arg_same("", 1); //~ ERROR arguments to this function are incorrect + two_arg_same("", ""); //~ ERROR arguments to this function are incorrect + two_arg_diff(1, ""); //~ ERROR arguments to this function are incorrect + two_arg_diff("", 1.0); //~ ERROR arguments to this function are incorrect + two_arg_diff("", ""); //~ ERROR arguments to this function are incorrect + + // Providing invalid arguments to a three parameter function + three_arg_diff(X{}, 1.0, ""); //~ ERROR arguments to this function are incorrect + three_arg_diff(1, X {}, ""); //~ ERROR arguments to this function are incorrect + three_arg_diff(1, 1.0, X {}); //~ ERROR arguments to this function are incorrect + + three_arg_diff(X {}, X {}, ""); //~ ERROR arguments to this function are incorrect + three_arg_diff(X {}, 1.0, X {}); //~ ERROR arguments to this function are incorrect + three_arg_diff(1, X {}, X {}); //~ ERROR arguments to this function are incorrect + + three_arg_diff(X {}, X {}, X {}); //~ ERROR arguments to this function are incorrect + + three_arg_repeat(X {}, 1, ""); //~ ERROR arguments to this function are incorrect + three_arg_repeat(1, X {}, ""); //~ ERROR arguments to this function are incorrect + three_arg_repeat(1, 1, X {}); //~ ERROR arguments to this function are incorrect + + three_arg_repeat(X {}, X {}, ""); //~ ERROR arguments to this function are incorrect + three_arg_repeat(X {}, 1, X {}); //~ ERROR arguments to this function are incorrect + three_arg_repeat(1, X {}, X{}); //~ ERROR arguments to this function are incorrect + + three_arg_repeat(X {}, X {}, X {}); //~ ERROR arguments to this function are incorrect +} \ No newline at end of file diff --git a/src/test/ui/argument-suggestions/invalid_arguments.stderr b/src/test/ui/argument-suggestions/invalid_arguments.stderr new file mode 100644 index 0000000000000..93617e1de77bd --- /dev/null +++ b/src/test/ui/argument-suggestions/invalid_arguments.stderr @@ -0,0 +1,349 @@ +error[E0059]: arguments to this function are incorrect + --> $DIR/invalid_arguments.rs:13:11 + | +LL | one_arg(1.0); + | ^^^ expected i32, found {float} + | +note: function defined here + --> $DIR/invalid_arguments.rs:5:4 + | +LL | fn one_arg(_a: i32) {} + | ^^^^^^^ ------- + +error[E0059]: multiple arguments to this function are incorrect + --> $DIR/invalid_arguments.rs:16:19 + | +LL | two_arg_same(1, ""); + | ^^ ^ missing argument of type i32 + | | + | no parameter of type &'static str is needed in two_arg_same + | +note: function defined here + --> $DIR/invalid_arguments.rs:6:4 + | +LL | fn two_arg_same(_a: i32, _b: i32) {} + | ^^^^^^^^^^^^ ------- ------- +help: the following changes might help + | +LL | two_arg_same(1, ) {i32},; + | -- ^^^^^^ + +error[E0059]: multiple arguments to this function are incorrect + --> $DIR/invalid_arguments.rs:17:16 + | +LL | two_arg_same("", 1); + | ^^ ^ missing argument of type i32 + | | + | no parameter of type &'static str is needed in two_arg_same + | +note: function defined here + --> $DIR/invalid_arguments.rs:6:4 + | +LL | fn two_arg_same(_a: i32, _b: i32) {} + | ^^^^^^^^^^^^ ------- ------- +help: the following changes might help + | +LL | two_arg_same(1) {i32},; + | -- ^^^^^^ + +error[E0059]: multiple arguments to this function are incorrect + --> $DIR/invalid_arguments.rs:18:16 + | +LL | two_arg_same("", ""); + | ^^ ^^ expected i32, found &'static str + | | + | expected i32, found &'static str + | +note: function defined here + --> $DIR/invalid_arguments.rs:6:4 + | +LL | fn two_arg_same(_a: i32, _b: i32) {} + | ^^^^^^^^^^^^ ------- ------- +help: providing these parameters may help + | +LL | two_arg_same( {i32},, {i32},); + | ^^^^^^ ^^^^^^ + +error[E0059]: arguments to this function are incorrect + --> $DIR/invalid_arguments.rs:19:19 + | +LL | two_arg_diff(1, ""); + | ^^ expected f32, found &'static str + | +note: function defined here + --> $DIR/invalid_arguments.rs:7:4 + | +LL | fn two_arg_diff(_a: i32, _b: f32) {} + | ^^^^^^^^^^^^ ------- ------- + +error[E0059]: arguments to this function are incorrect + --> $DIR/invalid_arguments.rs:20:16 + | +LL | two_arg_diff("", 1.0); + | ^^ expected i32, found &'static str + | +note: function defined here + --> $DIR/invalid_arguments.rs:7:4 + | +LL | fn two_arg_diff(_a: i32, _b: f32) {} + | ^^^^^^^^^^^^ ------- ------- + +error[E0059]: multiple arguments to this function are incorrect + --> $DIR/invalid_arguments.rs:21:16 + | +LL | two_arg_diff("", ""); + | ^^ ^^ expected f32, found &'static str + | | + | expected i32, found &'static str + | +note: function defined here + --> $DIR/invalid_arguments.rs:7:4 + | +LL | fn two_arg_diff(_a: i32, _b: f32) {} + | ^^^^^^^^^^^^ ------- ------- +help: providing these parameters may help + | +LL | two_arg_diff( {i32},, {f32},); + | ^^^^^^ ^^^^^^ + +error[E0059]: arguments to this function are incorrect + --> $DIR/invalid_arguments.rs:24:18 + | +LL | three_arg_diff(X{}, 1.0, ""); + | ^^^ expected i32, found X + | +note: function defined here + --> $DIR/invalid_arguments.rs:8:4 + | +LL | fn three_arg_diff(_a: i32, _b: f32, _c: &str) {} + | ^^^^^^^^^^^^^^ ------- ------- -------- + +error[E0059]: arguments to this function are incorrect + --> $DIR/invalid_arguments.rs:25:21 + | +LL | three_arg_diff(1, X {}, ""); + | ^^^^ expected f32, found X + | +note: function defined here + --> $DIR/invalid_arguments.rs:8:4 + | +LL | fn three_arg_diff(_a: i32, _b: f32, _c: &str) {} + | ^^^^^^^^^^^^^^ ------- ------- -------- + +error[E0059]: arguments to this function are incorrect + --> $DIR/invalid_arguments.rs:26:26 + | +LL | three_arg_diff(1, 1.0, X {}); + | ^^^^ expected &str, found X + | +note: function defined here + --> $DIR/invalid_arguments.rs:8:4 + | +LL | fn three_arg_diff(_a: i32, _b: f32, _c: &str) {} + | ^^^^^^^^^^^^^^ ------- ------- -------- + +error[E0059]: multiple arguments to this function are incorrect + --> $DIR/invalid_arguments.rs:28:18 + | +LL | three_arg_diff(X {}, X {}, ""); + | ^^^^ ^^^^ expected f32, found X + | | + | expected i32, found X + | +note: function defined here + --> $DIR/invalid_arguments.rs:8:4 + | +LL | fn three_arg_diff(_a: i32, _b: f32, _c: &str) {} + | ^^^^^^^^^^^^^^ ------- ------- -------- +help: providing these parameters may help + | +LL | three_arg_diff( {i32},, {f32},, ""); + | ^^^^^^ ^^^^^^ + +error[E0059]: multiple arguments to this function are incorrect + --> $DIR/invalid_arguments.rs:29:18 + | +LL | three_arg_diff(X {}, 1.0, X {}); + | ^^^^ ^^^^ expected &str, found X + | | + | expected i32, found X + | +note: function defined here + --> $DIR/invalid_arguments.rs:8:4 + | +LL | fn three_arg_diff(_a: i32, _b: f32, _c: &str) {} + | ^^^^^^^^^^^^^^ ------- ------- -------- +help: providing these parameters may help + | +LL | three_arg_diff( {i32},, 1.0, {&str},); + | ^^^^^^ ^^^^^^^ + +error[E0059]: multiple arguments to this function are incorrect + --> $DIR/invalid_arguments.rs:30:21 + | +LL | three_arg_diff(1, X {}, X {}); + | ^^^^ ^^^^ expected &str, found X + | | + | expected f32, found X + | +note: function defined here + --> $DIR/invalid_arguments.rs:8:4 + | +LL | fn three_arg_diff(_a: i32, _b: f32, _c: &str) {} + | ^^^^^^^^^^^^^^ ------- ------- -------- +help: providing these parameters may help + | +LL | three_arg_diff(1, {f32},, {&str},); + | ^^^^^^ ^^^^^^^ + +error[E0059]: multiple arguments to this function are incorrect + --> $DIR/invalid_arguments.rs:32:18 + | +LL | three_arg_diff(X {}, X {}, X {}); + | ^^^^ ^^^^ ^^^^ expected &str, found X + | | | + | | expected f32, found X + | expected i32, found X + | +note: function defined here + --> $DIR/invalid_arguments.rs:8:4 + | +LL | fn three_arg_diff(_a: i32, _b: f32, _c: &str) {} + | ^^^^^^^^^^^^^^ ------- ------- -------- +help: providing these parameters may help + | +LL | three_arg_diff( {i32},, {f32},, {&str},); + | ^^^^^^ ^^^^^^ ^^^^^^^ + +error[E0059]: multiple arguments to this function are incorrect + --> $DIR/invalid_arguments.rs:34:20 + | +LL | three_arg_repeat(X {}, 1, ""); + | ^^^^ ^^^ ^ missing argument of type &str + | | || + | | |no parameter of type &'static str is needed in three_arg_repeat + | | missing argument of type i32 + | no parameter of type X is needed in three_arg_repeat + | +note: function defined here + --> $DIR/invalid_arguments.rs:9:4 + | +LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {} + | ^^^^^^^^^^^^^^^^ ------- ------- -------- +help: the following changes might help + | +LL | three_arg_repeat(1, {i32}, ) {&str},; + | -- ^^^^^^-- ^^^^^^^ + +error[E0059]: multiple arguments to this function are incorrect + --> $DIR/invalid_arguments.rs:35:23 + | +LL | three_arg_repeat(1, X {}, ""); + | ^^^^ ^^^ ^ missing argument of type &str + | | || + | | |no parameter of type &'static str is needed in three_arg_repeat + | | missing argument of type i32 + | no parameter of type X is needed in three_arg_repeat + | +note: function defined here + --> $DIR/invalid_arguments.rs:9:4 + | +LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {} + | ^^^^^^^^^^^^^^^^ ------- ------- -------- +help: the following changes might help + | +LL | three_arg_repeat(1, {i32}, ) {&str},; + | -- ^^^^^^^^^^ + +error[E0059]: arguments to this function are incorrect + --> $DIR/invalid_arguments.rs:36:26 + | +LL | three_arg_repeat(1, 1, X {}); + | ^^^^ expected &str, found X + | +note: function defined here + --> $DIR/invalid_arguments.rs:9:4 + | +LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {} + | ^^^^^^^^^^^^^^^^ ------- ------- -------- + +error[E0059]: multiple arguments to this function are incorrect + --> $DIR/invalid_arguments.rs:38:20 + | +LL | three_arg_repeat(X {}, X {}, ""); + | ^^^^ ^^^^ expected i32, found X + | | + | expected i32, found X + | +note: function defined here + --> $DIR/invalid_arguments.rs:9:4 + | +LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {} + | ^^^^^^^^^^^^^^^^ ------- ------- -------- +help: providing these parameters may help + | +LL | three_arg_repeat( {i32},, {i32},, ""); + | ^^^^^^ ^^^^^^ + +error[E0059]: multiple arguments to this function are incorrect + --> $DIR/invalid_arguments.rs:39:20 + | +LL | three_arg_repeat(X {}, 1, X {}); + | ^^^^ ^^^^^ ^ missing argument of type &str + | | || + | | |no parameter of type X is needed in three_arg_repeat + | | missing argument of type i32 + | no parameter of type X is needed in three_arg_repeat + | +note: function defined here + --> $DIR/invalid_arguments.rs:9:4 + | +LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {} + | ^^^^^^^^^^^^^^^^ ------- ------- -------- +help: the following changes might help + | +LL | three_arg_repeat(1, {i32}, ) {&str},; + | -- ^^^^^^-- ^^^^^^^ + +error[E0059]: multiple arguments to this function are incorrect + --> $DIR/invalid_arguments.rs:40:23 + | +LL | three_arg_repeat(1, X {}, X{}); + | ^^^^ ^^^^ ^ missing argument of type &str + | | || + | | |no parameter of type X is needed in three_arg_repeat + | | missing argument of type i32 + | no parameter of type X is needed in three_arg_repeat + | +note: function defined here + --> $DIR/invalid_arguments.rs:9:4 + | +LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {} + | ^^^^^^^^^^^^^^^^ ------- ------- -------- +help: the following changes might help + | +LL | three_arg_repeat(1, {i32}, ) {&str},; + | -- ^^^^^^^^^^ + +error[E0059]: multiple arguments to this function are incorrect + --> $DIR/invalid_arguments.rs:42:20 + | +LL | three_arg_repeat(X {}, X {}, X {}); + | ^^^^ ^^^^ ^^^^ expected &str, found X + | | | + | | expected i32, found X + | expected i32, found X + | +note: function defined here + --> $DIR/invalid_arguments.rs:9:4 + | +LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {} + | ^^^^^^^^^^^^^^^^ ------- ------- -------- +help: providing these parameters may help + | +LL | three_arg_repeat( {i32},, {i32},, {&str},); + | ^^^^^^ ^^^^^^ ^^^^^^^ + +error: aborting due to 21 previous errors + +For more information about this error, try `rustc --explain E0059`. diff --git a/src/test/ui/argument-suggestions/missing_arguments.rs b/src/test/ui/argument-suggestions/missing_arguments.rs new file mode 100644 index 0000000000000..841ffe4e7ed48 --- /dev/null +++ b/src/test/ui/argument-suggestions/missing_arguments.rs @@ -0,0 +1,40 @@ +fn one_arg(_a: i32) {} +fn two_same(_a: i32, _b: i32) {} +fn two_diff(_a: i32, _b: f32) {} +fn three_same(_a: i32, _b: i32, _c: i32) {} +fn three_diff(_a: i32, _b: f32, _c: &str) {} +fn four_repeated(_a: i32, _b: f32, _c: f32, _d: &str) {} +fn complex(_a: i32, _b: f32, _c: i32, _d: f32, _e: &str) {} + +fn main() { + one_arg(); //~ ERROR arguments to this function are incorrect + // The headers here show the types expected, + // with formatting to emphasize which arguments are missing + /* i32 f32 */ + two_same( ); //~ ERROR arguments to this function are incorrect + two_same( 1 ); //~ ERROR arguments to this function are incorrect + two_diff( ); //~ ERROR arguments to this function are incorrect + two_diff( 1 ); //~ ERROR arguments to this function are incorrect + two_diff( 1.0 ); //~ ERROR arguments to this function are incorrect + + /* i32 i32 i32 */ + three_same( ); //~ ERROR arguments to this function are incorrect + three_same( 1 ); //~ ERROR arguments to this function are incorrect + three_same( 1, 1 ); //~ ERROR arguments to this function are incorrect + + /* i32 f32 &str */ + three_diff( 1.0, "" ); //~ ERROR arguments to this function are incorrect + three_diff( 1, "" ); //~ ERROR arguments to this function are incorrect + three_diff( 1, 1.0, ); //~ ERROR arguments to this function are incorrect + three_diff( "" ); //~ ERROR arguments to this function are incorrect + three_diff( 1.0 ); //~ ERROR arguments to this function are incorrect + three_diff( 1, ); //~ ERROR arguments to this function are incorrect + + /* i32 f32 f32 &str */ + four_repeated( ); //~ ERROR arguments to this function are incorrect + four_repeated( 1, "" ); //~ ERROR arguments to this function are incorrect + + /* i32 f32 i32 f32 &str */ + complex( ); //~ ERROR arguments to this function are incorrect + complex( 1, "" ); //~ ERROR arguments to this function are incorrect +} \ No newline at end of file diff --git a/src/test/ui/argument-suggestions/missing_arguments.stderr b/src/test/ui/argument-suggestions/missing_arguments.stderr new file mode 100644 index 0000000000000..e7429cff3f94f --- /dev/null +++ b/src/test/ui/argument-suggestions/missing_arguments.stderr @@ -0,0 +1,314 @@ +error[E0059]: arguments to this function are incorrect + --> $DIR/missing_arguments.rs:10:11 + | +LL | one_arg(); + | ^ missing argument of type i32 + | +note: function defined here + --> $DIR/missing_arguments.rs:1:4 + | +LL | fn one_arg(_a: i32) {} + | ^^^^^^^ ------- + +error[E0059]: multiple arguments to this function are incorrect + --> $DIR/missing_arguments.rs:14:27 + | +LL | two_same( ); + | ^ + | | + | missing argument of type i32 + | missing argument of type i32 + | +note: function defined here + --> $DIR/missing_arguments.rs:2:4 + | +LL | fn two_same(_a: i32, _b: i32) {} + | ^^^^^^^^ ------- ------- +help: providing these parameters may help + | +LL | two_same( {i32}, {i32},); + | ^^^^^^ + +error[E0059]: arguments to this function are incorrect + --> $DIR/missing_arguments.rs:15:27 + | +LL | two_same( 1 ); + | ^ missing argument of type i32 + | +note: function defined here + --> $DIR/missing_arguments.rs:2:4 + | +LL | fn two_same(_a: i32, _b: i32) {} + | ^^^^^^^^ ------- ------- + +error[E0059]: multiple arguments to this function are incorrect + --> $DIR/missing_arguments.rs:16:27 + | +LL | two_diff( ); + | ^ + | | + | missing argument of type i32 + | missing argument of type f32 + | +note: function defined here + --> $DIR/missing_arguments.rs:3:4 + | +LL | fn two_diff(_a: i32, _b: f32) {} + | ^^^^^^^^ ------- ------- +help: providing these parameters may help + | +LL | two_diff( {i32}, {f32},); + | ^^^^^^ + +error[E0059]: arguments to this function are incorrect + --> $DIR/missing_arguments.rs:17:27 + | +LL | two_diff( 1 ); + | ^ missing argument of type f32 + | +note: function defined here + --> $DIR/missing_arguments.rs:3:4 + | +LL | fn two_diff(_a: i32, _b: f32) {} + | ^^^^^^^^ ------- ------- + +error[E0059]: arguments to this function are incorrect + --> $DIR/missing_arguments.rs:18:26 + | +LL | two_diff( 1.0 ); + | ^ missing argument of type i32 + | +note: function defined here + --> $DIR/missing_arguments.rs:3:4 + | +LL | fn two_diff(_a: i32, _b: f32) {} + | ^^^^^^^^ ------- ------- + +error[E0059]: multiple arguments to this function are incorrect + --> $DIR/missing_arguments.rs:21:37 + | +LL | three_same( ); + | ^ + | | + | missing argument of type i32 + | missing argument of type i32 + | missing argument of type i32 + | +note: function defined here + --> $DIR/missing_arguments.rs:4:4 + | +LL | fn three_same(_a: i32, _b: i32, _c: i32) {} + | ^^^^^^^^^^ ------- ------- ------- +help: providing these parameters may help + | +LL | three_same( {i32}, {i32}, {i32},); + | ^^^^^^ + +error[E0059]: multiple arguments to this function are incorrect + --> $DIR/missing_arguments.rs:22:37 + | +LL | three_same( 1 ); + | ^ + | | + | missing argument of type i32 + | missing argument of type i32 + | +note: function defined here + --> $DIR/missing_arguments.rs:4:4 + | +LL | fn three_same(_a: i32, _b: i32, _c: i32) {} + | ^^^^^^^^^^ ------- ------- ------- +help: providing these parameters may help + | +LL | three_same( 1 {i32}, {i32},); + | ^^^^^^ + +error[E0059]: arguments to this function are incorrect + --> $DIR/missing_arguments.rs:23:37 + | +LL | three_same( 1, 1 ); + | ^ missing argument of type i32 + | +note: function defined here + --> $DIR/missing_arguments.rs:4:4 + | +LL | fn three_same(_a: i32, _b: i32, _c: i32) {} + | ^^^^^^^^^^ ------- ------- ------- + +error[E0059]: arguments to this function are incorrect + --> $DIR/missing_arguments.rs:26:28 + | +LL | three_diff( 1.0, "" ); + | ^ missing argument of type i32 + | +note: function defined here + --> $DIR/missing_arguments.rs:5:4 + | +LL | fn three_diff(_a: i32, _b: f32, _c: &str) {} + | ^^^^^^^^^^ ------- ------- -------- + +error[E0059]: arguments to this function are incorrect + --> $DIR/missing_arguments.rs:27:36 + | +LL | three_diff( 1, "" ); + | ^ missing argument of type f32 + | +note: function defined here + --> $DIR/missing_arguments.rs:5:4 + | +LL | fn three_diff(_a: i32, _b: f32, _c: &str) {} + | ^^^^^^^^^^ ------- ------- -------- + +error[E0059]: arguments to this function are incorrect + --> $DIR/missing_arguments.rs:28:37 + | +LL | three_diff( 1, 1.0, ); + | ^ missing argument of type &str + | +note: function defined here + --> $DIR/missing_arguments.rs:5:4 + | +LL | fn three_diff(_a: i32, _b: f32, _c: &str) {} + | ^^^^^^^^^^ ------- ------- -------- + +error[E0059]: multiple arguments to this function are incorrect + --> $DIR/missing_arguments.rs:29:36 + | +LL | three_diff( "" ); + | ^^ missing argument of type f32 + | | + | missing argument of type i32 + | +note: function defined here + --> $DIR/missing_arguments.rs:5:4 + | +LL | fn three_diff(_a: i32, _b: f32, _c: &str) {} + | ^^^^^^^^^^ ------- ------- -------- +help: providing these parameters may help + | +LL | three_diff( "" {i32}, {f32},); + | ^^^^^^ ^^^^^^ + +error[E0059]: multiple arguments to this function are incorrect + --> $DIR/missing_arguments.rs:30:28 + | +LL | three_diff( 1.0 ); + | ^ ^ missing argument of type &str + | | + | missing argument of type i32 + | +note: function defined here + --> $DIR/missing_arguments.rs:5:4 + | +LL | fn three_diff(_a: i32, _b: f32, _c: &str) {} + | ^^^^^^^^^^ ------- ------- -------- +help: providing these parameters may help + | +LL | three_diff( 1.0 {i32}, {&str},); + | ^^^^^^ ^^^^^^^ + +error[E0059]: multiple arguments to this function are incorrect + --> $DIR/missing_arguments.rs:31:37 + | +LL | three_diff( 1, ); + | ^ + | | + | missing argument of type f32 + | missing argument of type &str + | +note: function defined here + --> $DIR/missing_arguments.rs:5:4 + | +LL | fn three_diff(_a: i32, _b: f32, _c: &str) {} + | ^^^^^^^^^^ ------- ------- -------- +help: providing these parameters may help + | +LL | three_diff( 1, {f32}, {&str},); + | ^^^^^^^ + +error[E0059]: multiple arguments to this function are incorrect + --> $DIR/missing_arguments.rs:34:48 + | +LL | four_repeated( ); + | ^ + | | + | missing argument of type i32 + | missing argument of type f32 + | missing argument of type f32 + | missing argument of type &str + | +note: function defined here + --> $DIR/missing_arguments.rs:6:4 + | +LL | fn four_repeated(_a: i32, _b: f32, _c: f32, _d: &str) {} + | ^^^^^^^^^^^^^ ------- ------- ------- -------- +help: providing these parameters may help + | +LL | four_repeated( {i32}, {f32}, {f32}, {&str},); + | ^^^^^^^ + +error[E0059]: multiple arguments to this function are incorrect + --> $DIR/missing_arguments.rs:35:46 + | +LL | four_repeated( 1, "" ); + | ^ ^ missing argument of type f32 + | | + | missing argument of type f32 + | +note: function defined here + --> $DIR/missing_arguments.rs:6:4 + | +LL | fn four_repeated(_a: i32, _b: f32, _c: f32, _d: &str) {} + | ^^^^^^^^^^^^^ ------- ------- ------- -------- +help: providing these parameters may help + | +LL | four_repeated( 1, "" {f32}, {f32},); + | ^^^^^^ ^^^^^^ + +error[E0059]: multiple arguments to this function are incorrect + --> $DIR/missing_arguments.rs:38:50 + | +LL | complex( ); + | ^ + | | + | missing argument of type i32 + | missing argument of type f32 + | missing argument of type i32 + | missing argument of type f32 + | missing argument of type &str + | +note: function defined here + --> $DIR/missing_arguments.rs:7:4 + | +LL | fn complex(_a: i32, _b: f32, _c: i32, _d: f32, _e: &str) {} + | ^^^^^^^ ------- ------- ------- ------- -------- +help: providing these parameters may help + | +LL | complex( {i32}, {f32}, {i32}, {f32}, {&str},); + | ^^^^^^^ + +error[E0059]: multiple arguments to this function are incorrect + --> $DIR/missing_arguments.rs:39:45 + | +LL | complex( 1, "" ); + | ^^ ^ ^ + | | | | + | | | missing argument of type f32 + | | | missing argument of type &str + | | | missing argument of type i32 + | | missing argument of type f32 + | no parameter of type &'static str is needed in complex + | +note: function defined here + --> $DIR/missing_arguments.rs:7:4 + | +LL | fn complex(_a: i32, _b: f32, _c: i32, _d: f32, _e: &str) {} + | ^^^^^^^ ------- ------- ------- ------- -------- +help: the following changes might help + | +LL | complex( 1, {f32}, {f32}, {&str}, {i32},); + | -- ^^^^^^ ^^^^^^^ + +error: aborting due to 19 previous errors + +For more information about this error, try `rustc --explain E0059`. diff --git a/src/test/ui/argument-suggestions/mixed_cases.rs b/src/test/ui/argument-suggestions/mixed_cases.rs new file mode 100644 index 0000000000000..19826d6eebbfa --- /dev/null +++ b/src/test/ui/argument-suggestions/mixed_cases.rs @@ -0,0 +1,24 @@ +// Cases where multiple argument suggestions are mixed + +struct X {} + +fn two_args(_a: i32, _b: f32) {} +fn three_args(_a: i32, _b: f32, _c: &str) {} + +fn main() { + // Extra + Invalid + two_args(1, "", X {}); //~ ERROR arguments to this function are incorrect + three_args(1, "", X {}, ""); //~ ERROR arguments to this function are incorrect + + // Missing and Invalid + three_args(1, X {}); //~ ERROR arguments to this function are incorrect + + // Missing and Extra + three_args(1, "", X {}); //~ ERROR arguments to this function are incorrect + + // Swapped and Invalid + three_args("", X {}, 1); //~ ERROR arguments to this function are incorrect + + // Swapped and missing + three_args("", 1); //~ ERROR arguments to this function are incorrect +} \ No newline at end of file diff --git a/src/test/ui/argument-suggestions/mixed_cases.stderr b/src/test/ui/argument-suggestions/mixed_cases.stderr new file mode 100644 index 0000000000000..f41542b68a3aa --- /dev/null +++ b/src/test/ui/argument-suggestions/mixed_cases.stderr @@ -0,0 +1,114 @@ +error[E0059]: multiple arguments to this function are incorrect + --> $DIR/mixed_cases.rs:10:15 + | +LL | two_args(1, "", X {}); + | ^^ ^^^^ no parameter of type X is needed in two_args + | | + | expected f32, found &'static str + | +note: function defined here + --> $DIR/mixed_cases.rs:5:4 + | +LL | fn two_args(_a: i32, _b: f32) {} + | ^^^^^^^^ ------- ------- +help: the following changes might help + | +LL | two_args(1, {f32},, ); + | ^^^^^^ -- + +error[E0059]: multiple arguments to this function are incorrect + --> $DIR/mixed_cases.rs:11:20 + | +LL | three_args(1, "", X {}, ""); + | ^^^^^ ^^ no parameter of type &'static str is needed in three_args + | || + | |no parameter of type X is needed in three_args + | missing argument of type f32 + | +note: function defined here + --> $DIR/mixed_cases.rs:6:4 + | +LL | fn three_args(_a: i32, _b: f32, _c: &str) {} + | ^^^^^^^^^^ ------- ------- -------- +help: the following changes might help + | +LL | three_args(1, "", {f32}, ); + | ^^^^^^-- -- + +error[E0059]: multiple arguments to this function are incorrect + --> $DIR/mixed_cases.rs:14:17 + | +LL | three_args(1, X {}); + | ^^^^^ missing argument of type &str + | | + | expected f32, found X + | +note: function defined here + --> $DIR/mixed_cases.rs:6:4 + | +LL | fn three_args(_a: i32, _b: f32, _c: &str) {} + | ^^^^^^^^^^ ------- ------- -------- +help: providing these parameters may help + | +LL | three_args(1, {f32}, {&str},); + | ^^^^^^^^^^^ + +error[E0059]: multiple arguments to this function are incorrect + --> $DIR/mixed_cases.rs:17:20 + | +LL | three_args(1, "", X {}); + | ^^^^^ no parameter of type X is needed in three_args + | | + | missing argument of type f32 + | +note: function defined here + --> $DIR/mixed_cases.rs:6:4 + | +LL | fn three_args(_a: i32, _b: f32, _c: &str) {} + | ^^^^^^^^^^ ------- ------- -------- +help: the following changes might help + | +LL | three_args(1, "", {f32}, ); + | ^^^^^^-- + +error[E0059]: multiple arguments to this function are incorrect + --> $DIR/mixed_cases.rs:20:14 + | +LL | three_args("", X {}, 1); + | ^^ ^^^^ ^ expected &str, found {integer} + | | | + | | expected f32, found X + | expected i32, found &'static str + | +note: function defined here + --> $DIR/mixed_cases.rs:6:4 + | +LL | fn three_args(_a: i32, _b: f32, _c: &str) {} + | ^^^^^^^^^^ ------- ------- -------- +help: the following changes might help + | +LL | three_args(1, {f32},, ""); + | ^ ^^^^^^ ^^ + +error[E0059]: multiple arguments to this function are incorrect + --> $DIR/mixed_cases.rs:23:14 + | +LL | three_args("", 1); + | ^^ ^ ^ missing argument of type f32 + | | | + | | expected f32, found {integer} + | expected i32, found &'static str + | +note: function defined here + --> $DIR/mixed_cases.rs:6:4 + | +LL | fn three_args(_a: i32, _b: f32, _c: &str) {} + | ^^^^^^^^^^ ------- ------- -------- +help: the following changes might help + | +LL | three_args(1, "") {f32},; + | ^ ^^ ^^^^^^ + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0059`. diff --git a/src/test/ui/argument-suggestions/permuted_arguments.rs b/src/test/ui/argument-suggestions/permuted_arguments.rs new file mode 100644 index 0000000000000..580f86b0034b0 --- /dev/null +++ b/src/test/ui/argument-suggestions/permuted_arguments.rs @@ -0,0 +1,13 @@ +// More complicated permutations +struct X {} +struct Y {} + +fn three_args(_a: i32, _b: f32, _c: &str) {} +fn many_args(_a: i32, _b: f32, _c: &str, _d: X, _e: Y) {} + +fn main() { + // b, c, a + three_args(1.0, "", 1); //~ ERROR arguments to this function are incorrect + // d, e, b, a, c + many_args(X {}, Y {}, 1, 1.0, ""); //~ ERROR arguments to this function are incorrect +} \ No newline at end of file diff --git a/src/test/ui/argument-suggestions/permuted_arguments.stderr b/src/test/ui/argument-suggestions/permuted_arguments.stderr new file mode 100644 index 0000000000000..de18481759963 --- /dev/null +++ b/src/test/ui/argument-suggestions/permuted_arguments.stderr @@ -0,0 +1,43 @@ +error[E0059]: arguments to this function are incorrect + --> $DIR/permuted_arguments.rs:10:14 + | +LL | three_args(1.0, "", 1); + | ^^^ ^^ ^ expected &str, found {integer} + | | | + | | expected f32, found &'static str + | expected i32, found {float} + | +note: function defined here + --> $DIR/permuted_arguments.rs:5:4 + | +LL | fn three_args(_a: i32, _b: f32, _c: &str) {} + | ^^^^^^^^^^ ------- ------- -------- +help: reordering these parameters might help + | +LL | three_args(1, 1.0, ""); + | ^ ^^^ ^^ + +error[E0059]: arguments to this function are incorrect + --> $DIR/permuted_arguments.rs:12:13 + | +LL | many_args(X {}, Y {}, 1, 1.0, ""); + | ^^^^ ^^^^ ^ ^^^ ^^ expected Y, found &'static str + | | | | | + | | | | expected X, found {float} + | | | expected &str, found {integer} + | | expected f32, found Y + | expected i32, found X + | +note: function defined here + --> $DIR/permuted_arguments.rs:6:4 + | +LL | fn many_args(_a: i32, _b: f32, _c: &str, _d: X, _e: Y) {} + | ^^^^^^^^^ ------- ------- -------- ----- ----- +help: reordering these parameters might help + | +LL | many_args(1, 1.0, "", X {}, Y {}); + | ^ ^^^ ^^ ^^^^ ^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0059`. diff --git a/src/test/ui/argument-suggestions/swapped_arguments.rs b/src/test/ui/argument-suggestions/swapped_arguments.rs new file mode 100644 index 0000000000000..8ad5644edc12f --- /dev/null +++ b/src/test/ui/argument-suggestions/swapped_arguments.rs @@ -0,0 +1,14 @@ +struct X {} + +fn two_args(_a: i32, _b: f32) {} +fn three_args(_a: i32, _b: f32, _c: &str) {} +fn four_args(_a: i32, _b: f32, _c: &str, _d: X) {} + +fn main() { + two_args(1.0, 1); //~ ERROR arguments to this function are incorrect + three_args(1.0, 1, ""); //~ ERROR arguments to this function are incorrect + three_args( 1, "", 1.0); //~ ERROR arguments to this function are incorrect + three_args( "", 1.0, 1); //~ ERROR arguments to this function are incorrect + + four_args(1.0, 1, X {}, ""); //~ ERROR arguments to this function are incorrect +} \ No newline at end of file diff --git a/src/test/ui/argument-suggestions/swapped_arguments.stderr b/src/test/ui/argument-suggestions/swapped_arguments.stderr new file mode 100644 index 0000000000000..6a3fbe9cf52ad --- /dev/null +++ b/src/test/ui/argument-suggestions/swapped_arguments.stderr @@ -0,0 +1,95 @@ +error[E0059]: arguments to this function are incorrect + --> $DIR/swapped_arguments.rs:8:12 + | +LL | two_args(1.0, 1); + | ^^^ ^ expected f32, found {integer} + | | + | expected i32, found {float} + | +note: function defined here + --> $DIR/swapped_arguments.rs:3:4 + | +LL | fn two_args(_a: i32, _b: f32) {} + | ^^^^^^^^ ------- ------- +help: swapping these two arguments might help + | +LL | two_args(1, 1.0); + | ^ ^^^ + +error[E0059]: arguments to this function are incorrect + --> $DIR/swapped_arguments.rs:9:14 + | +LL | three_args(1.0, 1, ""); + | ^^^ ^ expected f32, found {integer} + | | + | expected i32, found {float} + | +note: function defined here + --> $DIR/swapped_arguments.rs:4:4 + | +LL | fn three_args(_a: i32, _b: f32, _c: &str) {} + | ^^^^^^^^^^ ------- ------- -------- +help: swapping these two arguments might help + | +LL | three_args(1, 1.0, ""); + | ^ ^^^ + +error[E0059]: arguments to this function are incorrect + --> $DIR/swapped_arguments.rs:10:20 + | +LL | three_args( 1, "", 1.0); + | ^^ ^^^ expected &str, found {float} + | | + | expected f32, found &'static str + | +note: function defined here + --> $DIR/swapped_arguments.rs:4:4 + | +LL | fn three_args(_a: i32, _b: f32, _c: &str) {} + | ^^^^^^^^^^ ------- ------- -------- +help: swapping these two arguments might help + | +LL | three_args( 1, 1.0, ""); + | ^^^ ^^ + +error[E0059]: arguments to this function are incorrect + --> $DIR/swapped_arguments.rs:11:15 + | +LL | three_args( "", 1.0, 1); + | ^^ ^ expected &str, found {integer} + | | + | expected i32, found &'static str + | +note: function defined here + --> $DIR/swapped_arguments.rs:4:4 + | +LL | fn three_args(_a: i32, _b: f32, _c: &str) {} + | ^^^^^^^^^^ ------- ------- -------- +help: swapping these two arguments might help + | +LL | three_args( 1, 1.0, ""); + | ^ ^^ + +error[E0059]: multiple arguments to this function are incorrect + --> $DIR/swapped_arguments.rs:13:13 + | +LL | four_args(1.0, 1, X {}, ""); + | ^^^ ^ ^^^^ ^^ expected X, found &'static str + | | | | + | | | expected &str, found X + | | expected f32, found {integer} + | expected i32, found {float} + | +note: function defined here + --> $DIR/swapped_arguments.rs:5:4 + | +LL | fn four_args(_a: i32, _b: f32, _c: &str, _d: X) {} + | ^^^^^^^^^ ------- ------- -------- ----- +help: swapping these sets of arguments might help + | +LL | four_args(1, 1.0, "", X {}); + | ^ ^^^ ^^ ^^^^ + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0059`. From 74faf967fbd8886b56eba5059cffcf28285cefa7 Mon Sep 17 00:00:00 2001 From: Pi Lanningham Date: Thu, 14 Jan 2021 21:13:29 -0500 Subject: [PATCH 09/21] Refactor final_arg_types to use a presized array Previously, it was a tuple including the index of the argument it was discussing, but this made it awkward to look up the types later. The primary purpose of this was to pass it to another helper function, so I refactored that as well. Rather than trying to figure out the iterator chain that would work with the new structure, I just wrote the loop manually. --- .../rustc_typeck/src/check/fn_ctxt/checks.rs | 48 +++++++++--------- src/test/ui/argument-suggestions/basic.stderr | 12 ++--- .../ui/argument-suggestions/complex.stderr | 12 ++--- .../invalid_arguments.stderr | 50 +++++++++---------- .../argument-suggestions/mixed_cases.stderr | 14 +++--- .../permuted_arguments.stderr | 16 +++--- .../swapped_arguments.stderr | 24 ++++----- 7 files changed, 89 insertions(+), 87 deletions(-) diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs index 5e5ada8e8a732..770eef3d85cb7 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs @@ -189,7 +189,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let mut deferred_arguments: Vec = vec![]; // We'll also want to keep track of the fully coerced argument types, for an awkward hack near the end - let mut final_arg_types: Vec<(usize, Ty<'_>, Ty<'_>)> = vec![]; + let mut final_arg_types: Vec, Ty<'_>)>> = vec![None; provided_arg_count]; // We introduce a helper function to demand that a given argument satisfy a given input // This is more complicated than just checking type equality, as arguments could be coerced @@ -291,7 +291,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Demand that this argument satisfies the input in the slot it's in let (compatible, checked_ty, coerced_ty) = demand_compatible(idx, idx); // Keep track of these for below - final_arg_types.push((idx, checked_ty, coerced_ty)); + final_arg_types[idx] = Some((checked_ty, coerced_ty)); // If we fail at some point, we'll want to provide better error messages, so hold onto this info if compatible { @@ -309,7 +309,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.point_at_type_arg_instead_of_call_if_possible(errors, call_expr); self.point_at_arg_instead_of_call_if_possible( errors, - &final_arg_types[..], + &final_arg_types, call_span, &provided_args, ); @@ -649,7 +649,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { Issue::Invalid(arg) => { let span = provided_args[arg].span; let expected_type = expected_input_tys[arg]; - let found_type = final_arg_types.iter().find(|(i, _, _)| *i == arg).unwrap().1; + let found_type = final_arg_types[arg].unwrap().1; labels.push((span, format!("expected {}, found {}", expected_type, found_type))); suggestion_type = match suggestion_type { NoSuggestion | Provide => Provide, @@ -720,8 +720,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let second_snippet = source_map.span_to_snippet(second_span).unwrap(); let expected_types = (expected_input_tys[arg], expected_input_tys[other]); let found_types = ( - final_arg_types.iter().find(|(i, _, _)| *i == arg).unwrap().1, - final_arg_types.iter().find(|(i, _, _)| *i == other).unwrap().1, + final_arg_types[arg].unwrap().1, + final_arg_types[other].unwrap().1, ); labels.push((first_span, format!("expected {}, found {}", expected_types.0, found_types.0))); suggestions.push((first_span, second_snippet)); @@ -739,7 +739,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let dst_span = provided_args[dst].span; let snippet = source_map.span_to_snippet(src_span).unwrap(); let expected_type = expected_input_tys[dst]; - let found_type = final_arg_types.iter().find(|(i, _, _)| *i == dst).unwrap().1; + let found_type = final_arg_types[dst].unwrap().1; labels.push((dst_span, format!("expected {}, found {}", expected_type, found_type))); suggestions.push((dst_span, snippet)); suggestion_type = match suggestion_type { @@ -1356,7 +1356,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { fn point_at_arg_instead_of_call_if_possible( &self, errors: &mut Vec>, - final_arg_types: &[(usize, Ty<'tcx>, Ty<'tcx>)], + final_arg_types: &[Option<(Ty<'tcx>, Ty<'tcx>)>], call_sp: Span, args: &'tcx [hir::Expr<'tcx>], ) { @@ -1379,21 +1379,23 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { { // Collect the argument position for all arguments that could have caused this // `FulfillmentError`. - let mut referenced_in = final_arg_types - .iter() - .map(|&(i, checked_ty, _)| (i, checked_ty)) - .chain(final_arg_types.iter().map(|&(i, _, coerced_ty)| (i, coerced_ty))) - .flat_map(|(i, ty)| { - let ty = self.resolve_vars_if_possible(ty); - // We walk the argument type because the argument's type could have - // been `Option`, but the `FulfillmentError` references `T`. - if ty.walk().any(|arg| arg == predicate.self_ty().into()) { - Some(i) - } else { - None - } - }) - .collect::>(); + let mut checked_tys = vec![]; + let mut coerced_tys = vec![]; + for (i, &type_pair) in final_arg_types.iter().enumerate() { + if let Some((checked_ty, coerced_ty)) = type_pair { + checked_tys.push((i, checked_ty)); + coerced_tys.push((i, coerced_ty)); + } + } + let mut referenced_in = vec![]; + for &(i, ty) in checked_tys.iter().chain(coerced_tys.iter()) { + let ty = self.resolve_vars_if_possible(ty); + // We walk the argument type because the argument's type could have + // been `Option`, but the `FulfillmentError` references `T`. + if ty.walk().any(|arg| arg == predicate.self_ty().into()) { + referenced_in.push(i); + } + } // Both checked and coerced types could have matched, thus we need to remove // duplicates. diff --git a/src/test/ui/argument-suggestions/basic.stderr b/src/test/ui/argument-suggestions/basic.stderr index 518d2ce5d50ce..ba6afe150b66f 100644 --- a/src/test/ui/argument-suggestions/basic.stderr +++ b/src/test/ui/argument-suggestions/basic.stderr @@ -2,7 +2,7 @@ error[E0059]: arguments to this function are incorrect --> $DIR/basic.rs:20:13 | LL | invalid(1.0); - | ^^^ expected u32, found {float} + | ^^^ expected u32, found u32 | note: function defined here --> $DIR/basic.rs:13:4 @@ -41,9 +41,9 @@ error[E0059]: arguments to this function are incorrect --> $DIR/basic.rs:23:13 | LL | swapped("", 1); - | ^^ ^ expected &str, found {integer} + | ^^ ^ expected &str, found &str | | - | expected u32, found &'static str + | expected u32, found u32 | note: function defined here --> $DIR/basic.rs:16:4 @@ -59,10 +59,10 @@ error[E0059]: arguments to this function are incorrect --> $DIR/basic.rs:24:14 | LL | permuted(Y {}, Z {}, X {}); - | ^^^^ ^^^^ ^^^^ expected Z, found X + | ^^^^ ^^^^ ^^^^ expected Z, found Z | | | - | | expected Y, found Z - | expected X, found Y + | | expected Y, found Y + | expected X, found X | note: function defined here --> $DIR/basic.rs:17:4 diff --git a/src/test/ui/argument-suggestions/complex.stderr b/src/test/ui/argument-suggestions/complex.stderr index 7f2d1ca2a1155..59a87bee91a81 100644 --- a/src/test/ui/argument-suggestions/complex.stderr +++ b/src/test/ui/argument-suggestions/complex.stderr @@ -2,15 +2,15 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/complex.rs:14:11 | LL | complex(1.0, H {}, &"", G{}, F::X2, Z {}, X {}, Y {}); - | ^^^ ^^^^ ^^^^ ^^^^^ ^^^^ ^^^^ ^^^^ expected Z, found Y + | ^^^ ^^^^ ^^^^ ^^^^^ ^^^^ ^^^^ ^^^^ expected Z, found Z | | | || | | | - | | | || | | expected Y, found X - | | | || | expected X, found Z - | | | || expected G, found F - | | | |expected F, found G + | | | || | | expected Y, found Y + | | | || | expected X, found X + | | | || expected G, found G + | | | |expected F, found F | | | missing argument of type E | | no parameter of type H is needed in complex - | expected u32, found {float} + | expected u32, found u32 | note: function defined here --> $DIR/complex.rs:11:4 diff --git a/src/test/ui/argument-suggestions/invalid_arguments.stderr b/src/test/ui/argument-suggestions/invalid_arguments.stderr index 93617e1de77bd..f6bd291005777 100644 --- a/src/test/ui/argument-suggestions/invalid_arguments.stderr +++ b/src/test/ui/argument-suggestions/invalid_arguments.stderr @@ -2,7 +2,7 @@ error[E0059]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:13:11 | LL | one_arg(1.0); - | ^^^ expected i32, found {float} + | ^^^ expected i32, found i32 | note: function defined here --> $DIR/invalid_arguments.rs:5:4 @@ -50,9 +50,9 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/invalid_arguments.rs:18:16 | LL | two_arg_same("", ""); - | ^^ ^^ expected i32, found &'static str + | ^^ ^^ expected i32, found i32 | | - | expected i32, found &'static str + | expected i32, found i32 | note: function defined here --> $DIR/invalid_arguments.rs:6:4 @@ -68,7 +68,7 @@ error[E0059]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:19:19 | LL | two_arg_diff(1, ""); - | ^^ expected f32, found &'static str + | ^^ expected f32, found f32 | note: function defined here --> $DIR/invalid_arguments.rs:7:4 @@ -80,7 +80,7 @@ error[E0059]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:20:16 | LL | two_arg_diff("", 1.0); - | ^^ expected i32, found &'static str + | ^^ expected i32, found i32 | note: function defined here --> $DIR/invalid_arguments.rs:7:4 @@ -92,9 +92,9 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/invalid_arguments.rs:21:16 | LL | two_arg_diff("", ""); - | ^^ ^^ expected f32, found &'static str + | ^^ ^^ expected f32, found f32 | | - | expected i32, found &'static str + | expected i32, found i32 | note: function defined here --> $DIR/invalid_arguments.rs:7:4 @@ -110,7 +110,7 @@ error[E0059]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:24:18 | LL | three_arg_diff(X{}, 1.0, ""); - | ^^^ expected i32, found X + | ^^^ expected i32, found i32 | note: function defined here --> $DIR/invalid_arguments.rs:8:4 @@ -122,7 +122,7 @@ error[E0059]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:25:21 | LL | three_arg_diff(1, X {}, ""); - | ^^^^ expected f32, found X + | ^^^^ expected f32, found f32 | note: function defined here --> $DIR/invalid_arguments.rs:8:4 @@ -134,7 +134,7 @@ error[E0059]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:26:26 | LL | three_arg_diff(1, 1.0, X {}); - | ^^^^ expected &str, found X + | ^^^^ expected &str, found &str | note: function defined here --> $DIR/invalid_arguments.rs:8:4 @@ -146,9 +146,9 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/invalid_arguments.rs:28:18 | LL | three_arg_diff(X {}, X {}, ""); - | ^^^^ ^^^^ expected f32, found X + | ^^^^ ^^^^ expected f32, found f32 | | - | expected i32, found X + | expected i32, found i32 | note: function defined here --> $DIR/invalid_arguments.rs:8:4 @@ -164,9 +164,9 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/invalid_arguments.rs:29:18 | LL | three_arg_diff(X {}, 1.0, X {}); - | ^^^^ ^^^^ expected &str, found X + | ^^^^ ^^^^ expected &str, found &str | | - | expected i32, found X + | expected i32, found i32 | note: function defined here --> $DIR/invalid_arguments.rs:8:4 @@ -182,9 +182,9 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/invalid_arguments.rs:30:21 | LL | three_arg_diff(1, X {}, X {}); - | ^^^^ ^^^^ expected &str, found X + | ^^^^ ^^^^ expected &str, found &str | | - | expected f32, found X + | expected f32, found f32 | note: function defined here --> $DIR/invalid_arguments.rs:8:4 @@ -200,10 +200,10 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/invalid_arguments.rs:32:18 | LL | three_arg_diff(X {}, X {}, X {}); - | ^^^^ ^^^^ ^^^^ expected &str, found X + | ^^^^ ^^^^ ^^^^ expected &str, found &str | | | - | | expected f32, found X - | expected i32, found X + | | expected f32, found f32 + | expected i32, found i32 | note: function defined here --> $DIR/invalid_arguments.rs:8:4 @@ -259,7 +259,7 @@ error[E0059]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:36:26 | LL | three_arg_repeat(1, 1, X {}); - | ^^^^ expected &str, found X + | ^^^^ expected &str, found &str | note: function defined here --> $DIR/invalid_arguments.rs:9:4 @@ -271,9 +271,9 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/invalid_arguments.rs:38:20 | LL | three_arg_repeat(X {}, X {}, ""); - | ^^^^ ^^^^ expected i32, found X + | ^^^^ ^^^^ expected i32, found i32 | | - | expected i32, found X + | expected i32, found i32 | note: function defined here --> $DIR/invalid_arguments.rs:9:4 @@ -329,10 +329,10 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/invalid_arguments.rs:42:20 | LL | three_arg_repeat(X {}, X {}, X {}); - | ^^^^ ^^^^ ^^^^ expected &str, found X + | ^^^^ ^^^^ ^^^^ expected &str, found &str | | | - | | expected i32, found X - | expected i32, found X + | | expected i32, found i32 + | expected i32, found i32 | note: function defined here --> $DIR/invalid_arguments.rs:9:4 diff --git a/src/test/ui/argument-suggestions/mixed_cases.stderr b/src/test/ui/argument-suggestions/mixed_cases.stderr index f41542b68a3aa..43cc44e1c7ed2 100644 --- a/src/test/ui/argument-suggestions/mixed_cases.stderr +++ b/src/test/ui/argument-suggestions/mixed_cases.stderr @@ -4,7 +4,7 @@ error[E0059]: multiple arguments to this function are incorrect LL | two_args(1, "", X {}); | ^^ ^^^^ no parameter of type X is needed in two_args | | - | expected f32, found &'static str + | expected f32, found f32 | note: function defined here --> $DIR/mixed_cases.rs:5:4 @@ -41,7 +41,7 @@ error[E0059]: multiple arguments to this function are incorrect LL | three_args(1, X {}); | ^^^^^ missing argument of type &str | | - | expected f32, found X + | expected f32, found f32 | note: function defined here --> $DIR/mixed_cases.rs:6:4 @@ -75,10 +75,10 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/mixed_cases.rs:20:14 | LL | three_args("", X {}, 1); - | ^^ ^^^^ ^ expected &str, found {integer} + | ^^ ^^^^ ^ expected &str, found &str | | | - | | expected f32, found X - | expected i32, found &'static str + | | expected f32, found f32 + | expected i32, found i32 | note: function defined here --> $DIR/mixed_cases.rs:6:4 @@ -96,8 +96,8 @@ error[E0059]: multiple arguments to this function are incorrect LL | three_args("", 1); | ^^ ^ ^ missing argument of type f32 | | | - | | expected f32, found {integer} - | expected i32, found &'static str + | | expected f32, found f32 + | expected i32, found i32 | note: function defined here --> $DIR/mixed_cases.rs:6:4 diff --git a/src/test/ui/argument-suggestions/permuted_arguments.stderr b/src/test/ui/argument-suggestions/permuted_arguments.stderr index de18481759963..74ccdd3d004fb 100644 --- a/src/test/ui/argument-suggestions/permuted_arguments.stderr +++ b/src/test/ui/argument-suggestions/permuted_arguments.stderr @@ -2,10 +2,10 @@ error[E0059]: arguments to this function are incorrect --> $DIR/permuted_arguments.rs:10:14 | LL | three_args(1.0, "", 1); - | ^^^ ^^ ^ expected &str, found {integer} + | ^^^ ^^ ^ expected &str, found &str | | | - | | expected f32, found &'static str - | expected i32, found {float} + | | expected f32, found f32 + | expected i32, found i32 | note: function defined here --> $DIR/permuted_arguments.rs:5:4 @@ -21,12 +21,12 @@ error[E0059]: arguments to this function are incorrect --> $DIR/permuted_arguments.rs:12:13 | LL | many_args(X {}, Y {}, 1, 1.0, ""); - | ^^^^ ^^^^ ^ ^^^ ^^ expected Y, found &'static str + | ^^^^ ^^^^ ^ ^^^ ^^ expected Y, found Y | | | | | - | | | | expected X, found {float} - | | | expected &str, found {integer} - | | expected f32, found Y - | expected i32, found X + | | | | expected X, found X + | | | expected &str, found &str + | | expected f32, found f32 + | expected i32, found i32 | note: function defined here --> $DIR/permuted_arguments.rs:6:4 diff --git a/src/test/ui/argument-suggestions/swapped_arguments.stderr b/src/test/ui/argument-suggestions/swapped_arguments.stderr index 6a3fbe9cf52ad..2ffba36e34af8 100644 --- a/src/test/ui/argument-suggestions/swapped_arguments.stderr +++ b/src/test/ui/argument-suggestions/swapped_arguments.stderr @@ -2,9 +2,9 @@ error[E0059]: arguments to this function are incorrect --> $DIR/swapped_arguments.rs:8:12 | LL | two_args(1.0, 1); - | ^^^ ^ expected f32, found {integer} + | ^^^ ^ expected f32, found f32 | | - | expected i32, found {float} + | expected i32, found i32 | note: function defined here --> $DIR/swapped_arguments.rs:3:4 @@ -20,9 +20,9 @@ error[E0059]: arguments to this function are incorrect --> $DIR/swapped_arguments.rs:9:14 | LL | three_args(1.0, 1, ""); - | ^^^ ^ expected f32, found {integer} + | ^^^ ^ expected f32, found f32 | | - | expected i32, found {float} + | expected i32, found i32 | note: function defined here --> $DIR/swapped_arguments.rs:4:4 @@ -38,9 +38,9 @@ error[E0059]: arguments to this function are incorrect --> $DIR/swapped_arguments.rs:10:20 | LL | three_args( 1, "", 1.0); - | ^^ ^^^ expected &str, found {float} + | ^^ ^^^ expected &str, found &str | | - | expected f32, found &'static str + | expected f32, found f32 | note: function defined here --> $DIR/swapped_arguments.rs:4:4 @@ -56,9 +56,9 @@ error[E0059]: arguments to this function are incorrect --> $DIR/swapped_arguments.rs:11:15 | LL | three_args( "", 1.0, 1); - | ^^ ^ expected &str, found {integer} + | ^^ ^ expected &str, found &str | | - | expected i32, found &'static str + | expected i32, found i32 | note: function defined here --> $DIR/swapped_arguments.rs:4:4 @@ -74,11 +74,11 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/swapped_arguments.rs:13:13 | LL | four_args(1.0, 1, X {}, ""); - | ^^^ ^ ^^^^ ^^ expected X, found &'static str + | ^^^ ^ ^^^^ ^^ expected X, found X | | | | - | | | expected &str, found X - | | expected f32, found {integer} - | expected i32, found {float} + | | | expected &str, found &str + | | expected f32, found f32 + | expected i32, found i32 | note: function defined here --> $DIR/swapped_arguments.rs:5:4 From d455267100559260575604b239a054e23e1d31a1 Mon Sep 17 00:00:00 2001 From: Pi Lanningham Date: Thu, 14 Jan 2021 21:19:45 -0500 Subject: [PATCH 10/21] Remove an if clause that wasn't neccesary --- compiler/rustc_typeck/src/check/fn_ctxt/checks.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs index 770eef3d85cb7..7bb2260ccdad8 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs @@ -360,18 +360,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // First, set up some utility functions for the algorithm below // Remove a given input or argument from consideration let eliminate_input = |mat: &mut Vec>, ii: &mut Vec, idx| { - if idx >= ii.len() { - return; // FIXME: Should this ICE as a compiler bug? - } ii.remove(idx); for row in mat { row.remove(idx); } }; let eliminate_arg = |mat: &mut Vec>, ai: &mut Vec, idx| { - if idx >= ai.len() { - return; // FIXME: Should this ICE as a compiler bug? - } ai.remove(idx); mat.remove(idx); }; From d570d59ee41fa55e65b9388ac6be5e992747ac61 Mon Sep 17 00:00:00 2001 From: Pi Lanningham Date: Thu, 14 Jan 2021 21:30:21 -0500 Subject: [PATCH 11/21] Make the fn_name more nuanced --- .../rustc_typeck/src/check/fn_ctxt/checks.rs | 25 ++++++++++++---- src/test/ui/argument-suggestions/basic.stderr | 2 +- .../ui/argument-suggestions/complex.stderr | 2 +- .../extra_arguments.stderr | 30 +++++++++---------- .../invalid_arguments.stderr | 20 ++++++------- .../missing_arguments.stderr | 2 +- .../argument-suggestions/mixed_cases.stderr | 8 ++--- 7 files changed, 51 insertions(+), 38 deletions(-) diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs index 7bb2260ccdad8..08ca248304a6e 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs @@ -665,13 +665,26 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { span }; let found_type = self.check_expr(&provided_args[arg]); - let fn_name = fn_def_id - .and_then(|def_id| tcx.hir().get_if_local(def_id)) - .and_then(|node| node.ident()) - .map(|ident| format!("{}", ident)) - .unwrap_or("this function".to_string()); + // TODO: if someone knows the method-chain-foo to achieve this, let me know + // but I didn't have the patience for it lol + let fn_name = if let Some(def_id) = fn_def_id { + let node = tcx.hir().get_if_local(def_id); + let def_kind = tcx.def_kind(def_id); + let descr = def_kind.descr(def_id); + if let Some(node) = node { + if let Some(ident) = node.ident() { + format!("{}", ident) + } else { + format!("this {}", descr) + } + } else { + format!("this {}", descr) + } + } else { + "here".to_string() + }; - labels.push((span, format!("no parameter of type {} is needed in {}", found_type, fn_name))); + labels.push((span, format!("no parameter of type {} is needed {}", found_type, fn_name))); suggestion_type = match suggestion_type { NoSuggestion | Remove => Remove, _ => Changes, diff --git a/src/test/ui/argument-suggestions/basic.stderr b/src/test/ui/argument-suggestions/basic.stderr index ba6afe150b66f..2bd1dea1de40c 100644 --- a/src/test/ui/argument-suggestions/basic.stderr +++ b/src/test/ui/argument-suggestions/basic.stderr @@ -16,7 +16,7 @@ error[E0059]: arguments to this function are incorrect LL | extra(""); | ^^ | | - | no parameter of type &'static str is needed in extra + | no parameter of type &'static str is needed extra | help: removing this argument may help | note: function defined here diff --git a/src/test/ui/argument-suggestions/complex.stderr b/src/test/ui/argument-suggestions/complex.stderr index 59a87bee91a81..16365c82fe798 100644 --- a/src/test/ui/argument-suggestions/complex.stderr +++ b/src/test/ui/argument-suggestions/complex.stderr @@ -9,7 +9,7 @@ LL | complex(1.0, H {}, &"", G{}, F::X2, Z {}, X {}, Y {}); | | | || expected G, found G | | | |expected F, found F | | | missing argument of type E - | | no parameter of type H is needed in complex + | | no parameter of type H is needed complex | expected u32, found u32 | note: function defined here diff --git a/src/test/ui/argument-suggestions/extra_arguments.stderr b/src/test/ui/argument-suggestions/extra_arguments.stderr index 2c2ee030e39c7..ac58c2611a0fd 100644 --- a/src/test/ui/argument-suggestions/extra_arguments.stderr +++ b/src/test/ui/argument-suggestions/extra_arguments.stderr @@ -4,7 +4,7 @@ error[E0059]: arguments to this function are incorrect LL | empty(""); | ^^ | | - | no parameter of type &'static str is needed in empty + | no parameter of type &'static str is needed empty | help: removing this argument may help | note: function defined here @@ -19,7 +19,7 @@ error[E0059]: arguments to this function are incorrect LL | one_arg(1, 1); | ^ | | - | no parameter of type {integer} is needed in one_arg + | no parameter of type {integer} is needed one_arg | help: removing this argument may help | note: function defined here @@ -34,7 +34,7 @@ error[E0059]: arguments to this function are incorrect LL | one_arg(1, ""); | ^^ | | - | no parameter of type &'static str is needed in one_arg + | no parameter of type &'static str is needed one_arg | help: removing this argument may help | note: function defined here @@ -47,9 +47,9 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/extra_arguments.rs:11:14 | LL | one_arg(1, "", 1.0); - | ^^ ^^^ no parameter of type {float} is needed in one_arg + | ^^ ^^^ no parameter of type {float} is needed one_arg | | - | no parameter of type &'static str is needed in one_arg + | no parameter of type &'static str is needed one_arg | note: function defined here --> $DIR/extra_arguments.rs:2:4 @@ -67,7 +67,7 @@ error[E0059]: arguments to this function are incorrect LL | two_arg_same(1, 1, 1); | ^ | | - | no parameter of type {integer} is needed in two_arg_same + | no parameter of type {integer} is needed two_arg_same | help: removing this argument may help | note: function defined here @@ -82,7 +82,7 @@ error[E0059]: arguments to this function are incorrect LL | two_arg_same(1, 1, 1.0); | ^^^ | | - | no parameter of type {float} is needed in two_arg_same + | no parameter of type {float} is needed two_arg_same | help: removing this argument may help | note: function defined here @@ -95,10 +95,10 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/extra_arguments.rs:16:19 | LL | two_arg_diff(1, 1, ""); - | ^ ^^^ no parameter of type &'static str is needed in two_arg_diff + | ^ ^^^ no parameter of type &'static str is needed two_arg_diff | | | | | missing argument of type &str - | no parameter of type {integer} is needed in two_arg_diff + | no parameter of type {integer} is needed two_arg_diff | note: function defined here --> $DIR/extra_arguments.rs:4:4 @@ -116,7 +116,7 @@ error[E0059]: arguments to this function are incorrect LL | two_arg_diff(1, "", ""); | ^^ | | - | no parameter of type &'static str is needed in two_arg_diff + | no parameter of type &'static str is needed two_arg_diff | help: removing this argument may help | note: function defined here @@ -129,11 +129,11 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/extra_arguments.rs:18:19 | LL | two_arg_diff(1, 1, "", ""); - | ^ ^^^ ^^ no parameter of type &'static str is needed in two_arg_diff + | ^ ^^^ ^^ no parameter of type &'static str is needed two_arg_diff | | || - | | |no parameter of type &'static str is needed in two_arg_diff + | | |no parameter of type &'static str is needed two_arg_diff | | missing argument of type &str - | no parameter of type {integer} is needed in two_arg_diff + | no parameter of type {integer} is needed two_arg_diff | note: function defined here --> $DIR/extra_arguments.rs:4:4 @@ -149,9 +149,9 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/extra_arguments.rs:19:23 | LL | two_arg_diff(1, "", 1, ""); - | ^ ^^ no parameter of type &'static str is needed in two_arg_diff + | ^ ^^ no parameter of type &'static str is needed two_arg_diff | | - | no parameter of type {integer} is needed in two_arg_diff + | no parameter of type {integer} is needed two_arg_diff | note: function defined here --> $DIR/extra_arguments.rs:4:4 diff --git a/src/test/ui/argument-suggestions/invalid_arguments.stderr b/src/test/ui/argument-suggestions/invalid_arguments.stderr index f6bd291005777..14c0678063e81 100644 --- a/src/test/ui/argument-suggestions/invalid_arguments.stderr +++ b/src/test/ui/argument-suggestions/invalid_arguments.stderr @@ -16,7 +16,7 @@ error[E0059]: multiple arguments to this function are incorrect LL | two_arg_same(1, ""); | ^^ ^ missing argument of type i32 | | - | no parameter of type &'static str is needed in two_arg_same + | no parameter of type &'static str is needed two_arg_same | note: function defined here --> $DIR/invalid_arguments.rs:6:4 @@ -34,7 +34,7 @@ error[E0059]: multiple arguments to this function are incorrect LL | two_arg_same("", 1); | ^^ ^ missing argument of type i32 | | - | no parameter of type &'static str is needed in two_arg_same + | no parameter of type &'static str is needed two_arg_same | note: function defined here --> $DIR/invalid_arguments.rs:6:4 @@ -221,9 +221,9 @@ error[E0059]: multiple arguments to this function are incorrect LL | three_arg_repeat(X {}, 1, ""); | ^^^^ ^^^ ^ missing argument of type &str | | || - | | |no parameter of type &'static str is needed in three_arg_repeat + | | |no parameter of type &'static str is needed three_arg_repeat | | missing argument of type i32 - | no parameter of type X is needed in three_arg_repeat + | no parameter of type X is needed three_arg_repeat | note: function defined here --> $DIR/invalid_arguments.rs:9:4 @@ -241,9 +241,9 @@ error[E0059]: multiple arguments to this function are incorrect LL | three_arg_repeat(1, X {}, ""); | ^^^^ ^^^ ^ missing argument of type &str | | || - | | |no parameter of type &'static str is needed in three_arg_repeat + | | |no parameter of type &'static str is needed three_arg_repeat | | missing argument of type i32 - | no parameter of type X is needed in three_arg_repeat + | no parameter of type X is needed three_arg_repeat | note: function defined here --> $DIR/invalid_arguments.rs:9:4 @@ -291,9 +291,9 @@ error[E0059]: multiple arguments to this function are incorrect LL | three_arg_repeat(X {}, 1, X {}); | ^^^^ ^^^^^ ^ missing argument of type &str | | || - | | |no parameter of type X is needed in three_arg_repeat + | | |no parameter of type X is needed three_arg_repeat | | missing argument of type i32 - | no parameter of type X is needed in three_arg_repeat + | no parameter of type X is needed three_arg_repeat | note: function defined here --> $DIR/invalid_arguments.rs:9:4 @@ -311,9 +311,9 @@ error[E0059]: multiple arguments to this function are incorrect LL | three_arg_repeat(1, X {}, X{}); | ^^^^ ^^^^ ^ missing argument of type &str | | || - | | |no parameter of type X is needed in three_arg_repeat + | | |no parameter of type X is needed three_arg_repeat | | missing argument of type i32 - | no parameter of type X is needed in three_arg_repeat + | no parameter of type X is needed three_arg_repeat | note: function defined here --> $DIR/invalid_arguments.rs:9:4 diff --git a/src/test/ui/argument-suggestions/missing_arguments.stderr b/src/test/ui/argument-suggestions/missing_arguments.stderr index e7429cff3f94f..2542732693e7d 100644 --- a/src/test/ui/argument-suggestions/missing_arguments.stderr +++ b/src/test/ui/argument-suggestions/missing_arguments.stderr @@ -297,7 +297,7 @@ LL | complex( 1, "" ); | | | missing argument of type &str | | | missing argument of type i32 | | missing argument of type f32 - | no parameter of type &'static str is needed in complex + | no parameter of type &'static str is needed complex | note: function defined here --> $DIR/missing_arguments.rs:7:4 diff --git a/src/test/ui/argument-suggestions/mixed_cases.stderr b/src/test/ui/argument-suggestions/mixed_cases.stderr index 43cc44e1c7ed2..205e165508fd3 100644 --- a/src/test/ui/argument-suggestions/mixed_cases.stderr +++ b/src/test/ui/argument-suggestions/mixed_cases.stderr @@ -2,7 +2,7 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/mixed_cases.rs:10:15 | LL | two_args(1, "", X {}); - | ^^ ^^^^ no parameter of type X is needed in two_args + | ^^ ^^^^ no parameter of type X is needed two_args | | | expected f32, found f32 | @@ -20,9 +20,9 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/mixed_cases.rs:11:20 | LL | three_args(1, "", X {}, ""); - | ^^^^^ ^^ no parameter of type &'static str is needed in three_args + | ^^^^^ ^^ no parameter of type &'static str is needed three_args | || - | |no parameter of type X is needed in three_args + | |no parameter of type X is needed three_args | missing argument of type f32 | note: function defined here @@ -57,7 +57,7 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/mixed_cases.rs:17:20 | LL | three_args(1, "", X {}); - | ^^^^^ no parameter of type X is needed in three_args + | ^^^^^ no parameter of type X is needed three_args | | | missing argument of type f32 | From 6eb1da0a592d6d2192162bd544199722f4b4a173 Mon Sep 17 00:00:00 2001 From: Pi Lanningham Date: Thu, 14 Jan 2021 23:11:06 -0500 Subject: [PATCH 12/21] Fixed a bug related to invalid arguments Consider this case: ``` fn some_func(a: i32, b: i32) {} some_func(1, ""); ``` Before this change, the first 1 would register as able to satisfy the second parameter, so the "" would show up as "extra" and we'd remove it. We would then allow the first argument to satisfy the first parameter, and the second parameter would have no argument, so it would show up as "missing". A simpler way to express this is just that the type of the second argument is invalid. By doing one pass of satisfying arguments first, we can handle this case. --- .../rustc_typeck/src/check/fn_ctxt/checks.rs | 51 +++++--- src/test/ui/argument-suggestions/basic.stderr | 4 +- .../ui/argument-suggestions/complex.stderr | 4 +- .../extra_arguments.stderr | 44 +++---- .../invalid_arguments.stderr | 122 +++++++----------- .../missing_arguments.stderr | 20 ++- .../argument-suggestions/mixed_cases.stderr | 14 +- 7 files changed, 119 insertions(+), 140 deletions(-) diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs index 08ca248304a6e..5f4eb31052ffe 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs @@ -379,6 +379,23 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { eliminate_arg(mat, ai, arg_idx); }; + let eliminate_satisfied = |mat: &mut Vec>, ii: &mut Vec, ai: &mut Vec| { + let mut i = cmp::min(ii.len(), ai.len()); + while i > 0 { + let idx = i - 1; + if mat[idx][idx] { + satisfy_input( + mat, + ii, + ai, + idx, + idx, + ); + } + i -= 1; + } + }; + // A list of the issues we might find enum Issue { Invalid(usize), @@ -528,6 +545,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { return None; }; + // Before we start looking for issues, eliminate any arguments that are already satisfied, + // so that an argument which is already spoken for by the input it's in doesn't + // spill over into another similarly typed input + // ex: + // fn some_func(_a: i32, _a: i32) {} + // some_func(1, ""); + // Without this elimination, the first argument causes the second argument + // to show up as both a missing input and extra argument, rather than + // just an invalid type. + eliminate_satisfied(&mut compatibility_matrix, &mut input_indexes, &mut arg_indexes); + // As we encounter issues, we'll transcribe them to their actual indices let mut issues: Vec = vec![]; // Until we've elimineated / satisfied all arguments/inputs @@ -601,20 +629,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { None => { // We didn't find any issues, so we need to push the algorithm forward // First, eliminate any arguments that currently satisfy their inputs - let mut i = cmp::min(arg_indexes.len(), input_indexes.len()); - while i > 0 { - let idx = i - 1; - if compatibility_matrix[idx][idx] { - satisfy_input( - &mut compatibility_matrix, - &mut input_indexes, - &mut arg_indexes, - idx, - idx, - ); - } - i -= 1; - } + eliminate_satisfied(&mut compatibility_matrix, &mut input_indexes, &mut arg_indexes); } }; } @@ -643,7 +658,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { Issue::Invalid(arg) => { let span = provided_args[arg].span; let expected_type = expected_input_tys[arg]; - let found_type = final_arg_types[arg].unwrap().1; + let found_type = final_arg_types[arg].unwrap().0; labels.push((span, format!("expected {}, found {}", expected_type, found_type))); suggestion_type = match suggestion_type { NoSuggestion | Provide => Provide, @@ -673,12 +688,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let descr = def_kind.descr(def_id); if let Some(node) = node { if let Some(ident) = node.ident() { - format!("{}", ident) + format!("in {}", ident) } else { - format!("this {}", descr) + format!("in this {}", descr) } } else { - format!("this {}", descr) + format!("in this {}", descr) } } else { "here".to_string() diff --git a/src/test/ui/argument-suggestions/basic.stderr b/src/test/ui/argument-suggestions/basic.stderr index 2bd1dea1de40c..fba0ebe69b7bc 100644 --- a/src/test/ui/argument-suggestions/basic.stderr +++ b/src/test/ui/argument-suggestions/basic.stderr @@ -2,7 +2,7 @@ error[E0059]: arguments to this function are incorrect --> $DIR/basic.rs:20:13 | LL | invalid(1.0); - | ^^^ expected u32, found u32 + | ^^^ expected u32, found {float} | note: function defined here --> $DIR/basic.rs:13:4 @@ -16,7 +16,7 @@ error[E0059]: arguments to this function are incorrect LL | extra(""); | ^^ | | - | no parameter of type &'static str is needed extra + | no parameter of type &'static str is needed in extra | help: removing this argument may help | note: function defined here diff --git a/src/test/ui/argument-suggestions/complex.stderr b/src/test/ui/argument-suggestions/complex.stderr index 16365c82fe798..0448e297aa917 100644 --- a/src/test/ui/argument-suggestions/complex.stderr +++ b/src/test/ui/argument-suggestions/complex.stderr @@ -9,8 +9,8 @@ LL | complex(1.0, H {}, &"", G{}, F::X2, Z {}, X {}, Y {}); | | | || expected G, found G | | | |expected F, found F | | | missing argument of type E - | | no parameter of type H is needed complex - | expected u32, found u32 + | | no parameter of type H is needed in complex + | expected u32, found {float} | note: function defined here --> $DIR/complex.rs:11:4 diff --git a/src/test/ui/argument-suggestions/extra_arguments.stderr b/src/test/ui/argument-suggestions/extra_arguments.stderr index ac58c2611a0fd..528a7df8b5f2e 100644 --- a/src/test/ui/argument-suggestions/extra_arguments.stderr +++ b/src/test/ui/argument-suggestions/extra_arguments.stderr @@ -4,7 +4,7 @@ error[E0059]: arguments to this function are incorrect LL | empty(""); | ^^ | | - | no parameter of type &'static str is needed empty + | no parameter of type &'static str is needed in empty | help: removing this argument may help | note: function defined here @@ -19,7 +19,7 @@ error[E0059]: arguments to this function are incorrect LL | one_arg(1, 1); | ^ | | - | no parameter of type {integer} is needed one_arg + | no parameter of type {integer} is needed in one_arg | help: removing this argument may help | note: function defined here @@ -34,7 +34,7 @@ error[E0059]: arguments to this function are incorrect LL | one_arg(1, ""); | ^^ | | - | no parameter of type &'static str is needed one_arg + | no parameter of type &'static str is needed in one_arg | help: removing this argument may help | note: function defined here @@ -47,9 +47,9 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/extra_arguments.rs:11:14 | LL | one_arg(1, "", 1.0); - | ^^ ^^^ no parameter of type {float} is needed one_arg + | ^^ ^^^ no parameter of type {float} is needed in one_arg | | - | no parameter of type &'static str is needed one_arg + | no parameter of type &'static str is needed in one_arg | note: function defined here --> $DIR/extra_arguments.rs:2:4 @@ -67,7 +67,7 @@ error[E0059]: arguments to this function are incorrect LL | two_arg_same(1, 1, 1); | ^ | | - | no parameter of type {integer} is needed two_arg_same + | no parameter of type {integer} is needed in two_arg_same | help: removing this argument may help | note: function defined here @@ -82,7 +82,7 @@ error[E0059]: arguments to this function are incorrect LL | two_arg_same(1, 1, 1.0); | ^^^ | | - | no parameter of type {float} is needed two_arg_same + | no parameter of type {float} is needed in two_arg_same | help: removing this argument may help | note: function defined here @@ -95,10 +95,9 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/extra_arguments.rs:16:19 | LL | two_arg_diff(1, 1, ""); - | ^ ^^^ no parameter of type &'static str is needed two_arg_diff - | | | - | | missing argument of type &str - | no parameter of type {integer} is needed two_arg_diff + | ^ ^^ no parameter of type &'static str is needed in two_arg_diff + | | + | expected &str, found {integer} | note: function defined here --> $DIR/extra_arguments.rs:4:4 @@ -107,8 +106,8 @@ LL | fn two_arg_diff(_a: i32, _b: &str) {} | ^^^^^^^^^^^^ ------- -------- help: the following changes might help | -LL | two_arg_diff(1, {&str}, ); - | -- ^^^^^^^-- +LL | two_arg_diff(1, {&str},, ); + | ^^^^^^^ -- error[E0059]: arguments to this function are incorrect --> $DIR/extra_arguments.rs:17:23 @@ -116,7 +115,7 @@ error[E0059]: arguments to this function are incorrect LL | two_arg_diff(1, "", ""); | ^^ | | - | no parameter of type &'static str is needed two_arg_diff + | no parameter of type &'static str is needed in two_arg_diff | help: removing this argument may help | note: function defined here @@ -129,11 +128,10 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/extra_arguments.rs:18:19 | LL | two_arg_diff(1, 1, "", ""); - | ^ ^^^ ^^ no parameter of type &'static str is needed two_arg_diff - | | || - | | |no parameter of type &'static str is needed two_arg_diff - | | missing argument of type &str - | no parameter of type {integer} is needed two_arg_diff + | ^ ^^ ^^ no parameter of type &'static str is needed in two_arg_diff + | | | + | | no parameter of type &'static str is needed in two_arg_diff + | expected &str, found {integer} | note: function defined here --> $DIR/extra_arguments.rs:4:4 @@ -142,16 +140,16 @@ LL | fn two_arg_diff(_a: i32, _b: &str) {} | ^^^^^^^^^^^^ ------- -------- help: the following changes might help | -LL | two_arg_diff(1, {&str}, ); - | -- ^^^^^^^--- +LL | two_arg_diff(1, {&str},, ); + | ^^^^^^^ -- -- error[E0059]: multiple arguments to this function are incorrect --> $DIR/extra_arguments.rs:19:23 | LL | two_arg_diff(1, "", 1, ""); - | ^ ^^ no parameter of type &'static str is needed two_arg_diff + | ^ ^^ no parameter of type &'static str is needed in two_arg_diff | | - | no parameter of type {integer} is needed two_arg_diff + | no parameter of type {integer} is needed in two_arg_diff | note: function defined here --> $DIR/extra_arguments.rs:4:4 diff --git a/src/test/ui/argument-suggestions/invalid_arguments.stderr b/src/test/ui/argument-suggestions/invalid_arguments.stderr index 14c0678063e81..e69a9e61f8496 100644 --- a/src/test/ui/argument-suggestions/invalid_arguments.stderr +++ b/src/test/ui/argument-suggestions/invalid_arguments.stderr @@ -2,7 +2,7 @@ error[E0059]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:13:11 | LL | one_arg(1.0); - | ^^^ expected i32, found i32 + | ^^^ expected i32, found {float} | note: function defined here --> $DIR/invalid_arguments.rs:5:4 @@ -10,49 +10,37 @@ note: function defined here LL | fn one_arg(_a: i32) {} | ^^^^^^^ ------- -error[E0059]: multiple arguments to this function are incorrect +error[E0059]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:16:19 | LL | two_arg_same(1, ""); - | ^^ ^ missing argument of type i32 - | | - | no parameter of type &'static str is needed two_arg_same + | ^^ expected i32, found &'static str | note: function defined here --> $DIR/invalid_arguments.rs:6:4 | LL | fn two_arg_same(_a: i32, _b: i32) {} | ^^^^^^^^^^^^ ------- ------- -help: the following changes might help - | -LL | two_arg_same(1, ) {i32},; - | -- ^^^^^^ -error[E0059]: multiple arguments to this function are incorrect +error[E0059]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:17:16 | LL | two_arg_same("", 1); - | ^^ ^ missing argument of type i32 - | | - | no parameter of type &'static str is needed two_arg_same + | ^^ expected i32, found &'static str | note: function defined here --> $DIR/invalid_arguments.rs:6:4 | LL | fn two_arg_same(_a: i32, _b: i32) {} | ^^^^^^^^^^^^ ------- ------- -help: the following changes might help - | -LL | two_arg_same(1) {i32},; - | -- ^^^^^^ error[E0059]: multiple arguments to this function are incorrect --> $DIR/invalid_arguments.rs:18:16 | LL | two_arg_same("", ""); - | ^^ ^^ expected i32, found i32 + | ^^ ^^ expected i32, found &'static str | | - | expected i32, found i32 + | expected i32, found &'static str | note: function defined here --> $DIR/invalid_arguments.rs:6:4 @@ -68,7 +56,7 @@ error[E0059]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:19:19 | LL | two_arg_diff(1, ""); - | ^^ expected f32, found f32 + | ^^ expected f32, found &'static str | note: function defined here --> $DIR/invalid_arguments.rs:7:4 @@ -80,7 +68,7 @@ error[E0059]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:20:16 | LL | two_arg_diff("", 1.0); - | ^^ expected i32, found i32 + | ^^ expected i32, found &'static str | note: function defined here --> $DIR/invalid_arguments.rs:7:4 @@ -92,9 +80,9 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/invalid_arguments.rs:21:16 | LL | two_arg_diff("", ""); - | ^^ ^^ expected f32, found f32 + | ^^ ^^ expected f32, found &'static str | | - | expected i32, found i32 + | expected i32, found &'static str | note: function defined here --> $DIR/invalid_arguments.rs:7:4 @@ -110,7 +98,7 @@ error[E0059]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:24:18 | LL | three_arg_diff(X{}, 1.0, ""); - | ^^^ expected i32, found i32 + | ^^^ expected i32, found X | note: function defined here --> $DIR/invalid_arguments.rs:8:4 @@ -122,7 +110,7 @@ error[E0059]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:25:21 | LL | three_arg_diff(1, X {}, ""); - | ^^^^ expected f32, found f32 + | ^^^^ expected f32, found X | note: function defined here --> $DIR/invalid_arguments.rs:8:4 @@ -134,7 +122,7 @@ error[E0059]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:26:26 | LL | three_arg_diff(1, 1.0, X {}); - | ^^^^ expected &str, found &str + | ^^^^ expected &str, found X | note: function defined here --> $DIR/invalid_arguments.rs:8:4 @@ -146,9 +134,9 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/invalid_arguments.rs:28:18 | LL | three_arg_diff(X {}, X {}, ""); - | ^^^^ ^^^^ expected f32, found f32 + | ^^^^ ^^^^ expected f32, found X | | - | expected i32, found i32 + | expected i32, found X | note: function defined here --> $DIR/invalid_arguments.rs:8:4 @@ -164,9 +152,9 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/invalid_arguments.rs:29:18 | LL | three_arg_diff(X {}, 1.0, X {}); - | ^^^^ ^^^^ expected &str, found &str + | ^^^^ ^^^^ expected &str, found X | | - | expected i32, found i32 + | expected i32, found X | note: function defined here --> $DIR/invalid_arguments.rs:8:4 @@ -182,9 +170,9 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/invalid_arguments.rs:30:21 | LL | three_arg_diff(1, X {}, X {}); - | ^^^^ ^^^^ expected &str, found &str + | ^^^^ ^^^^ expected &str, found X | | - | expected f32, found f32 + | expected f32, found X | note: function defined here --> $DIR/invalid_arguments.rs:8:4 @@ -200,10 +188,10 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/invalid_arguments.rs:32:18 | LL | three_arg_diff(X {}, X {}, X {}); - | ^^^^ ^^^^ ^^^^ expected &str, found &str + | ^^^^ ^^^^ ^^^^ expected &str, found X | | | - | | expected f32, found f32 - | expected i32, found i32 + | | expected f32, found X + | expected i32, found X | note: function defined here --> $DIR/invalid_arguments.rs:8:4 @@ -215,51 +203,35 @@ help: providing these parameters may help LL | three_arg_diff( {i32},, {f32},, {&str},); | ^^^^^^ ^^^^^^ ^^^^^^^ -error[E0059]: multiple arguments to this function are incorrect +error[E0059]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:34:20 | LL | three_arg_repeat(X {}, 1, ""); - | ^^^^ ^^^ ^ missing argument of type &str - | | || - | | |no parameter of type &'static str is needed three_arg_repeat - | | missing argument of type i32 - | no parameter of type X is needed three_arg_repeat + | ^^^^ expected i32, found X | note: function defined here --> $DIR/invalid_arguments.rs:9:4 | LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {} | ^^^^^^^^^^^^^^^^ ------- ------- -------- -help: the following changes might help - | -LL | three_arg_repeat(1, {i32}, ) {&str},; - | -- ^^^^^^-- ^^^^^^^ -error[E0059]: multiple arguments to this function are incorrect +error[E0059]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:35:23 | LL | three_arg_repeat(1, X {}, ""); - | ^^^^ ^^^ ^ missing argument of type &str - | | || - | | |no parameter of type &'static str is needed three_arg_repeat - | | missing argument of type i32 - | no parameter of type X is needed three_arg_repeat + | ^^^^ expected i32, found X | note: function defined here --> $DIR/invalid_arguments.rs:9:4 | LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {} | ^^^^^^^^^^^^^^^^ ------- ------- -------- -help: the following changes might help - | -LL | three_arg_repeat(1, {i32}, ) {&str},; - | -- ^^^^^^^^^^ error[E0059]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:36:26 | LL | three_arg_repeat(1, 1, X {}); - | ^^^^ expected &str, found &str + | ^^^^ expected &str, found X | note: function defined here --> $DIR/invalid_arguments.rs:9:4 @@ -271,9 +243,9 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/invalid_arguments.rs:38:20 | LL | three_arg_repeat(X {}, X {}, ""); - | ^^^^ ^^^^ expected i32, found i32 + | ^^^^ ^^^^ expected i32, found X | | - | expected i32, found i32 + | expected i32, found X | note: function defined here --> $DIR/invalid_arguments.rs:9:4 @@ -289,50 +261,46 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/invalid_arguments.rs:39:20 | LL | three_arg_repeat(X {}, 1, X {}); - | ^^^^ ^^^^^ ^ missing argument of type &str - | | || - | | |no parameter of type X is needed three_arg_repeat - | | missing argument of type i32 - | no parameter of type X is needed three_arg_repeat + | ^^^^ ^^^^ expected &str, found X + | | + | expected i32, found X | note: function defined here --> $DIR/invalid_arguments.rs:9:4 | LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {} | ^^^^^^^^^^^^^^^^ ------- ------- -------- -help: the following changes might help +help: providing these parameters may help | -LL | three_arg_repeat(1, {i32}, ) {&str},; - | -- ^^^^^^-- ^^^^^^^ +LL | three_arg_repeat( {i32},, 1, {&str},); + | ^^^^^^ ^^^^^^^ error[E0059]: multiple arguments to this function are incorrect --> $DIR/invalid_arguments.rs:40:23 | LL | three_arg_repeat(1, X {}, X{}); - | ^^^^ ^^^^ ^ missing argument of type &str - | | || - | | |no parameter of type X is needed three_arg_repeat - | | missing argument of type i32 - | no parameter of type X is needed three_arg_repeat + | ^^^^ ^^^ expected &str, found X + | | + | expected i32, found X | note: function defined here --> $DIR/invalid_arguments.rs:9:4 | LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {} | ^^^^^^^^^^^^^^^^ ------- ------- -------- -help: the following changes might help +help: providing these parameters may help | -LL | three_arg_repeat(1, {i32}, ) {&str},; - | -- ^^^^^^^^^^ +LL | three_arg_repeat(1, {i32},, {&str},); + | ^^^^^^ ^^^^^^^ error[E0059]: multiple arguments to this function are incorrect --> $DIR/invalid_arguments.rs:42:20 | LL | three_arg_repeat(X {}, X {}, X {}); - | ^^^^ ^^^^ ^^^^ expected &str, found &str + | ^^^^ ^^^^ ^^^^ expected &str, found X | | | - | | expected i32, found i32 - | expected i32, found i32 + | | expected i32, found X + | expected i32, found X | note: function defined here --> $DIR/invalid_arguments.rs:9:4 diff --git a/src/test/ui/argument-suggestions/missing_arguments.stderr b/src/test/ui/argument-suggestions/missing_arguments.stderr index 2542732693e7d..5535c9520d015 100644 --- a/src/test/ui/argument-suggestions/missing_arguments.stderr +++ b/src/test/ui/argument-suggestions/missing_arguments.stderr @@ -288,26 +288,24 @@ LL | complex( {i32}, {f32}, {i32}, {f32 | ^^^^^^^ error[E0059]: multiple arguments to this function are incorrect - --> $DIR/missing_arguments.rs:39:45 + --> $DIR/missing_arguments.rs:39:48 | LL | complex( 1, "" ); - | ^^ ^ ^ - | | | | - | | | missing argument of type f32 - | | | missing argument of type &str - | | | missing argument of type i32 - | | missing argument of type f32 - | no parameter of type &'static str is needed complex + | ^ ^ + | | | + | | missing argument of type i32 + | | missing argument of type f32 + | missing argument of type f32 | note: function defined here --> $DIR/missing_arguments.rs:7:4 | LL | fn complex(_a: i32, _b: f32, _c: i32, _d: f32, _e: &str) {} | ^^^^^^^ ------- ------- ------- ------- -------- -help: the following changes might help +help: providing these parameters may help | -LL | complex( 1, {f32}, {f32}, {&str}, {i32},); - | -- ^^^^^^ ^^^^^^^ +LL | complex( 1, "" {f32}, {i32}, {f32},); + | ^^^^^^ ^^^^^^ error: aborting due to 19 previous errors diff --git a/src/test/ui/argument-suggestions/mixed_cases.stderr b/src/test/ui/argument-suggestions/mixed_cases.stderr index 205e165508fd3..f939d939a0e27 100644 --- a/src/test/ui/argument-suggestions/mixed_cases.stderr +++ b/src/test/ui/argument-suggestions/mixed_cases.stderr @@ -2,9 +2,9 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/mixed_cases.rs:10:15 | LL | two_args(1, "", X {}); - | ^^ ^^^^ no parameter of type X is needed two_args + | ^^ ^^^^ no parameter of type X is needed in two_args | | - | expected f32, found f32 + | expected f32, found &'static str | note: function defined here --> $DIR/mixed_cases.rs:5:4 @@ -20,9 +20,9 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/mixed_cases.rs:11:20 | LL | three_args(1, "", X {}, ""); - | ^^^^^ ^^ no parameter of type &'static str is needed three_args + | ^^^^^ ^^ no parameter of type &'static str is needed in three_args | || - | |no parameter of type X is needed three_args + | |no parameter of type X is needed in three_args | missing argument of type f32 | note: function defined here @@ -41,7 +41,7 @@ error[E0059]: multiple arguments to this function are incorrect LL | three_args(1, X {}); | ^^^^^ missing argument of type &str | | - | expected f32, found f32 + | expected f32, found X | note: function defined here --> $DIR/mixed_cases.rs:6:4 @@ -57,7 +57,7 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/mixed_cases.rs:17:20 | LL | three_args(1, "", X {}); - | ^^^^^ no parameter of type X is needed three_args + | ^^^^^ no parameter of type X is needed in three_args | | | missing argument of type f32 | @@ -77,7 +77,7 @@ error[E0059]: multiple arguments to this function are incorrect LL | three_args("", X {}, 1); | ^^ ^^^^ ^ expected &str, found &str | | | - | | expected f32, found f32 + | | expected f32, found X | expected i32, found i32 | note: function defined here From ddb50d35b892a6cb2a404483b13942626b99aec7 Mon Sep 17 00:00:00 2001 From: Pi Lanningham Date: Thu, 14 Jan 2021 23:16:57 -0500 Subject: [PATCH 13/21] Corrects the spans and types for the Invalid case Since the Invalid case covers a specific argument, we don't have to do span math or add commas, since all the comma, newline, etc. cases are in the original code --- .../rustc_typeck/src/check/fn_ctxt/checks.rs | 6 +- src/test/ui/argument-suggestions/basic.stderr | 8 ++ .../ui/argument-suggestions/complex.stderr | 4 +- .../extra_arguments.stderr | 8 +- .../invalid_arguments.stderr | 104 +++++++++++++----- .../missing_arguments.stderr | 54 +++++++-- .../argument-suggestions/mixed_cases.stderr | 14 +-- 7 files changed, 141 insertions(+), 57 deletions(-) diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs index 5f4eb31052ffe..fe22e09b77f87 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs @@ -664,7 +664,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { NoSuggestion | Provide => Provide, _ => Changes, }; - suggestions.push((span, format!(" {{{}}},", expected_type))); + suggestions.push((span, format!("{{{}}}", expected_type))); } Issue::Extra(arg) => { // FIXME: This could probably be a lot cleaner, but I dunno how @@ -815,8 +815,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let suggestion_text = match (suggestion_type, issue_count) { (Remove, 1) => Some("removing this argument may help"), (Remove, _) => Some("removing these argument may help"), - (Provide, 1) => None, - (Provide, _) => Some("providing these parameters may help"), + (Provide, 1) => Some("provideing a parameter of the correct type here may help"), + (Provide, _) => Some("providing parameters of these types may help"), (Swap, 1) => Some("swapping these two arguments might help"), (Swap, _) => Some("swapping these sets of arguments might help"), (Reorder, _) => Some("reordering these parameters might help"), diff --git a/src/test/ui/argument-suggestions/basic.stderr b/src/test/ui/argument-suggestions/basic.stderr index fba0ebe69b7bc..af152eefa1db7 100644 --- a/src/test/ui/argument-suggestions/basic.stderr +++ b/src/test/ui/argument-suggestions/basic.stderr @@ -9,6 +9,10 @@ note: function defined here | LL | fn invalid(_i: u32) {} | ^^^^^^^ ------- +help: provideing a parameter of the correct type here may help + | +LL | invalid({u32}); + | ^^^^^ error[E0059]: arguments to this function are incorrect --> $DIR/basic.rs:21:11 @@ -36,6 +40,10 @@ note: function defined here | LL | fn missing(_i: u32) {} | ^^^^^^^ ------- +help: provideing a parameter of the correct type here may help + | +LL | missing( {u32},); + | ^^^^^^ error[E0059]: arguments to this function are incorrect --> $DIR/basic.rs:23:13 diff --git a/src/test/ui/argument-suggestions/complex.stderr b/src/test/ui/argument-suggestions/complex.stderr index 0448e297aa917..fb3092052b885 100644 --- a/src/test/ui/argument-suggestions/complex.stderr +++ b/src/test/ui/argument-suggestions/complex.stderr @@ -19,8 +19,8 @@ LL | fn complex(_i: u32, _s: &str, _e: E, _f: F, _g: G, _x: X, _y: Y, _z: Z ) {} | ^^^^^^^ ------- -------- ----- ----- ----- ----- ----- ------ help: the following changes might help | -LL | complex( {u32},, &"", {E}, F::X2, G{}, X {}, Y {}, Z {}); - | ^^^^^^ -- ^^^^ ^^^^^ ^^^ ^^^^ ^^^^ ^^^^ +LL | complex({u32}, &"", {E}, F::X2, G{}, X {}, Y {}, Z {}); + | ^^^^^ -- ^^^^ ^^^^^ ^^^ ^^^^ ^^^^ ^^^^ error: aborting due to previous error diff --git a/src/test/ui/argument-suggestions/extra_arguments.stderr b/src/test/ui/argument-suggestions/extra_arguments.stderr index 528a7df8b5f2e..1eef5ec6d85cb 100644 --- a/src/test/ui/argument-suggestions/extra_arguments.stderr +++ b/src/test/ui/argument-suggestions/extra_arguments.stderr @@ -106,8 +106,8 @@ LL | fn two_arg_diff(_a: i32, _b: &str) {} | ^^^^^^^^^^^^ ------- -------- help: the following changes might help | -LL | two_arg_diff(1, {&str},, ); - | ^^^^^^^ -- +LL | two_arg_diff(1, {&str}, ); + | ^^^^^^ -- error[E0059]: arguments to this function are incorrect --> $DIR/extra_arguments.rs:17:23 @@ -140,8 +140,8 @@ LL | fn two_arg_diff(_a: i32, _b: &str) {} | ^^^^^^^^^^^^ ------- -------- help: the following changes might help | -LL | two_arg_diff(1, {&str},, ); - | ^^^^^^^ -- -- +LL | two_arg_diff(1, {&str}, ); + | ^^^^^^ -- -- error[E0059]: multiple arguments to this function are incorrect --> $DIR/extra_arguments.rs:19:23 diff --git a/src/test/ui/argument-suggestions/invalid_arguments.stderr b/src/test/ui/argument-suggestions/invalid_arguments.stderr index e69a9e61f8496..e741d48e3fa90 100644 --- a/src/test/ui/argument-suggestions/invalid_arguments.stderr +++ b/src/test/ui/argument-suggestions/invalid_arguments.stderr @@ -9,6 +9,10 @@ note: function defined here | LL | fn one_arg(_a: i32) {} | ^^^^^^^ ------- +help: provideing a parameter of the correct type here may help + | +LL | one_arg({i32}); + | ^^^^^ error[E0059]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:16:19 @@ -21,6 +25,10 @@ note: function defined here | LL | fn two_arg_same(_a: i32, _b: i32) {} | ^^^^^^^^^^^^ ------- ------- +help: provideing a parameter of the correct type here may help + | +LL | two_arg_same(1, {i32}); + | ^^^^^ error[E0059]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:17:16 @@ -33,6 +41,10 @@ note: function defined here | LL | fn two_arg_same(_a: i32, _b: i32) {} | ^^^^^^^^^^^^ ------- ------- +help: provideing a parameter of the correct type here may help + | +LL | two_arg_same({i32}, 1); + | ^^^^^ error[E0059]: multiple arguments to this function are incorrect --> $DIR/invalid_arguments.rs:18:16 @@ -47,10 +59,10 @@ note: function defined here | LL | fn two_arg_same(_a: i32, _b: i32) {} | ^^^^^^^^^^^^ ------- ------- -help: providing these parameters may help +help: providing parameters of these types may help | -LL | two_arg_same( {i32},, {i32},); - | ^^^^^^ ^^^^^^ +LL | two_arg_same({i32}, {i32}); + | ^^^^^ ^^^^^ error[E0059]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:19:19 @@ -63,6 +75,10 @@ note: function defined here | LL | fn two_arg_diff(_a: i32, _b: f32) {} | ^^^^^^^^^^^^ ------- ------- +help: provideing a parameter of the correct type here may help + | +LL | two_arg_diff(1, {f32}); + | ^^^^^ error[E0059]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:20:16 @@ -75,6 +91,10 @@ note: function defined here | LL | fn two_arg_diff(_a: i32, _b: f32) {} | ^^^^^^^^^^^^ ------- ------- +help: provideing a parameter of the correct type here may help + | +LL | two_arg_diff({i32}, 1.0); + | ^^^^^ error[E0059]: multiple arguments to this function are incorrect --> $DIR/invalid_arguments.rs:21:16 @@ -89,10 +109,10 @@ note: function defined here | LL | fn two_arg_diff(_a: i32, _b: f32) {} | ^^^^^^^^^^^^ ------- ------- -help: providing these parameters may help +help: providing parameters of these types may help | -LL | two_arg_diff( {i32},, {f32},); - | ^^^^^^ ^^^^^^ +LL | two_arg_diff({i32}, {f32}); + | ^^^^^ ^^^^^ error[E0059]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:24:18 @@ -105,6 +125,10 @@ note: function defined here | LL | fn three_arg_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^^^^^ ------- ------- -------- +help: provideing a parameter of the correct type here may help + | +LL | three_arg_diff({i32}, 1.0, ""); + | ^^^^^ error[E0059]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:25:21 @@ -117,6 +141,10 @@ note: function defined here | LL | fn three_arg_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^^^^^ ------- ------- -------- +help: provideing a parameter of the correct type here may help + | +LL | three_arg_diff(1, {f32}, ""); + | ^^^^^ error[E0059]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:26:26 @@ -129,6 +157,10 @@ note: function defined here | LL | fn three_arg_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^^^^^ ------- ------- -------- +help: provideing a parameter of the correct type here may help + | +LL | three_arg_diff(1, 1.0, {&str}); + | ^^^^^^ error[E0059]: multiple arguments to this function are incorrect --> $DIR/invalid_arguments.rs:28:18 @@ -143,10 +175,10 @@ note: function defined here | LL | fn three_arg_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^^^^^ ------- ------- -------- -help: providing these parameters may help +help: providing parameters of these types may help | -LL | three_arg_diff( {i32},, {f32},, ""); - | ^^^^^^ ^^^^^^ +LL | three_arg_diff({i32}, {f32}, ""); + | ^^^^^ ^^^^^ error[E0059]: multiple arguments to this function are incorrect --> $DIR/invalid_arguments.rs:29:18 @@ -161,10 +193,10 @@ note: function defined here | LL | fn three_arg_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^^^^^ ------- ------- -------- -help: providing these parameters may help +help: providing parameters of these types may help | -LL | three_arg_diff( {i32},, 1.0, {&str},); - | ^^^^^^ ^^^^^^^ +LL | three_arg_diff({i32}, 1.0, {&str}); + | ^^^^^ ^^^^^^ error[E0059]: multiple arguments to this function are incorrect --> $DIR/invalid_arguments.rs:30:21 @@ -179,10 +211,10 @@ note: function defined here | LL | fn three_arg_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^^^^^ ------- ------- -------- -help: providing these parameters may help +help: providing parameters of these types may help | -LL | three_arg_diff(1, {f32},, {&str},); - | ^^^^^^ ^^^^^^^ +LL | three_arg_diff(1, {f32}, {&str}); + | ^^^^^ ^^^^^^ error[E0059]: multiple arguments to this function are incorrect --> $DIR/invalid_arguments.rs:32:18 @@ -198,10 +230,10 @@ note: function defined here | LL | fn three_arg_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^^^^^ ------- ------- -------- -help: providing these parameters may help +help: providing parameters of these types may help | -LL | three_arg_diff( {i32},, {f32},, {&str},); - | ^^^^^^ ^^^^^^ ^^^^^^^ +LL | three_arg_diff({i32}, {f32}, {&str}); + | ^^^^^ ^^^^^ ^^^^^^ error[E0059]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:34:20 @@ -214,6 +246,10 @@ note: function defined here | LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {} | ^^^^^^^^^^^^^^^^ ------- ------- -------- +help: provideing a parameter of the correct type here may help + | +LL | three_arg_repeat({i32}, 1, ""); + | ^^^^^ error[E0059]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:35:23 @@ -226,6 +262,10 @@ note: function defined here | LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {} | ^^^^^^^^^^^^^^^^ ------- ------- -------- +help: provideing a parameter of the correct type here may help + | +LL | three_arg_repeat(1, {i32}, ""); + | ^^^^^ error[E0059]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:36:26 @@ -238,6 +278,10 @@ note: function defined here | LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {} | ^^^^^^^^^^^^^^^^ ------- ------- -------- +help: provideing a parameter of the correct type here may help + | +LL | three_arg_repeat(1, 1, {&str}); + | ^^^^^^ error[E0059]: multiple arguments to this function are incorrect --> $DIR/invalid_arguments.rs:38:20 @@ -252,10 +296,10 @@ note: function defined here | LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {} | ^^^^^^^^^^^^^^^^ ------- ------- -------- -help: providing these parameters may help +help: providing parameters of these types may help | -LL | three_arg_repeat( {i32},, {i32},, ""); - | ^^^^^^ ^^^^^^ +LL | three_arg_repeat({i32}, {i32}, ""); + | ^^^^^ ^^^^^ error[E0059]: multiple arguments to this function are incorrect --> $DIR/invalid_arguments.rs:39:20 @@ -270,10 +314,10 @@ note: function defined here | LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {} | ^^^^^^^^^^^^^^^^ ------- ------- -------- -help: providing these parameters may help +help: providing parameters of these types may help | -LL | three_arg_repeat( {i32},, 1, {&str},); - | ^^^^^^ ^^^^^^^ +LL | three_arg_repeat({i32}, 1, {&str}); + | ^^^^^ ^^^^^^ error[E0059]: multiple arguments to this function are incorrect --> $DIR/invalid_arguments.rs:40:23 @@ -288,10 +332,10 @@ note: function defined here | LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {} | ^^^^^^^^^^^^^^^^ ------- ------- -------- -help: providing these parameters may help +help: providing parameters of these types may help | -LL | three_arg_repeat(1, {i32},, {&str},); - | ^^^^^^ ^^^^^^^ +LL | three_arg_repeat(1, {i32}, {&str}); + | ^^^^^ ^^^^^^ error[E0059]: multiple arguments to this function are incorrect --> $DIR/invalid_arguments.rs:42:20 @@ -307,10 +351,10 @@ note: function defined here | LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {} | ^^^^^^^^^^^^^^^^ ------- ------- -------- -help: providing these parameters may help +help: providing parameters of these types may help | -LL | three_arg_repeat( {i32},, {i32},, {&str},); - | ^^^^^^ ^^^^^^ ^^^^^^^ +LL | three_arg_repeat({i32}, {i32}, {&str}); + | ^^^^^ ^^^^^ ^^^^^^ error: aborting due to 21 previous errors diff --git a/src/test/ui/argument-suggestions/missing_arguments.stderr b/src/test/ui/argument-suggestions/missing_arguments.stderr index 5535c9520d015..c35cfb69369cb 100644 --- a/src/test/ui/argument-suggestions/missing_arguments.stderr +++ b/src/test/ui/argument-suggestions/missing_arguments.stderr @@ -9,6 +9,10 @@ note: function defined here | LL | fn one_arg(_a: i32) {} | ^^^^^^^ ------- +help: provideing a parameter of the correct type here may help + | +LL | one_arg( {i32},); + | ^^^^^^ error[E0059]: multiple arguments to this function are incorrect --> $DIR/missing_arguments.rs:14:27 @@ -24,7 +28,7 @@ note: function defined here | LL | fn two_same(_a: i32, _b: i32) {} | ^^^^^^^^ ------- ------- -help: providing these parameters may help +help: providing parameters of these types may help | LL | two_same( {i32}, {i32},); | ^^^^^^ @@ -40,6 +44,10 @@ note: function defined here | LL | fn two_same(_a: i32, _b: i32) {} | ^^^^^^^^ ------- ------- +help: provideing a parameter of the correct type here may help + | +LL | two_same( 1 {i32},); + | ^^^^^^ error[E0059]: multiple arguments to this function are incorrect --> $DIR/missing_arguments.rs:16:27 @@ -55,7 +63,7 @@ note: function defined here | LL | fn two_diff(_a: i32, _b: f32) {} | ^^^^^^^^ ------- ------- -help: providing these parameters may help +help: providing parameters of these types may help | LL | two_diff( {i32}, {f32},); | ^^^^^^ @@ -71,6 +79,10 @@ note: function defined here | LL | fn two_diff(_a: i32, _b: f32) {} | ^^^^^^^^ ------- ------- +help: provideing a parameter of the correct type here may help + | +LL | two_diff( 1 {f32},); + | ^^^^^^ error[E0059]: arguments to this function are incorrect --> $DIR/missing_arguments.rs:18:26 @@ -83,6 +95,10 @@ note: function defined here | LL | fn two_diff(_a: i32, _b: f32) {} | ^^^^^^^^ ------- ------- +help: provideing a parameter of the correct type here may help + | +LL | two_diff( 1.0 {i32}, ); + | ^^^^^^ error[E0059]: multiple arguments to this function are incorrect --> $DIR/missing_arguments.rs:21:37 @@ -99,7 +115,7 @@ note: function defined here | LL | fn three_same(_a: i32, _b: i32, _c: i32) {} | ^^^^^^^^^^ ------- ------- ------- -help: providing these parameters may help +help: providing parameters of these types may help | LL | three_same( {i32}, {i32}, {i32},); | ^^^^^^ @@ -118,7 +134,7 @@ note: function defined here | LL | fn three_same(_a: i32, _b: i32, _c: i32) {} | ^^^^^^^^^^ ------- ------- ------- -help: providing these parameters may help +help: providing parameters of these types may help | LL | three_same( 1 {i32}, {i32},); | ^^^^^^ @@ -134,6 +150,10 @@ note: function defined here | LL | fn three_same(_a: i32, _b: i32, _c: i32) {} | ^^^^^^^^^^ ------- ------- ------- +help: provideing a parameter of the correct type here may help + | +LL | three_same( 1, 1 {i32},); + | ^^^^^^ error[E0059]: arguments to this function are incorrect --> $DIR/missing_arguments.rs:26:28 @@ -146,6 +166,10 @@ note: function defined here | LL | fn three_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- +help: provideing a parameter of the correct type here may help + | +LL | three_diff( 1.0, {i32}, "" ); + | ^^^^^^ error[E0059]: arguments to this function are incorrect --> $DIR/missing_arguments.rs:27:36 @@ -158,6 +182,10 @@ note: function defined here | LL | fn three_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- +help: provideing a parameter of the correct type here may help + | +LL | three_diff( 1, "" {f32}, ); + | ^^^^^^ error[E0059]: arguments to this function are incorrect --> $DIR/missing_arguments.rs:28:37 @@ -170,6 +198,10 @@ note: function defined here | LL | fn three_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- +help: provideing a parameter of the correct type here may help + | +LL | three_diff( 1, 1.0, {&str},); + | ^^^^^^^ error[E0059]: multiple arguments to this function are incorrect --> $DIR/missing_arguments.rs:29:36 @@ -184,7 +216,7 @@ note: function defined here | LL | fn three_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- -help: providing these parameters may help +help: providing parameters of these types may help | LL | three_diff( "" {i32}, {f32},); | ^^^^^^ ^^^^^^ @@ -202,7 +234,7 @@ note: function defined here | LL | fn three_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- -help: providing these parameters may help +help: providing parameters of these types may help | LL | three_diff( 1.0 {i32}, {&str},); | ^^^^^^ ^^^^^^^ @@ -221,7 +253,7 @@ note: function defined here | LL | fn three_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- -help: providing these parameters may help +help: providing parameters of these types may help | LL | three_diff( 1, {f32}, {&str},); | ^^^^^^^ @@ -242,7 +274,7 @@ note: function defined here | LL | fn four_repeated(_a: i32, _b: f32, _c: f32, _d: &str) {} | ^^^^^^^^^^^^^ ------- ------- ------- -------- -help: providing these parameters may help +help: providing parameters of these types may help | LL | four_repeated( {i32}, {f32}, {f32}, {&str},); | ^^^^^^^ @@ -260,7 +292,7 @@ note: function defined here | LL | fn four_repeated(_a: i32, _b: f32, _c: f32, _d: &str) {} | ^^^^^^^^^^^^^ ------- ------- ------- -------- -help: providing these parameters may help +help: providing parameters of these types may help | LL | four_repeated( 1, "" {f32}, {f32},); | ^^^^^^ ^^^^^^ @@ -282,7 +314,7 @@ note: function defined here | LL | fn complex(_a: i32, _b: f32, _c: i32, _d: f32, _e: &str) {} | ^^^^^^^ ------- ------- ------- ------- -------- -help: providing these parameters may help +help: providing parameters of these types may help | LL | complex( {i32}, {f32}, {i32}, {f32}, {&str},); | ^^^^^^^ @@ -302,7 +334,7 @@ note: function defined here | LL | fn complex(_a: i32, _b: f32, _c: i32, _d: f32, _e: &str) {} | ^^^^^^^ ------- ------- ------- ------- -------- -help: providing these parameters may help +help: providing parameters of these types may help | LL | complex( 1, "" {f32}, {i32}, {f32},); | ^^^^^^ ^^^^^^ diff --git a/src/test/ui/argument-suggestions/mixed_cases.stderr b/src/test/ui/argument-suggestions/mixed_cases.stderr index f939d939a0e27..2a45f0a985f5c 100644 --- a/src/test/ui/argument-suggestions/mixed_cases.stderr +++ b/src/test/ui/argument-suggestions/mixed_cases.stderr @@ -13,8 +13,8 @@ LL | fn two_args(_a: i32, _b: f32) {} | ^^^^^^^^ ------- ------- help: the following changes might help | -LL | two_args(1, {f32},, ); - | ^^^^^^ -- +LL | two_args(1, {f32}, ); + | ^^^^^ -- error[E0059]: multiple arguments to this function are incorrect --> $DIR/mixed_cases.rs:11:20 @@ -48,10 +48,10 @@ note: function defined here | LL | fn three_args(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- -help: providing these parameters may help +help: providing parameters of these types may help | -LL | three_args(1, {f32}, {&str},); - | ^^^^^^^^^^^ +LL | three_args(1, {f32} {&str},); + | ^^^^^^^^^^^^ error[E0059]: multiple arguments to this function are incorrect --> $DIR/mixed_cases.rs:17:20 @@ -87,8 +87,8 @@ LL | fn three_args(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- help: the following changes might help | -LL | three_args(1, {f32},, ""); - | ^ ^^^^^^ ^^ +LL | three_args(1, {f32}, ""); + | ^ ^^^^^ ^^ error[E0059]: multiple arguments to this function are incorrect --> $DIR/mixed_cases.rs:23:14 From b8c651f17de7a694df91d14eddec13ff5fa50fd9 Mon Sep 17 00:00:00 2001 From: Pi Lanningham Date: Fri, 15 Jan 2021 01:57:02 -0500 Subject: [PATCH 14/21] A fix for a &str type check, and a pass at extra span alignment There were some test cases where "" wasn't typechecking against &str in the "soft" typechecking path (the one that doesn't persist new constraints.) I found a method that appears to typecheck without persisting new constraints, but I can't be sure, so I'll need to double check that. For now, this new expression typechecking method works well. This also tries to carefully handle eliminating extra arguments. Spans are tricky, as we need to eliminate commas correctly, and the suggestion code gets angry if we have overlapping spans, so this tries to find contiguous blocks to eliminate. I'll probably simplify this now that I understand the logic a bit better, but it's late, so I'm going to bed. --- compiler/rustc_typeck/src/check/expr.rs | 2 +- .../rustc_typeck/src/check/fn_ctxt/checks.rs | 134 +++++++++++---- src/test/ui/argument-suggestions/basic.stderr | 2 +- .../ui/argument-suggestions/complex.stderr | 4 +- .../argument-suggestions/extra_arguments.rs | 15 ++ .../extra_arguments.stderr | 156 ++++++++++++------ .../argument-suggestions/mixed_cases.stderr | 20 +-- .../ui/argument-suggestions/scratch.stdout | 11 ++ 8 files changed, 244 insertions(+), 100 deletions(-) create mode 100644 src/test/ui/argument-suggestions/scratch.stdout diff --git a/compiler/rustc_typeck/src/check/expr.rs b/compiler/rustc_typeck/src/check/expr.rs index 93eb2cfc72a80..1e6d590e74d8b 100644 --- a/compiler/rustc_typeck/src/check/expr.rs +++ b/compiler/rustc_typeck/src/check/expr.rs @@ -221,7 +221,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ty } - fn check_expr_kind( + pub(super) fn check_expr_kind( &self, expr: &'tcx hir::Expr<'tcx>, expected: Expectation<'tcx>, diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs index fe22e09b77f87..def78223f914e 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs @@ -235,6 +235,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let check_compatible = |arg_idx, input_idx| { let formal_input_ty: Ty<'tcx> = formal_input_tys[input_idx]; let expected_input_ty: Ty<'tcx> = expected_input_tys[input_idx]; + // If either is an error type, we defy the usual convention and consider them to *not* be // coercible. This prevents our error message heuristic from trying to pass errors into @@ -244,25 +245,27 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } let provided_arg: &hir::Expr<'tcx> = &provided_args[arg_idx]; - let tables = self.in_progress_typeck_results.map(|t| t.borrow()).unwrap(); - let maybe_ty = tables.node_type_opt(provided_arg.hir_id); - if let Some(checked_ty) = maybe_ty { - let expectation = Expectation::rvalue_hint(self, expected_input_ty); - let coerced_ty = expectation.only_has_type(self).unwrap_or(formal_input_ty); - let can_coerce = self.can_coerce(checked_ty, coerced_ty); - - let is_super = self - .at(&self.misc(provided_arg.span), self.param_env) - .sup(formal_input_ty, coerced_ty) - .is_ok(); - // Same as above: if either the coerce type or the checked type is an error type, - // consider them *not* compatible. - return !coerced_ty.references_error() - && !checked_ty.references_error() - && can_coerce - && is_super; - } - return false; + let expectation = Expectation::rvalue_hint(self, expected_input_ty); + // TODO: check that this is safe; I don't believe this commits any of the obligations, but I can't be sure. + // + // I had another method of "soft" type checking before, + // but it was failing to find the type of some expressions (like "") + // so I prodded this method and made it pub(super) so I could call it, and it seems to work well. + let checked_ty = self.check_expr_kind(provided_arg, expectation); + + let coerced_ty = expectation.only_has_type(self).unwrap_or(formal_input_ty); + let can_coerce = self.can_coerce(checked_ty, coerced_ty); + + let is_super = self + .at(&self.misc(provided_arg.span), self.param_env) + .sup(formal_input_ty, coerced_ty) + .is_ok(); + // Same as above: if either the coerce type or the checked type is an error type, + // consider them *not* compatible. + return !coerced_ty.references_error() + && !checked_ty.references_error() + && can_coerce + && is_super; }; // Check each argument, to satisfy the input it was provided for @@ -652,6 +655,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let mut labels = vec![]; let mut suggestions = vec![]; let mut suggestion_type = NoSuggestion; + let mut eliminated_args = vec![false; provided_arg_count]; let source_map = self.sess().source_map(); for issue in issues { match issue { @@ -667,18 +671,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { suggestions.push((span, format!("{{{}}}", expected_type))); } Issue::Extra(arg) => { - // FIXME: This could probably be a lot cleaner, but I dunno how let span = provided_args[arg].span; - let hungry_span = if arg < provided_args.len() - 1 { - // Eat the comma - Span::new( - span.lo(), - span.hi() + BytePos(2), - span.ctxt(), - ) - } else { - span - }; + + // We want to suggest deleting this arg, + // but dealing with formatting before and after is tricky + // so we mark it as deleted, so we can do a scan afterwards + eliminated_args[arg] = true; let found_type = self.check_expr(&provided_args[arg]); // TODO: if someone knows the method-chain-foo to achieve this, let me know // but I didn't have the patience for it lol @@ -688,23 +686,22 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let descr = def_kind.descr(def_id); if let Some(node) = node { if let Some(ident) = node.ident() { - format!("in {}", ident) + format!("for {}", ident) } else { - format!("in this {}", descr) + format!("for this {}", descr) } } else { - format!("in this {}", descr) + format!("for this {}", descr) } } else { "here".to_string() }; - labels.push((span, format!("no parameter of type {} is needed {}", found_type, fn_name))); + labels.push((span, format!("this parameter of type {} isn't needed {}", found_type, fn_name))); suggestion_type = match suggestion_type { NoSuggestion | Remove => Remove, _ => Changes, }; - suggestions.push((hungry_span, format!(""))); } Issue::Missing(arg) => { // FIXME: The spans here are all kinds of wrong for multiple missing arguments etc. @@ -808,13 +805,78 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { for (span, label) in labels { err.span_label(span, label); } + + // Before constructing our multipart suggestions, we need to add in all the suggestions + // to eliminate extra parameters + // We can't overlap spans in a suggestion or weird things happen + let mut lo = None; + let mut hi = None; + let mut in_block = false; + for (idx, eliminated) in eliminated_args.iter().enumerate() { + match (in_block, eliminated, idx == eliminated_args.len() - 1) { + (false, true, false) => { + // We just encountered the start of a block of eliminated parameters + lo = Some(idx); + in_block = true; + }, + (false, true, true) => { + // We encountered a single eliminated arg at the end of the arg list + lo = Some(idx); + hi = Some(idx); + } + (true, false, _) => { + // We encountered the end of a block, set the hi so the logic below kicks in + hi = Some(idx - 1); + in_block = false; + }, + (true, true, true) => { + hi = Some(idx); + in_block = false; + } + _ => {} + } + if lo.is_some() && hi.is_some() { + let (lo_idx, hi_idx) = (lo.unwrap(), hi.unwrap()); + // We've found a contiguous block, so emit the elimination + // be careful abound the boundaries + let ctxt = provided_args[0].span.ctxt(); + let (lo_bp, hi_bp) = match (lo_idx == 0, hi_idx == provided_arg_count - 1) { + // If we have an arg to our left, chop off it's comma + // a, xx, xx, xx + // [-----------) + (false, _) => { + (provided_args[lo_idx - 1].span.hi(), provided_args[hi_idx].span.hi()) + }, + // If we start from the first arg, and we have an arg to our right, chop of the last params comma + // xx, xx, xx, a + // [-----------) + (true, false) => { + (provided_args[lo_idx].span.lo(), provided_args[hi_idx + 1].span.lo()) + }, + // If every argument was eliminated, don't need to worry about commas before or after + // xx, xx, xx, xx + // [-------------) + (true, true) => { + (provided_args[lo_idx].span.lo(), provided_args[hi_idx].span.hi()) + }, + }; + let eliminated_span = Span::new( + lo_bp, + hi_bp, + ctxt, + ); + suggestions.push((eliminated_span, "".to_string())); + lo = None; + hi = None; + } + } // And add a series of suggestions // FIXME: for simpler cases, this might be overkill if suggestions.len() > 0 { let suggestion_text = match (suggestion_type, issue_count) { (Remove, 1) => Some("removing this argument may help"), - (Remove, _) => Some("removing these argument may help"), + (Remove, _) => Some("removing these arguments may help"), (Provide, 1) => Some("provideing a parameter of the correct type here may help"), (Provide, _) => Some("providing parameters of these types may help"), (Swap, 1) => Some("swapping these two arguments might help"), diff --git a/src/test/ui/argument-suggestions/basic.stderr b/src/test/ui/argument-suggestions/basic.stderr index af152eefa1db7..773125339b386 100644 --- a/src/test/ui/argument-suggestions/basic.stderr +++ b/src/test/ui/argument-suggestions/basic.stderr @@ -20,7 +20,7 @@ error[E0059]: arguments to this function are incorrect LL | extra(""); | ^^ | | - | no parameter of type &'static str is needed in extra + | this parameter of type &'static str isn't needed for extra | help: removing this argument may help | note: function defined here diff --git a/src/test/ui/argument-suggestions/complex.stderr b/src/test/ui/argument-suggestions/complex.stderr index fb3092052b885..1417933409b81 100644 --- a/src/test/ui/argument-suggestions/complex.stderr +++ b/src/test/ui/argument-suggestions/complex.stderr @@ -9,7 +9,7 @@ LL | complex(1.0, H {}, &"", G{}, F::X2, Z {}, X {}, Y {}); | | | || expected G, found G | | | |expected F, found F | | | missing argument of type E - | | no parameter of type H is needed in complex + | | this parameter of type H isn't needed for complex | expected u32, found {float} | note: function defined here @@ -20,7 +20,7 @@ LL | fn complex(_i: u32, _s: &str, _e: E, _f: F, _g: G, _x: X, _y: Y, _z: Z ) {} help: the following changes might help | LL | complex({u32}, &"", {E}, F::X2, G{}, X {}, Y {}, Z {}); - | ^^^^^ -- ^^^^ ^^^^^ ^^^ ^^^^ ^^^^ ^^^^ + | ^^--^ ^^^^ ^^^^^ ^^^ ^^^^ ^^^^ ^^^^ error: aborting due to previous error diff --git a/src/test/ui/argument-suggestions/extra_arguments.rs b/src/test/ui/argument-suggestions/extra_arguments.rs index 5f8e192209839..0788a58658893 100644 --- a/src/test/ui/argument-suggestions/extra_arguments.rs +++ b/src/test/ui/argument-suggestions/extra_arguments.rs @@ -17,4 +17,19 @@ fn main() { two_arg_diff(1, "", ""); //~ ERROR arguments to this function are incorrect two_arg_diff(1, 1, "", ""); //~ ERROR arguments to this function are incorrect two_arg_diff(1, "", 1, ""); //~ ERROR arguments to this function are incorrect + + // Check with weird spacing and newlines + two_arg_same(1, 1, ""); //~ ERROR arguments to this function are incorrect + two_arg_diff(1, 1, ""); //~ ERROR arguments to this function are incorrect + two_arg_same( + 1, + 1, + "" //~ ERROR arguments to this function are incorrect + ); + + two_arg_diff( + 1, + 1, //~ ERROR arguments to this function are incorrect + "" + ); } \ No newline at end of file diff --git a/src/test/ui/argument-suggestions/extra_arguments.stderr b/src/test/ui/argument-suggestions/extra_arguments.stderr index 1eef5ec6d85cb..f2ec9e33ead57 100644 --- a/src/test/ui/argument-suggestions/extra_arguments.stderr +++ b/src/test/ui/argument-suggestions/extra_arguments.stderr @@ -4,7 +4,7 @@ error[E0059]: arguments to this function are incorrect LL | empty(""); | ^^ | | - | no parameter of type &'static str is needed in empty + | this parameter of type &'static str isn't needed for empty | help: removing this argument may help | note: function defined here @@ -17,10 +17,10 @@ error[E0059]: arguments to this function are incorrect --> $DIR/extra_arguments.rs:9:14 | LL | one_arg(1, 1); - | ^ - | | - | no parameter of type {integer} is needed in one_arg - | help: removing this argument may help + | --^ + | | | + | | this parameter of type {integer} isn't needed for one_arg + | help: removing this argument may help | note: function defined here --> $DIR/extra_arguments.rs:2:4 @@ -32,10 +32,10 @@ error[E0059]: arguments to this function are incorrect --> $DIR/extra_arguments.rs:10:14 | LL | one_arg(1, ""); - | ^^ - | | - | no parameter of type &'static str is needed in one_arg - | help: removing this argument may help + | --^^ + | | | + | | this parameter of type &'static str isn't needed for one_arg + | help: removing this argument may help | note: function defined here --> $DIR/extra_arguments.rs:2:4 @@ -47,28 +47,26 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/extra_arguments.rs:11:14 | LL | one_arg(1, "", 1.0); - | ^^ ^^^ no parameter of type {float} is needed in one_arg - | | - | no parameter of type &'static str is needed in one_arg + | --^^--^^^ + | | | | + | | | this parameter of type {float} isn't needed for one_arg + | | this parameter of type &'static str isn't needed for one_arg + | help: removing these arguments may help | note: function defined here --> $DIR/extra_arguments.rs:2:4 | LL | fn one_arg(_a: i32) {} | ^^^^^^^ ------- -help: removing these argument may help - | -LL | one_arg(1, ); - | -- -- error[E0059]: arguments to this function are incorrect --> $DIR/extra_arguments.rs:13:22 | LL | two_arg_same(1, 1, 1); - | ^ - | | - | no parameter of type {integer} is needed in two_arg_same - | help: removing this argument may help + | --^ + | | | + | | this parameter of type {integer} isn't needed for two_arg_same + | help: removing this argument may help | note: function defined here --> $DIR/extra_arguments.rs:3:4 @@ -80,10 +78,10 @@ error[E0059]: arguments to this function are incorrect --> $DIR/extra_arguments.rs:14:22 | LL | two_arg_same(1, 1, 1.0); - | ^^^ - | | - | no parameter of type {float} is needed in two_arg_same - | help: removing this argument may help + | --^^^ + | | | + | | this parameter of type {float} isn't needed for two_arg_same + | help: removing this argument may help | note: function defined here --> $DIR/extra_arguments.rs:3:4 @@ -91,32 +89,29 @@ note: function defined here LL | fn two_arg_same(_a: i32, _b: i32) {} | ^^^^^^^^^^^^ ------- ------- -error[E0059]: multiple arguments to this function are incorrect +error[E0059]: arguments to this function are incorrect --> $DIR/extra_arguments.rs:16:19 | LL | two_arg_diff(1, 1, ""); - | ^ ^^ no parameter of type &'static str is needed in two_arg_diff - | | - | expected &str, found {integer} + | --^ + | | | + | | this parameter of type {integer} isn't needed for two_arg_diff + | help: removing this argument may help | note: function defined here --> $DIR/extra_arguments.rs:4:4 | LL | fn two_arg_diff(_a: i32, _b: &str) {} | ^^^^^^^^^^^^ ------- -------- -help: the following changes might help - | -LL | two_arg_diff(1, {&str}, ); - | ^^^^^^ -- error[E0059]: arguments to this function are incorrect --> $DIR/extra_arguments.rs:17:23 | LL | two_arg_diff(1, "", ""); - | ^^ - | | - | no parameter of type &'static str is needed in two_arg_diff - | help: removing this argument may help + | --^^ + | | | + | | this parameter of type &'static str isn't needed for two_arg_diff + | help: removing this argument may help | note: function defined here --> $DIR/extra_arguments.rs:4:4 @@ -128,39 +123,100 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/extra_arguments.rs:18:19 | LL | two_arg_diff(1, 1, "", ""); - | ^ ^^ ^^ no parameter of type &'static str is needed in two_arg_diff - | | | - | | no parameter of type &'static str is needed in two_arg_diff - | expected &str, found {integer} + | ^ ^^ this parameter of type &'static str isn't needed for two_arg_diff + | | + | this parameter of type {integer} isn't needed for two_arg_diff | note: function defined here --> $DIR/extra_arguments.rs:4:4 | LL | fn two_arg_diff(_a: i32, _b: &str) {} | ^^^^^^^^^^^^ ------- -------- -help: the following changes might help +help: removing these arguments may help | -LL | two_arg_diff(1, {&str}, ); - | ^^^^^^ -- -- +LL | two_arg_diff(1, ""); + | -- -- error[E0059]: multiple arguments to this function are incorrect --> $DIR/extra_arguments.rs:19:23 | LL | two_arg_diff(1, "", 1, ""); - | ^ ^^ no parameter of type &'static str is needed in two_arg_diff - | | - | no parameter of type {integer} is needed in two_arg_diff + | --^--^^ + | | | | + | | | this parameter of type &'static str isn't needed for two_arg_diff + | | this parameter of type {integer} isn't needed for two_arg_diff + | help: removing these arguments may help | note: function defined here --> $DIR/extra_arguments.rs:4:4 | LL | fn two_arg_diff(_a: i32, _b: &str) {} | ^^^^^^^^^^^^ ------- -------- -help: removing these argument may help + +error[E0059]: arguments to this function are incorrect + --> $DIR/extra_arguments.rs:22:26 + | +LL | two_arg_same(1, 1, ""); + | ------^^ + | | | + | | this parameter of type &'static str isn't needed for two_arg_same + | help: removing this argument may help + | +note: function defined here + --> $DIR/extra_arguments.rs:3:4 + | +LL | fn two_arg_same(_a: i32, _b: i32) {} + | ^^^^^^^^^^^^ ------- ------- + +error[E0059]: arguments to this function are incorrect + --> $DIR/extra_arguments.rs:23:19 + | +LL | two_arg_diff(1, 1, ""); + | --^ + | | | + | | this parameter of type {integer} isn't needed for two_arg_diff + | help: removing this argument may help + | +note: function defined here + --> $DIR/extra_arguments.rs:4:4 | -LL | two_arg_diff(1, "", ); - | -- -- +LL | fn two_arg_diff(_a: i32, _b: &str) {} + | ^^^^^^^^^^^^ ------- -------- + +error[E0059]: arguments to this function are incorrect + --> $DIR/extra_arguments.rs:27:5 + | +LL | 1, + | ______- +LL | | "" + | | ^- + | |_____|| + | |help: removing this argument may help + | this parameter of type &'static str isn't needed for two_arg_same + | +note: function defined here + --> $DIR/extra_arguments.rs:3:4 + | +LL | fn two_arg_same(_a: i32, _b: i32) {} + | ^^^^^^^^^^^^ ------- ------- + +error[E0059]: arguments to this function are incorrect + --> $DIR/extra_arguments.rs:32:5 + | +LL | 1, + | ______- +LL | | 1, + | | ^ + | | | + | |_____this parameter of type {integer} isn't needed for two_arg_diff + | help: removing this argument may help + | +note: function defined here + --> $DIR/extra_arguments.rs:4:4 + | +LL | fn two_arg_diff(_a: i32, _b: &str) {} + | ^^^^^^^^^^^^ ------- -------- -error: aborting due to 10 previous errors +error: aborting due to 14 previous errors For more information about this error, try `rustc --explain E0059`. diff --git a/src/test/ui/argument-suggestions/mixed_cases.stderr b/src/test/ui/argument-suggestions/mixed_cases.stderr index 2a45f0a985f5c..ec4bb7106f40a 100644 --- a/src/test/ui/argument-suggestions/mixed_cases.stderr +++ b/src/test/ui/argument-suggestions/mixed_cases.stderr @@ -2,7 +2,7 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/mixed_cases.rs:10:15 | LL | two_args(1, "", X {}); - | ^^ ^^^^ no parameter of type X is needed in two_args + | ^^ ^^^^ this parameter of type X isn't needed for two_args | | | expected f32, found &'static str | @@ -13,16 +13,16 @@ LL | fn two_args(_a: i32, _b: f32) {} | ^^^^^^^^ ------- ------- help: the following changes might help | -LL | two_args(1, {f32}, ); - | ^^^^^ -- +LL | two_args(1, {f32}); + | ^--^^ error[E0059]: multiple arguments to this function are incorrect --> $DIR/mixed_cases.rs:11:20 | LL | three_args(1, "", X {}, ""); - | ^^^^^ ^^ no parameter of type &'static str is needed in three_args + | ^^^^^ ^^ this parameter of type &'static str isn't needed for three_args | || - | |no parameter of type X is needed in three_args + | |this parameter of type X isn't needed for three_args | missing argument of type f32 | note: function defined here @@ -32,8 +32,8 @@ LL | fn three_args(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- help: the following changes might help | -LL | three_args(1, "", {f32}, ); - | ^^^^^^-- -- +LL | three_args(1, "" {f32}, X {}, ""); + | -- ^^^^^^ error[E0059]: multiple arguments to this function are incorrect --> $DIR/mixed_cases.rs:14:17 @@ -57,7 +57,7 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/mixed_cases.rs:17:20 | LL | three_args(1, "", X {}); - | ^^^^^ no parameter of type X is needed in three_args + | ^^^^^ this parameter of type X isn't needed for three_args | | | missing argument of type f32 | @@ -68,8 +68,8 @@ LL | fn three_args(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- help: the following changes might help | -LL | three_args(1, "", {f32}, ); - | ^^^^^^-- +LL | three_args(1, "" {f32}, X {}); + | -- ^^^^^^ error[E0059]: multiple arguments to this function are incorrect --> $DIR/mixed_cases.rs:20:14 diff --git a/src/test/ui/argument-suggestions/scratch.stdout b/src/test/ui/argument-suggestions/scratch.stdout new file mode 100644 index 0000000000000..1afaedb4fe88f --- /dev/null +++ b/src/test/ui/argument-suggestions/scratch.stdout @@ -0,0 +1,11 @@ +~~ [false, true, true, false, true] +~~ 0 - false +~~ 1 - true +~~ Start of block +~~ 2 - true +~~ 3 - false +~~ End of block +~~ Eliminating $DIR/scratch.rs:4:12: 4:21 (#0) +~~ 4 - true +~~ Single end +~~ Eliminating $DIR/scratch.rs:4:24: 4:28 (#0) From 28b5a1f91a2ef444dfee02bdd6b683163fbc73c4 Mon Sep 17 00:00:00 2001 From: Pi Lanningham Date: Sat, 16 Jan 2021 02:06:46 -0500 Subject: [PATCH 15/21] Add a multipart_suggestion_verbose This forces it to always show the subwindow for the suggestion. Also uses HasPlaceholders when appropriate. --- compiler/rustc_errors/src/diagnostic.rs | 22 +++ .../rustc_errors/src/diagnostic_builder.rs | 14 ++ .../rustc_typeck/src/check/fn_ctxt/checks.rs | 22 +-- src/test/ui/argument-suggestions/basic.stderr | 17 +-- .../ui/argument-suggestions/complex.stderr | 2 +- .../extra_arguments.stderr | 133 ++++++++++-------- .../invalid_arguments.stderr | 42 +++--- .../missing_arguments.stderr | 38 ++--- .../argument-suggestions/mixed_cases.stderr | 12 +- .../permuted_arguments.stderr | 4 +- .../swapped_arguments.stderr | 10 +- 11 files changed, 182 insertions(+), 134 deletions(-) diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs index e61476bf23e1e..648cde600c765 100644 --- a/compiler/rustc_errors/src/diagnostic.rs +++ b/compiler/rustc_errors/src/diagnostic.rs @@ -307,6 +307,28 @@ impl Diagnostic { self } + /// Show a suggestion that has multiple parts to it, always as it's own subwindow. + /// In other words, multiple changes need to be applied as part of this suggestion. + pub fn multipart_suggestion_verbose( + &mut self, + msg: &str, + suggestion: Vec<(Span, String)>, + applicability: Applicability, + ) -> &mut Self { + self.suggestions.push(CodeSuggestion { + substitutions: vec![Substitution { + parts: suggestion + .into_iter() + .map(|(span, snippet)| SubstitutionPart { snippet, span }) + .collect(), + }], + msg: msg.to_owned(), + style: SuggestionStyle::ShowAlways, + applicability, + }); + self + } + /// Show multiple suggestions that have multiple parts. /// See also [`Diagnostic::multipart_suggestion()`]. pub fn multipart_suggestions( diff --git a/compiler/rustc_errors/src/diagnostic_builder.rs b/compiler/rustc_errors/src/diagnostic_builder.rs index f165a60336a6a..8d93a866e9e4d 100644 --- a/compiler/rustc_errors/src/diagnostic_builder.rs +++ b/compiler/rustc_errors/src/diagnostic_builder.rs @@ -280,6 +280,20 @@ impl<'a> DiagnosticBuilder<'a> { self } + /// See [`Diagnostic::multipart_suggestion_verbose()`]. + pub fn multipart_suggestion_verbose( + &mut self, + msg: &str, + suggestion: Vec<(Span, String)>, + applicability: Applicability, + ) -> &mut Self { + if !self.0.allow_suggestions { + return self; + } + self.0.diagnostic.multipart_suggestion_verbose(msg, suggestion, applicability); + self + } + /// See [`Diagnostic::multipart_suggestions()`]. pub fn multipart_suggestions( &mut self, diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs index def78223f914e..6d8d6a54db02a 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs @@ -874,21 +874,21 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // And add a series of suggestions // FIXME: for simpler cases, this might be overkill if suggestions.len() > 0 { - let suggestion_text = match (suggestion_type, issue_count) { - (Remove, 1) => Some("removing this argument may help"), - (Remove, _) => Some("removing these arguments may help"), - (Provide, 1) => Some("provideing a parameter of the correct type here may help"), - (Provide, _) => Some("providing parameters of these types may help"), - (Swap, 1) => Some("swapping these two arguments might help"), - (Swap, _) => Some("swapping these sets of arguments might help"), - (Reorder, _) => Some("reordering these parameters might help"), - _ => Some("the following changes might help"), + let suggestion_text = match (&suggestion_type, issue_count) { + (Remove, 1) => Some("remove this argument"), + (Remove, _) => Some("remove these arguments"), + (Provide, 1) => Some("provide a parameter of the correct type here"), + (Provide, _) => Some("provide parameters of the correct types"), + (Swap, 1) => Some("swap these two arguments"), + (Swap, _) => Some("swap these arguments"), + (Reorder, _) => Some("reorder these parameters"), + _ => Some("make these changes"), }; if let Some(suggestion_text) = suggestion_text { - err.multipart_suggestion( + err.multipart_suggestion_verbose( suggestion_text, suggestions, - Applicability::MaybeIncorrect, + if matches!(suggestion_type, Provide) { Applicability::HasPlaceholders } else { Applicability::MaybeIncorrect }, ); } } diff --git a/src/test/ui/argument-suggestions/basic.stderr b/src/test/ui/argument-suggestions/basic.stderr index 773125339b386..8b1175a043732 100644 --- a/src/test/ui/argument-suggestions/basic.stderr +++ b/src/test/ui/argument-suggestions/basic.stderr @@ -9,7 +9,7 @@ note: function defined here | LL | fn invalid(_i: u32) {} | ^^^^^^^ ------- -help: provideing a parameter of the correct type here may help +help: provide a parameter of the correct type here | LL | invalid({u32}); | ^^^^^ @@ -18,16 +18,17 @@ error[E0059]: arguments to this function are incorrect --> $DIR/basic.rs:21:11 | LL | extra(""); - | ^^ - | | - | this parameter of type &'static str isn't needed for extra - | help: removing this argument may help + | ^^ this parameter of type &'static str isn't needed for extra | note: function defined here --> $DIR/basic.rs:14:4 | LL | fn extra() {} | ^^^^^ +help: remove this argument + | +LL | extra(); + | -- error[E0059]: arguments to this function are incorrect --> $DIR/basic.rs:22:13 @@ -40,7 +41,7 @@ note: function defined here | LL | fn missing(_i: u32) {} | ^^^^^^^ ------- -help: provideing a parameter of the correct type here may help +help: provide a parameter of the correct type here | LL | missing( {u32},); | ^^^^^^ @@ -58,7 +59,7 @@ note: function defined here | LL | fn swapped(_i: u32, _s: &str) {} | ^^^^^^^ ------- -------- -help: swapping these two arguments might help +help: swap these two arguments | LL | swapped(1, ""); | ^ ^^ @@ -77,7 +78,7 @@ note: function defined here | LL | fn permuted(_x: X, _y: Y, _z: Z) {} | ^^^^^^^^ ----- ----- ----- -help: reordering these parameters might help +help: reorder these parameters | LL | permuted(X {}, Y {}, Z {}); | ^^^^ ^^^^ ^^^^ diff --git a/src/test/ui/argument-suggestions/complex.stderr b/src/test/ui/argument-suggestions/complex.stderr index 1417933409b81..ccc842a328696 100644 --- a/src/test/ui/argument-suggestions/complex.stderr +++ b/src/test/ui/argument-suggestions/complex.stderr @@ -17,7 +17,7 @@ note: function defined here | LL | fn complex(_i: u32, _s: &str, _e: E, _f: F, _g: G, _x: X, _y: Y, _z: Z ) {} | ^^^^^^^ ------- -------- ----- ----- ----- ----- ----- ------ -help: the following changes might help +help: make these changes | LL | complex({u32}, &"", {E}, F::X2, G{}, X {}, Y {}, Z {}); | ^^--^ ^^^^ ^^^^^ ^^^ ^^^^ ^^^^ ^^^^ diff --git a/src/test/ui/argument-suggestions/extra_arguments.stderr b/src/test/ui/argument-suggestions/extra_arguments.stderr index f2ec9e33ead57..946be63edb304 100644 --- a/src/test/ui/argument-suggestions/extra_arguments.stderr +++ b/src/test/ui/argument-suggestions/extra_arguments.stderr @@ -2,122 +2,131 @@ error[E0059]: arguments to this function are incorrect --> $DIR/extra_arguments.rs:7:9 | LL | empty(""); - | ^^ - | | - | this parameter of type &'static str isn't needed for empty - | help: removing this argument may help + | ^^ this parameter of type &'static str isn't needed for empty | note: function defined here --> $DIR/extra_arguments.rs:1:4 | LL | fn empty() {} | ^^^^^ +help: remove this argument + | +LL | empty(); + | -- error[E0059]: arguments to this function are incorrect --> $DIR/extra_arguments.rs:9:14 | LL | one_arg(1, 1); - | --^ - | | | - | | this parameter of type {integer} isn't needed for one_arg - | help: removing this argument may help + | ^ this parameter of type {integer} isn't needed for one_arg | note: function defined here --> $DIR/extra_arguments.rs:2:4 | LL | fn one_arg(_a: i32) {} | ^^^^^^^ ------- +help: remove this argument + | +LL | one_arg(1); + | -- error[E0059]: arguments to this function are incorrect --> $DIR/extra_arguments.rs:10:14 | LL | one_arg(1, ""); - | --^^ - | | | - | | this parameter of type &'static str isn't needed for one_arg - | help: removing this argument may help + | ^^ this parameter of type &'static str isn't needed for one_arg | note: function defined here --> $DIR/extra_arguments.rs:2:4 | LL | fn one_arg(_a: i32) {} | ^^^^^^^ ------- +help: remove this argument + | +LL | one_arg(1); + | -- error[E0059]: multiple arguments to this function are incorrect --> $DIR/extra_arguments.rs:11:14 | LL | one_arg(1, "", 1.0); - | --^^--^^^ - | | | | - | | | this parameter of type {float} isn't needed for one_arg - | | this parameter of type &'static str isn't needed for one_arg - | help: removing these arguments may help + | ^^ ^^^ this parameter of type {float} isn't needed for one_arg + | | + | this parameter of type &'static str isn't needed for one_arg | note: function defined here --> $DIR/extra_arguments.rs:2:4 | LL | fn one_arg(_a: i32) {} | ^^^^^^^ ------- +help: remove these arguments + | +LL | one_arg(1); + | -- error[E0059]: arguments to this function are incorrect --> $DIR/extra_arguments.rs:13:22 | LL | two_arg_same(1, 1, 1); - | --^ - | | | - | | this parameter of type {integer} isn't needed for two_arg_same - | help: removing this argument may help + | ^ this parameter of type {integer} isn't needed for two_arg_same | note: function defined here --> $DIR/extra_arguments.rs:3:4 | LL | fn two_arg_same(_a: i32, _b: i32) {} | ^^^^^^^^^^^^ ------- ------- +help: remove this argument + | +LL | two_arg_same(1, 1); + | -- error[E0059]: arguments to this function are incorrect --> $DIR/extra_arguments.rs:14:22 | LL | two_arg_same(1, 1, 1.0); - | --^^^ - | | | - | | this parameter of type {float} isn't needed for two_arg_same - | help: removing this argument may help + | ^^^ this parameter of type {float} isn't needed for two_arg_same | note: function defined here --> $DIR/extra_arguments.rs:3:4 | LL | fn two_arg_same(_a: i32, _b: i32) {} | ^^^^^^^^^^^^ ------- ------- +help: remove this argument + | +LL | two_arg_same(1, 1); + | -- error[E0059]: arguments to this function are incorrect --> $DIR/extra_arguments.rs:16:19 | LL | two_arg_diff(1, 1, ""); - | --^ - | | | - | | this parameter of type {integer} isn't needed for two_arg_diff - | help: removing this argument may help + | ^ this parameter of type {integer} isn't needed for two_arg_diff | note: function defined here --> $DIR/extra_arguments.rs:4:4 | LL | fn two_arg_diff(_a: i32, _b: &str) {} | ^^^^^^^^^^^^ ------- -------- +help: remove this argument + | +LL | two_arg_diff(1, ""); + | -- error[E0059]: arguments to this function are incorrect --> $DIR/extra_arguments.rs:17:23 | LL | two_arg_diff(1, "", ""); - | --^^ - | | | - | | this parameter of type &'static str isn't needed for two_arg_diff - | help: removing this argument may help + | ^^ this parameter of type &'static str isn't needed for two_arg_diff | note: function defined here --> $DIR/extra_arguments.rs:4:4 | LL | fn two_arg_diff(_a: i32, _b: &str) {} | ^^^^^^^^^^^^ ------- -------- +help: remove this argument + | +LL | two_arg_diff(1, ""); + | -- error[E0059]: multiple arguments to this function are incorrect --> $DIR/extra_arguments.rs:18:19 @@ -132,7 +141,7 @@ note: function defined here | LL | fn two_arg_diff(_a: i32, _b: &str) {} | ^^^^^^^^^^^^ ------- -------- -help: removing these arguments may help +help: remove these arguments | LL | two_arg_diff(1, ""); | -- -- @@ -141,81 +150,83 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/extra_arguments.rs:19:23 | LL | two_arg_diff(1, "", 1, ""); - | --^--^^ - | | | | - | | | this parameter of type &'static str isn't needed for two_arg_diff - | | this parameter of type {integer} isn't needed for two_arg_diff - | help: removing these arguments may help + | ^ ^^ this parameter of type &'static str isn't needed for two_arg_diff + | | + | this parameter of type {integer} isn't needed for two_arg_diff | note: function defined here --> $DIR/extra_arguments.rs:4:4 | LL | fn two_arg_diff(_a: i32, _b: &str) {} | ^^^^^^^^^^^^ ------- -------- +help: remove these arguments + | +LL | two_arg_diff(1, ""); + | -- error[E0059]: arguments to this function are incorrect --> $DIR/extra_arguments.rs:22:26 | LL | two_arg_same(1, 1, ""); - | ------^^ - | | | - | | this parameter of type &'static str isn't needed for two_arg_same - | help: removing this argument may help + | ^^ this parameter of type &'static str isn't needed for two_arg_same | note: function defined here --> $DIR/extra_arguments.rs:3:4 | LL | fn two_arg_same(_a: i32, _b: i32) {} | ^^^^^^^^^^^^ ------- ------- +help: remove this argument + | +LL | two_arg_same(1, 1); + | -- error[E0059]: arguments to this function are incorrect --> $DIR/extra_arguments.rs:23:19 | LL | two_arg_diff(1, 1, ""); - | --^ - | | | - | | this parameter of type {integer} isn't needed for two_arg_diff - | help: removing this argument may help + | ^ this parameter of type {integer} isn't needed for two_arg_diff | note: function defined here --> $DIR/extra_arguments.rs:4:4 | LL | fn two_arg_diff(_a: i32, _b: &str) {} | ^^^^^^^^^^^^ ------- -------- +help: remove this argument + | +LL | two_arg_diff(1, ""); + | -- error[E0059]: arguments to this function are incorrect --> $DIR/extra_arguments.rs:27:5 | -LL | 1, - | ______- -LL | | "" - | | ^- - | |_____|| - | |help: removing this argument may help - | this parameter of type &'static str isn't needed for two_arg_same +LL | "" + | ^^ this parameter of type &'static str isn't needed for two_arg_same | note: function defined here --> $DIR/extra_arguments.rs:3:4 | LL | fn two_arg_same(_a: i32, _b: i32) {} | ^^^^^^^^^^^^ ------- ------- +help: remove this argument + | +LL | 1 + | -- error[E0059]: arguments to this function are incorrect --> $DIR/extra_arguments.rs:32:5 | -LL | 1, - | ______- -LL | | 1, - | | ^ - | | | - | |_____this parameter of type {integer} isn't needed for two_arg_diff - | help: removing this argument may help +LL | 1, + | ^ this parameter of type {integer} isn't needed for two_arg_diff | note: function defined here --> $DIR/extra_arguments.rs:4:4 | LL | fn two_arg_diff(_a: i32, _b: &str) {} | ^^^^^^^^^^^^ ------- -------- +help: remove this argument + | +LL | 1, + | -- error: aborting due to 14 previous errors diff --git a/src/test/ui/argument-suggestions/invalid_arguments.stderr b/src/test/ui/argument-suggestions/invalid_arguments.stderr index e741d48e3fa90..1fd198ade29e0 100644 --- a/src/test/ui/argument-suggestions/invalid_arguments.stderr +++ b/src/test/ui/argument-suggestions/invalid_arguments.stderr @@ -9,7 +9,7 @@ note: function defined here | LL | fn one_arg(_a: i32) {} | ^^^^^^^ ------- -help: provideing a parameter of the correct type here may help +help: provide a parameter of the correct type here | LL | one_arg({i32}); | ^^^^^ @@ -25,7 +25,7 @@ note: function defined here | LL | fn two_arg_same(_a: i32, _b: i32) {} | ^^^^^^^^^^^^ ------- ------- -help: provideing a parameter of the correct type here may help +help: provide a parameter of the correct type here | LL | two_arg_same(1, {i32}); | ^^^^^ @@ -41,7 +41,7 @@ note: function defined here | LL | fn two_arg_same(_a: i32, _b: i32) {} | ^^^^^^^^^^^^ ------- ------- -help: provideing a parameter of the correct type here may help +help: provide a parameter of the correct type here | LL | two_arg_same({i32}, 1); | ^^^^^ @@ -59,7 +59,7 @@ note: function defined here | LL | fn two_arg_same(_a: i32, _b: i32) {} | ^^^^^^^^^^^^ ------- ------- -help: providing parameters of these types may help +help: provide parameters of the correct types | LL | two_arg_same({i32}, {i32}); | ^^^^^ ^^^^^ @@ -75,7 +75,7 @@ note: function defined here | LL | fn two_arg_diff(_a: i32, _b: f32) {} | ^^^^^^^^^^^^ ------- ------- -help: provideing a parameter of the correct type here may help +help: provide a parameter of the correct type here | LL | two_arg_diff(1, {f32}); | ^^^^^ @@ -91,7 +91,7 @@ note: function defined here | LL | fn two_arg_diff(_a: i32, _b: f32) {} | ^^^^^^^^^^^^ ------- ------- -help: provideing a parameter of the correct type here may help +help: provide a parameter of the correct type here | LL | two_arg_diff({i32}, 1.0); | ^^^^^ @@ -109,7 +109,7 @@ note: function defined here | LL | fn two_arg_diff(_a: i32, _b: f32) {} | ^^^^^^^^^^^^ ------- ------- -help: providing parameters of these types may help +help: provide parameters of the correct types | LL | two_arg_diff({i32}, {f32}); | ^^^^^ ^^^^^ @@ -125,7 +125,7 @@ note: function defined here | LL | fn three_arg_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^^^^^ ------- ------- -------- -help: provideing a parameter of the correct type here may help +help: provide a parameter of the correct type here | LL | three_arg_diff({i32}, 1.0, ""); | ^^^^^ @@ -141,7 +141,7 @@ note: function defined here | LL | fn three_arg_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^^^^^ ------- ------- -------- -help: provideing a parameter of the correct type here may help +help: provide a parameter of the correct type here | LL | three_arg_diff(1, {f32}, ""); | ^^^^^ @@ -157,7 +157,7 @@ note: function defined here | LL | fn three_arg_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^^^^^ ------- ------- -------- -help: provideing a parameter of the correct type here may help +help: provide a parameter of the correct type here | LL | three_arg_diff(1, 1.0, {&str}); | ^^^^^^ @@ -175,7 +175,7 @@ note: function defined here | LL | fn three_arg_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^^^^^ ------- ------- -------- -help: providing parameters of these types may help +help: provide parameters of the correct types | LL | three_arg_diff({i32}, {f32}, ""); | ^^^^^ ^^^^^ @@ -193,7 +193,7 @@ note: function defined here | LL | fn three_arg_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^^^^^ ------- ------- -------- -help: providing parameters of these types may help +help: provide parameters of the correct types | LL | three_arg_diff({i32}, 1.0, {&str}); | ^^^^^ ^^^^^^ @@ -211,7 +211,7 @@ note: function defined here | LL | fn three_arg_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^^^^^ ------- ------- -------- -help: providing parameters of these types may help +help: provide parameters of the correct types | LL | three_arg_diff(1, {f32}, {&str}); | ^^^^^ ^^^^^^ @@ -230,7 +230,7 @@ note: function defined here | LL | fn three_arg_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^^^^^ ------- ------- -------- -help: providing parameters of these types may help +help: provide parameters of the correct types | LL | three_arg_diff({i32}, {f32}, {&str}); | ^^^^^ ^^^^^ ^^^^^^ @@ -246,7 +246,7 @@ note: function defined here | LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {} | ^^^^^^^^^^^^^^^^ ------- ------- -------- -help: provideing a parameter of the correct type here may help +help: provide a parameter of the correct type here | LL | three_arg_repeat({i32}, 1, ""); | ^^^^^ @@ -262,7 +262,7 @@ note: function defined here | LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {} | ^^^^^^^^^^^^^^^^ ------- ------- -------- -help: provideing a parameter of the correct type here may help +help: provide a parameter of the correct type here | LL | three_arg_repeat(1, {i32}, ""); | ^^^^^ @@ -278,7 +278,7 @@ note: function defined here | LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {} | ^^^^^^^^^^^^^^^^ ------- ------- -------- -help: provideing a parameter of the correct type here may help +help: provide a parameter of the correct type here | LL | three_arg_repeat(1, 1, {&str}); | ^^^^^^ @@ -296,7 +296,7 @@ note: function defined here | LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {} | ^^^^^^^^^^^^^^^^ ------- ------- -------- -help: providing parameters of these types may help +help: provide parameters of the correct types | LL | three_arg_repeat({i32}, {i32}, ""); | ^^^^^ ^^^^^ @@ -314,7 +314,7 @@ note: function defined here | LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {} | ^^^^^^^^^^^^^^^^ ------- ------- -------- -help: providing parameters of these types may help +help: provide parameters of the correct types | LL | three_arg_repeat({i32}, 1, {&str}); | ^^^^^ ^^^^^^ @@ -332,7 +332,7 @@ note: function defined here | LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {} | ^^^^^^^^^^^^^^^^ ------- ------- -------- -help: providing parameters of these types may help +help: provide parameters of the correct types | LL | three_arg_repeat(1, {i32}, {&str}); | ^^^^^ ^^^^^^ @@ -351,7 +351,7 @@ note: function defined here | LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {} | ^^^^^^^^^^^^^^^^ ------- ------- -------- -help: providing parameters of these types may help +help: provide parameters of the correct types | LL | three_arg_repeat({i32}, {i32}, {&str}); | ^^^^^ ^^^^^ ^^^^^^ diff --git a/src/test/ui/argument-suggestions/missing_arguments.stderr b/src/test/ui/argument-suggestions/missing_arguments.stderr index c35cfb69369cb..4836b13285d44 100644 --- a/src/test/ui/argument-suggestions/missing_arguments.stderr +++ b/src/test/ui/argument-suggestions/missing_arguments.stderr @@ -9,7 +9,7 @@ note: function defined here | LL | fn one_arg(_a: i32) {} | ^^^^^^^ ------- -help: provideing a parameter of the correct type here may help +help: provide a parameter of the correct type here | LL | one_arg( {i32},); | ^^^^^^ @@ -28,7 +28,7 @@ note: function defined here | LL | fn two_same(_a: i32, _b: i32) {} | ^^^^^^^^ ------- ------- -help: providing parameters of these types may help +help: provide parameters of the correct types | LL | two_same( {i32}, {i32},); | ^^^^^^ @@ -44,7 +44,7 @@ note: function defined here | LL | fn two_same(_a: i32, _b: i32) {} | ^^^^^^^^ ------- ------- -help: provideing a parameter of the correct type here may help +help: provide a parameter of the correct type here | LL | two_same( 1 {i32},); | ^^^^^^ @@ -63,7 +63,7 @@ note: function defined here | LL | fn two_diff(_a: i32, _b: f32) {} | ^^^^^^^^ ------- ------- -help: providing parameters of these types may help +help: provide parameters of the correct types | LL | two_diff( {i32}, {f32},); | ^^^^^^ @@ -79,7 +79,7 @@ note: function defined here | LL | fn two_diff(_a: i32, _b: f32) {} | ^^^^^^^^ ------- ------- -help: provideing a parameter of the correct type here may help +help: provide a parameter of the correct type here | LL | two_diff( 1 {f32},); | ^^^^^^ @@ -95,7 +95,7 @@ note: function defined here | LL | fn two_diff(_a: i32, _b: f32) {} | ^^^^^^^^ ------- ------- -help: provideing a parameter of the correct type here may help +help: provide a parameter of the correct type here | LL | two_diff( 1.0 {i32}, ); | ^^^^^^ @@ -115,7 +115,7 @@ note: function defined here | LL | fn three_same(_a: i32, _b: i32, _c: i32) {} | ^^^^^^^^^^ ------- ------- ------- -help: providing parameters of these types may help +help: provide parameters of the correct types | LL | three_same( {i32}, {i32}, {i32},); | ^^^^^^ @@ -134,7 +134,7 @@ note: function defined here | LL | fn three_same(_a: i32, _b: i32, _c: i32) {} | ^^^^^^^^^^ ------- ------- ------- -help: providing parameters of these types may help +help: provide parameters of the correct types | LL | three_same( 1 {i32}, {i32},); | ^^^^^^ @@ -150,7 +150,7 @@ note: function defined here | LL | fn three_same(_a: i32, _b: i32, _c: i32) {} | ^^^^^^^^^^ ------- ------- ------- -help: provideing a parameter of the correct type here may help +help: provide a parameter of the correct type here | LL | three_same( 1, 1 {i32},); | ^^^^^^ @@ -166,7 +166,7 @@ note: function defined here | LL | fn three_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- -help: provideing a parameter of the correct type here may help +help: provide a parameter of the correct type here | LL | three_diff( 1.0, {i32}, "" ); | ^^^^^^ @@ -182,7 +182,7 @@ note: function defined here | LL | fn three_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- -help: provideing a parameter of the correct type here may help +help: provide a parameter of the correct type here | LL | three_diff( 1, "" {f32}, ); | ^^^^^^ @@ -198,7 +198,7 @@ note: function defined here | LL | fn three_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- -help: provideing a parameter of the correct type here may help +help: provide a parameter of the correct type here | LL | three_diff( 1, 1.0, {&str},); | ^^^^^^^ @@ -216,7 +216,7 @@ note: function defined here | LL | fn three_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- -help: providing parameters of these types may help +help: provide parameters of the correct types | LL | three_diff( "" {i32}, {f32},); | ^^^^^^ ^^^^^^ @@ -234,7 +234,7 @@ note: function defined here | LL | fn three_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- -help: providing parameters of these types may help +help: provide parameters of the correct types | LL | three_diff( 1.0 {i32}, {&str},); | ^^^^^^ ^^^^^^^ @@ -253,7 +253,7 @@ note: function defined here | LL | fn three_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- -help: providing parameters of these types may help +help: provide parameters of the correct types | LL | three_diff( 1, {f32}, {&str},); | ^^^^^^^ @@ -274,7 +274,7 @@ note: function defined here | LL | fn four_repeated(_a: i32, _b: f32, _c: f32, _d: &str) {} | ^^^^^^^^^^^^^ ------- ------- ------- -------- -help: providing parameters of these types may help +help: provide parameters of the correct types | LL | four_repeated( {i32}, {f32}, {f32}, {&str},); | ^^^^^^^ @@ -292,7 +292,7 @@ note: function defined here | LL | fn four_repeated(_a: i32, _b: f32, _c: f32, _d: &str) {} | ^^^^^^^^^^^^^ ------- ------- ------- -------- -help: providing parameters of these types may help +help: provide parameters of the correct types | LL | four_repeated( 1, "" {f32}, {f32},); | ^^^^^^ ^^^^^^ @@ -314,7 +314,7 @@ note: function defined here | LL | fn complex(_a: i32, _b: f32, _c: i32, _d: f32, _e: &str) {} | ^^^^^^^ ------- ------- ------- ------- -------- -help: providing parameters of these types may help +help: provide parameters of the correct types | LL | complex( {i32}, {f32}, {i32}, {f32}, {&str},); | ^^^^^^^ @@ -334,7 +334,7 @@ note: function defined here | LL | fn complex(_a: i32, _b: f32, _c: i32, _d: f32, _e: &str) {} | ^^^^^^^ ------- ------- ------- ------- -------- -help: providing parameters of these types may help +help: provide parameters of the correct types | LL | complex( 1, "" {f32}, {i32}, {f32},); | ^^^^^^ ^^^^^^ diff --git a/src/test/ui/argument-suggestions/mixed_cases.stderr b/src/test/ui/argument-suggestions/mixed_cases.stderr index ec4bb7106f40a..1d2f6e98a9814 100644 --- a/src/test/ui/argument-suggestions/mixed_cases.stderr +++ b/src/test/ui/argument-suggestions/mixed_cases.stderr @@ -11,7 +11,7 @@ note: function defined here | LL | fn two_args(_a: i32, _b: f32) {} | ^^^^^^^^ ------- ------- -help: the following changes might help +help: make these changes | LL | two_args(1, {f32}); | ^--^^ @@ -30,7 +30,7 @@ note: function defined here | LL | fn three_args(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- -help: the following changes might help +help: make these changes | LL | three_args(1, "" {f32}, X {}, ""); | -- ^^^^^^ @@ -48,7 +48,7 @@ note: function defined here | LL | fn three_args(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- -help: providing parameters of these types may help +help: provide parameters of the correct types | LL | three_args(1, {f32} {&str},); | ^^^^^^^^^^^^ @@ -66,7 +66,7 @@ note: function defined here | LL | fn three_args(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- -help: the following changes might help +help: make these changes | LL | three_args(1, "" {f32}, X {}); | -- ^^^^^^ @@ -85,7 +85,7 @@ note: function defined here | LL | fn three_args(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- -help: the following changes might help +help: make these changes | LL | three_args(1, {f32}, ""); | ^ ^^^^^ ^^ @@ -104,7 +104,7 @@ note: function defined here | LL | fn three_args(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- -help: the following changes might help +help: make these changes | LL | three_args(1, "") {f32},; | ^ ^^ ^^^^^^ diff --git a/src/test/ui/argument-suggestions/permuted_arguments.stderr b/src/test/ui/argument-suggestions/permuted_arguments.stderr index 74ccdd3d004fb..099e6912903dc 100644 --- a/src/test/ui/argument-suggestions/permuted_arguments.stderr +++ b/src/test/ui/argument-suggestions/permuted_arguments.stderr @@ -12,7 +12,7 @@ note: function defined here | LL | fn three_args(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- -help: reordering these parameters might help +help: reorder these parameters | LL | three_args(1, 1.0, ""); | ^ ^^^ ^^ @@ -33,7 +33,7 @@ note: function defined here | LL | fn many_args(_a: i32, _b: f32, _c: &str, _d: X, _e: Y) {} | ^^^^^^^^^ ------- ------- -------- ----- ----- -help: reordering these parameters might help +help: reorder these parameters | LL | many_args(1, 1.0, "", X {}, Y {}); | ^ ^^^ ^^ ^^^^ ^^^^ diff --git a/src/test/ui/argument-suggestions/swapped_arguments.stderr b/src/test/ui/argument-suggestions/swapped_arguments.stderr index 2ffba36e34af8..15916f2581b0d 100644 --- a/src/test/ui/argument-suggestions/swapped_arguments.stderr +++ b/src/test/ui/argument-suggestions/swapped_arguments.stderr @@ -11,7 +11,7 @@ note: function defined here | LL | fn two_args(_a: i32, _b: f32) {} | ^^^^^^^^ ------- ------- -help: swapping these two arguments might help +help: swap these two arguments | LL | two_args(1, 1.0); | ^ ^^^ @@ -29,7 +29,7 @@ note: function defined here | LL | fn three_args(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- -help: swapping these two arguments might help +help: swap these two arguments | LL | three_args(1, 1.0, ""); | ^ ^^^ @@ -47,7 +47,7 @@ note: function defined here | LL | fn three_args(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- -help: swapping these two arguments might help +help: swap these two arguments | LL | three_args( 1, 1.0, ""); | ^^^ ^^ @@ -65,7 +65,7 @@ note: function defined here | LL | fn three_args(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- -help: swapping these two arguments might help +help: swap these two arguments | LL | three_args( 1, 1.0, ""); | ^ ^^ @@ -85,7 +85,7 @@ note: function defined here | LL | fn four_args(_a: i32, _b: f32, _c: &str, _d: X) {} | ^^^^^^^^^ ------- ------- -------- ----- -help: swapping these sets of arguments might help +help: swap these arguments | LL | four_args(1, 1.0, "", X {}); | ^ ^^^ ^^ ^^^^ From 552583c47bbce58ff6fef253bd734b31db5f393b Mon Sep 17 00:00:00 2001 From: Pi Lanningham Date: Sun, 17 Jan 2021 00:57:07 -0500 Subject: [PATCH 16/21] Give preference to latter commas --- .../rustc_typeck/src/check/fn_ctxt/checks.rs | 27 ++++++++++--------- .../ui/argument-suggestions/complex.stderr | 2 +- .../extra_arguments.stderr | 12 ++++----- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs index 6d8d6a54db02a..c34eb10f081d7 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs @@ -812,11 +812,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let mut lo = None; let mut hi = None; let mut in_block = false; - for (idx, eliminated) in eliminated_args.iter().enumerate() { - match (in_block, eliminated, idx == eliminated_args.len() - 1) { + // Scan backwards over the args (scanning backwards lets us favor the commas after, rather than before) + for (idx, eliminated) in eliminated_args.iter().enumerate().rev() { + match (in_block, eliminated, idx == 0) { (false, true, false) => { // We just encountered the start of a block of eliminated parameters - lo = Some(idx); + hi = Some(idx); in_block = true; }, (false, true, true) => { @@ -826,11 +827,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } (true, false, _) => { // We encountered the end of a block, set the hi so the logic below kicks in - hi = Some(idx - 1); + lo = Some(idx + 1); in_block = false; }, (true, true, true) => { - hi = Some(idx); + lo = Some(idx); in_block = false; } _ => {} @@ -841,18 +842,18 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // be careful abound the boundaries let ctxt = provided_args[0].span.ctxt(); let (lo_bp, hi_bp) = match (lo_idx == 0, hi_idx == provided_arg_count - 1) { - // If we have an arg to our left, chop off it's comma - // a, xx, xx, xx - // [-----------) - (false, _) => { - (provided_args[lo_idx - 1].span.hi(), provided_args[hi_idx].span.hi()) - }, - // If we start from the first arg, and we have an arg to our right, chop of the last params comma + // If we have an arg to our right, we need to eat the comma of the last eliminated param // xx, xx, xx, a // [-----------) - (true, false) => { + (_, false) => { (provided_args[lo_idx].span.lo(), provided_args[hi_idx + 1].span.lo()) }, + // If this block extends to the last argument, and theres an arg to the left, eat its comma + // a, xx, xx, xx + // [-----------) + (false, true) => { + (provided_args[lo_idx - 1].span.hi(), provided_args[hi_idx].span.hi()) + }, // If every argument was eliminated, don't need to worry about commas before or after // xx, xx, xx, xx // [-------------) diff --git a/src/test/ui/argument-suggestions/complex.stderr b/src/test/ui/argument-suggestions/complex.stderr index ccc842a328696..c5273624a63fd 100644 --- a/src/test/ui/argument-suggestions/complex.stderr +++ b/src/test/ui/argument-suggestions/complex.stderr @@ -20,7 +20,7 @@ LL | fn complex(_i: u32, _s: &str, _e: E, _f: F, _g: G, _x: X, _y: Y, _z: Z ) {} help: make these changes | LL | complex({u32}, &"", {E}, F::X2, G{}, X {}, Y {}, Z {}); - | ^^--^ ^^^^ ^^^^^ ^^^ ^^^^ ^^^^ ^^^^ + | ^^^^^ -- ^^^^ ^^^^^ ^^^ ^^^^ ^^^^ ^^^^ error: aborting due to previous error diff --git a/src/test/ui/argument-suggestions/extra_arguments.stderr b/src/test/ui/argument-suggestions/extra_arguments.stderr index 946be63edb304..77ac006b77064 100644 --- a/src/test/ui/argument-suggestions/extra_arguments.stderr +++ b/src/test/ui/argument-suggestions/extra_arguments.stderr @@ -110,7 +110,7 @@ LL | fn two_arg_diff(_a: i32, _b: &str) {} help: remove this argument | LL | two_arg_diff(1, ""); - | -- + | -- error[E0059]: arguments to this function are incorrect --> $DIR/extra_arguments.rs:17:23 @@ -144,7 +144,7 @@ LL | fn two_arg_diff(_a: i32, _b: &str) {} help: remove these arguments | LL | two_arg_diff(1, ""); - | -- -- + | ---- error[E0059]: multiple arguments to this function are incorrect --> $DIR/extra_arguments.rs:19:23 @@ -193,8 +193,8 @@ LL | fn two_arg_diff(_a: i32, _b: &str) {} | ^^^^^^^^^^^^ ------- -------- help: remove this argument | -LL | two_arg_diff(1, ""); - | -- +LL | two_arg_diff(1, ""); + | -- error[E0059]: arguments to this function are incorrect --> $DIR/extra_arguments.rs:27:5 @@ -225,8 +225,8 @@ LL | fn two_arg_diff(_a: i32, _b: &str) {} | ^^^^^^^^^^^^ ------- -------- help: remove this argument | -LL | 1, - | -- +LL | "" + | -- error: aborting due to 14 previous errors From de1a6c83b40319809f3947876cc47798557a5f77 Mon Sep 17 00:00:00 2001 From: Pi Lanningham Date: Sun, 17 Jan 2021 01:41:21 -0500 Subject: [PATCH 17/21] Another round of improvements on spans The 'extra' spans are one iteration better, but still wrong, especially when there are arguments missing in the middle; Need another pass on this --- .../rustc_typeck/src/check/fn_ctxt/checks.rs | 52 +++--- src/test/ui/argument-suggestions/basic.stderr | 4 +- .../ui/argument-suggestions/complex.stderr | 18 +- .../argument-suggestions/missing_arguments.rs | 4 +- .../missing_arguments.stderr | 160 +++++++++--------- .../argument-suggestions/mixed_cases.stderr | 35 ++-- 6 files changed, 143 insertions(+), 130 deletions(-) diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs index c34eb10f081d7..2da4450d191b3 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs @@ -19,10 +19,9 @@ use rustc_middle::ty::adjustment::AllowTwoPhase; use rustc_middle::ty::fold::TypeFoldable; use rustc_middle::ty::{self, Ty}; use rustc_session::Session; -use rustc_span::{self, MultiSpan, Span}; +use rustc_span::{self, BytePos, MultiSpan, Span}; use rustc_span::{ symbol::{sym, Ident}, - BytePos, }; use rustc_trait_selection::traits::{self, ObligationCauseCode, StatementAsExpression}; @@ -656,6 +655,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let mut suggestions = vec![]; let mut suggestion_type = NoSuggestion; let mut eliminated_args = vec![false; provided_arg_count]; + let mut current_arg_count = provided_arg_count; // Incremented if we insert an argument let source_map = self.sess().source_map(); for issue in issues { match issue { @@ -704,33 +704,45 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }; } Issue::Missing(arg) => { - // FIXME: The spans here are all kinds of wrong for multiple missing arguments etc. - let prev_span = if arg < provided_args.len() { - provided_args[arg].span - } else { - call_span - }; - // If we're missing something in the middle, shift the span slightly to eat the comma - let missing_span = if arg < provided_args.len() { - Span::new( - prev_span.hi() + BytePos(1), - prev_span.hi() + BytePos(1), - prev_span.ctxt(), + let expected_type = expected_input_tys[arg]; + let (missing_span, suggested_arg) = if arg < provided_arg_count { + let span = provided_args[arg].span; + ( + Span::new( + span.lo(), + span.lo(), + span.ctxt(), + ), + format!("{{{}}}, ", expected_type) + ) + } else if provided_arg_count > 0 { + let prev = provided_args[provided_arg_count - 1].span; + ( + Span::new( + prev.hi(), + prev.hi(), + prev.ctxt(), + ), + format!(", {{{}}}", expected_type) ) } else { - Span::new( - prev_span.hi() - BytePos(1), - prev_span.hi() - BytePos(1), - prev_span.ctxt(), + let include_comma = current_arg_count > 0; + ( + Span::new( + call_span.hi() - BytePos(1), + call_span.hi() - BytePos(1), + call_span.ctxt() + ), + format!("{}{{{}}}", if include_comma { ", " } else { "" }, expected_type) ) }; - let expected_type = expected_input_tys[arg]; + current_arg_count += 1; labels.push((missing_span, format!("missing argument of type {}", expected_type))); suggestion_type = match suggestion_type { NoSuggestion | Provide => Provide, _ => Changes, }; - suggestions.push((missing_span, format!(" {{{}}},", expected_type))); + suggestions.push((missing_span, suggested_arg)); } Issue::Swap(arg, other) => { let first_span = provided_args[arg].span; diff --git a/src/test/ui/argument-suggestions/basic.stderr b/src/test/ui/argument-suggestions/basic.stderr index 8b1175a043732..547c3f9bc8354 100644 --- a/src/test/ui/argument-suggestions/basic.stderr +++ b/src/test/ui/argument-suggestions/basic.stderr @@ -43,8 +43,8 @@ LL | fn missing(_i: u32) {} | ^^^^^^^ ------- help: provide a parameter of the correct type here | -LL | missing( {u32},); - | ^^^^^^ +LL | missing({u32}); + | ^^^^^ error[E0059]: arguments to this function are incorrect --> $DIR/basic.rs:23:13 diff --git a/src/test/ui/argument-suggestions/complex.stderr b/src/test/ui/argument-suggestions/complex.stderr index c5273624a63fd..973cd4660f077 100644 --- a/src/test/ui/argument-suggestions/complex.stderr +++ b/src/test/ui/argument-suggestions/complex.stderr @@ -2,13 +2,13 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/complex.rs:14:11 | LL | complex(1.0, H {}, &"", G{}, F::X2, Z {}, X {}, Y {}); - | ^^^ ^^^^ ^^^^ ^^^^^ ^^^^ ^^^^ ^^^^ expected Z, found Z - | | | || | | | - | | | || | | expected Y, found Y - | | | || | expected X, found X - | | | || expected G, found G - | | | |expected F, found F - | | | missing argument of type E + | ^^^ ^^^^ ^ ^^^ ^^^^^ ^^^^ ^^^^ ^^^^ expected Z, found Z + | | | | | | | | + | | | | | | | expected Y, found Y + | | | | | | expected X, found X + | | | | | expected G, found G + | | | | expected F, found F + | | | missing argument of type E | | this parameter of type H isn't needed for complex | expected u32, found {float} | @@ -19,8 +19,8 @@ LL | fn complex(_i: u32, _s: &str, _e: E, _f: F, _g: G, _x: X, _y: Y, _z: Z ) {} | ^^^^^^^ ------- -------- ----- ----- ----- ----- ----- ------ help: make these changes | -LL | complex({u32}, &"", {E}, F::X2, G{}, X {}, Y {}, Z {}); - | ^^^^^ -- ^^^^ ^^^^^ ^^^ ^^^^ ^^^^ ^^^^ +LL | complex({u32}, {E}, &"", F::X2, G{}, X {}, Y {}, Z {}); + | ^^^^^ -- ^^^^^^^^^ ^^^ ^^^^ ^^^^ ^^^^ error: aborting due to previous error diff --git a/src/test/ui/argument-suggestions/missing_arguments.rs b/src/test/ui/argument-suggestions/missing_arguments.rs index 841ffe4e7ed48..d8b28809b2b44 100644 --- a/src/test/ui/argument-suggestions/missing_arguments.rs +++ b/src/test/ui/argument-suggestions/missing_arguments.rs @@ -25,10 +25,10 @@ fn main() { /* i32 f32 &str */ three_diff( 1.0, "" ); //~ ERROR arguments to this function are incorrect three_diff( 1, "" ); //~ ERROR arguments to this function are incorrect - three_diff( 1, 1.0, ); //~ ERROR arguments to this function are incorrect + three_diff( 1, 1.0 ); //~ ERROR arguments to this function are incorrect three_diff( "" ); //~ ERROR arguments to this function are incorrect three_diff( 1.0 ); //~ ERROR arguments to this function are incorrect - three_diff( 1, ); //~ ERROR arguments to this function are incorrect + three_diff( 1 ); //~ ERROR arguments to this function are incorrect /* i32 f32 f32 &str */ four_repeated( ); //~ ERROR arguments to this function are incorrect diff --git a/src/test/ui/argument-suggestions/missing_arguments.stderr b/src/test/ui/argument-suggestions/missing_arguments.stderr index 4836b13285d44..1f3859342da04 100644 --- a/src/test/ui/argument-suggestions/missing_arguments.stderr +++ b/src/test/ui/argument-suggestions/missing_arguments.stderr @@ -11,8 +11,8 @@ LL | fn one_arg(_a: i32) {} | ^^^^^^^ ------- help: provide a parameter of the correct type here | -LL | one_arg( {i32},); - | ^^^^^^ +LL | one_arg({i32}); + | ^^^^^ error[E0059]: multiple arguments to this function are incorrect --> $DIR/missing_arguments.rs:14:27 @@ -30,14 +30,14 @@ LL | fn two_same(_a: i32, _b: i32) {} | ^^^^^^^^ ------- ------- help: provide parameters of the correct types | -LL | two_same( {i32}, {i32},); - | ^^^^^^ +LL | two_same( {i32}, {i32}); + | ^^^^^^^ error[E0059]: arguments to this function are incorrect - --> $DIR/missing_arguments.rs:15:27 + --> $DIR/missing_arguments.rs:15:16 | LL | two_same( 1 ); - | ^ missing argument of type i32 + | ^ missing argument of type i32 | note: function defined here --> $DIR/missing_arguments.rs:2:4 @@ -46,8 +46,8 @@ LL | fn two_same(_a: i32, _b: i32) {} | ^^^^^^^^ ------- ------- help: provide a parameter of the correct type here | -LL | two_same( 1 {i32},); - | ^^^^^^ +LL | two_same( 1, {i32} ); + | ^^^^^^^ error[E0059]: multiple arguments to this function are incorrect --> $DIR/missing_arguments.rs:16:27 @@ -65,14 +65,14 @@ LL | fn two_diff(_a: i32, _b: f32) {} | ^^^^^^^^ ------- ------- help: provide parameters of the correct types | -LL | two_diff( {i32}, {f32},); - | ^^^^^^ +LL | two_diff( {i32}, {f32}); + | ^^^^^^^ error[E0059]: arguments to this function are incorrect - --> $DIR/missing_arguments.rs:17:27 + --> $DIR/missing_arguments.rs:17:16 | LL | two_diff( 1 ); - | ^ missing argument of type f32 + | ^ missing argument of type f32 | note: function defined here --> $DIR/missing_arguments.rs:3:4 @@ -81,14 +81,14 @@ LL | fn two_diff(_a: i32, _b: f32) {} | ^^^^^^^^ ------- ------- help: provide a parameter of the correct type here | -LL | two_diff( 1 {f32},); - | ^^^^^^ +LL | two_diff( 1, {f32} ); + | ^^^^^^^ error[E0059]: arguments to this function are incorrect - --> $DIR/missing_arguments.rs:18:26 + --> $DIR/missing_arguments.rs:18:22 | LL | two_diff( 1.0 ); - | ^ missing argument of type i32 + | ^ missing argument of type i32 | note: function defined here --> $DIR/missing_arguments.rs:3:4 @@ -97,8 +97,8 @@ LL | fn two_diff(_a: i32, _b: f32) {} | ^^^^^^^^ ------- ------- help: provide a parameter of the correct type here | -LL | two_diff( 1.0 {i32}, ); - | ^^^^^^ +LL | two_diff( {i32}, 1.0 ); + | ^^^^^^ error[E0059]: multiple arguments to this function are incorrect --> $DIR/missing_arguments.rs:21:37 @@ -117,17 +117,17 @@ LL | fn three_same(_a: i32, _b: i32, _c: i32) {} | ^^^^^^^^^^ ------- ------- ------- help: provide parameters of the correct types | -LL | three_same( {i32}, {i32}, {i32},); - | ^^^^^^ +LL | three_same( {i32}, {i32}, {i32}); + | ^^^^^^^ error[E0059]: multiple arguments to this function are incorrect - --> $DIR/missing_arguments.rs:22:37 + --> $DIR/missing_arguments.rs:22:18 | LL | three_same( 1 ); - | ^ - | | - | missing argument of type i32 - | missing argument of type i32 + | ^ + | | + | missing argument of type i32 + | missing argument of type i32 | note: function defined here --> $DIR/missing_arguments.rs:4:4 @@ -136,14 +136,14 @@ LL | fn three_same(_a: i32, _b: i32, _c: i32) {} | ^^^^^^^^^^ ------- ------- ------- help: provide parameters of the correct types | -LL | three_same( 1 {i32}, {i32},); - | ^^^^^^ +LL | three_same( 1, {i32}, {i32} ); + | ^^^^^^^ error[E0059]: arguments to this function are incorrect - --> $DIR/missing_arguments.rs:23:37 + --> $DIR/missing_arguments.rs:23:26 | LL | three_same( 1, 1 ); - | ^ missing argument of type i32 + | ^ missing argument of type i32 | note: function defined here --> $DIR/missing_arguments.rs:4:4 @@ -152,14 +152,14 @@ LL | fn three_same(_a: i32, _b: i32, _c: i32) {} | ^^^^^^^^^^ ------- ------- ------- help: provide a parameter of the correct type here | -LL | three_same( 1, 1 {i32},); - | ^^^^^^ +LL | three_same( 1, 1, {i32} ); + | ^^^^^^^ error[E0059]: arguments to this function are incorrect - --> $DIR/missing_arguments.rs:26:28 + --> $DIR/missing_arguments.rs:26:24 | LL | three_diff( 1.0, "" ); - | ^ missing argument of type i32 + | ^ missing argument of type i32 | note: function defined here --> $DIR/missing_arguments.rs:5:4 @@ -168,14 +168,14 @@ LL | fn three_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- help: provide a parameter of the correct type here | -LL | three_diff( 1.0, {i32}, "" ); - | ^^^^^^ +LL | three_diff( {i32}, 1.0, "" ); + | ^^^^^^ error[E0059]: arguments to this function are incorrect - --> $DIR/missing_arguments.rs:27:36 + --> $DIR/missing_arguments.rs:27:33 | LL | three_diff( 1, "" ); - | ^ missing argument of type f32 + | ^ missing argument of type f32 | note: function defined here --> $DIR/missing_arguments.rs:5:4 @@ -184,14 +184,14 @@ LL | fn three_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- help: provide a parameter of the correct type here | -LL | three_diff( 1, "" {f32}, ); - | ^^^^^^ +LL | three_diff( 1, {f32}, "" ); + | ^^^^^^ error[E0059]: arguments to this function are incorrect - --> $DIR/missing_arguments.rs:28:37 + --> $DIR/missing_arguments.rs:28:27 | LL | three_diff( 1, 1.0, ); - | ^ missing argument of type &str + | ^ missing argument of type &str | note: function defined here --> $DIR/missing_arguments.rs:5:4 @@ -200,16 +200,16 @@ LL | fn three_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- help: provide a parameter of the correct type here | -LL | three_diff( 1, 1.0, {&str},); - | ^^^^^^^ +LL | three_diff( 1, 1.0, {&str}, ); + | ^^^^^^^^ error[E0059]: multiple arguments to this function are incorrect - --> $DIR/missing_arguments.rs:29:36 + --> $DIR/missing_arguments.rs:29:33 | LL | three_diff( "" ); - | ^^ missing argument of type f32 - | | - | missing argument of type i32 + | ^ ^ missing argument of type f32 + | | + | missing argument of type i32 | note: function defined here --> $DIR/missing_arguments.rs:5:4 @@ -218,16 +218,16 @@ LL | fn three_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- help: provide parameters of the correct types | -LL | three_diff( "" {i32}, {f32},); - | ^^^^^^ ^^^^^^ +LL | three_diff( {i32}, "", {f32} ); + | ^^^^^^ ^^^^^^^ error[E0059]: multiple arguments to this function are incorrect - --> $DIR/missing_arguments.rs:30:28 + --> $DIR/missing_arguments.rs:30:24 | LL | three_diff( 1.0 ); - | ^ ^ missing argument of type &str - | | - | missing argument of type i32 + | ^ ^ missing argument of type &str + | | + | missing argument of type i32 | note: function defined here --> $DIR/missing_arguments.rs:5:4 @@ -236,17 +236,17 @@ LL | fn three_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- help: provide parameters of the correct types | -LL | three_diff( 1.0 {i32}, {&str},); - | ^^^^^^ ^^^^^^^ +LL | three_diff( {i32}, 1.0, {&str} ); + | ^^^^^^ ^^^^^^^^ error[E0059]: multiple arguments to this function are incorrect - --> $DIR/missing_arguments.rs:31:37 + --> $DIR/missing_arguments.rs:31:18 | LL | three_diff( 1, ); - | ^ - | | - | missing argument of type f32 - | missing argument of type &str + | ^ + | | + | missing argument of type f32 + | missing argument of type &str | note: function defined here --> $DIR/missing_arguments.rs:5:4 @@ -255,8 +255,8 @@ LL | fn three_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- help: provide parameters of the correct types | -LL | three_diff( 1, {f32}, {&str},); - | ^^^^^^^ +LL | three_diff( 1, {f32}, {&str}, ); + | ^^^^^^^^ error[E0059]: multiple arguments to this function are incorrect --> $DIR/missing_arguments.rs:34:48 @@ -276,16 +276,16 @@ LL | fn four_repeated(_a: i32, _b: f32, _c: f32, _d: &str) {} | ^^^^^^^^^^^^^ ------- ------- ------- -------- help: provide parameters of the correct types | -LL | four_repeated( {i32}, {f32}, {f32}, {&str},); - | ^^^^^^^ +LL | four_repeated( {i32}, {f32}, {f32}, {&str}); + | ^^^^^^^^ error[E0059]: multiple arguments to this function are incorrect - --> $DIR/missing_arguments.rs:35:46 + --> $DIR/missing_arguments.rs:35:43 | LL | four_repeated( 1, "" ); - | ^ ^ missing argument of type f32 - | | - | missing argument of type f32 + | ^ ^ missing argument of type f32 + | | + | missing argument of type f32 | note: function defined here --> $DIR/missing_arguments.rs:6:4 @@ -294,8 +294,8 @@ LL | fn four_repeated(_a: i32, _b: f32, _c: f32, _d: &str) {} | ^^^^^^^^^^^^^ ------- ------- ------- -------- help: provide parameters of the correct types | -LL | four_repeated( 1, "" {f32}, {f32},); - | ^^^^^^ ^^^^^^ +LL | four_repeated( 1, {f32}, "", {f32} ); + | ^^^^^^ ^^^^^^^ error[E0059]: multiple arguments to this function are incorrect --> $DIR/missing_arguments.rs:38:50 @@ -316,18 +316,18 @@ LL | fn complex(_a: i32, _b: f32, _c: i32, _d: f32, _e: &str) {} | ^^^^^^^ ------- ------- ------- ------- -------- help: provide parameters of the correct types | -LL | complex( {i32}, {f32}, {i32}, {f32}, {&str},); - | ^^^^^^^ +LL | complex( {i32}, {f32}, {i32}, {f32}, {&str}); + | ^^^^^^^^ error[E0059]: multiple arguments to this function are incorrect - --> $DIR/missing_arguments.rs:39:48 + --> $DIR/missing_arguments.rs:39:45 | LL | complex( 1, "" ); - | ^ ^ - | | | - | | missing argument of type i32 - | | missing argument of type f32 - | missing argument of type f32 + | ^ ^ + | | | + | | missing argument of type i32 + | | missing argument of type f32 + | missing argument of type f32 | note: function defined here --> $DIR/missing_arguments.rs:7:4 @@ -336,8 +336,8 @@ LL | fn complex(_a: i32, _b: f32, _c: i32, _d: f32, _e: &str) {} | ^^^^^^^ ------- ------- ------- ------- -------- help: provide parameters of the correct types | -LL | complex( 1, "" {f32}, {i32}, {f32},); - | ^^^^^^ ^^^^^^ +LL | complex( 1, {f32}, "", {i32}, {f32} ); + | ^^^^^^ ^^^^^^^ error: aborting due to 19 previous errors diff --git a/src/test/ui/argument-suggestions/mixed_cases.stderr b/src/test/ui/argument-suggestions/mixed_cases.stderr index 1d2f6e98a9814..4337389f6d9fa 100644 --- a/src/test/ui/argument-suggestions/mixed_cases.stderr +++ b/src/test/ui/argument-suggestions/mixed_cases.stderr @@ -17,13 +17,13 @@ LL | two_args(1, {f32}); | ^--^^ error[E0059]: multiple arguments to this function are incorrect - --> $DIR/mixed_cases.rs:11:20 + --> $DIR/mixed_cases.rs:11:17 | LL | three_args(1, "", X {}, ""); - | ^^^^^ ^^ this parameter of type &'static str isn't needed for three_args - | || - | |this parameter of type X isn't needed for three_args - | missing argument of type f32 + | ^ ^^^^ ^^ this parameter of type &'static str isn't needed for three_args + | | | + | | this parameter of type X isn't needed for three_args + | missing argument of type f32 | note: function defined here --> $DIR/mixed_cases.rs:6:4 @@ -32,8 +32,8 @@ LL | fn three_args(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- help: make these changes | -LL | three_args(1, "" {f32}, X {}, ""); - | -- ^^^^^^ +LL | three_args(1, {f32}, ""); + | ^^^^^^ -- error[E0059]: multiple arguments to this function are incorrect --> $DIR/mixed_cases.rs:14:17 @@ -50,16 +50,16 @@ LL | fn three_args(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- help: provide parameters of the correct types | -LL | three_args(1, {f32} {&str},); +LL | three_args(1, {f32}, {&str}); | ^^^^^^^^^^^^ error[E0059]: multiple arguments to this function are incorrect - --> $DIR/mixed_cases.rs:17:20 + --> $DIR/mixed_cases.rs:17:17 | LL | three_args(1, "", X {}); - | ^^^^^ this parameter of type X isn't needed for three_args - | | - | missing argument of type f32 + | ^ ^^^^ this parameter of type X isn't needed for three_args + | | + | missing argument of type f32 | note: function defined here --> $DIR/mixed_cases.rs:6:4 @@ -68,8 +68,8 @@ LL | fn three_args(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- help: make these changes | -LL | three_args(1, "" {f32}, X {}); - | -- ^^^^^^ +LL | three_args(1, {f32}, ""); + | ^^^^^^ -- error[E0059]: multiple arguments to this function are incorrect --> $DIR/mixed_cases.rs:20:14 @@ -94,8 +94,9 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/mixed_cases.rs:23:14 | LL | three_args("", 1); - | ^^ ^ ^ missing argument of type f32 + | ^^ ^ | | | + | | missing argument of type f32 | | expected f32, found f32 | expected i32, found i32 | @@ -106,8 +107,8 @@ LL | fn three_args(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- help: make these changes | -LL | three_args(1, "") {f32},; - | ^ ^^ ^^^^^^ +LL | three_args(1, {f32}, ""); + | ^ ^^^^^^ error: aborting due to 6 previous errors From 807f656c7cd57b87c1f98196a85ef4bc3abde45d Mon Sep 17 00:00:00 2001 From: Pi Lanningham Date: Tue, 19 Jan 2021 02:32:22 -0500 Subject: [PATCH 18/21] Refactor the check code to simplify the suggestions. Rather than dropping individual suggestion spans, I just re-construct the function call from scratch. This makes fiddling with commas sooo much easier. The highlighting of individual errors is temporarily disabled, I'll add that back in temporarily. --- .../rustc_typeck/src/check/fn_ctxt/checks.rs | 336 +++++------------- src/test/ui/argument-suggestions/basic.stderr | 45 ++- .../ui/argument-suggestions/complex.stderr | 16 +- .../argument-suggestions/extra_arguments.rs | 8 +- .../extra_arguments.stderr | 134 +++---- .../invalid_arguments.stderr | 190 +++++----- .../missing_arguments.stderr | 229 +++++------- .../argument-suggestions/mixed_cases.stderr | 54 +-- .../permuted_arguments.stderr | 24 +- .../swapped_arguments.stderr | 58 ++- 10 files changed, 413 insertions(+), 681 deletions(-) diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs index 2da4450d191b3..99575e5d2f80a 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs @@ -19,7 +19,7 @@ use rustc_middle::ty::adjustment::AllowTwoPhase; use rustc_middle::ty::fold::TypeFoldable; use rustc_middle::ty::{self, Ty}; use rustc_session::Session; -use rustc_span::{self, BytePos, MultiSpan, Span}; +use rustc_span::{self, MultiSpan, Span}; use rustc_span::{ symbol::{sym, Ident}, }; @@ -381,11 +381,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { eliminate_arg(mat, ai, arg_idx); }; - let eliminate_satisfied = |mat: &mut Vec>, ii: &mut Vec, ai: &mut Vec| { + let eliminate_satisfied = |mat: &mut Vec>, ii: &mut Vec, ai: &mut Vec| -> Vec<(usize, usize)> { let mut i = cmp::min(ii.len(), ai.len()); + let mut eliminated = vec![]; while i > 0 { let idx = i - 1; if mat[idx][idx] { + eliminated.push((ai[idx], ii[idx])); satisfy_input( mat, ii, @@ -396,14 +398,20 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } i -= 1; } + return eliminated; }; // A list of the issues we might find enum Issue { + // The given argument is the invalid type for the input Invalid(usize), + // There is a missing input Missing(usize), + // There's a superfluous argument Extra(usize), + // Two arguments should be swapped Swap(usize, usize), + // Several arguments should be reordered Permutation(Vec>), } // Check for the above mismatch cases @@ -547,6 +555,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { return None; }; + // As we encounter issues, keep track of what we want to provide for the suggestion + let mut suggested_inputs: Vec> = vec![None; minimum_input_count]; + let mut issues = vec![]; + let source_map = self.sess().source_map(); + // Before we start looking for issues, eliminate any arguments that are already satisfied, // so that an argument which is already spoken for by the input it's in doesn't // spill over into another similarly typed input @@ -556,36 +569,61 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Without this elimination, the first argument causes the second argument // to show up as both a missing input and extra argument, rather than // just an invalid type. - eliminate_satisfied(&mut compatibility_matrix, &mut input_indexes, &mut arg_indexes); + for (arg, inp) in eliminate_satisfied(&mut compatibility_matrix, &mut input_indexes, &mut arg_indexes) { + let arg_span = provided_args[arg].span; + let arg_text = source_map.span_to_snippet(arg_span).unwrap(); + suggested_inputs[inp] = Some(arg_text); + } - // As we encounter issues, we'll transcribe them to their actual indices - let mut issues: Vec = vec![]; // Until we've elimineated / satisfied all arguments/inputs while input_indexes.len() > 0 || arg_indexes.len() > 0 { // Check for the first relevant issue match find_issue(&compatibility_matrix, &input_indexes, &arg_indexes) { Some(Issue::Invalid(idx)) => { - // Eliminate the input and the arg, while transposing to the original index + // Eliminate the input and the arg, proposing a placeholder of the correct type + let input_idx = input_indexes[idx]; + let expected_ty = expected_input_tys[input_idx]; + let input_ty = self.resolve_vars_if_possible(expected_ty); + if input_ty.is_unit() { + suggested_inputs[input_idx] = Some("()".to_string()); + } else { + suggested_inputs[input_idx] = Some(format!("{{{}}}", input_ty)); + } issues.push(Issue::Invalid(arg_indexes[idx])); eliminate_input(&mut compatibility_matrix, &mut input_indexes, idx); eliminate_arg(&mut compatibility_matrix, &mut arg_indexes, idx); } Some(Issue::Extra(idx)) => { + // Eliminate the argument (without touching any inputs) issues.push(Issue::Extra(arg_indexes[idx])); eliminate_arg(&mut compatibility_matrix, &mut arg_indexes, idx); } Some(Issue::Missing(idx)) => { - // FIXME: improve these with help from code reviewers - let input_ty = - self.resolve_vars_if_possible(expected_input_tys[input_indexes[idx]]); + let input_idx = input_indexes[idx]; + let expected_ty = expected_input_tys[input_idx]; + let input_ty = self.resolve_vars_if_possible(expected_ty); if input_ty.is_unit() { - info!("~~~ Issue: Maybe use ()?"); // FIXME + suggested_inputs[input_idx] = Some("()".to_string()); + } else { + suggested_inputs[input_idx] = Some(format!("{{{}}}", input_ty)); } issues.push(Issue::Missing(input_indexes[idx])); eliminate_input(&mut compatibility_matrix, &mut input_indexes, idx); } Some(Issue::Swap(idx, other)) => { - issues.push(Issue::Swap(arg_indexes[idx], arg_indexes[other])); + let input_idx = input_indexes[idx]; + let other_input_idx = input_indexes[other]; + let arg_idx = arg_indexes[idx]; + let other_arg_idx = arg_indexes[other]; + let first_span = provided_args[arg_idx].span; + let second_span = provided_args[other_arg_idx].span; + let first_snippet = source_map.span_to_snippet(first_span).unwrap(); + let second_snippet = source_map.span_to_snippet(second_span).unwrap(); + suggested_inputs[input_idx] = Some(second_snippet); + suggested_inputs[other_input_idx] = Some(first_snippet); + + issues.push(Issue::Swap(arg_idx, other_arg_idx)); + let (min, max) = (cmp::min(idx, other), cmp::max(idx, other)); satisfy_input( &mut compatibility_matrix, @@ -610,11 +648,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { args.iter() .filter_map(|&a| a) .collect(); - // FIXME: Is there a cleaner way to do this? - let mut real_idxs = vec![None; provided_args.len()]; - for (src, dst) in args.iter().enumerate() { - real_idxs[arg_indexes[src]] = dst.map(|dst| arg_indexes[dst]); + + let mut real_idxs = vec![None; provided_arg_count]; + for (src, dst) in args.iter().enumerate().filter(|(_, &a)| a.is_some()) { + let src_arg = arg_indexes[src]; + let dst_arg = arg_indexes[dst.unwrap()]; + let dest_input = input_indexes[dst.unwrap()]; + let src_span = provided_args[src_arg].span; + suggested_inputs[dest_input] = Some(source_map.span_to_snippet(src_span).unwrap()); + real_idxs[src_arg] = Some(dst_arg); } + issues.push(Issue::Permutation(real_idxs)); idxs.sort(); idxs.reverse(); @@ -631,176 +675,37 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { None => { // We didn't find any issues, so we need to push the algorithm forward // First, eliminate any arguments that currently satisfy their inputs - eliminate_satisfied(&mut compatibility_matrix, &mut input_indexes, &mut arg_indexes); + for (arg, inp) in eliminate_satisfied(&mut compatibility_matrix, &mut input_indexes, &mut arg_indexes) { + let arg_span = provided_args[arg].span; + let arg_text = source_map.span_to_snippet(arg_span).unwrap(); + suggested_inputs[inp] = Some(arg_text); + } } }; } let issue_count = issues.len(); if issue_count > 0 { - // This represents the kind of wording we want to use on the suggestion - enum SuggestionType { - NoSuggestion, - Remove, // Suggest removing an argument - Provide, // Suggest providing an argument of a given type - Swap, // Suggest swapping a few arguments - Reorder, // Suggest an arbitrary permutation (more complicated than swaps) - Changes // Suggest a mixed bag of generic changes, which may include multiple of the above - } - use SuggestionType::*; - - // We found issues, so let's construct a diagnostic that summarizes the issues we found - // FIXME: This might need some refining in code review - let mut labels = vec![]; - let mut suggestions = vec![]; - let mut suggestion_type = NoSuggestion; - let mut eliminated_args = vec![false; provided_arg_count]; - let mut current_arg_count = provided_arg_count; // Incremented if we insert an argument - let source_map = self.sess().source_map(); - for issue in issues { - match issue { - Issue::Invalid(arg) => { - let span = provided_args[arg].span; - let expected_type = expected_input_tys[arg]; - let found_type = final_arg_types[arg].unwrap().0; - labels.push((span, format!("expected {}, found {}", expected_type, found_type))); - suggestion_type = match suggestion_type { - NoSuggestion | Provide => Provide, - _ => Changes, - }; - suggestions.push((span, format!("{{{}}}", expected_type))); - } - Issue::Extra(arg) => { - let span = provided_args[arg].span; - - // We want to suggest deleting this arg, - // but dealing with formatting before and after is tricky - // so we mark it as deleted, so we can do a scan afterwards - eliminated_args[arg] = true; - let found_type = self.check_expr(&provided_args[arg]); - // TODO: if someone knows the method-chain-foo to achieve this, let me know - // but I didn't have the patience for it lol - let fn_name = if let Some(def_id) = fn_def_id { - let node = tcx.hir().get_if_local(def_id); - let def_kind = tcx.def_kind(def_id); - let descr = def_kind.descr(def_id); - if let Some(node) = node { - if let Some(ident) = node.ident() { - format!("for {}", ident) - } else { - format!("for this {}", descr) - } - } else { - format!("for this {}", descr) - } - } else { - "here".to_string() - }; - - labels.push((span, format!("this parameter of type {} isn't needed {}", found_type, fn_name))); - suggestion_type = match suggestion_type { - NoSuggestion | Remove => Remove, - _ => Changes, - }; - } - Issue::Missing(arg) => { - let expected_type = expected_input_tys[arg]; - let (missing_span, suggested_arg) = if arg < provided_arg_count { - let span = provided_args[arg].span; - ( - Span::new( - span.lo(), - span.lo(), - span.ctxt(), - ), - format!("{{{}}}, ", expected_type) - ) - } else if provided_arg_count > 0 { - let prev = provided_args[provided_arg_count - 1].span; - ( - Span::new( - prev.hi(), - prev.hi(), - prev.ctxt(), - ), - format!(", {{{}}}", expected_type) - ) - } else { - let include_comma = current_arg_count > 0; - ( - Span::new( - call_span.hi() - BytePos(1), - call_span.hi() - BytePos(1), - call_span.ctxt() - ), - format!("{}{{{}}}", if include_comma { ", " } else { "" }, expected_type) - ) - }; - current_arg_count += 1; - labels.push((missing_span, format!("missing argument of type {}", expected_type))); - suggestion_type = match suggestion_type { - NoSuggestion | Provide => Provide, - _ => Changes, - }; - suggestions.push((missing_span, suggested_arg)); - } - Issue::Swap(arg, other) => { - let first_span = provided_args[arg].span; - let second_span = provided_args[other].span; - let first_snippet = source_map.span_to_snippet(first_span).unwrap(); - let second_snippet = source_map.span_to_snippet(second_span).unwrap(); - let expected_types = (expected_input_tys[arg], expected_input_tys[other]); - let found_types = ( - final_arg_types[arg].unwrap().1, - final_arg_types[other].unwrap().1, - ); - labels.push((first_span, format!("expected {}, found {}", expected_types.0, found_types.0))); - suggestions.push((first_span, second_snippet)); - labels.push((second_span, format!("expected {}, found {}", expected_types.1, found_types.1))); - suggestions.push((second_span, first_snippet)); - suggestion_type = match suggestion_type { - NoSuggestion | Swap => Swap, - _ => Changes, - }; - } - Issue::Permutation(args) => { - for (src, &arg) in args.iter().enumerate() { - if let Some(dst) = arg { - let src_span = provided_args[src].span; - let dst_span = provided_args[dst].span; - let snippet = source_map.span_to_snippet(src_span).unwrap(); - let expected_type = expected_input_tys[dst]; - let found_type = final_arg_types[dst].unwrap().1; - labels.push((dst_span, format!("expected {}, found {}", expected_type, found_type))); - suggestions.push((dst_span, snippet)); - suggestion_type = match suggestion_type { - NoSuggestion | Reorder => Reorder, - _ => Changes, - }; - } - } - } - } - } // Now construct our error from the various things we've labeled - let highlight_sp = MultiSpan::from_spans(labels.iter().map(|s| s.0).collect()); let mut err = struct_span_err!( tcx.sess, - highlight_sp, + call_span, E0059, // FIXME: Choose a different code? "{}arguments to this function are incorrect", if issue_count > 1 { "multiple " } else { "" } ); // Call out where the function is defined + let mut fn_name: String = "".to_string(); if let Some(def_id) = fn_def_id { if let Some(node) = tcx.hir().get_if_local(def_id) { - let mut spans: MultiSpan = node + let span = node .ident() .map(|ident| ident.span) - .unwrap_or_else(|| tcx.hir().span(node.hir_id().unwrap())) - .into(); + .unwrap_or_else(|| tcx.hir().span(node.hir_id().unwrap())); + fn_name = source_map.span_to_snippet(span).unwrap(); + let mut spans: MultiSpan = span.into(); if let Some(id) = node.body_id() { let body = tcx.hir().body(id); @@ -813,95 +718,28 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } - // annotate each of the labels - for (span, label) in labels { - err.span_label(span, label); - } - - // Before constructing our multipart suggestions, we need to add in all the suggestions - // to eliminate extra parameters - // We can't overlap spans in a suggestion or weird things happen - let mut lo = None; - let mut hi = None; - let mut in_block = false; - // Scan backwards over the args (scanning backwards lets us favor the commas after, rather than before) - for (idx, eliminated) in eliminated_args.iter().enumerate().rev() { - match (in_block, eliminated, idx == 0) { - (false, true, false) => { - // We just encountered the start of a block of eliminated parameters - hi = Some(idx); - in_block = true; - }, - (false, true, true) => { - // We encountered a single eliminated arg at the end of the arg list - lo = Some(idx); - hi = Some(idx); + // And add a series of suggestions + // FIXME: for simpler cases, this might be overkill + if issues.len() > 0 { + let suggestion_text = Some("make these changes"); + let mut suggestion = format!("{}(", fn_name).to_string(); + for (idx, input) in suggested_inputs.iter().enumerate() { + if let Some(sug) = input { + suggestion += sug; + } else { + suggestion += "??"; } - (true, false, _) => { - // We encountered the end of a block, set the hi so the logic below kicks in - lo = Some(idx + 1); - in_block = false; - }, - (true, true, true) => { - lo = Some(idx); - in_block = false; + if idx < minimum_input_count - 1 { + suggestion += ", "; } - _ => {} } - if lo.is_some() && hi.is_some() { - let (lo_idx, hi_idx) = (lo.unwrap(), hi.unwrap()); - // We've found a contiguous block, so emit the elimination - // be careful abound the boundaries - let ctxt = provided_args[0].span.ctxt(); - let (lo_bp, hi_bp) = match (lo_idx == 0, hi_idx == provided_arg_count - 1) { - // If we have an arg to our right, we need to eat the comma of the last eliminated param - // xx, xx, xx, a - // [-----------) - (_, false) => { - (provided_args[lo_idx].span.lo(), provided_args[hi_idx + 1].span.lo()) - }, - // If this block extends to the last argument, and theres an arg to the left, eat its comma - // a, xx, xx, xx - // [-----------) - (false, true) => { - (provided_args[lo_idx - 1].span.hi(), provided_args[hi_idx].span.hi()) - }, - // If every argument was eliminated, don't need to worry about commas before or after - // xx, xx, xx, xx - // [-------------) - (true, true) => { - (provided_args[lo_idx].span.lo(), provided_args[hi_idx].span.hi()) - }, - }; - let eliminated_span = Span::new( - lo_bp, - hi_bp, - ctxt, - ); - suggestions.push((eliminated_span, "".to_string())); - lo = None; - hi = None; - } - } - - // And add a series of suggestions - // FIXME: for simpler cases, this might be overkill - if suggestions.len() > 0 { - let suggestion_text = match (&suggestion_type, issue_count) { - (Remove, 1) => Some("remove this argument"), - (Remove, _) => Some("remove these arguments"), - (Provide, 1) => Some("provide a parameter of the correct type here"), - (Provide, _) => Some("provide parameters of the correct types"), - (Swap, 1) => Some("swap these two arguments"), - (Swap, _) => Some("swap these arguments"), - (Reorder, _) => Some("reorder these parameters"), - _ => Some("make these changes"), - }; + suggestion += ")"; if let Some(suggestion_text) = suggestion_text { - err.multipart_suggestion_verbose( + err.span_suggestion_verbose( + call_span, suggestion_text, - suggestions, - if matches!(suggestion_type, Provide) { Applicability::HasPlaceholders } else { Applicability::MaybeIncorrect }, + suggestion, + Applicability::HasPlaceholders, ); } } diff --git a/src/test/ui/argument-suggestions/basic.stderr b/src/test/ui/argument-suggestions/basic.stderr index 547c3f9bc8354..95f6541825f30 100644 --- a/src/test/ui/argument-suggestions/basic.stderr +++ b/src/test/ui/argument-suggestions/basic.stderr @@ -1,87 +1,82 @@ error[E0059]: arguments to this function are incorrect - --> $DIR/basic.rs:20:13 + --> $DIR/basic.rs:20:5 | LL | invalid(1.0); - | ^^^ expected u32, found {float} + | ^^^^^^^^^^^^ | note: function defined here --> $DIR/basic.rs:13:4 | LL | fn invalid(_i: u32) {} | ^^^^^^^ ------- -help: provide a parameter of the correct type here +help: make these changes | LL | invalid({u32}); - | ^^^^^ + | ^^^^^^^^^^^^^^ error[E0059]: arguments to this function are incorrect - --> $DIR/basic.rs:21:11 + --> $DIR/basic.rs:21:5 | LL | extra(""); - | ^^ this parameter of type &'static str isn't needed for extra + | ^^^^^^^^^ | note: function defined here --> $DIR/basic.rs:14:4 | LL | fn extra() {} | ^^^^^ -help: remove this argument +help: make these changes | LL | extra(); - | -- + | ^^^^^^^ error[E0059]: arguments to this function are incorrect - --> $DIR/basic.rs:22:13 + --> $DIR/basic.rs:22:5 | LL | missing(); - | ^ missing argument of type u32 + | ^^^^^^^^^ | note: function defined here --> $DIR/basic.rs:15:4 | LL | fn missing(_i: u32) {} | ^^^^^^^ ------- -help: provide a parameter of the correct type here +help: make these changes | LL | missing({u32}); - | ^^^^^ + | ^^^^^^^^^^^^^^ error[E0059]: arguments to this function are incorrect - --> $DIR/basic.rs:23:13 + --> $DIR/basic.rs:23:5 | LL | swapped("", 1); - | ^^ ^ expected &str, found &str - | | - | expected u32, found u32 + | ^^^^^^^^^^^^^^ | note: function defined here --> $DIR/basic.rs:16:4 | LL | fn swapped(_i: u32, _s: &str) {} | ^^^^^^^ ------- -------- -help: swap these two arguments +help: make these changes | LL | swapped(1, ""); - | ^ ^^ + | ^^^^^^^^^^^^^^ error[E0059]: arguments to this function are incorrect - --> $DIR/basic.rs:24:14 + --> $DIR/basic.rs:24:5 | LL | permuted(Y {}, Z {}, X {}); - | ^^^^ ^^^^ ^^^^ expected Z, found Z - | | | - | | expected Y, found Y - | expected X, found X + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/basic.rs:17:4 | LL | fn permuted(_x: X, _y: Y, _z: Z) {} | ^^^^^^^^ ----- ----- ----- -help: reorder these parameters +help: make these changes | LL | permuted(X {}, Y {}, Z {}); - | ^^^^ ^^^^ ^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 5 previous errors diff --git a/src/test/ui/argument-suggestions/complex.stderr b/src/test/ui/argument-suggestions/complex.stderr index 973cd4660f077..57a9c3724a3d4 100644 --- a/src/test/ui/argument-suggestions/complex.stderr +++ b/src/test/ui/argument-suggestions/complex.stderr @@ -1,16 +1,8 @@ error[E0059]: multiple arguments to this function are incorrect - --> $DIR/complex.rs:14:11 + --> $DIR/complex.rs:14:3 | LL | complex(1.0, H {}, &"", G{}, F::X2, Z {}, X {}, Y {}); - | ^^^ ^^^^ ^ ^^^ ^^^^^ ^^^^ ^^^^ ^^^^ expected Z, found Z - | | | | | | | | - | | | | | | | expected Y, found Y - | | | | | | expected X, found X - | | | | | expected G, found G - | | | | expected F, found F - | | | missing argument of type E - | | this parameter of type H isn't needed for complex - | expected u32, found {float} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/complex.rs:11:4 @@ -19,8 +11,8 @@ LL | fn complex(_i: u32, _s: &str, _e: E, _f: F, _g: G, _x: X, _y: Y, _z: Z ) {} | ^^^^^^^ ------- -------- ----- ----- ----- ----- ----- ------ help: make these changes | -LL | complex({u32}, {E}, &"", F::X2, G{}, X {}, Y {}, Z {}); - | ^^^^^ -- ^^^^^^^^^ ^^^ ^^^^ ^^^^ ^^^^ +LL | complex({u32}, &"", {E}, F::X2, G{}, X {}, Y {}, Z {}); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/argument-suggestions/extra_arguments.rs b/src/test/ui/argument-suggestions/extra_arguments.rs index 0788a58658893..68269b19b8c2a 100644 --- a/src/test/ui/argument-suggestions/extra_arguments.rs +++ b/src/test/ui/argument-suggestions/extra_arguments.rs @@ -21,15 +21,15 @@ fn main() { // Check with weird spacing and newlines two_arg_same(1, 1, ""); //~ ERROR arguments to this function are incorrect two_arg_diff(1, 1, ""); //~ ERROR arguments to this function are incorrect - two_arg_same( + two_arg_same( //~ ERROR arguments to this function are incorrect 1, 1, - "" //~ ERROR arguments to this function are incorrect + "" ); - two_arg_diff( + two_arg_diff( //~ ERROR arguments to this function are incorrect + 1, 1, - 1, //~ ERROR arguments to this function are incorrect "" ); } \ No newline at end of file diff --git a/src/test/ui/argument-suggestions/extra_arguments.stderr b/src/test/ui/argument-suggestions/extra_arguments.stderr index 77ac006b77064..e8e2978a965e9 100644 --- a/src/test/ui/argument-suggestions/extra_arguments.stderr +++ b/src/test/ui/argument-suggestions/extra_arguments.stderr @@ -1,232 +1,234 @@ error[E0059]: arguments to this function are incorrect - --> $DIR/extra_arguments.rs:7:9 + --> $DIR/extra_arguments.rs:7:3 | LL | empty(""); - | ^^ this parameter of type &'static str isn't needed for empty + | ^^^^^^^^^ | note: function defined here --> $DIR/extra_arguments.rs:1:4 | LL | fn empty() {} | ^^^^^ -help: remove this argument +help: make these changes | LL | empty(); - | -- + | ^^^^^^^ error[E0059]: arguments to this function are incorrect - --> $DIR/extra_arguments.rs:9:14 + --> $DIR/extra_arguments.rs:9:3 | LL | one_arg(1, 1); - | ^ this parameter of type {integer} isn't needed for one_arg + | ^^^^^^^^^^^^^ | note: function defined here --> $DIR/extra_arguments.rs:2:4 | LL | fn one_arg(_a: i32) {} | ^^^^^^^ ------- -help: remove this argument +help: make these changes | LL | one_arg(1); - | -- + | ^^^^^^^^^^ error[E0059]: arguments to this function are incorrect - --> $DIR/extra_arguments.rs:10:14 + --> $DIR/extra_arguments.rs:10:3 | LL | one_arg(1, ""); - | ^^ this parameter of type &'static str isn't needed for one_arg + | ^^^^^^^^^^^^^^ | note: function defined here --> $DIR/extra_arguments.rs:2:4 | LL | fn one_arg(_a: i32) {} | ^^^^^^^ ------- -help: remove this argument +help: make these changes | LL | one_arg(1); - | -- + | ^^^^^^^^^^ error[E0059]: multiple arguments to this function are incorrect - --> $DIR/extra_arguments.rs:11:14 + --> $DIR/extra_arguments.rs:11:3 | LL | one_arg(1, "", 1.0); - | ^^ ^^^ this parameter of type {float} isn't needed for one_arg - | | - | this parameter of type &'static str isn't needed for one_arg + | ^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/extra_arguments.rs:2:4 | LL | fn one_arg(_a: i32) {} | ^^^^^^^ ------- -help: remove these arguments +help: make these changes | LL | one_arg(1); - | -- + | ^^^^^^^^^^ error[E0059]: arguments to this function are incorrect - --> $DIR/extra_arguments.rs:13:22 + --> $DIR/extra_arguments.rs:13:3 | LL | two_arg_same(1, 1, 1); - | ^ this parameter of type {integer} isn't needed for two_arg_same + | ^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/extra_arguments.rs:3:4 | LL | fn two_arg_same(_a: i32, _b: i32) {} | ^^^^^^^^^^^^ ------- ------- -help: remove this argument +help: make these changes | LL | two_arg_same(1, 1); - | -- + | ^^^^^^^^^^^^^^^^^^ error[E0059]: arguments to this function are incorrect - --> $DIR/extra_arguments.rs:14:22 + --> $DIR/extra_arguments.rs:14:3 | LL | two_arg_same(1, 1, 1.0); - | ^^^ this parameter of type {float} isn't needed for two_arg_same + | ^^^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/extra_arguments.rs:3:4 | LL | fn two_arg_same(_a: i32, _b: i32) {} | ^^^^^^^^^^^^ ------- ------- -help: remove this argument +help: make these changes | LL | two_arg_same(1, 1); - | -- + | ^^^^^^^^^^^^^^^^^^ error[E0059]: arguments to this function are incorrect - --> $DIR/extra_arguments.rs:16:19 + --> $DIR/extra_arguments.rs:16:3 | LL | two_arg_diff(1, 1, ""); - | ^ this parameter of type {integer} isn't needed for two_arg_diff + | ^^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/extra_arguments.rs:4:4 | LL | fn two_arg_diff(_a: i32, _b: &str) {} | ^^^^^^^^^^^^ ------- -------- -help: remove this argument +help: make these changes | LL | two_arg_diff(1, ""); - | -- + | ^^^^^^^^^^^^^^^^^^^ error[E0059]: arguments to this function are incorrect - --> $DIR/extra_arguments.rs:17:23 + --> $DIR/extra_arguments.rs:17:3 | LL | two_arg_diff(1, "", ""); - | ^^ this parameter of type &'static str isn't needed for two_arg_diff + | ^^^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/extra_arguments.rs:4:4 | LL | fn two_arg_diff(_a: i32, _b: &str) {} | ^^^^^^^^^^^^ ------- -------- -help: remove this argument +help: make these changes | LL | two_arg_diff(1, ""); - | -- + | ^^^^^^^^^^^^^^^^^^^ error[E0059]: multiple arguments to this function are incorrect - --> $DIR/extra_arguments.rs:18:19 + --> $DIR/extra_arguments.rs:18:3 | LL | two_arg_diff(1, 1, "", ""); - | ^ ^^ this parameter of type &'static str isn't needed for two_arg_diff - | | - | this parameter of type {integer} isn't needed for two_arg_diff + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/extra_arguments.rs:4:4 | LL | fn two_arg_diff(_a: i32, _b: &str) {} | ^^^^^^^^^^^^ ------- -------- -help: remove these arguments +help: make these changes | LL | two_arg_diff(1, ""); - | ---- + | ^^^^^^^^^^^^^^^^^^^ error[E0059]: multiple arguments to this function are incorrect - --> $DIR/extra_arguments.rs:19:23 + --> $DIR/extra_arguments.rs:19:3 | LL | two_arg_diff(1, "", 1, ""); - | ^ ^^ this parameter of type &'static str isn't needed for two_arg_diff - | | - | this parameter of type {integer} isn't needed for two_arg_diff + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/extra_arguments.rs:4:4 | LL | fn two_arg_diff(_a: i32, _b: &str) {} | ^^^^^^^^^^^^ ------- -------- -help: remove these arguments +help: make these changes | LL | two_arg_diff(1, ""); - | -- + | ^^^^^^^^^^^^^^^^^^^ error[E0059]: arguments to this function are incorrect - --> $DIR/extra_arguments.rs:22:26 + --> $DIR/extra_arguments.rs:22:3 | LL | two_arg_same(1, 1, ""); - | ^^ this parameter of type &'static str isn't needed for two_arg_same + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/extra_arguments.rs:3:4 | LL | fn two_arg_same(_a: i32, _b: i32) {} | ^^^^^^^^^^^^ ------- ------- -help: remove this argument +help: make these changes | LL | two_arg_same(1, 1); - | -- + | ^^^^^^^^^^^^^^^^^^ error[E0059]: arguments to this function are incorrect - --> $DIR/extra_arguments.rs:23:19 + --> $DIR/extra_arguments.rs:23:3 | LL | two_arg_diff(1, 1, ""); - | ^ this parameter of type {integer} isn't needed for two_arg_diff + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/extra_arguments.rs:4:4 | LL | fn two_arg_diff(_a: i32, _b: &str) {} | ^^^^^^^^^^^^ ------- -------- -help: remove this argument +help: make these changes | LL | two_arg_diff(1, ""); - | -- + | ^^^^^^^^^^^^^^^^^^^ error[E0059]: arguments to this function are incorrect - --> $DIR/extra_arguments.rs:27:5 + --> $DIR/extra_arguments.rs:24:3 | -LL | "" - | ^^ this parameter of type &'static str isn't needed for two_arg_same +LL | / two_arg_same( +LL | | 1, +LL | | 1, +LL | | "" +LL | | ); + | |___^ | note: function defined here --> $DIR/extra_arguments.rs:3:4 | LL | fn two_arg_same(_a: i32, _b: i32) {} | ^^^^^^^^^^^^ ------- ------- -help: remove this argument +help: make these changes | -LL | 1 - | -- +LL | two_arg_same(1, 1); + | ^^^^^^^^^^^^^^^^^^ error[E0059]: arguments to this function are incorrect - --> $DIR/extra_arguments.rs:32:5 + --> $DIR/extra_arguments.rs:30:3 | -LL | 1, - | ^ this parameter of type {integer} isn't needed for two_arg_diff +LL | / two_arg_diff( +LL | | 1, +LL | | 1, +LL | | "" +LL | | ); + | |___^ | note: function defined here --> $DIR/extra_arguments.rs:4:4 | LL | fn two_arg_diff(_a: i32, _b: &str) {} | ^^^^^^^^^^^^ ------- -------- -help: remove this argument +help: make these changes | -LL | "" - | -- +LL | two_arg_diff(1, ""); + | ^^^^^^^^^^^^^^^^^^^ error: aborting due to 14 previous errors diff --git a/src/test/ui/argument-suggestions/invalid_arguments.stderr b/src/test/ui/argument-suggestions/invalid_arguments.stderr index 1fd198ade29e0..b2d251e94cd67 100644 --- a/src/test/ui/argument-suggestions/invalid_arguments.stderr +++ b/src/test/ui/argument-suggestions/invalid_arguments.stderr @@ -1,360 +1,338 @@ error[E0059]: arguments to this function are incorrect - --> $DIR/invalid_arguments.rs:13:11 + --> $DIR/invalid_arguments.rs:13:3 | LL | one_arg(1.0); - | ^^^ expected i32, found {float} + | ^^^^^^^^^^^^ | note: function defined here --> $DIR/invalid_arguments.rs:5:4 | LL | fn one_arg(_a: i32) {} | ^^^^^^^ ------- -help: provide a parameter of the correct type here +help: make these changes | LL | one_arg({i32}); - | ^^^^^ + | ^^^^^^^^^^^^^^ error[E0059]: arguments to this function are incorrect - --> $DIR/invalid_arguments.rs:16:19 + --> $DIR/invalid_arguments.rs:16:3 | LL | two_arg_same(1, ""); - | ^^ expected i32, found &'static str + | ^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/invalid_arguments.rs:6:4 | LL | fn two_arg_same(_a: i32, _b: i32) {} | ^^^^^^^^^^^^ ------- ------- -help: provide a parameter of the correct type here +help: make these changes | LL | two_arg_same(1, {i32}); - | ^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^ error[E0059]: arguments to this function are incorrect - --> $DIR/invalid_arguments.rs:17:16 + --> $DIR/invalid_arguments.rs:17:3 | LL | two_arg_same("", 1); - | ^^ expected i32, found &'static str + | ^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/invalid_arguments.rs:6:4 | LL | fn two_arg_same(_a: i32, _b: i32) {} | ^^^^^^^^^^^^ ------- ------- -help: provide a parameter of the correct type here +help: make these changes | LL | two_arg_same({i32}, 1); - | ^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^ error[E0059]: multiple arguments to this function are incorrect - --> $DIR/invalid_arguments.rs:18:16 + --> $DIR/invalid_arguments.rs:18:3 | LL | two_arg_same("", ""); - | ^^ ^^ expected i32, found &'static str - | | - | expected i32, found &'static str + | ^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/invalid_arguments.rs:6:4 | LL | fn two_arg_same(_a: i32, _b: i32) {} | ^^^^^^^^^^^^ ------- ------- -help: provide parameters of the correct types +help: make these changes | LL | two_arg_same({i32}, {i32}); - | ^^^^^ ^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0059]: arguments to this function are incorrect - --> $DIR/invalid_arguments.rs:19:19 + --> $DIR/invalid_arguments.rs:19:3 | LL | two_arg_diff(1, ""); - | ^^ expected f32, found &'static str + | ^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/invalid_arguments.rs:7:4 | LL | fn two_arg_diff(_a: i32, _b: f32) {} | ^^^^^^^^^^^^ ------- ------- -help: provide a parameter of the correct type here +help: make these changes | LL | two_arg_diff(1, {f32}); - | ^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^ error[E0059]: arguments to this function are incorrect - --> $DIR/invalid_arguments.rs:20:16 + --> $DIR/invalid_arguments.rs:20:3 | LL | two_arg_diff("", 1.0); - | ^^ expected i32, found &'static str + | ^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/invalid_arguments.rs:7:4 | LL | fn two_arg_diff(_a: i32, _b: f32) {} | ^^^^^^^^^^^^ ------- ------- -help: provide a parameter of the correct type here +help: make these changes | LL | two_arg_diff({i32}, 1.0); - | ^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^ error[E0059]: multiple arguments to this function are incorrect - --> $DIR/invalid_arguments.rs:21:16 + --> $DIR/invalid_arguments.rs:21:3 | LL | two_arg_diff("", ""); - | ^^ ^^ expected f32, found &'static str - | | - | expected i32, found &'static str + | ^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/invalid_arguments.rs:7:4 | LL | fn two_arg_diff(_a: i32, _b: f32) {} | ^^^^^^^^^^^^ ------- ------- -help: provide parameters of the correct types +help: make these changes | LL | two_arg_diff({i32}, {f32}); - | ^^^^^ ^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0059]: arguments to this function are incorrect - --> $DIR/invalid_arguments.rs:24:18 + --> $DIR/invalid_arguments.rs:24:3 | LL | three_arg_diff(X{}, 1.0, ""); - | ^^^ expected i32, found X + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/invalid_arguments.rs:8:4 | LL | fn three_arg_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^^^^^ ------- ------- -------- -help: provide a parameter of the correct type here +help: make these changes | LL | three_arg_diff({i32}, 1.0, ""); - | ^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0059]: arguments to this function are incorrect - --> $DIR/invalid_arguments.rs:25:21 + --> $DIR/invalid_arguments.rs:25:3 | LL | three_arg_diff(1, X {}, ""); - | ^^^^ expected f32, found X + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/invalid_arguments.rs:8:4 | LL | fn three_arg_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^^^^^ ------- ------- -------- -help: provide a parameter of the correct type here +help: make these changes | LL | three_arg_diff(1, {f32}, ""); - | ^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0059]: arguments to this function are incorrect - --> $DIR/invalid_arguments.rs:26:26 + --> $DIR/invalid_arguments.rs:26:3 | LL | three_arg_diff(1, 1.0, X {}); - | ^^^^ expected &str, found X + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/invalid_arguments.rs:8:4 | LL | fn three_arg_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^^^^^ ------- ------- -------- -help: provide a parameter of the correct type here +help: make these changes | LL | three_arg_diff(1, 1.0, {&str}); - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0059]: multiple arguments to this function are incorrect - --> $DIR/invalid_arguments.rs:28:18 + --> $DIR/invalid_arguments.rs:28:3 | LL | three_arg_diff(X {}, X {}, ""); - | ^^^^ ^^^^ expected f32, found X - | | - | expected i32, found X + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/invalid_arguments.rs:8:4 | LL | fn three_arg_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^^^^^ ------- ------- -------- -help: provide parameters of the correct types +help: make these changes | LL | three_arg_diff({i32}, {f32}, ""); - | ^^^^^ ^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0059]: multiple arguments to this function are incorrect - --> $DIR/invalid_arguments.rs:29:18 + --> $DIR/invalid_arguments.rs:29:3 | LL | three_arg_diff(X {}, 1.0, X {}); - | ^^^^ ^^^^ expected &str, found X - | | - | expected i32, found X + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/invalid_arguments.rs:8:4 | LL | fn three_arg_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^^^^^ ------- ------- -------- -help: provide parameters of the correct types +help: make these changes | LL | three_arg_diff({i32}, 1.0, {&str}); - | ^^^^^ ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0059]: multiple arguments to this function are incorrect - --> $DIR/invalid_arguments.rs:30:21 + --> $DIR/invalid_arguments.rs:30:3 | LL | three_arg_diff(1, X {}, X {}); - | ^^^^ ^^^^ expected &str, found X - | | - | expected f32, found X + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/invalid_arguments.rs:8:4 | LL | fn three_arg_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^^^^^ ------- ------- -------- -help: provide parameters of the correct types +help: make these changes | LL | three_arg_diff(1, {f32}, {&str}); - | ^^^^^ ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0059]: multiple arguments to this function are incorrect - --> $DIR/invalid_arguments.rs:32:18 + --> $DIR/invalid_arguments.rs:32:3 | LL | three_arg_diff(X {}, X {}, X {}); - | ^^^^ ^^^^ ^^^^ expected &str, found X - | | | - | | expected f32, found X - | expected i32, found X + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/invalid_arguments.rs:8:4 | LL | fn three_arg_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^^^^^ ------- ------- -------- -help: provide parameters of the correct types +help: make these changes | LL | three_arg_diff({i32}, {f32}, {&str}); - | ^^^^^ ^^^^^ ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0059]: arguments to this function are incorrect - --> $DIR/invalid_arguments.rs:34:20 + --> $DIR/invalid_arguments.rs:34:3 | LL | three_arg_repeat(X {}, 1, ""); - | ^^^^ expected i32, found X + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/invalid_arguments.rs:9:4 | LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {} | ^^^^^^^^^^^^^^^^ ------- ------- -------- -help: provide a parameter of the correct type here +help: make these changes | LL | three_arg_repeat({i32}, 1, ""); - | ^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0059]: arguments to this function are incorrect - --> $DIR/invalid_arguments.rs:35:23 + --> $DIR/invalid_arguments.rs:35:3 | LL | three_arg_repeat(1, X {}, ""); - | ^^^^ expected i32, found X + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/invalid_arguments.rs:9:4 | LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {} | ^^^^^^^^^^^^^^^^ ------- ------- -------- -help: provide a parameter of the correct type here +help: make these changes | LL | three_arg_repeat(1, {i32}, ""); - | ^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0059]: arguments to this function are incorrect - --> $DIR/invalid_arguments.rs:36:26 + --> $DIR/invalid_arguments.rs:36:3 | LL | three_arg_repeat(1, 1, X {}); - | ^^^^ expected &str, found X + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/invalid_arguments.rs:9:4 | LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {} | ^^^^^^^^^^^^^^^^ ------- ------- -------- -help: provide a parameter of the correct type here +help: make these changes | LL | three_arg_repeat(1, 1, {&str}); - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0059]: multiple arguments to this function are incorrect - --> $DIR/invalid_arguments.rs:38:20 + --> $DIR/invalid_arguments.rs:38:3 | LL | three_arg_repeat(X {}, X {}, ""); - | ^^^^ ^^^^ expected i32, found X - | | - | expected i32, found X + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/invalid_arguments.rs:9:4 | LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {} | ^^^^^^^^^^^^^^^^ ------- ------- -------- -help: provide parameters of the correct types +help: make these changes | LL | three_arg_repeat({i32}, {i32}, ""); - | ^^^^^ ^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0059]: multiple arguments to this function are incorrect - --> $DIR/invalid_arguments.rs:39:20 + --> $DIR/invalid_arguments.rs:39:3 | LL | three_arg_repeat(X {}, 1, X {}); - | ^^^^ ^^^^ expected &str, found X - | | - | expected i32, found X + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/invalid_arguments.rs:9:4 | LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {} | ^^^^^^^^^^^^^^^^ ------- ------- -------- -help: provide parameters of the correct types +help: make these changes | LL | three_arg_repeat({i32}, 1, {&str}); - | ^^^^^ ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0059]: multiple arguments to this function are incorrect - --> $DIR/invalid_arguments.rs:40:23 + --> $DIR/invalid_arguments.rs:40:3 | LL | three_arg_repeat(1, X {}, X{}); - | ^^^^ ^^^ expected &str, found X - | | - | expected i32, found X + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/invalid_arguments.rs:9:4 | LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {} | ^^^^^^^^^^^^^^^^ ------- ------- -------- -help: provide parameters of the correct types +help: make these changes | LL | three_arg_repeat(1, {i32}, {&str}); - | ^^^^^ ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0059]: multiple arguments to this function are incorrect - --> $DIR/invalid_arguments.rs:42:20 + --> $DIR/invalid_arguments.rs:42:3 | LL | three_arg_repeat(X {}, X {}, X {}); - | ^^^^ ^^^^ ^^^^ expected &str, found X - | | | - | | expected i32, found X - | expected i32, found X + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/invalid_arguments.rs:9:4 | LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {} | ^^^^^^^^^^^^^^^^ ------- ------- -------- -help: provide parameters of the correct types +help: make these changes | LL | three_arg_repeat({i32}, {i32}, {&str}); - | ^^^^^ ^^^^^ ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 21 previous errors diff --git a/src/test/ui/argument-suggestions/missing_arguments.stderr b/src/test/ui/argument-suggestions/missing_arguments.stderr index 1f3859342da04..c6ef5690a676e 100644 --- a/src/test/ui/argument-suggestions/missing_arguments.stderr +++ b/src/test/ui/argument-suggestions/missing_arguments.stderr @@ -1,343 +1,306 @@ error[E0059]: arguments to this function are incorrect - --> $DIR/missing_arguments.rs:10:11 + --> $DIR/missing_arguments.rs:10:3 | LL | one_arg(); - | ^ missing argument of type i32 + | ^^^^^^^^^ | note: function defined here --> $DIR/missing_arguments.rs:1:4 | LL | fn one_arg(_a: i32) {} | ^^^^^^^ ------- -help: provide a parameter of the correct type here +help: make these changes | LL | one_arg({i32}); - | ^^^^^ + | ^^^^^^^^^^^^^^ error[E0059]: multiple arguments to this function are incorrect - --> $DIR/missing_arguments.rs:14:27 + --> $DIR/missing_arguments.rs:14:3 | LL | two_same( ); - | ^ - | | - | missing argument of type i32 - | missing argument of type i32 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/missing_arguments.rs:2:4 | LL | fn two_same(_a: i32, _b: i32) {} | ^^^^^^^^ ------- ------- -help: provide parameters of the correct types +help: make these changes | -LL | two_same( {i32}, {i32}); - | ^^^^^^^ +LL | two_same({i32}, {i32}); + | ^^^^^^^^^^^^^^^^^^^^^^ error[E0059]: arguments to this function are incorrect - --> $DIR/missing_arguments.rs:15:16 + --> $DIR/missing_arguments.rs:15:3 | LL | two_same( 1 ); - | ^ missing argument of type i32 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/missing_arguments.rs:2:4 | LL | fn two_same(_a: i32, _b: i32) {} | ^^^^^^^^ ------- ------- -help: provide a parameter of the correct type here +help: make these changes | -LL | two_same( 1, {i32} ); - | ^^^^^^^ +LL | two_same(1, {i32}); + | ^^^^^^^^^^^^^^^^^^ error[E0059]: multiple arguments to this function are incorrect - --> $DIR/missing_arguments.rs:16:27 + --> $DIR/missing_arguments.rs:16:3 | LL | two_diff( ); - | ^ - | | - | missing argument of type i32 - | missing argument of type f32 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/missing_arguments.rs:3:4 | LL | fn two_diff(_a: i32, _b: f32) {} | ^^^^^^^^ ------- ------- -help: provide parameters of the correct types +help: make these changes | -LL | two_diff( {i32}, {f32}); - | ^^^^^^^ +LL | two_diff({i32}, {f32}); + | ^^^^^^^^^^^^^^^^^^^^^^ error[E0059]: arguments to this function are incorrect - --> $DIR/missing_arguments.rs:17:16 + --> $DIR/missing_arguments.rs:17:3 | LL | two_diff( 1 ); - | ^ missing argument of type f32 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/missing_arguments.rs:3:4 | LL | fn two_diff(_a: i32, _b: f32) {} | ^^^^^^^^ ------- ------- -help: provide a parameter of the correct type here +help: make these changes | -LL | two_diff( 1, {f32} ); - | ^^^^^^^ +LL | two_diff(1, {f32}); + | ^^^^^^^^^^^^^^^^^^ error[E0059]: arguments to this function are incorrect - --> $DIR/missing_arguments.rs:18:22 + --> $DIR/missing_arguments.rs:18:3 | LL | two_diff( 1.0 ); - | ^ missing argument of type i32 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/missing_arguments.rs:3:4 | LL | fn two_diff(_a: i32, _b: f32) {} | ^^^^^^^^ ------- ------- -help: provide a parameter of the correct type here +help: make these changes | -LL | two_diff( {i32}, 1.0 ); - | ^^^^^^ +LL | two_diff({i32}, 1.0); + | ^^^^^^^^^^^^^^^^^^^^ error[E0059]: multiple arguments to this function are incorrect - --> $DIR/missing_arguments.rs:21:37 + --> $DIR/missing_arguments.rs:21:3 | LL | three_same( ); - | ^ - | | - | missing argument of type i32 - | missing argument of type i32 - | missing argument of type i32 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/missing_arguments.rs:4:4 | LL | fn three_same(_a: i32, _b: i32, _c: i32) {} | ^^^^^^^^^^ ------- ------- ------- -help: provide parameters of the correct types +help: make these changes | -LL | three_same( {i32}, {i32}, {i32}); - | ^^^^^^^ +LL | three_same({i32}, {i32}, {i32}); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0059]: multiple arguments to this function are incorrect - --> $DIR/missing_arguments.rs:22:18 + --> $DIR/missing_arguments.rs:22:3 | LL | three_same( 1 ); - | ^ - | | - | missing argument of type i32 - | missing argument of type i32 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/missing_arguments.rs:4:4 | LL | fn three_same(_a: i32, _b: i32, _c: i32) {} | ^^^^^^^^^^ ------- ------- ------- -help: provide parameters of the correct types +help: make these changes | -LL | three_same( 1, {i32}, {i32} ); - | ^^^^^^^ +LL | three_same(1, {i32}, {i32}); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0059]: arguments to this function are incorrect - --> $DIR/missing_arguments.rs:23:26 + --> $DIR/missing_arguments.rs:23:3 | LL | three_same( 1, 1 ); - | ^ missing argument of type i32 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/missing_arguments.rs:4:4 | LL | fn three_same(_a: i32, _b: i32, _c: i32) {} | ^^^^^^^^^^ ------- ------- ------- -help: provide a parameter of the correct type here +help: make these changes | -LL | three_same( 1, 1, {i32} ); - | ^^^^^^^ +LL | three_same(1, 1, {i32}); + | ^^^^^^^^^^^^^^^^^^^^^^^ error[E0059]: arguments to this function are incorrect - --> $DIR/missing_arguments.rs:26:24 + --> $DIR/missing_arguments.rs:26:3 | LL | three_diff( 1.0, "" ); - | ^ missing argument of type i32 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/missing_arguments.rs:5:4 | LL | fn three_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- -help: provide a parameter of the correct type here +help: make these changes | -LL | three_diff( {i32}, 1.0, "" ); - | ^^^^^^ +LL | three_diff({i32}, 1.0, ""); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0059]: arguments to this function are incorrect - --> $DIR/missing_arguments.rs:27:33 + --> $DIR/missing_arguments.rs:27:3 | LL | three_diff( 1, "" ); - | ^ missing argument of type f32 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/missing_arguments.rs:5:4 | LL | fn three_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- -help: provide a parameter of the correct type here +help: make these changes | -LL | three_diff( 1, {f32}, "" ); - | ^^^^^^ +LL | three_diff(1, {f32}, ""); + | ^^^^^^^^^^^^^^^^^^^^^^^^ error[E0059]: arguments to this function are incorrect - --> $DIR/missing_arguments.rs:28:27 + --> $DIR/missing_arguments.rs:28:3 | -LL | three_diff( 1, 1.0, ); - | ^ missing argument of type &str +LL | three_diff( 1, 1.0 ); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/missing_arguments.rs:5:4 | LL | fn three_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- -help: provide a parameter of the correct type here +help: make these changes | -LL | three_diff( 1, 1.0, {&str}, ); - | ^^^^^^^^ +LL | three_diff(1, 1.0, {&str}); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0059]: multiple arguments to this function are incorrect - --> $DIR/missing_arguments.rs:29:33 + --> $DIR/missing_arguments.rs:29:3 | LL | three_diff( "" ); - | ^ ^ missing argument of type f32 - | | - | missing argument of type i32 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/missing_arguments.rs:5:4 | LL | fn three_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- -help: provide parameters of the correct types +help: make these changes | -LL | three_diff( {i32}, "", {f32} ); - | ^^^^^^ ^^^^^^^ +LL | three_diff({i32}, {f32}, ""); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0059]: multiple arguments to this function are incorrect - --> $DIR/missing_arguments.rs:30:24 + --> $DIR/missing_arguments.rs:30:3 | LL | three_diff( 1.0 ); - | ^ ^ missing argument of type &str - | | - | missing argument of type i32 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/missing_arguments.rs:5:4 | LL | fn three_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- -help: provide parameters of the correct types +help: make these changes | -LL | three_diff( {i32}, 1.0, {&str} ); - | ^^^^^^ ^^^^^^^^ +LL | three_diff({i32}, 1.0, {&str}); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0059]: multiple arguments to this function are incorrect - --> $DIR/missing_arguments.rs:31:18 + --> $DIR/missing_arguments.rs:31:3 | -LL | three_diff( 1, ); - | ^ - | | - | missing argument of type f32 - | missing argument of type &str +LL | three_diff( 1 ); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/missing_arguments.rs:5:4 | LL | fn three_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- -help: provide parameters of the correct types +help: make these changes | -LL | three_diff( 1, {f32}, {&str}, ); - | ^^^^^^^^ +LL | three_diff(1, {f32}, {&str}); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0059]: multiple arguments to this function are incorrect - --> $DIR/missing_arguments.rs:34:48 + --> $DIR/missing_arguments.rs:34:3 | LL | four_repeated( ); - | ^ - | | - | missing argument of type i32 - | missing argument of type f32 - | missing argument of type f32 - | missing argument of type &str + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/missing_arguments.rs:6:4 | LL | fn four_repeated(_a: i32, _b: f32, _c: f32, _d: &str) {} | ^^^^^^^^^^^^^ ------- ------- ------- -------- -help: provide parameters of the correct types +help: make these changes | -LL | four_repeated( {i32}, {f32}, {f32}, {&str}); - | ^^^^^^^^ +LL | four_repeated({i32}, {f32}, {f32}, {&str}); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0059]: multiple arguments to this function are incorrect - --> $DIR/missing_arguments.rs:35:43 + --> $DIR/missing_arguments.rs:35:3 | LL | four_repeated( 1, "" ); - | ^ ^ missing argument of type f32 - | | - | missing argument of type f32 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/missing_arguments.rs:6:4 | LL | fn four_repeated(_a: i32, _b: f32, _c: f32, _d: &str) {} | ^^^^^^^^^^^^^ ------- ------- ------- -------- -help: provide parameters of the correct types +help: make these changes | -LL | four_repeated( 1, {f32}, "", {f32} ); - | ^^^^^^ ^^^^^^^ +LL | four_repeated(1, {f32}, {f32}, ""); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0059]: multiple arguments to this function are incorrect - --> $DIR/missing_arguments.rs:38:50 + --> $DIR/missing_arguments.rs:38:3 | LL | complex( ); - | ^ - | | - | missing argument of type i32 - | missing argument of type f32 - | missing argument of type i32 - | missing argument of type f32 - | missing argument of type &str + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/missing_arguments.rs:7:4 | LL | fn complex(_a: i32, _b: f32, _c: i32, _d: f32, _e: &str) {} | ^^^^^^^ ------- ------- ------- ------- -------- -help: provide parameters of the correct types +help: make these changes | -LL | complex( {i32}, {f32}, {i32}, {f32}, {&str}); - | ^^^^^^^^ +LL | complex({i32}, {f32}, {i32}, {f32}, {&str}); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0059]: multiple arguments to this function are incorrect - --> $DIR/missing_arguments.rs:39:45 + --> $DIR/missing_arguments.rs:39:3 | LL | complex( 1, "" ); - | ^ ^ - | | | - | | missing argument of type i32 - | | missing argument of type f32 - | missing argument of type f32 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/missing_arguments.rs:7:4 | LL | fn complex(_a: i32, _b: f32, _c: i32, _d: f32, _e: &str) {} | ^^^^^^^ ------- ------- ------- ------- -------- -help: provide parameters of the correct types +help: make these changes | -LL | complex( 1, {f32}, "", {i32}, {f32} ); - | ^^^^^^ ^^^^^^^ +LL | complex(1, {f32}, {i32}, {f32}, ""); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 19 previous errors diff --git a/src/test/ui/argument-suggestions/mixed_cases.stderr b/src/test/ui/argument-suggestions/mixed_cases.stderr index 4337389f6d9fa..05c08b609137d 100644 --- a/src/test/ui/argument-suggestions/mixed_cases.stderr +++ b/src/test/ui/argument-suggestions/mixed_cases.stderr @@ -1,10 +1,8 @@ error[E0059]: multiple arguments to this function are incorrect - --> $DIR/mixed_cases.rs:10:15 + --> $DIR/mixed_cases.rs:10:3 | LL | two_args(1, "", X {}); - | ^^ ^^^^ this parameter of type X isn't needed for two_args - | | - | expected f32, found &'static str + | ^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/mixed_cases.rs:5:4 @@ -14,16 +12,13 @@ LL | fn two_args(_a: i32, _b: f32) {} help: make these changes | LL | two_args(1, {f32}); - | ^--^^ + | ^^^^^^^^^^^^^^^^^^ error[E0059]: multiple arguments to this function are incorrect - --> $DIR/mixed_cases.rs:11:17 + --> $DIR/mixed_cases.rs:11:3 | LL | three_args(1, "", X {}, ""); - | ^ ^^^^ ^^ this parameter of type &'static str isn't needed for three_args - | | | - | | this parameter of type X isn't needed for three_args - | missing argument of type f32 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/mixed_cases.rs:6:4 @@ -33,33 +28,29 @@ LL | fn three_args(_a: i32, _b: f32, _c: &str) {} help: make these changes | LL | three_args(1, {f32}, ""); - | ^^^^^^ -- + | ^^^^^^^^^^^^^^^^^^^^^^^^ error[E0059]: multiple arguments to this function are incorrect - --> $DIR/mixed_cases.rs:14:17 + --> $DIR/mixed_cases.rs:14:3 | LL | three_args(1, X {}); - | ^^^^^ missing argument of type &str - | | - | expected f32, found X + | ^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/mixed_cases.rs:6:4 | LL | fn three_args(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- -help: provide parameters of the correct types +help: make these changes | LL | three_args(1, {f32}, {&str}); - | ^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0059]: multiple arguments to this function are incorrect - --> $DIR/mixed_cases.rs:17:17 + --> $DIR/mixed_cases.rs:17:3 | LL | three_args(1, "", X {}); - | ^ ^^^^ this parameter of type X isn't needed for three_args - | | - | missing argument of type f32 + | ^^^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/mixed_cases.rs:6:4 @@ -69,16 +60,13 @@ LL | fn three_args(_a: i32, _b: f32, _c: &str) {} help: make these changes | LL | three_args(1, {f32}, ""); - | ^^^^^^ -- + | ^^^^^^^^^^^^^^^^^^^^^^^^ error[E0059]: multiple arguments to this function are incorrect - --> $DIR/mixed_cases.rs:20:14 + --> $DIR/mixed_cases.rs:20:3 | LL | three_args("", X {}, 1); - | ^^ ^^^^ ^ expected &str, found &str - | | | - | | expected f32, found X - | expected i32, found i32 + | ^^^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/mixed_cases.rs:6:4 @@ -88,17 +76,13 @@ LL | fn three_args(_a: i32, _b: f32, _c: &str) {} help: make these changes | LL | three_args(1, {f32}, ""); - | ^ ^^^^^ ^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^ error[E0059]: multiple arguments to this function are incorrect - --> $DIR/mixed_cases.rs:23:14 + --> $DIR/mixed_cases.rs:23:3 | LL | three_args("", 1); - | ^^ ^ - | | | - | | missing argument of type f32 - | | expected f32, found f32 - | expected i32, found i32 + | ^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/mixed_cases.rs:6:4 @@ -108,7 +92,7 @@ LL | fn three_args(_a: i32, _b: f32, _c: &str) {} help: make these changes | LL | three_args(1, {f32}, ""); - | ^ ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 6 previous errors diff --git a/src/test/ui/argument-suggestions/permuted_arguments.stderr b/src/test/ui/argument-suggestions/permuted_arguments.stderr index 099e6912903dc..d5dc12a1bcd77 100644 --- a/src/test/ui/argument-suggestions/permuted_arguments.stderr +++ b/src/test/ui/argument-suggestions/permuted_arguments.stderr @@ -1,42 +1,34 @@ error[E0059]: arguments to this function are incorrect - --> $DIR/permuted_arguments.rs:10:14 + --> $DIR/permuted_arguments.rs:10:3 | LL | three_args(1.0, "", 1); - | ^^^ ^^ ^ expected &str, found &str - | | | - | | expected f32, found f32 - | expected i32, found i32 + | ^^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/permuted_arguments.rs:5:4 | LL | fn three_args(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- -help: reorder these parameters +help: make these changes | LL | three_args(1, 1.0, ""); - | ^ ^^^ ^^ + | ^^^^^^^^^^^^^^^^^^^^^^ error[E0059]: arguments to this function are incorrect - --> $DIR/permuted_arguments.rs:12:13 + --> $DIR/permuted_arguments.rs:12:3 | LL | many_args(X {}, Y {}, 1, 1.0, ""); - | ^^^^ ^^^^ ^ ^^^ ^^ expected Y, found Y - | | | | | - | | | | expected X, found X - | | | expected &str, found &str - | | expected f32, found f32 - | expected i32, found i32 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/permuted_arguments.rs:6:4 | LL | fn many_args(_a: i32, _b: f32, _c: &str, _d: X, _e: Y) {} | ^^^^^^^^^ ------- ------- -------- ----- ----- -help: reorder these parameters +help: make these changes | LL | many_args(1, 1.0, "", X {}, Y {}); - | ^ ^^^ ^^ ^^^^ ^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/argument-suggestions/swapped_arguments.stderr b/src/test/ui/argument-suggestions/swapped_arguments.stderr index 15916f2581b0d..9034b72b86e92 100644 --- a/src/test/ui/argument-suggestions/swapped_arguments.stderr +++ b/src/test/ui/argument-suggestions/swapped_arguments.stderr @@ -1,94 +1,82 @@ error[E0059]: arguments to this function are incorrect - --> $DIR/swapped_arguments.rs:8:12 + --> $DIR/swapped_arguments.rs:8:3 | LL | two_args(1.0, 1); - | ^^^ ^ expected f32, found f32 - | | - | expected i32, found i32 + | ^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/swapped_arguments.rs:3:4 | LL | fn two_args(_a: i32, _b: f32) {} | ^^^^^^^^ ------- ------- -help: swap these two arguments +help: make these changes | LL | two_args(1, 1.0); - | ^ ^^^ + | ^^^^^^^^^^^^^^^^ error[E0059]: arguments to this function are incorrect - --> $DIR/swapped_arguments.rs:9:14 + --> $DIR/swapped_arguments.rs:9:3 | LL | three_args(1.0, 1, ""); - | ^^^ ^ expected f32, found f32 - | | - | expected i32, found i32 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/swapped_arguments.rs:4:4 | LL | fn three_args(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- -help: swap these two arguments +help: make these changes | -LL | three_args(1, 1.0, ""); - | ^ ^^^ +LL | three_args(1, 1.0, ""); + | ^^^^^^^^^^^^^^^^^^^^^^ error[E0059]: arguments to this function are incorrect - --> $DIR/swapped_arguments.rs:10:20 + --> $DIR/swapped_arguments.rs:10:3 | LL | three_args( 1, "", 1.0); - | ^^ ^^^ expected &str, found &str - | | - | expected f32, found f32 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/swapped_arguments.rs:4:4 | LL | fn three_args(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- -help: swap these two arguments +help: make these changes | -LL | three_args( 1, 1.0, ""); - | ^^^ ^^ +LL | three_args(1, 1.0, ""); + | ^^^^^^^^^^^^^^^^^^^^^^ error[E0059]: arguments to this function are incorrect - --> $DIR/swapped_arguments.rs:11:15 + --> $DIR/swapped_arguments.rs:11:3 | LL | three_args( "", 1.0, 1); - | ^^ ^ expected &str, found &str - | | - | expected i32, found i32 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/swapped_arguments.rs:4:4 | LL | fn three_args(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- -help: swap these two arguments +help: make these changes | -LL | three_args( 1, 1.0, ""); - | ^ ^^ +LL | three_args(1, 1.0, ""); + | ^^^^^^^^^^^^^^^^^^^^^^ error[E0059]: multiple arguments to this function are incorrect - --> $DIR/swapped_arguments.rs:13:13 + --> $DIR/swapped_arguments.rs:13:3 | LL | four_args(1.0, 1, X {}, ""); - | ^^^ ^ ^^^^ ^^ expected X, found X - | | | | - | | | expected &str, found &str - | | expected f32, found f32 - | expected i32, found i32 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: function defined here --> $DIR/swapped_arguments.rs:5:4 | LL | fn four_args(_a: i32, _b: f32, _c: &str, _d: X) {} | ^^^^^^^^^ ------- ------- -------- ----- -help: swap these arguments +help: make these changes | LL | four_args(1, 1.0, "", X {}); - | ^ ^^^ ^^ ^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 5 previous errors From c3dea909e6813d4006fefcc7984a52bd23684a0c Mon Sep 17 00:00:00 2001 From: Pi Lanningham Date: Fri, 5 Feb 2021 23:51:37 -0500 Subject: [PATCH 19/21] Add back error span labels @estebank suggested we only annotate these if there are 5 or less. In addition to the suggestion at the bottom of the error, we label the specific problems we encounter without suggesting how to fix it. This also ladders the suggestion text: if there's just one thing to suggest, use specific language about the suggestion; however, if there are multiple suggestions, use a generic "did you mean" Even though the comment on span_suggestion suggests against this, Camelid on zulip pointed out that there are already a few suggestions like this, and any other language sounds slightly awkward. --- .../rustc_typeck/src/check/fn_ctxt/checks.rs | 133 ++++++++++++----- src/test/ui/argument-suggestions/basic.stderr | 35 +++-- .../ui/argument-suggestions/complex.stderr | 2 +- .../extra_arguments.stderr | 81 ++++++---- .../invalid_arguments.stderr | 138 ++++++++++++------ .../missing_arguments.stderr | 108 ++++++++++---- .../argument-suggestions/mixed_cases.stderr | 45 ++++-- .../permuted_arguments.stderr | 22 ++- .../swapped_arguments.stderr | 45 ++++-- 9 files changed, 431 insertions(+), 178 deletions(-) diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs index 99575e5d2f80a..c5a80d8db69a1 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs @@ -557,7 +557,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // As we encounter issues, keep track of what we want to provide for the suggestion let mut suggested_inputs: Vec> = vec![None; minimum_input_count]; - let mut issues = vec![]; + let mut labels = vec![]; + let mut suggestion_text = None; let source_map = self.sess().source_map(); // Before we start looking for issues, eliminate any arguments that are already satisfied, @@ -589,15 +590,33 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } else { suggested_inputs[input_idx] = Some(format!("{{{}}}", input_ty)); } - issues.push(Issue::Invalid(arg_indexes[idx])); + let provided_ty = if let Some((ty, _)) = final_arg_types[idx] { + format!(", found {}", ty) + } else { + "".into() + }; + labels.push((provided_args[idx].span, format!("expected {}{}", expected_ty, provided_ty))); + suggestion_text = match suggestion_text { + None => Some("provide an argument of the correct type"), + Some(_) => Some("did you mean") + }; eliminate_input(&mut compatibility_matrix, &mut input_indexes, idx); eliminate_arg(&mut compatibility_matrix, &mut arg_indexes, idx); - } + }, Some(Issue::Extra(idx)) => { // Eliminate the argument (without touching any inputs) - issues.push(Issue::Extra(arg_indexes[idx])); + let arg_type = if let Some((_, ty)) = final_arg_types[idx] { + format!(" of type {}", ty) + } else { + "".into() + }; + labels.push((provided_args[idx].span, format!("argument{} unexpected", arg_type))); + suggestion_text = match suggestion_text { + None => Some("remove the extra argument"), + Some(_) => Some("did you mean") + }; eliminate_arg(&mut compatibility_matrix, &mut arg_indexes, idx); - } + }, Some(Issue::Missing(idx)) => { let input_idx = input_indexes[idx]; let expected_ty = expected_input_tys[input_idx]; @@ -607,9 +626,23 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } else { suggested_inputs[input_idx] = Some(format!("{{{}}}", input_ty)); } - issues.push(Issue::Missing(input_indexes[idx])); + // NOTE: Because we might be re-arranging arguments, might have extra arguments, etc. + // It's hard to *really* know where we should provide this error label, so this is a + // decent heuristic + let span = if input_idx < provided_arg_count { + let arg_span = provided_args[input_idx].span; + Span::new(arg_span.lo(), arg_span.hi(), arg_span.ctxt()) + } else { + // Otherwise just label the whole function + call_span + }; + labels.push((span, format!("an argument of type {} is missing", input_ty))); + suggestion_text = match suggestion_text { + None => Some("provide the argument"), + Some(_) => Some("did you mean") + }; eliminate_input(&mut compatibility_matrix, &mut input_indexes, idx); - } + }, Some(Issue::Swap(idx, other)) => { let input_idx = input_indexes[idx]; let other_input_idx = input_indexes[other]; @@ -622,7 +655,24 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { suggested_inputs[input_idx] = Some(second_snippet); suggested_inputs[other_input_idx] = Some(first_snippet); - issues.push(Issue::Swap(arg_idx, other_arg_idx)); + let first_expected_ty = self.resolve_vars_if_possible(expected_input_tys[input_idx]); + let first_provided_ty = if let Some((ty, _)) = final_arg_types[arg_idx] { + format!(",found {}", ty) + } else { + "".into() + }; + labels.push((first_span, format!("expected {}{}", first_expected_ty, first_provided_ty))); + let other_expected_ty = self.resolve_vars_if_possible(expected_input_tys[other_input_idx]); + let other_provided_ty = if let Some((ty, _)) = final_arg_types[other_arg_idx] { + format!(",found {}", ty) + } else { + "".into() + }; + labels.push((second_span, format!("expected {}{}", other_expected_ty, other_provided_ty))); + suggestion_text = match suggestion_text { + None => Some("swap these arguments"), + Some(_) => Some("did you mean") + }; let (min, max) = (cmp::min(idx, other), cmp::max(idx, other)); satisfy_input( @@ -639,7 +689,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { max - 1, // Subtract 1 because we already removed the "min" row min, ); - } + }, Some(Issue::Permutation(args)) => { // FIXME: If satisfy_input ever did anything non-trivial (emit obligations to help type checking, for example) // we'd want to call this function with the correct arg/input pairs, but for now, we just throw them in a bucket. @@ -656,10 +706,22 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let dest_input = input_indexes[dst.unwrap()]; let src_span = provided_args[src_arg].span; suggested_inputs[dest_input] = Some(source_map.span_to_snippet(src_span).unwrap()); + + let expected_ty = self.resolve_vars_if_possible(expected_input_tys[dest_input]); + let provided_ty = if let Some((ty, _)) = final_arg_types[dst_arg] { + format!(",found {}", ty) + } else { + "".into() + }; + labels.push((provided_args[dst_arg].span, format!("expected {}{}", expected_ty, provided_ty))); real_idxs[src_arg] = Some(dst_arg); } - issues.push(Issue::Permutation(real_idxs)); + suggestion_text = match suggestion_text { + None => Some("reorder these arguments"), + Some(_) => Some("did you mean") + }; + idxs.sort(); idxs.reverse(); for i in idxs { @@ -671,7 +733,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { i, ); } - } + }, None => { // We didn't find any issues, so we need to push the algorithm forward // First, eliminate any arguments that currently satisfy their inputs @@ -684,7 +746,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }; } - let issue_count = issues.len(); + let issue_count = labels.len(); if issue_count > 0 { // Now construct our error from the various things we've labeled @@ -695,6 +757,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { "{}arguments to this function are incorrect", if issue_count > 1 { "multiple " } else { "" } ); + + // If we have less than 5 things to say, it would be useful to call out exactly what's wrong + if issue_count <= 5 { + for (span, label) in labels { + err.span_label(span, label); + } + } // Call out where the function is defined let mut fn_name: String = "".to_string(); @@ -718,31 +787,27 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } - // And add a series of suggestions - // FIXME: for simpler cases, this might be overkill - if issues.len() > 0 { - let suggestion_text = Some("make these changes"); - let mut suggestion = format!("{}(", fn_name).to_string(); - for (idx, input) in suggested_inputs.iter().enumerate() { - if let Some(sug) = input { - suggestion += sug; - } else { - suggestion += "??"; - } - if idx < minimum_input_count - 1 { - suggestion += ", "; - } + // And add a suggestion block for all of the parameters + let mut suggestion = format!("{}(", fn_name).to_string(); + for (idx, input) in suggested_inputs.iter().enumerate() { + if let Some(sug) = input { + suggestion += sug; + } else { + suggestion += "??"; } - suggestion += ")"; - if let Some(suggestion_text) = suggestion_text { - err.span_suggestion_verbose( - call_span, - suggestion_text, - suggestion, - Applicability::HasPlaceholders, - ); + if idx < minimum_input_count - 1 { + suggestion += ", "; } } + suggestion += ")"; + if let Some(suggestion_text) = suggestion_text { + err.span_suggestion_verbose( + call_span, + suggestion_text, + suggestion, + Applicability::HasPlaceholders, + ); + } err.emit(); } diff --git a/src/test/ui/argument-suggestions/basic.stderr b/src/test/ui/argument-suggestions/basic.stderr index 95f6541825f30..f19cde3bb5c88 100644 --- a/src/test/ui/argument-suggestions/basic.stderr +++ b/src/test/ui/argument-suggestions/basic.stderr @@ -2,14 +2,16 @@ error[E0059]: arguments to this function are incorrect --> $DIR/basic.rs:20:5 | LL | invalid(1.0); - | ^^^^^^^^^^^^ + | ^^^^^^^^---^ + | | + | expected u32, found {float} | note: function defined here --> $DIR/basic.rs:13:4 | LL | fn invalid(_i: u32) {} | ^^^^^^^ ------- -help: make these changes +help: provide an argument of the correct type | LL | invalid({u32}); | ^^^^^^^^^^^^^^ @@ -18,14 +20,16 @@ error[E0059]: arguments to this function are incorrect --> $DIR/basic.rs:21:5 | LL | extra(""); - | ^^^^^^^^^ + | ^^^^^^--^ + | | + | argument unexpected | note: function defined here --> $DIR/basic.rs:14:4 | LL | fn extra() {} | ^^^^^ -help: make these changes +help: remove the extra argument | LL | extra(); | ^^^^^^^ @@ -34,46 +38,53 @@ error[E0059]: arguments to this function are incorrect --> $DIR/basic.rs:22:5 | LL | missing(); - | ^^^^^^^^^ + | ^^^^^^^^^ an argument of type u32 is missing | note: function defined here --> $DIR/basic.rs:15:4 | LL | fn missing(_i: u32) {} | ^^^^^^^ ------- -help: make these changes +help: provide the argument | LL | missing({u32}); | ^^^^^^^^^^^^^^ -error[E0059]: arguments to this function are incorrect +error[E0059]: multiple arguments to this function are incorrect --> $DIR/basic.rs:23:5 | LL | swapped("", 1); - | ^^^^^^^^^^^^^^ + | ^^^^^^^^--^^-^ + | | | + | | expected &str,found {integer} + | expected u32,found &'static str | note: function defined here --> $DIR/basic.rs:16:4 | LL | fn swapped(_i: u32, _s: &str) {} | ^^^^^^^ ------- -------- -help: make these changes +help: swap these arguments | LL | swapped(1, ""); | ^^^^^^^^^^^^^^ -error[E0059]: arguments to this function are incorrect +error[E0059]: multiple arguments to this function are incorrect --> $DIR/basic.rs:24:5 | LL | permuted(Y {}, Z {}, X {}); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^----^^----^^----^ + | | | | + | | | expected Z,found X + | | expected Y,found Z + | expected X,found Y | note: function defined here --> $DIR/basic.rs:17:4 | LL | fn permuted(_x: X, _y: Y, _z: Z) {} | ^^^^^^^^ ----- ----- ----- -help: make these changes +help: reorder these arguments | LL | permuted(X {}, Y {}, Z {}); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/argument-suggestions/complex.stderr b/src/test/ui/argument-suggestions/complex.stderr index 57a9c3724a3d4..97e554c3a2d2e 100644 --- a/src/test/ui/argument-suggestions/complex.stderr +++ b/src/test/ui/argument-suggestions/complex.stderr @@ -9,7 +9,7 @@ note: function defined here | LL | fn complex(_i: u32, _s: &str, _e: E, _f: F, _g: G, _x: X, _y: Y, _z: Z ) {} | ^^^^^^^ ------- -------- ----- ----- ----- ----- ----- ------ -help: make these changes +help: did you mean | LL | complex({u32}, &"", {E}, F::X2, G{}, X {}, Y {}, Z {}); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/argument-suggestions/extra_arguments.stderr b/src/test/ui/argument-suggestions/extra_arguments.stderr index e8e2978a965e9..aaf7a8f16bff8 100644 --- a/src/test/ui/argument-suggestions/extra_arguments.stderr +++ b/src/test/ui/argument-suggestions/extra_arguments.stderr @@ -2,14 +2,16 @@ error[E0059]: arguments to this function are incorrect --> $DIR/extra_arguments.rs:7:3 | LL | empty(""); - | ^^^^^^^^^ + | ^^^^^^--^ + | | + | argument unexpected | note: function defined here --> $DIR/extra_arguments.rs:1:4 | LL | fn empty() {} | ^^^^^ -help: make these changes +help: remove the extra argument | LL | empty(); | ^^^^^^^ @@ -18,14 +20,16 @@ error[E0059]: arguments to this function are incorrect --> $DIR/extra_arguments.rs:9:3 | LL | one_arg(1, 1); - | ^^^^^^^^^^^^^ + | ^^^^^^^^-^^^^ + | | + | argument of type i32 unexpected | note: function defined here --> $DIR/extra_arguments.rs:2:4 | LL | fn one_arg(_a: i32) {} | ^^^^^^^ ------- -help: make these changes +help: remove the extra argument | LL | one_arg(1); | ^^^^^^^^^^ @@ -34,14 +38,16 @@ error[E0059]: arguments to this function are incorrect --> $DIR/extra_arguments.rs:10:3 | LL | one_arg(1, ""); - | ^^^^^^^^^^^^^^ + | ^^^^^^^^-^^^^^ + | | + | argument of type i32 unexpected | note: function defined here --> $DIR/extra_arguments.rs:2:4 | LL | fn one_arg(_a: i32) {} | ^^^^^^^ ------- -help: make these changes +help: remove the extra argument | LL | one_arg(1); | ^^^^^^^^^^ @@ -50,14 +56,17 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/extra_arguments.rs:11:3 | LL | one_arg(1, "", 1.0); - | ^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^-^^^^^^^^^^ + | | + | argument of type i32 unexpected + | argument of type i32 unexpected | note: function defined here --> $DIR/extra_arguments.rs:2:4 | LL | fn one_arg(_a: i32) {} | ^^^^^^^ ------- -help: make these changes +help: did you mean | LL | one_arg(1); | ^^^^^^^^^^ @@ -66,14 +75,16 @@ error[E0059]: arguments to this function are incorrect --> $DIR/extra_arguments.rs:13:3 | LL | two_arg_same(1, 1, 1); - | ^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^-^^^^^^^ + | | + | argument of type i32 unexpected | note: function defined here --> $DIR/extra_arguments.rs:3:4 | LL | fn two_arg_same(_a: i32, _b: i32) {} | ^^^^^^^^^^^^ ------- ------- -help: make these changes +help: remove the extra argument | LL | two_arg_same(1, 1); | ^^^^^^^^^^^^^^^^^^ @@ -82,14 +93,16 @@ error[E0059]: arguments to this function are incorrect --> $DIR/extra_arguments.rs:14:3 | LL | two_arg_same(1, 1, 1.0); - | ^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^-^^^^^^^^^ + | | + | argument of type i32 unexpected | note: function defined here --> $DIR/extra_arguments.rs:3:4 | LL | fn two_arg_same(_a: i32, _b: i32) {} | ^^^^^^^^^^^^ ------- ------- -help: make these changes +help: remove the extra argument | LL | two_arg_same(1, 1); | ^^^^^^^^^^^^^^^^^^ @@ -98,14 +111,16 @@ error[E0059]: arguments to this function are incorrect --> $DIR/extra_arguments.rs:16:3 | LL | two_arg_diff(1, 1, ""); - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^-^^^^^^^^ + | | + | argument of type i32 unexpected | note: function defined here --> $DIR/extra_arguments.rs:4:4 | LL | fn two_arg_diff(_a: i32, _b: &str) {} | ^^^^^^^^^^^^ ------- -------- -help: make these changes +help: remove the extra argument | LL | two_arg_diff(1, ""); | ^^^^^^^^^^^^^^^^^^^ @@ -114,14 +129,16 @@ error[E0059]: arguments to this function are incorrect --> $DIR/extra_arguments.rs:17:3 | LL | two_arg_diff(1, "", ""); - | ^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^-^^^^^^^^^ + | | + | argument of type i32 unexpected | note: function defined here --> $DIR/extra_arguments.rs:4:4 | LL | fn two_arg_diff(_a: i32, _b: &str) {} | ^^^^^^^^^^^^ ------- -------- -help: make these changes +help: remove the extra argument | LL | two_arg_diff(1, ""); | ^^^^^^^^^^^^^^^^^^^ @@ -130,14 +147,17 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/extra_arguments.rs:18:3 | LL | two_arg_diff(1, 1, "", ""); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^-^^^^^^^^^^^^ + | | + | argument of type i32 unexpected + | argument of type i32 unexpected | note: function defined here --> $DIR/extra_arguments.rs:4:4 | LL | fn two_arg_diff(_a: i32, _b: &str) {} | ^^^^^^^^^^^^ ------- -------- -help: make these changes +help: did you mean | LL | two_arg_diff(1, ""); | ^^^^^^^^^^^^^^^^^^^ @@ -146,14 +166,17 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/extra_arguments.rs:19:3 | LL | two_arg_diff(1, "", 1, ""); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^-^^^^^^^^^^^^ + | | + | argument of type i32 unexpected + | argument of type i32 unexpected | note: function defined here --> $DIR/extra_arguments.rs:4:4 | LL | fn two_arg_diff(_a: i32, _b: &str) {} | ^^^^^^^^^^^^ ------- -------- -help: make these changes +help: did you mean | LL | two_arg_diff(1, ""); | ^^^^^^^^^^^^^^^^^^^ @@ -162,14 +185,16 @@ error[E0059]: arguments to this function are incorrect --> $DIR/extra_arguments.rs:22:3 | LL | two_arg_same(1, 1, ""); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^-^^^^^^^^^^^^ + | | + | argument of type i32 unexpected | note: function defined here --> $DIR/extra_arguments.rs:3:4 | LL | fn two_arg_same(_a: i32, _b: i32) {} | ^^^^^^^^^^^^ ------- ------- -help: make these changes +help: remove the extra argument | LL | two_arg_same(1, 1); | ^^^^^^^^^^^^^^^^^^ @@ -178,14 +203,16 @@ error[E0059]: arguments to this function are incorrect --> $DIR/extra_arguments.rs:23:3 | LL | two_arg_diff(1, 1, ""); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^-^^^^^^^^^^^^ + | | + | argument of type i32 unexpected | note: function defined here --> $DIR/extra_arguments.rs:4:4 | LL | fn two_arg_diff(_a: i32, _b: &str) {} | ^^^^^^^^^^^^ ------- -------- -help: make these changes +help: remove the extra argument | LL | two_arg_diff(1, ""); | ^^^^^^^^^^^^^^^^^^^ @@ -195,6 +222,7 @@ error[E0059]: arguments to this function are incorrect | LL | / two_arg_same( LL | | 1, + | | - argument of type i32 unexpected LL | | 1, LL | | "" LL | | ); @@ -205,7 +233,7 @@ note: function defined here | LL | fn two_arg_same(_a: i32, _b: i32) {} | ^^^^^^^^^^^^ ------- ------- -help: make these changes +help: remove the extra argument | LL | two_arg_same(1, 1); | ^^^^^^^^^^^^^^^^^^ @@ -215,6 +243,7 @@ error[E0059]: arguments to this function are incorrect | LL | / two_arg_diff( LL | | 1, + | | - argument of type i32 unexpected LL | | 1, LL | | "" LL | | ); @@ -225,7 +254,7 @@ note: function defined here | LL | fn two_arg_diff(_a: i32, _b: &str) {} | ^^^^^^^^^^^^ ------- -------- -help: make these changes +help: remove the extra argument | LL | two_arg_diff(1, ""); | ^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/argument-suggestions/invalid_arguments.stderr b/src/test/ui/argument-suggestions/invalid_arguments.stderr index b2d251e94cd67..0e47c157071a6 100644 --- a/src/test/ui/argument-suggestions/invalid_arguments.stderr +++ b/src/test/ui/argument-suggestions/invalid_arguments.stderr @@ -2,14 +2,16 @@ error[E0059]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:13:3 | LL | one_arg(1.0); - | ^^^^^^^^^^^^ + | ^^^^^^^^---^ + | | + | expected i32, found {float} | note: function defined here --> $DIR/invalid_arguments.rs:5:4 | LL | fn one_arg(_a: i32) {} | ^^^^^^^ ------- -help: make these changes +help: provide an argument of the correct type | LL | one_arg({i32}); | ^^^^^^^^^^^^^^ @@ -18,14 +20,16 @@ error[E0059]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:16:3 | LL | two_arg_same(1, ""); - | ^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^-^^^^^ + | | + | expected i32, found i32 | note: function defined here --> $DIR/invalid_arguments.rs:6:4 | LL | fn two_arg_same(_a: i32, _b: i32) {} | ^^^^^^^^^^^^ ------- ------- -help: make these changes +help: provide an argument of the correct type | LL | two_arg_same(1, {i32}); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -34,14 +38,16 @@ error[E0059]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:17:3 | LL | two_arg_same("", 1); - | ^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^--^^^^ + | | + | expected i32, found &'static str | note: function defined here --> $DIR/invalid_arguments.rs:6:4 | LL | fn two_arg_same(_a: i32, _b: i32) {} | ^^^^^^^^^^^^ ------- ------- -help: make these changes +help: provide an argument of the correct type | LL | two_arg_same({i32}, 1); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -50,14 +56,17 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/invalid_arguments.rs:18:3 | LL | two_arg_same("", ""); - | ^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^--^^^^^ + | | + | expected i32, found &'static str + | expected i32, found &'static str | note: function defined here --> $DIR/invalid_arguments.rs:6:4 | LL | fn two_arg_same(_a: i32, _b: i32) {} | ^^^^^^^^^^^^ ------- ------- -help: make these changes +help: did you mean | LL | two_arg_same({i32}, {i32}); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -66,14 +75,16 @@ error[E0059]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:19:3 | LL | two_arg_diff(1, ""); - | ^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^-^^^^^ + | | + | expected f32, found i32 | note: function defined here --> $DIR/invalid_arguments.rs:7:4 | LL | fn two_arg_diff(_a: i32, _b: f32) {} | ^^^^^^^^^^^^ ------- ------- -help: make these changes +help: provide an argument of the correct type | LL | two_arg_diff(1, {f32}); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -82,14 +93,16 @@ error[E0059]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:20:3 | LL | two_arg_diff("", 1.0); - | ^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^--^^^^^^ + | | + | expected i32, found &'static str | note: function defined here --> $DIR/invalid_arguments.rs:7:4 | LL | fn two_arg_diff(_a: i32, _b: f32) {} | ^^^^^^^^^^^^ ------- ------- -help: make these changes +help: provide an argument of the correct type | LL | two_arg_diff({i32}, 1.0); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -98,14 +111,17 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/invalid_arguments.rs:21:3 | LL | two_arg_diff("", ""); - | ^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^--^^^^^ + | | + | expected i32, found &'static str + | expected f32, found &'static str | note: function defined here --> $DIR/invalid_arguments.rs:7:4 | LL | fn two_arg_diff(_a: i32, _b: f32) {} | ^^^^^^^^^^^^ ------- ------- -help: make these changes +help: did you mean | LL | two_arg_diff({i32}, {f32}); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -114,14 +130,16 @@ error[E0059]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:24:3 | LL | three_arg_diff(X{}, 1.0, ""); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^---^^^^^^^^^^ + | | + | expected i32, found X | note: function defined here --> $DIR/invalid_arguments.rs:8:4 | LL | fn three_arg_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^^^^^ ------- ------- -------- -help: make these changes +help: provide an argument of the correct type | LL | three_arg_diff({i32}, 1.0, ""); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -130,14 +148,16 @@ error[E0059]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:25:3 | LL | three_arg_diff(1, X {}, ""); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^-^^^^^^^^^^^ + | | + | expected f32, found i32 | note: function defined here --> $DIR/invalid_arguments.rs:8:4 | LL | fn three_arg_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^^^^^ ------- ------- -------- -help: make these changes +help: provide an argument of the correct type | LL | three_arg_diff(1, {f32}, ""); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -146,14 +166,16 @@ error[E0059]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:26:3 | LL | three_arg_diff(1, 1.0, X {}); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^-^^^^^^^^^^^^ + | | + | expected &str, found i32 | note: function defined here --> $DIR/invalid_arguments.rs:8:4 | LL | fn three_arg_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^^^^^ ------- ------- -------- -help: make these changes +help: provide an argument of the correct type | LL | three_arg_diff(1, 1.0, {&str}); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -162,14 +184,17 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/invalid_arguments.rs:28:3 | LL | three_arg_diff(X {}, X {}, ""); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^----^^^^^^^^^^^ + | | + | expected i32, found X + | expected f32, found X | note: function defined here --> $DIR/invalid_arguments.rs:8:4 | LL | fn three_arg_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^^^^^ ------- ------- -------- -help: make these changes +help: did you mean | LL | three_arg_diff({i32}, {f32}, ""); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -178,14 +203,17 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/invalid_arguments.rs:29:3 | LL | three_arg_diff(X {}, 1.0, X {}); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^----^^^^^^^^^^^^ + | | + | expected i32, found X + | expected &str, found X | note: function defined here --> $DIR/invalid_arguments.rs:8:4 | LL | fn three_arg_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^^^^^ ------- ------- -------- -help: make these changes +help: did you mean | LL | three_arg_diff({i32}, 1.0, {&str}); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -194,14 +222,17 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/invalid_arguments.rs:30:3 | LL | three_arg_diff(1, X {}, X {}); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^-^^^^^^^^^^^^^ + | | + | expected f32, found i32 + | expected &str, found i32 | note: function defined here --> $DIR/invalid_arguments.rs:8:4 | LL | fn three_arg_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^^^^^ ------- ------- -------- -help: make these changes +help: did you mean | LL | three_arg_diff(1, {f32}, {&str}); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -210,14 +241,18 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/invalid_arguments.rs:32:3 | LL | three_arg_diff(X {}, X {}, X {}); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^----^^^^^^^^^^^^^ + | | + | expected i32, found X + | expected f32, found X + | expected &str, found X | note: function defined here --> $DIR/invalid_arguments.rs:8:4 | LL | fn three_arg_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^^^^^ ------- ------- -------- -help: make these changes +help: did you mean | LL | three_arg_diff({i32}, {f32}, {&str}); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -226,14 +261,16 @@ error[E0059]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:34:3 | LL | three_arg_repeat(X {}, 1, ""); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^----^^^^^^^^ + | | + | expected i32, found X | note: function defined here --> $DIR/invalid_arguments.rs:9:4 | LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {} | ^^^^^^^^^^^^^^^^ ------- ------- -------- -help: make these changes +help: provide an argument of the correct type | LL | three_arg_repeat({i32}, 1, ""); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -242,14 +279,16 @@ error[E0059]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:35:3 | LL | three_arg_repeat(1, X {}, ""); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^-^^^^^^^^^^^ + | | + | expected i32, found i32 | note: function defined here --> $DIR/invalid_arguments.rs:9:4 | LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {} | ^^^^^^^^^^^^^^^^ ------- ------- -------- -help: make these changes +help: provide an argument of the correct type | LL | three_arg_repeat(1, {i32}, ""); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -258,14 +297,16 @@ error[E0059]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:36:3 | LL | three_arg_repeat(1, 1, X {}); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^-^^^^^^^^^^ + | | + | expected &str, found i32 | note: function defined here --> $DIR/invalid_arguments.rs:9:4 | LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {} | ^^^^^^^^^^^^^^^^ ------- ------- -------- -help: make these changes +help: provide an argument of the correct type | LL | three_arg_repeat(1, 1, {&str}); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -274,14 +315,17 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/invalid_arguments.rs:38:3 | LL | three_arg_repeat(X {}, X {}, ""); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^----^^^^^^^^^^^ + | | + | expected i32, found X + | expected i32, found X | note: function defined here --> $DIR/invalid_arguments.rs:9:4 | LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {} | ^^^^^^^^^^^^^^^^ ------- ------- -------- -help: make these changes +help: did you mean | LL | three_arg_repeat({i32}, {i32}, ""); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -290,14 +334,17 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/invalid_arguments.rs:39:3 | LL | three_arg_repeat(X {}, 1, X {}); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^----^^^^^^^^^^ + | | + | expected i32, found X + | expected &str, found X | note: function defined here --> $DIR/invalid_arguments.rs:9:4 | LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {} | ^^^^^^^^^^^^^^^^ ------- ------- -------- -help: make these changes +help: did you mean | LL | three_arg_repeat({i32}, 1, {&str}); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -306,14 +353,17 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/invalid_arguments.rs:40:3 | LL | three_arg_repeat(1, X {}, X{}); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^-^^^^^^^^^^^^ + | | + | expected i32, found i32 + | expected &str, found i32 | note: function defined here --> $DIR/invalid_arguments.rs:9:4 | LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {} | ^^^^^^^^^^^^^^^^ ------- ------- -------- -help: make these changes +help: did you mean | LL | three_arg_repeat(1, {i32}, {&str}); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -322,14 +372,18 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/invalid_arguments.rs:42:3 | LL | three_arg_repeat(X {}, X {}, X {}); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^----^^^^^^^^^^^^^ + | | + | expected i32, found X + | expected i32, found X + | expected &str, found X | note: function defined here --> $DIR/invalid_arguments.rs:9:4 | LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {} | ^^^^^^^^^^^^^^^^ ------- ------- -------- -help: make these changes +help: did you mean | LL | three_arg_repeat({i32}, {i32}, {&str}); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/argument-suggestions/missing_arguments.stderr b/src/test/ui/argument-suggestions/missing_arguments.stderr index c6ef5690a676e..a111b137bd2a6 100644 --- a/src/test/ui/argument-suggestions/missing_arguments.stderr +++ b/src/test/ui/argument-suggestions/missing_arguments.stderr @@ -2,14 +2,14 @@ error[E0059]: arguments to this function are incorrect --> $DIR/missing_arguments.rs:10:3 | LL | one_arg(); - | ^^^^^^^^^ + | ^^^^^^^^^ an argument of type i32 is missing | note: function defined here --> $DIR/missing_arguments.rs:1:4 | LL | fn one_arg(_a: i32) {} | ^^^^^^^ ------- -help: make these changes +help: provide the argument | LL | one_arg({i32}); | ^^^^^^^^^^^^^^ @@ -19,13 +19,16 @@ error[E0059]: multiple arguments to this function are incorrect | LL | two_same( ); | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | an argument of type i32 is missing + | an argument of type i32 is missing | note: function defined here --> $DIR/missing_arguments.rs:2:4 | LL | fn two_same(_a: i32, _b: i32) {} | ^^^^^^^^ ------- ------- -help: make these changes +help: did you mean | LL | two_same({i32}, {i32}); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -34,14 +37,14 @@ error[E0059]: arguments to this function are incorrect --> $DIR/missing_arguments.rs:15:3 | LL | two_same( 1 ); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^ an argument of type i32 is missing | note: function defined here --> $DIR/missing_arguments.rs:2:4 | LL | fn two_same(_a: i32, _b: i32) {} | ^^^^^^^^ ------- ------- -help: make these changes +help: provide the argument | LL | two_same(1, {i32}); | ^^^^^^^^^^^^^^^^^^ @@ -51,13 +54,16 @@ error[E0059]: multiple arguments to this function are incorrect | LL | two_diff( ); | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | an argument of type i32 is missing + | an argument of type f32 is missing | note: function defined here --> $DIR/missing_arguments.rs:3:4 | LL | fn two_diff(_a: i32, _b: f32) {} | ^^^^^^^^ ------- ------- -help: make these changes +help: did you mean | LL | two_diff({i32}, {f32}); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -66,14 +72,14 @@ error[E0059]: arguments to this function are incorrect --> $DIR/missing_arguments.rs:17:3 | LL | two_diff( 1 ); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^ an argument of type f32 is missing | note: function defined here --> $DIR/missing_arguments.rs:3:4 | LL | fn two_diff(_a: i32, _b: f32) {} | ^^^^^^^^ ------- ------- -help: make these changes +help: provide the argument | LL | two_diff(1, {f32}); | ^^^^^^^^^^^^^^^^^^ @@ -82,14 +88,16 @@ error[E0059]: arguments to this function are incorrect --> $DIR/missing_arguments.rs:18:3 | LL | two_diff( 1.0 ); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^---^^^ + | | + | an argument of type i32 is missing | note: function defined here --> $DIR/missing_arguments.rs:3:4 | LL | fn two_diff(_a: i32, _b: f32) {} | ^^^^^^^^ ------- ------- -help: make these changes +help: provide the argument | LL | two_diff({i32}, 1.0); | ^^^^^^^^^^^^^^^^^^^^ @@ -99,13 +107,17 @@ error[E0059]: multiple arguments to this function are incorrect | LL | three_same( ); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | an argument of type i32 is missing + | an argument of type i32 is missing + | an argument of type i32 is missing | note: function defined here --> $DIR/missing_arguments.rs:4:4 | LL | fn three_same(_a: i32, _b: i32, _c: i32) {} | ^^^^^^^^^^ ------- ------- ------- -help: make these changes +help: did you mean | LL | three_same({i32}, {i32}, {i32}); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -115,13 +127,16 @@ error[E0059]: multiple arguments to this function are incorrect | LL | three_same( 1 ); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | an argument of type i32 is missing + | an argument of type i32 is missing | note: function defined here --> $DIR/missing_arguments.rs:4:4 | LL | fn three_same(_a: i32, _b: i32, _c: i32) {} | ^^^^^^^^^^ ------- ------- ------- -help: make these changes +help: did you mean | LL | three_same(1, {i32}, {i32}); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -130,14 +145,14 @@ error[E0059]: arguments to this function are incorrect --> $DIR/missing_arguments.rs:23:3 | LL | three_same( 1, 1 ); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ an argument of type i32 is missing | note: function defined here --> $DIR/missing_arguments.rs:4:4 | LL | fn three_same(_a: i32, _b: i32, _c: i32) {} | ^^^^^^^^^^ ------- ------- ------- -help: make these changes +help: provide the argument | LL | three_same(1, 1, {i32}); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -146,14 +161,16 @@ error[E0059]: arguments to this function are incorrect --> $DIR/missing_arguments.rs:26:3 | LL | three_diff( 1.0, "" ); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^---^^^^^^^^^^^ + | | + | an argument of type i32 is missing | note: function defined here --> $DIR/missing_arguments.rs:5:4 | LL | fn three_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- -help: make these changes +help: provide the argument | LL | three_diff({i32}, 1.0, ""); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -162,14 +179,16 @@ error[E0059]: arguments to this function are incorrect --> $DIR/missing_arguments.rs:27:3 | LL | three_diff( 1, "" ); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--^^^ + | | + | an argument of type f32 is missing | note: function defined here --> $DIR/missing_arguments.rs:5:4 | LL | fn three_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- -help: make these changes +help: provide the argument | LL | three_diff(1, {f32}, ""); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -178,14 +197,14 @@ error[E0059]: arguments to this function are incorrect --> $DIR/missing_arguments.rs:28:3 | LL | three_diff( 1, 1.0 ); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ an argument of type &str is missing | note: function defined here --> $DIR/missing_arguments.rs:5:4 | LL | fn three_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- -help: make these changes +help: provide the argument | LL | three_diff(1, 1.0, {&str}); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -194,14 +213,17 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/missing_arguments.rs:29:3 | LL | three_diff( "" ); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--^^^ + | | | + | | an argument of type i32 is missing + | an argument of type f32 is missing | note: function defined here --> $DIR/missing_arguments.rs:5:4 | LL | fn three_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- -help: make these changes +help: did you mean | LL | three_diff({i32}, {f32}, ""); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -210,14 +232,17 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/missing_arguments.rs:30:3 | LL | three_diff( 1.0 ); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^---^^^^^^^^^^^ + | | | + | | an argument of type i32 is missing + | an argument of type &str is missing | note: function defined here --> $DIR/missing_arguments.rs:5:4 | LL | fn three_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- -help: make these changes +help: did you mean | LL | three_diff({i32}, 1.0, {&str}); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -227,13 +252,16 @@ error[E0059]: multiple arguments to this function are incorrect | LL | three_diff( 1 ); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | an argument of type f32 is missing + | an argument of type &str is missing | note: function defined here --> $DIR/missing_arguments.rs:5:4 | LL | fn three_diff(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- -help: make these changes +help: did you mean | LL | three_diff(1, {f32}, {&str}); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -243,13 +271,18 @@ error[E0059]: multiple arguments to this function are incorrect | LL | four_repeated( ); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | an argument of type i32 is missing + | an argument of type f32 is missing + | an argument of type f32 is missing + | an argument of type &str is missing | note: function defined here --> $DIR/missing_arguments.rs:6:4 | LL | fn four_repeated(_a: i32, _b: f32, _c: f32, _d: &str) {} | ^^^^^^^^^^^^^ ------- ------- ------- -------- -help: make these changes +help: did you mean | LL | four_repeated({i32}, {f32}, {f32}, {&str}); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -258,14 +291,17 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/missing_arguments.rs:35:3 | LL | four_repeated( 1, "" ); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--^^^^ + | | | + | | an argument of type f32 is missing + | an argument of type f32 is missing | note: function defined here --> $DIR/missing_arguments.rs:6:4 | LL | fn four_repeated(_a: i32, _b: f32, _c: f32, _d: &str) {} | ^^^^^^^^^^^^^ ------- ------- ------- -------- -help: make these changes +help: did you mean | LL | four_repeated(1, {f32}, {f32}, ""); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -275,13 +311,19 @@ error[E0059]: multiple arguments to this function are incorrect | LL | complex( ); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | an argument of type i32 is missing + | an argument of type f32 is missing + | an argument of type i32 is missing + | an argument of type f32 is missing + | an argument of type &str is missing | note: function defined here --> $DIR/missing_arguments.rs:7:4 | LL | fn complex(_a: i32, _b: f32, _c: i32, _d: f32, _e: &str) {} | ^^^^^^^ ------- ------- ------- ------- -------- -help: make these changes +help: did you mean | LL | complex({i32}, {f32}, {i32}, {f32}, {&str}); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -290,14 +332,18 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/missing_arguments.rs:39:3 | LL | complex( 1, "" ); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--^^^^ + | | | + | | an argument of type f32 is missing + | an argument of type i32 is missing + | an argument of type f32 is missing | note: function defined here --> $DIR/missing_arguments.rs:7:4 | LL | fn complex(_a: i32, _b: f32, _c: i32, _d: f32, _e: &str) {} | ^^^^^^^ ------- ------- ------- ------- -------- -help: make these changes +help: did you mean | LL | complex(1, {f32}, {i32}, {f32}, ""); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/argument-suggestions/mixed_cases.stderr b/src/test/ui/argument-suggestions/mixed_cases.stderr index 05c08b609137d..fe221abc242af 100644 --- a/src/test/ui/argument-suggestions/mixed_cases.stderr +++ b/src/test/ui/argument-suggestions/mixed_cases.stderr @@ -2,14 +2,17 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/mixed_cases.rs:10:3 | LL | two_args(1, "", X {}); - | ^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^-^^^^^^^^^^^ + | | + | expected f32, found i32 + | argument of type i32 unexpected | note: function defined here --> $DIR/mixed_cases.rs:5:4 | LL | fn two_args(_a: i32, _b: f32) {} | ^^^^^^^^ ------- ------- -help: make these changes +help: did you mean | LL | two_args(1, {f32}); | ^^^^^^^^^^^^^^^^^^ @@ -18,14 +21,18 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/mixed_cases.rs:11:3 | LL | three_args(1, "", X {}, ""); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^-^^--^^^^^^^^^^^ + | | | + | | an argument of type f32 is missing + | | argument of type f32 unexpected + | argument of type i32 unexpected | note: function defined here --> $DIR/mixed_cases.rs:6:4 | LL | fn three_args(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- -help: make these changes +help: did you mean | LL | three_args(1, {f32}, ""); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -34,14 +41,17 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/mixed_cases.rs:14:3 | LL | three_args(1, X {}); - | ^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^-^^^^^^^ + | | | + | | expected f32, found i32 + | an argument of type &str is missing | note: function defined here --> $DIR/mixed_cases.rs:6:4 | LL | fn three_args(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- -help: make these changes +help: did you mean | LL | three_args(1, {f32}, {&str}); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -50,14 +60,17 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/mixed_cases.rs:17:3 | LL | three_args(1, "", X {}); - | ^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^--^^^^^^^ + | | + | an argument of type f32 is missing + | argument of type f32 unexpected | note: function defined here --> $DIR/mixed_cases.rs:6:4 | LL | fn three_args(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- -help: make these changes +help: did you mean | LL | three_args(1, {f32}, ""); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -66,14 +79,18 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/mixed_cases.rs:20:3 | LL | three_args("", X {}, 1); - | ^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^--^^^^^^^^-^ + | | | + | | expected &str,found {integer} + | expected i32,found &'static str + | expected f32, found &'static str | note: function defined here --> $DIR/mixed_cases.rs:6:4 | LL | fn three_args(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- -help: make these changes +help: did you mean | LL | three_args(1, {f32}, ""); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -82,14 +99,18 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/mixed_cases.rs:23:3 | LL | three_args("", 1); - | ^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^--^^-^ + | | | + | | an argument of type f32 is missing + | | expected &str,found {integer} + | expected i32,found &'static str | note: function defined here --> $DIR/mixed_cases.rs:6:4 | LL | fn three_args(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- -help: make these changes +help: did you mean | LL | three_args(1, {f32}, ""); | ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/argument-suggestions/permuted_arguments.stderr b/src/test/ui/argument-suggestions/permuted_arguments.stderr index d5dc12a1bcd77..85b6e86bb5c5b 100644 --- a/src/test/ui/argument-suggestions/permuted_arguments.stderr +++ b/src/test/ui/argument-suggestions/permuted_arguments.stderr @@ -1,31 +1,41 @@ -error[E0059]: arguments to this function are incorrect +error[E0059]: multiple arguments to this function are incorrect --> $DIR/permuted_arguments.rs:10:3 | LL | three_args(1.0, "", 1); - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^---^^--^^-^ + | | | | + | | | expected &str,found {integer} + | | expected f32,found &'static str + | expected i32,found {float} | note: function defined here --> $DIR/permuted_arguments.rs:5:4 | LL | fn three_args(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- -help: make these changes +help: reorder these arguments | LL | three_args(1, 1.0, ""); | ^^^^^^^^^^^^^^^^^^^^^^ -error[E0059]: arguments to this function are incorrect +error[E0059]: multiple arguments to this function are incorrect --> $DIR/permuted_arguments.rs:12:3 | LL | many_args(X {}, Y {}, 1, 1.0, ""); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^----^^----^^-^^---^^--^ + | | | | | | + | | | | | expected Y,found &'static str + | | | | expected X,found {float} + | | | expected &str,found {integer} + | | expected f32,found Y + | expected i32,found X | note: function defined here --> $DIR/permuted_arguments.rs:6:4 | LL | fn many_args(_a: i32, _b: f32, _c: &str, _d: X, _e: Y) {} | ^^^^^^^^^ ------- ------- -------- ----- ----- -help: make these changes +help: reorder these arguments | LL | many_args(1, 1.0, "", X {}, Y {}); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/argument-suggestions/swapped_arguments.stderr b/src/test/ui/argument-suggestions/swapped_arguments.stderr index 9034b72b86e92..9d0cae48641fa 100644 --- a/src/test/ui/argument-suggestions/swapped_arguments.stderr +++ b/src/test/ui/argument-suggestions/swapped_arguments.stderr @@ -1,63 +1,75 @@ -error[E0059]: arguments to this function are incorrect +error[E0059]: multiple arguments to this function are incorrect --> $DIR/swapped_arguments.rs:8:3 | LL | two_args(1.0, 1); - | ^^^^^^^^^^^^^^^^ + | ^^^^^^^^^---^^-^ + | | | + | | expected f32,found {integer} + | expected i32,found {float} | note: function defined here --> $DIR/swapped_arguments.rs:3:4 | LL | fn two_args(_a: i32, _b: f32) {} | ^^^^^^^^ ------- ------- -help: make these changes +help: swap these arguments | LL | two_args(1, 1.0); | ^^^^^^^^^^^^^^^^ -error[E0059]: arguments to this function are incorrect +error[E0059]: multiple arguments to this function are incorrect --> $DIR/swapped_arguments.rs:9:3 | LL | three_args(1.0, 1, ""); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^---^^^^-^^^^^^ + | | | + | | expected f32,found {integer} + | expected i32,found {float} | note: function defined here --> $DIR/swapped_arguments.rs:4:4 | LL | fn three_args(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- -help: make these changes +help: swap these arguments | LL | three_args(1, 1.0, ""); | ^^^^^^^^^^^^^^^^^^^^^^ -error[E0059]: arguments to this function are incorrect +error[E0059]: multiple arguments to this function are incorrect --> $DIR/swapped_arguments.rs:10:3 | LL | three_args( 1, "", 1.0); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^--^^---^ + | | | + | | expected &str,found {float} + | expected f32,found &'static str | note: function defined here --> $DIR/swapped_arguments.rs:4:4 | LL | fn three_args(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- -help: make these changes +help: swap these arguments | LL | three_args(1, 1.0, ""); | ^^^^^^^^^^^^^^^^^^^^^^ -error[E0059]: arguments to this function are incorrect +error[E0059]: multiple arguments to this function are incorrect --> $DIR/swapped_arguments.rs:11:3 | LL | three_args( "", 1.0, 1); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^--^^^^^^^^^-^ + | | | + | | expected &str,found {integer} + | expected i32,found &'static str | note: function defined here --> $DIR/swapped_arguments.rs:4:4 | LL | fn three_args(_a: i32, _b: f32, _c: &str) {} | ^^^^^^^^^^ ------- ------- -------- -help: make these changes +help: swap these arguments | LL | three_args(1, 1.0, ""); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -66,14 +78,19 @@ error[E0059]: multiple arguments to this function are incorrect --> $DIR/swapped_arguments.rs:13:3 | LL | four_args(1.0, 1, X {}, ""); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^---^^-^^----^^--^ + | | | | | + | | | | expected X,found &'static str + | | | expected &str,found X + | | expected f32,found {integer} + | expected i32,found {float} | note: function defined here --> $DIR/swapped_arguments.rs:5:4 | LL | fn four_args(_a: i32, _b: f32, _c: &str, _d: X) {} | ^^^^^^^^^ ------- ------- -------- ----- -help: make these changes +help: did you mean | LL | four_args(1, 1.0, "", X {}); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ From 1d6bab012b4d79b4a112b1fc062a61ed58848fe4 Mon Sep 17 00:00:00 2001 From: Pi Lanningham Date: Sat, 6 Feb 2021 00:22:00 -0500 Subject: [PATCH 20/21] Linting and formatting fixes --- .../rustc_typeck/src/check/fn_ctxt/checks.rs | 117 ++++++++++-------- src/test/ui/argument-suggestions/complex.rs | 2 +- .../argument-suggestions/extra_arguments.rs | 8 +- .../argument-suggestions/invalid_arguments.rs | 8 +- .../argument-suggestions/missing_arguments.rs | 12 +- .../missing_arguments.stderr | 12 +- .../ui/argument-suggestions/mixed_cases.rs | 2 +- .../permuted_arguments.rs | 2 +- .../ui/argument-suggestions/scratch.stdout | 11 -- .../argument-suggestions/swapped_arguments.rs | 2 +- 10 files changed, 92 insertions(+), 84 deletions(-) delete mode 100644 src/test/ui/argument-suggestions/scratch.stdout diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs index c5a80d8db69a1..8eefa31b337a2 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs @@ -19,10 +19,8 @@ use rustc_middle::ty::adjustment::AllowTwoPhase; use rustc_middle::ty::fold::TypeFoldable; use rustc_middle::ty::{self, Ty}; use rustc_session::Session; +use rustc_span::symbol::{sym, Ident}; use rustc_span::{self, MultiSpan, Span}; -use rustc_span::{ - symbol::{sym, Ident}, -}; use rustc_trait_selection::traits::{self, ObligationCauseCode, StatementAsExpression}; use std::cmp; @@ -234,7 +232,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let check_compatible = |arg_idx, input_idx| { let formal_input_ty: Ty<'tcx> = formal_input_tys[input_idx]; let expected_input_ty: Ty<'tcx> = expected_input_tys[input_idx]; - // If either is an error type, we defy the usual convention and consider them to *not* be // coercible. This prevents our error message heuristic from trying to pass errors into @@ -245,11 +242,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let provided_arg: &hir::Expr<'tcx> = &provided_args[arg_idx]; let expectation = Expectation::rvalue_hint(self, expected_input_ty); - // TODO: check that this is safe; I don't believe this commits any of the obligations, but I can't be sure. + // FIXME: check that this is safe; I don't believe this commits any of the obligations, but I can't be sure. // // I had another method of "soft" type checking before, // but it was failing to find the type of some expressions (like "") - // so I prodded this method and made it pub(super) so I could call it, and it seems to work well. + // so I prodded this method and made it pub(super) so I could call it, and it seems to work well. let checked_ty = self.check_expr_kind(provided_arg, expectation); let coerced_ty = expectation.only_has_type(self).unwrap_or(formal_input_ty); @@ -381,20 +378,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { eliminate_arg(mat, ai, arg_idx); }; - let eliminate_satisfied = |mat: &mut Vec>, ii: &mut Vec, ai: &mut Vec| -> Vec<(usize, usize)> { + let eliminate_satisfied = |mat: &mut Vec>, + ii: &mut Vec, + ai: &mut Vec| + -> Vec<(usize, usize)> { let mut i = cmp::min(ii.len(), ai.len()); let mut eliminated = vec![]; while i > 0 { let idx = i - 1; if mat[idx][idx] { eliminated.push((ai[idx], ii[idx])); - satisfy_input( - mat, - ii, - ai, - idx, - idx, - ); + satisfy_input(mat, ii, ai, idx, idx); } i -= 1; } @@ -508,8 +502,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { loop { stack.push(j); // Look for params this one could slot into - let compat: Vec<_> = - mat[j].iter().enumerate().filter_map(|(i, &c)| if c { Some(i) } else { None }).collect(); + let compat: Vec<_> = mat[j] + .iter() + .enumerate() + .filter_map(|(i, &c)| if c { Some(i) } else { None }) + .collect(); if compat.len() != 1 { // this could go into multiple slots, don't bother exploring both is_cycle = false; @@ -570,7 +567,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Without this elimination, the first argument causes the second argument // to show up as both a missing input and extra argument, rather than // just an invalid type. - for (arg, inp) in eliminate_satisfied(&mut compatibility_matrix, &mut input_indexes, &mut arg_indexes) { + for (arg, inp) in + eliminate_satisfied(&mut compatibility_matrix, &mut input_indexes, &mut arg_indexes) + { let arg_span = provided_args[arg].span; let arg_text = source_map.span_to_snippet(arg_span).unwrap(); suggested_inputs[inp] = Some(arg_text); @@ -595,14 +594,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } else { "".into() }; - labels.push((provided_args[idx].span, format!("expected {}{}", expected_ty, provided_ty))); + labels.push(( + provided_args[idx].span, + format!("expected {}{}", expected_ty, provided_ty), + )); suggestion_text = match suggestion_text { None => Some("provide an argument of the correct type"), - Some(_) => Some("did you mean") + Some(_) => Some("did you mean"), }; eliminate_input(&mut compatibility_matrix, &mut input_indexes, idx); eliminate_arg(&mut compatibility_matrix, &mut arg_indexes, idx); - }, + } Some(Issue::Extra(idx)) => { // Eliminate the argument (without touching any inputs) let arg_type = if let Some((_, ty)) = final_arg_types[idx] { @@ -610,13 +612,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } else { "".into() }; - labels.push((provided_args[idx].span, format!("argument{} unexpected", arg_type))); + labels.push(( + provided_args[idx].span, + format!("argument{} unexpected", arg_type), + )); suggestion_text = match suggestion_text { None => Some("remove the extra argument"), - Some(_) => Some("did you mean") + Some(_) => Some("did you mean"), }; eliminate_arg(&mut compatibility_matrix, &mut arg_indexes, idx); - }, + } Some(Issue::Missing(idx)) => { let input_idx = input_indexes[idx]; let expected_ty = expected_input_tys[input_idx]; @@ -639,10 +644,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { labels.push((span, format!("an argument of type {} is missing", input_ty))); suggestion_text = match suggestion_text { None => Some("provide the argument"), - Some(_) => Some("did you mean") + Some(_) => Some("did you mean"), }; eliminate_input(&mut compatibility_matrix, &mut input_indexes, idx); - }, + } Some(Issue::Swap(idx, other)) => { let input_idx = input_indexes[idx]; let other_input_idx = input_indexes[other]; @@ -655,23 +660,32 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { suggested_inputs[input_idx] = Some(second_snippet); suggested_inputs[other_input_idx] = Some(first_snippet); - let first_expected_ty = self.resolve_vars_if_possible(expected_input_tys[input_idx]); + let first_expected_ty = + self.resolve_vars_if_possible(expected_input_tys[input_idx]); let first_provided_ty = if let Some((ty, _)) = final_arg_types[arg_idx] { format!(",found {}", ty) } else { "".into() }; - labels.push((first_span, format!("expected {}{}", first_expected_ty, first_provided_ty))); - let other_expected_ty = self.resolve_vars_if_possible(expected_input_tys[other_input_idx]); - let other_provided_ty = if let Some((ty, _)) = final_arg_types[other_arg_idx] { - format!(",found {}", ty) - } else { - "".into() - }; - labels.push((second_span, format!("expected {}{}", other_expected_ty, other_provided_ty))); + labels.push(( + first_span, + format!("expected {}{}", first_expected_ty, first_provided_ty), + )); + let other_expected_ty = + self.resolve_vars_if_possible(expected_input_tys[other_input_idx]); + let other_provided_ty = + if let Some((ty, _)) = final_arg_types[other_arg_idx] { + format!(",found {}", ty) + } else { + "".into() + }; + labels.push(( + second_span, + format!("expected {}{}", other_expected_ty, other_provided_ty), + )); suggestion_text = match suggestion_text { None => Some("swap these arguments"), - Some(_) => Some("did you mean") + Some(_) => Some("did you mean"), }; let (min, max) = (cmp::min(idx, other), cmp::max(idx, other)); @@ -689,15 +703,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { max - 1, // Subtract 1 because we already removed the "min" row min, ); - }, + } Some(Issue::Permutation(args)) => { // FIXME: If satisfy_input ever did anything non-trivial (emit obligations to help type checking, for example) // we'd want to call this function with the correct arg/input pairs, but for now, we just throw them in a bucket. // This works because they force a cycle, so each row is guaranteed to also be a column - let mut idxs: Vec = - args.iter() - .filter_map(|&a| a) - .collect(); + let mut idxs: Vec = args.iter().filter_map(|&a| a).collect(); let mut real_idxs = vec![None; provided_arg_count]; for (src, dst) in args.iter().enumerate().filter(|(_, &a)| a.is_some()) { @@ -705,21 +716,26 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let dst_arg = arg_indexes[dst.unwrap()]; let dest_input = input_indexes[dst.unwrap()]; let src_span = provided_args[src_arg].span; - suggested_inputs[dest_input] = Some(source_map.span_to_snippet(src_span).unwrap()); + suggested_inputs[dest_input] = + Some(source_map.span_to_snippet(src_span).unwrap()); - let expected_ty = self.resolve_vars_if_possible(expected_input_tys[dest_input]); + let expected_ty = + self.resolve_vars_if_possible(expected_input_tys[dest_input]); let provided_ty = if let Some((ty, _)) = final_arg_types[dst_arg] { format!(",found {}", ty) } else { "".into() }; - labels.push((provided_args[dst_arg].span, format!("expected {}{}", expected_ty, provided_ty))); + labels.push(( + provided_args[dst_arg].span, + format!("expected {}{}", expected_ty, provided_ty), + )); real_idxs[src_arg] = Some(dst_arg); } suggestion_text = match suggestion_text { None => Some("reorder these arguments"), - Some(_) => Some("did you mean") + Some(_) => Some("did you mean"), }; idxs.sort(); @@ -733,11 +749,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { i, ); } - }, + } None => { // We didn't find any issues, so we need to push the algorithm forward // First, eliminate any arguments that currently satisfy their inputs - for (arg, inp) in eliminate_satisfied(&mut compatibility_matrix, &mut input_indexes, &mut arg_indexes) { + for (arg, inp) in eliminate_satisfied( + &mut compatibility_matrix, + &mut input_indexes, + &mut arg_indexes, + ) { let arg_span = provided_args[arg].span; let arg_text = source_map.span_to_snippet(arg_span).unwrap(); suggested_inputs[inp] = Some(arg_text); @@ -748,16 +768,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let issue_count = labels.len(); if issue_count > 0 { - // Now construct our error from the various things we've labeled let mut err = struct_span_err!( tcx.sess, call_span, - E0059, // FIXME: Choose a different code? + E0308, // FIXME: Choose a different code? "{}arguments to this function are incorrect", if issue_count > 1 { "multiple " } else { "" } ); - + // If we have less than 5 things to say, it would be useful to call out exactly what's wrong if issue_count <= 5 { for (span, label) in labels { diff --git a/src/test/ui/argument-suggestions/complex.rs b/src/test/ui/argument-suggestions/complex.rs index 6e89dc2e6f378..384cdca7e4fdc 100644 --- a/src/test/ui/argument-suggestions/complex.rs +++ b/src/test/ui/argument-suggestions/complex.rs @@ -13,4 +13,4 @@ fn complex(_i: u32, _s: &str, _e: E, _f: F, _g: G, _x: X, _y: Y, _z: Z ) {} fn main() { complex(1.0, H {}, &"", G{}, F::X2, Z {}, X {}, Y {}); //~^ ERROR arguments to this function are incorrect -} \ No newline at end of file +} diff --git a/src/test/ui/argument-suggestions/extra_arguments.rs b/src/test/ui/argument-suggestions/extra_arguments.rs index 68269b19b8c2a..b2bca4bdcc29a 100644 --- a/src/test/ui/argument-suggestions/extra_arguments.rs +++ b/src/test/ui/argument-suggestions/extra_arguments.rs @@ -5,7 +5,7 @@ fn two_arg_diff(_a: i32, _b: &str) {} fn main() { empty(""); //~ ERROR arguments to this function are incorrect - + one_arg(1, 1); //~ ERROR arguments to this function are incorrect one_arg(1, ""); //~ ERROR arguments to this function are incorrect one_arg(1, "", 1.0); //~ ERROR arguments to this function are incorrect @@ -17,7 +17,7 @@ fn main() { two_arg_diff(1, "", ""); //~ ERROR arguments to this function are incorrect two_arg_diff(1, 1, "", ""); //~ ERROR arguments to this function are incorrect two_arg_diff(1, "", 1, ""); //~ ERROR arguments to this function are incorrect - + // Check with weird spacing and newlines two_arg_same(1, 1, ""); //~ ERROR arguments to this function are incorrect two_arg_diff(1, 1, ""); //~ ERROR arguments to this function are incorrect @@ -26,10 +26,10 @@ fn main() { 1, "" ); - + two_arg_diff( //~ ERROR arguments to this function are incorrect 1, 1, "" ); -} \ No newline at end of file +} diff --git a/src/test/ui/argument-suggestions/invalid_arguments.rs b/src/test/ui/argument-suggestions/invalid_arguments.rs index b42acae62420c..a8c159c43b163 100644 --- a/src/test/ui/argument-suggestions/invalid_arguments.rs +++ b/src/test/ui/argument-suggestions/invalid_arguments.rs @@ -11,7 +11,7 @@ fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {} fn main() { // Providing an incorrect argument for a single parameter function one_arg(1.0); //~ ERROR arguments to this function are incorrect - + // Providing one or two invalid arguments to a two parameter function two_arg_same(1, ""); //~ ERROR arguments to this function are incorrect two_arg_same("", 1); //~ ERROR arguments to this function are incorrect @@ -34,10 +34,10 @@ fn main() { three_arg_repeat(X {}, 1, ""); //~ ERROR arguments to this function are incorrect three_arg_repeat(1, X {}, ""); //~ ERROR arguments to this function are incorrect three_arg_repeat(1, 1, X {}); //~ ERROR arguments to this function are incorrect - + three_arg_repeat(X {}, X {}, ""); //~ ERROR arguments to this function are incorrect three_arg_repeat(X {}, 1, X {}); //~ ERROR arguments to this function are incorrect three_arg_repeat(1, X {}, X{}); //~ ERROR arguments to this function are incorrect - + three_arg_repeat(X {}, X {}, X {}); //~ ERROR arguments to this function are incorrect -} \ No newline at end of file +} diff --git a/src/test/ui/argument-suggestions/missing_arguments.rs b/src/test/ui/argument-suggestions/missing_arguments.rs index d8b28809b2b44..73ff138dd993c 100644 --- a/src/test/ui/argument-suggestions/missing_arguments.rs +++ b/src/test/ui/argument-suggestions/missing_arguments.rs @@ -10,7 +10,7 @@ fn main() { one_arg(); //~ ERROR arguments to this function are incorrect // The headers here show the types expected, // with formatting to emphasize which arguments are missing - /* i32 f32 */ + /* i32 f32 */ two_same( ); //~ ERROR arguments to this function are incorrect two_same( 1 ); //~ ERROR arguments to this function are incorrect two_diff( ); //~ ERROR arguments to this function are incorrect @@ -29,12 +29,12 @@ fn main() { three_diff( "" ); //~ ERROR arguments to this function are incorrect three_diff( 1.0 ); //~ ERROR arguments to this function are incorrect three_diff( 1 ); //~ ERROR arguments to this function are incorrect - + /* i32 f32 f32 &str */ four_repeated( ); //~ ERROR arguments to this function are incorrect four_repeated( 1, "" ); //~ ERROR arguments to this function are incorrect - /* i32 f32 i32 f32 &str */ - complex( ); //~ ERROR arguments to this function are incorrect - complex( 1, "" ); //~ ERROR arguments to this function are incorrect -} \ No newline at end of file + /* i32 f32 i32 f32 &str */ + complex( ); //~ ERROR arguments to this function are incorrect + complex( 1, "" ); //~ ERROR arguments to this function are incorrect +} diff --git a/src/test/ui/argument-suggestions/missing_arguments.stderr b/src/test/ui/argument-suggestions/missing_arguments.stderr index a111b137bd2a6..c5f50a0e8f4cb 100644 --- a/src/test/ui/argument-suggestions/missing_arguments.stderr +++ b/src/test/ui/argument-suggestions/missing_arguments.stderr @@ -309,8 +309,8 @@ LL | four_repeated(1, {f32}, {f32}, ""); error[E0059]: multiple arguments to this function are incorrect --> $DIR/missing_arguments.rs:38:3 | -LL | complex( ); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | complex( ); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | an argument of type i32 is missing | an argument of type f32 is missing @@ -331,10 +331,10 @@ LL | complex({i32}, {f32}, {i32}, {f32}, {&str}); error[E0059]: multiple arguments to this function are incorrect --> $DIR/missing_arguments.rs:39:3 | -LL | complex( 1, "" ); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--^^^^ - | | | - | | an argument of type f32 is missing +LL | complex( 1, "" ); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--^^^^ + | | | + | | an argument of type f32 is missing | an argument of type i32 is missing | an argument of type f32 is missing | diff --git a/src/test/ui/argument-suggestions/mixed_cases.rs b/src/test/ui/argument-suggestions/mixed_cases.rs index 19826d6eebbfa..45d96bac53cb8 100644 --- a/src/test/ui/argument-suggestions/mixed_cases.rs +++ b/src/test/ui/argument-suggestions/mixed_cases.rs @@ -21,4 +21,4 @@ fn main() { // Swapped and missing three_args("", 1); //~ ERROR arguments to this function are incorrect -} \ No newline at end of file +} diff --git a/src/test/ui/argument-suggestions/permuted_arguments.rs b/src/test/ui/argument-suggestions/permuted_arguments.rs index 580f86b0034b0..f512fde651cd9 100644 --- a/src/test/ui/argument-suggestions/permuted_arguments.rs +++ b/src/test/ui/argument-suggestions/permuted_arguments.rs @@ -10,4 +10,4 @@ fn main() { three_args(1.0, "", 1); //~ ERROR arguments to this function are incorrect // d, e, b, a, c many_args(X {}, Y {}, 1, 1.0, ""); //~ ERROR arguments to this function are incorrect -} \ No newline at end of file +} diff --git a/src/test/ui/argument-suggestions/scratch.stdout b/src/test/ui/argument-suggestions/scratch.stdout deleted file mode 100644 index 1afaedb4fe88f..0000000000000 --- a/src/test/ui/argument-suggestions/scratch.stdout +++ /dev/null @@ -1,11 +0,0 @@ -~~ [false, true, true, false, true] -~~ 0 - false -~~ 1 - true -~~ Start of block -~~ 2 - true -~~ 3 - false -~~ End of block -~~ Eliminating $DIR/scratch.rs:4:12: 4:21 (#0) -~~ 4 - true -~~ Single end -~~ Eliminating $DIR/scratch.rs:4:24: 4:28 (#0) diff --git a/src/test/ui/argument-suggestions/swapped_arguments.rs b/src/test/ui/argument-suggestions/swapped_arguments.rs index 8ad5644edc12f..a21de610c6a13 100644 --- a/src/test/ui/argument-suggestions/swapped_arguments.rs +++ b/src/test/ui/argument-suggestions/swapped_arguments.rs @@ -11,4 +11,4 @@ fn main() { three_args( "", 1.0, 1); //~ ERROR arguments to this function are incorrect four_args(1.0, 1, X {}, ""); //~ ERROR arguments to this function are incorrect -} \ No newline at end of file +} From 52672859a031e2c749e11c80b3a8727c781edbc5 Mon Sep 17 00:00:00 2001 From: Pi Lanningham Date: Sun, 7 Feb 2021 01:23:24 -0500 Subject: [PATCH 21/21] --bless error messages I left several tests failing, as they are likely cases my code needs to handle --- .../rustc_typeck/src/check/fn_ctxt/checks.rs | 19 +- src/test/ui/arg-count-mismatch.rs | 5 - src/test/ui/arg-count-mismatch.stderr | 17 - src/test/ui/arg-type-mismatch.rs | 5 - src/test/ui/arg-type-mismatch.stderr | 9 - src/test/ui/argument-suggestions/basic.stderr | 24 +- .../ui/argument-suggestions/complex.stderr | 4 +- .../extra_arguments.stderr | 30 +- .../invalid_arguments.stderr | 110 +- .../missing_arguments.stderr | 40 +- .../argument-suggestions/mixed_cases.stderr | 28 +- .../permuted_arguments.stderr | 22 +- .../swapped_arguments.stderr | 36 +- ...ociated-type-projection-from-supertrait.rs | 8 +- ...ted-type-projection-from-supertrait.stderr | 68 +- .../associated-types-path-2.rs | 2 +- .../associated-types-path-2.stderr | 19 +- .../async-await/dont-suggest-missing-await.rs | 2 +- .../dont-suggest-missing-await.stderr | 24 +- .../suggest-missing-await-closure.fixed | 4 +- .../suggest-missing-await-closure.rs | 2 +- .../suggest-missing-await-closure.stderr | 24 +- .../ui/async-await/suggest-missing-await.rs | 4 +- .../async-await/suggest-missing-await.stderr | 24 +- src/test/ui/c-variadic/variadic-ffi-1.rs | 6 +- src/test/ui/c-variadic/variadic-ffi-1.stderr | 37 +- src/test/ui/closures/closure-reform-bad.rs | 2 +- .../ui/closures/closure-reform-bad.stderr | 21 +- .../coerce-expect-unsized-ascribed.rs | 36 +- .../coerce-expect-unsized-ascribed.stderr | 32 +- src/test/ui/coercion/coerce-mut.rs | 2 +- src/test/ui/coercion/coerce-mut.stderr | 19 +- .../coerce-reborrow-multi-arg-fail.rs | 2 +- .../coerce-reborrow-multi-arg-fail.stderr | 19 +- src/test/ui/coercion/coerce-to-bang.rs | 22 +- src/test/ui/coercion/coerce-to-bang.stderr | 99 +- ...-argument-cross-crate-mismatch.full.stderr | 26 +- ...t-argument-cross-crate-mismatch.min.stderr | 26 +- .../const-argument-cross-crate-mismatch.rs | 4 +- .../issues/issue-62504.min.stderr | 27 +- .../ui/const-generics/issues/issue-62504.rs | 2 +- src/test/ui/conversion-methods.rs | 6 +- src/test/ui/conversion-methods.stderr | 6 +- src/test/ui/deref-suggestion.rs | 12 +- src/test/ui/deref-suggestion.stderr | 92 +- src/test/ui/did_you_mean/issue-42764.stderr | 23 +- src/test/ui/disambiguate-identical-names.rs | 2 +- .../ui/disambiguate-identical-names.stderr | 19 +- src/test/ui/error-codes/E0057.stderr | 26 +- src/test/ui/error-codes/E0060.stderr | 12 +- src/test/ui/error-codes/E0061.stderr | 22 +- src/test/ui/estr-subtyping.rs | 2 +- src/test/ui/estr-subtyping.stderr | 19 +- src/test/ui/fmt/ifmt-bad-arg.stderr | 28 +- .../type-mismatch-signature-deduction.rs | 2 +- .../missing-bounds.fixed | 8 +- .../missing-bounds.rs | 4 +- .../missing-bounds.stderr | 48 +- src/test/ui/hrtb/issue-58451.rs | 2 +- src/test/ui/hrtb/issue-58451.stderr | 12 +- .../ui/include-macros/mismatched-types.rs | 6 +- .../ui/include-macros/mismatched-types.stderr | 2 +- src/test/ui/indexing-requires-a-uint.rs | 2 +- src/test/ui/indexing-requires-a-uint.stderr | 19 +- .../ui/integer-literal-suffix-inference.rs | 104 +- .../integer-literal-suffix-inference.stderr | 944 +++++--- src/test/ui/issues/issue-10764.rs | 2 +- src/test/ui/issues/issue-10764.stderr | 19 +- src/test/ui/issues/issue-11374.stderr | 20 +- src/test/ui/issues/issue-11515.rs | 3 +- src/test/ui/issues/issue-12997-2.rs | 2 +- src/test/ui/issues/issue-12997-2.stderr | 11 +- src/test/ui/issues/issue-13359.rs | 4 +- src/test/ui/issues/issue-13359.stderr | 38 +- src/test/ui/issues/issue-13853.rs | 2 +- src/test/ui/issues/issue-13853.stderr | 20 +- src/test/ui/issues/issue-1448-2.rs | 2 +- src/test/ui/issues/issue-1448-2.stderr | 19 +- src/test/ui/issues/issue-15783.rs | 2 +- src/test/ui/issues/issue-15783.stderr | 19 +- src/test/ui/issues/issue-16939.rs | 2 +- src/test/ui/issues/issue-16939.stderr | 15 +- src/test/ui/issues/issue-17033.rs | 2 +- src/test/ui/issues/issue-17033.stderr | 12 +- src/test/ui/issues/issue-18819.rs | 2 +- src/test/ui/issues/issue-18819.stderr | 15 +- src/test/ui/issues/issue-24819.rs | 2 +- src/test/ui/issues/issue-24819.stderr | 19 +- src/test/ui/issues/issue-25439.stderr | 23 +- src/test/ui/issues/issue-26094.rs | 4 +- src/test/ui/issues/issue-26094.stderr | 17 +- src/test/ui/issues/issue-29084.rs | 2 +- src/test/ui/issues/issue-29084.stderr | 20 +- src/test/ui/issues/issue-3044.rs | 3 +- src/test/ui/issues/issue-3044.stderr | 29 +- .../ui/issues/issue-43420-no-over-suggest.rs | 2 +- .../issues/issue-43420-no-over-suggest.stderr | 19 +- src/test/ui/issues/issue-44023.rs | 3 +- src/test/ui/issues/issue-4517.rs | 2 +- src/test/ui/issues/issue-4517.stderr | 18 +- src/test/ui/issues/issue-46112.rs | 2 +- src/test/ui/issues/issue-46112.stderr | 15 +- ...6-consider-borrowing-cast-or-binexpr.fixed | 8 +- ...6756-consider-borrowing-cast-or-binexpr.rs | 4 +- ...-consider-borrowing-cast-or-binexpr.stderr | 36 +- src/test/ui/issues/issue-48364.rs | 2 +- src/test/ui/issues/issue-48364.stderr | 13 +- src/test/ui/issues/issue-4935.rs | 2 +- src/test/ui/issues/issue-4935.stderr | 14 +- src/test/ui/issues/issue-51154.rs | 2 +- src/test/ui/issues/issue-51154.stderr | 17 +- src/test/ui/issues/issue-5216.rs | 2 +- src/test/ui/issues/issue-5216.stderr | 19 +- src/test/ui/issues/issue-52533-1.rs | 2 +- src/test/ui/issues/issue-61106.rs | 2 +- src/test/ui/issues/issue-61106.stderr | 19 +- src/test/ui/issues/issue-61882.rs | 2 +- src/test/ui/issues/issue-61882.stderr | 18 +- src/test/ui/issues/issue-69306.rs | 10 +- src/test/ui/issues/issue-69306.stderr | 111 +- .../liveness/liveness-closure-require-ret.rs | 3 +- .../liveness-return-last-stmt-semi.rs | 2 +- src/test/ui/loops/loop-labeled-break-value.rs | 6 +- .../ui/loops/loop-labeled-break-value.stderr | 2 +- src/test/ui/match/match-tag-nullary.rs | 3 +- src/test/ui/match/match-tag-unary.rs | 3 +- src/test/ui/methods/method-call-err-msg.rs | 8 +- .../ui/methods/method-call-err-msg.stderr | 46 +- src/test/ui/methods/method-self-arg-1.rs | 4 +- src/test/ui/methods/method-self-arg-1.stderr | 38 +- src/test/ui/mismatched_types/issue-26480.rs | 3 +- src/test/ui/mismatched_types/issue-35030.rs | 2 +- .../ui/mismatched_types/issue-35030.stderr | 17 +- .../mismatched_types/numeric-literal-cast.rs | 6 +- .../numeric-literal-cast.stderr | 57 +- .../mismatched_types/overloaded-calls-bad.rs | 6 +- .../overloaded-calls-bad.stderr | 41 +- .../trait-bounds-cant-coerce.rs | 2 +- .../trait-bounds-cant-coerce.stderr | 19 +- src/test/ui/mut/mut-cross-borrowing.rs | 2 +- src/test/ui/mut/mut-cross-borrowing.stderr | 20 +- .../call-fn-never-arg-wrong-type.rs | 2 +- .../call-fn-never-arg-wrong-type.stderr | 19 +- src/test/ui/not-enough-arguments.rs | 4 +- src/test/ui/not-enough-arguments.stderr | 24 +- src/test/ui/numeric/len.rs | 2 +- src/test/ui/numeric/len.stderr | 19 +- .../numeric-cast-without-suggestion.rs | 42 +- .../numeric-cast-without-suggestion.stderr | 378 ++- src/test/ui/numeric/numeric-cast.fixed | 452 ++-- src/test/ui/numeric/numeric-cast.rs | 226 +- src/test/ui/numeric/numeric-cast.stderr | 2105 ++++++++++++----- src/test/ui/numeric/numeric-suffix.fixed | 268 +-- src/test/ui/numeric/numeric-suffix.rs | 268 +-- .../issue-64879-trailing-before-guard.rs | 3 +- .../or-patterns-binding-type-mismatch.rs | 6 +- .../or-patterns-binding-type-mismatch.stderr | 42 +- src/test/ui/overloaded-calls-nontuple.stderr | 9 +- src/test/ui/parser/fn-arg-doc-comment.rs | 4 +- src/test/ui/parser/fn-arg-doc-comment.stderr | 53 +- src/test/ui/pattern/pattern-error-continue.rs | 2 +- .../ui/pattern/pattern-error-continue.stderr | 18 +- src/test/ui/proc-macro/signature.rs | 2 +- src/test/ui/proc-macro/signature.stderr | 16 +- .../ui/range/issue-54505-no-literals.fixed | 48 +- src/test/ui/range/issue-54505-no-literals.rs | 24 +- .../ui/range/issue-54505-no-literals.stderr | 240 +- src/test/ui/range/issue-54505-no-std.rs | 12 +- src/test/ui/range/issue-54505-no-std.stderr | 120 +- src/test/ui/range/issue-54505.fixed | 24 +- src/test/ui/range/issue-54505.rs | 12 +- src/test/ui/range/issue-54505.stderr | 120 +- .../issue-73553-misinterp-range-literal.rs | 4 +- ...issue-73553-misinterp-range-literal.stderr | 40 +- ...ion-lifetime-bounds-on-fns-where-clause.rs | 3 +- .../ui/regions/regions-infer-not-param.rs | 6 +- .../ui/regions/regions-infer-not-param.stderr | 20 +- .../ui/resolve/resolve-primitive-fallback.rs | 2 +- .../resolve/resolve-primitive-fallback.stderr | 17 +- src/test/ui/short-error-format.stderr | 2 +- src/test/ui/span/E0057.stderr | 26 +- src/test/ui/span/coerce-suggestions.stderr | 38 +- src/test/ui/span/issue-34264.rs | 6 +- src/test/ui/span/issue-34264.stderr | 45 +- src/test/ui/span/missing-unit-argument.rs | 12 +- src/test/ui/span/missing-unit-argument.stderr | 61 +- src/test/ui/suggestions/as-ref.rs | 8 +- src/test/ui/suggestions/as-ref.stderr | 80 +- .../expected-boxed-future-isnt-pinned.rs | 2 +- .../expected-boxed-future-isnt-pinned.stderr | 26 +- .../recover-from-semicolon-trailing-item.rs | 2 +- ...ecover-from-semicolon-trailing-item.stderr | 18 +- src/test/ui/suggestions/suggest-box.fixed | 3 +- src/test/ui/suggestions/suggest-box.rs | 3 +- src/test/ui/suggestions/suggest-box.stderr | 4 +- ...-associated-type-restriction-fixable.fixed | 28 +- ...ing-associated-type-restriction-fixable.rs | 14 +- ...associated-type-restriction-fixable.stderr | 147 +- ...ith-missing-associated-type-restriction.rs | 16 +- ...missing-associated-type-restriction.stderr | 167 +- src/test/ui/switched-expectations.rs | 3 +- src/test/ui/terminal-width/flag-json.rs | 2 +- src/test/ui/terr-in-field.rs | 2 +- src/test/ui/terr-in-field.stderr | 18 +- src/test/ui/terr-sorts.rs | 2 +- src/test/ui/terr-sorts.stderr | 19 +- src/test/ui/traits/trait-bounds-sugar.rs | 2 +- src/test/ui/traits/trait-bounds-sugar.stderr | 19 +- .../ui/traits/traits-multidispatch-bad.rs | 2 +- .../ui/traits/traits-multidispatch-bad.stderr | 19 +- src/test/ui/tuple/tuple-arity-mismatch.rs | 4 +- src/test/ui/tuple/tuple-arity-mismatch.stderr | 38 +- src/test/ui/tutorial-suffix-inference-test.rs | 6 +- .../ui/tutorial-suffix-inference-test.stderr | 55 +- .../enum-variant-generic-args.rs | 4 +- .../enum-variant-generic-args.stderr | 44 +- ...ant-priority-higher-than-other-inherent.rs | 2 +- ...priority-higher-than-other-inherent.stderr | 13 +- .../type-ascription-instead-of-initializer.rs | 2 +- ...e-ascription-instead-of-initializer.stderr | 15 +- .../ui/type/type-mismatch-same-crate-name.rs | 4 +- .../type/type-mismatch-same-crate-name.stderr | 28 +- src/test/ui/type/type-mismatch.rs | 94 +- src/test/ui/type/type-mismatch.stderr | 891 +++++-- src/test/ui/ufcs/ufcs-qpath-self-mismatch.rs | 4 +- .../ui/ufcs/ufcs-qpath-self-mismatch.stderr | 28 +- .../unboxed-closure-no-cyclic-sig.stderr | 23 +- .../unboxed-closures-type-mismatch.rs | 2 +- .../unboxed-closures-type-mismatch.stderr | 14 +- .../ui/variance/variance-associated-types2.rs | 2 +- 230 files changed, 6524 insertions(+), 3499 deletions(-) delete mode 100644 src/test/ui/arg-count-mismatch.rs delete mode 100644 src/test/ui/arg-count-mismatch.stderr delete mode 100644 src/test/ui/arg-type-mismatch.rs delete mode 100644 src/test/ui/arg-type-mismatch.stderr diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs index 8eefa31b337a2..a5afc449d69ce 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs @@ -590,13 +590,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { suggested_inputs[input_idx] = Some(format!("{{{}}}", input_ty)); } let provided_ty = if let Some((ty, _)) = final_arg_types[idx] { - format!(", found {}", ty) + format!(", found `{}`", ty) } else { "".into() }; labels.push(( provided_args[idx].span, - format!("expected {}{}", expected_ty, provided_ty), + format!("expected `{}`{}", expected_ty, provided_ty), )); suggestion_text = match suggestion_text { None => Some("provide an argument of the correct type"), @@ -663,25 +663,25 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let first_expected_ty = self.resolve_vars_if_possible(expected_input_tys[input_idx]); let first_provided_ty = if let Some((ty, _)) = final_arg_types[arg_idx] { - format!(",found {}", ty) + format!(",found `{}`", ty) } else { "".into() }; labels.push(( first_span, - format!("expected {}{}", first_expected_ty, first_provided_ty), + format!("expected `{}`{}", first_expected_ty, first_provided_ty), )); let other_expected_ty = self.resolve_vars_if_possible(expected_input_tys[other_input_idx]); let other_provided_ty = if let Some((ty, _)) = final_arg_types[other_arg_idx] { - format!(",found {}", ty) + format!(",found `{}`", ty) } else { "".into() }; labels.push(( second_span, - format!("expected {}{}", other_expected_ty, other_provided_ty), + format!("expected `{}`{}", other_expected_ty, other_provided_ty), )); suggestion_text = match suggestion_text { None => Some("swap these arguments"), @@ -722,13 +722,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let expected_ty = self.resolve_vars_if_possible(expected_input_tys[dest_input]); let provided_ty = if let Some((ty, _)) = final_arg_types[dst_arg] { - format!(",found {}", ty) + format!(",found `{}`", ty) } else { "".into() }; labels.push(( provided_args[dst_arg].span, - format!("expected {}{}", expected_ty, provided_ty), + format!("expected `{}`{}", expected_ty, provided_ty), )); real_idxs[src_arg] = Some(dst_arg); } @@ -773,8 +773,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { tcx.sess, call_span, E0308, // FIXME: Choose a different code? - "{}arguments to this function are incorrect", - if issue_count > 1 { "multiple " } else { "" } + "arguments to this function are incorrect", ); // If we have less than 5 things to say, it would be useful to call out exactly what's wrong diff --git a/src/test/ui/arg-count-mismatch.rs b/src/test/ui/arg-count-mismatch.rs deleted file mode 100644 index 18926f5daf71a..0000000000000 --- a/src/test/ui/arg-count-mismatch.rs +++ /dev/null @@ -1,5 +0,0 @@ -// error-pattern: arguments were supplied - -fn f(x: isize) { } - -fn main() { let i: (); i = f(); } diff --git a/src/test/ui/arg-count-mismatch.stderr b/src/test/ui/arg-count-mismatch.stderr deleted file mode 100644 index d0577e4864a78..0000000000000 --- a/src/test/ui/arg-count-mismatch.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0061]: this function takes 1 argument but 0 arguments were supplied - --> $DIR/arg-count-mismatch.rs:5:28 - | -LL | fn main() { let i: (); i = f(); } - | ^-- supplied 0 arguments - | | - | 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 - -For more information about this error, try `rustc --explain E0061`. diff --git a/src/test/ui/arg-type-mismatch.rs b/src/test/ui/arg-type-mismatch.rs deleted file mode 100644 index 04ce2888785be..0000000000000 --- a/src/test/ui/arg-type-mismatch.rs +++ /dev/null @@ -1,5 +0,0 @@ -// error-pattern: mismatched types - -fn f(x: isize) { } - -fn main() { let i: (); i = f(()); } diff --git a/src/test/ui/arg-type-mismatch.stderr b/src/test/ui/arg-type-mismatch.stderr deleted file mode 100644 index 05b21efeecec4..0000000000000 --- a/src/test/ui/arg-type-mismatch.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/arg-type-mismatch.rs:5:30 - | -LL | fn main() { let i: (); i = f(()); } - | ^^ expected `isize`, found `()` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/argument-suggestions/basic.stderr b/src/test/ui/argument-suggestions/basic.stderr index f19cde3bb5c88..d43f837080444 100644 --- a/src/test/ui/argument-suggestions/basic.stderr +++ b/src/test/ui/argument-suggestions/basic.stderr @@ -1,10 +1,10 @@ -error[E0059]: arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/basic.rs:20:5 | LL | invalid(1.0); | ^^^^^^^^---^ | | - | expected u32, found {float} + | expected `u32`, found `{float}` | note: function defined here --> $DIR/basic.rs:13:4 @@ -16,7 +16,7 @@ help: provide an argument of the correct type LL | invalid({u32}); | ^^^^^^^^^^^^^^ -error[E0059]: arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/basic.rs:21:5 | LL | extra(""); @@ -34,7 +34,7 @@ help: remove the extra argument LL | extra(); | ^^^^^^^ -error[E0059]: arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/basic.rs:22:5 | LL | missing(); @@ -50,14 +50,14 @@ help: provide the argument LL | missing({u32}); | ^^^^^^^^^^^^^^ -error[E0059]: multiple arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/basic.rs:23:5 | LL | swapped("", 1); | ^^^^^^^^--^^-^ | | | - | | expected &str,found {integer} - | expected u32,found &'static str + | | expected `&str`,found `{integer}` + | expected `u32`,found `&'static str` | note: function defined here --> $DIR/basic.rs:16:4 @@ -69,15 +69,15 @@ help: swap these arguments LL | swapped(1, ""); | ^^^^^^^^^^^^^^ -error[E0059]: multiple arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/basic.rs:24:5 | LL | permuted(Y {}, Z {}, X {}); | ^^^^^^^^^----^^----^^----^ | | | | - | | | expected Z,found X - | | expected Y,found Z - | expected X,found Y + | | | expected `Z`,found `X` + | | expected `Y`,found `Z` + | expected `X`,found `Y` | note: function defined here --> $DIR/basic.rs:17:4 @@ -91,4 +91,4 @@ LL | permuted(X {}, Y {}, Z {}); error: aborting due to 5 previous errors -For more information about this error, try `rustc --explain E0059`. +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/argument-suggestions/complex.stderr b/src/test/ui/argument-suggestions/complex.stderr index 97e554c3a2d2e..efea77c2ed40b 100644 --- a/src/test/ui/argument-suggestions/complex.stderr +++ b/src/test/ui/argument-suggestions/complex.stderr @@ -1,4 +1,4 @@ -error[E0059]: multiple arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/complex.rs:14:3 | LL | complex(1.0, H {}, &"", G{}, F::X2, Z {}, X {}, Y {}); @@ -16,4 +16,4 @@ LL | complex({u32}, &"", {E}, F::X2, G{}, X {}, Y {}, Z {}); error: aborting due to previous error -For more information about this error, try `rustc --explain E0059`. +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/argument-suggestions/extra_arguments.stderr b/src/test/ui/argument-suggestions/extra_arguments.stderr index aaf7a8f16bff8..be99da736550a 100644 --- a/src/test/ui/argument-suggestions/extra_arguments.stderr +++ b/src/test/ui/argument-suggestions/extra_arguments.stderr @@ -1,4 +1,4 @@ -error[E0059]: arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/extra_arguments.rs:7:3 | LL | empty(""); @@ -16,7 +16,7 @@ help: remove the extra argument LL | empty(); | ^^^^^^^ -error[E0059]: arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/extra_arguments.rs:9:3 | LL | one_arg(1, 1); @@ -34,7 +34,7 @@ help: remove the extra argument LL | one_arg(1); | ^^^^^^^^^^ -error[E0059]: arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/extra_arguments.rs:10:3 | LL | one_arg(1, ""); @@ -52,7 +52,7 @@ help: remove the extra argument LL | one_arg(1); | ^^^^^^^^^^ -error[E0059]: multiple arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/extra_arguments.rs:11:3 | LL | one_arg(1, "", 1.0); @@ -71,7 +71,7 @@ help: did you mean LL | one_arg(1); | ^^^^^^^^^^ -error[E0059]: arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/extra_arguments.rs:13:3 | LL | two_arg_same(1, 1, 1); @@ -89,7 +89,7 @@ help: remove the extra argument LL | two_arg_same(1, 1); | ^^^^^^^^^^^^^^^^^^ -error[E0059]: arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/extra_arguments.rs:14:3 | LL | two_arg_same(1, 1, 1.0); @@ -107,7 +107,7 @@ help: remove the extra argument LL | two_arg_same(1, 1); | ^^^^^^^^^^^^^^^^^^ -error[E0059]: arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/extra_arguments.rs:16:3 | LL | two_arg_diff(1, 1, ""); @@ -125,7 +125,7 @@ help: remove the extra argument LL | two_arg_diff(1, ""); | ^^^^^^^^^^^^^^^^^^^ -error[E0059]: arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/extra_arguments.rs:17:3 | LL | two_arg_diff(1, "", ""); @@ -143,7 +143,7 @@ help: remove the extra argument LL | two_arg_diff(1, ""); | ^^^^^^^^^^^^^^^^^^^ -error[E0059]: multiple arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/extra_arguments.rs:18:3 | LL | two_arg_diff(1, 1, "", ""); @@ -162,7 +162,7 @@ help: did you mean LL | two_arg_diff(1, ""); | ^^^^^^^^^^^^^^^^^^^ -error[E0059]: multiple arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/extra_arguments.rs:19:3 | LL | two_arg_diff(1, "", 1, ""); @@ -181,7 +181,7 @@ help: did you mean LL | two_arg_diff(1, ""); | ^^^^^^^^^^^^^^^^^^^ -error[E0059]: arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/extra_arguments.rs:22:3 | LL | two_arg_same(1, 1, ""); @@ -199,7 +199,7 @@ help: remove the extra argument LL | two_arg_same(1, 1); | ^^^^^^^^^^^^^^^^^^ -error[E0059]: arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/extra_arguments.rs:23:3 | LL | two_arg_diff(1, 1, ""); @@ -217,7 +217,7 @@ help: remove the extra argument LL | two_arg_diff(1, ""); | ^^^^^^^^^^^^^^^^^^^ -error[E0059]: arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/extra_arguments.rs:24:3 | LL | / two_arg_same( @@ -238,7 +238,7 @@ help: remove the extra argument LL | two_arg_same(1, 1); | ^^^^^^^^^^^^^^^^^^ -error[E0059]: arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/extra_arguments.rs:30:3 | LL | / two_arg_diff( @@ -261,4 +261,4 @@ LL | two_arg_diff(1, ""); error: aborting due to 14 previous errors -For more information about this error, try `rustc --explain E0059`. +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/argument-suggestions/invalid_arguments.stderr b/src/test/ui/argument-suggestions/invalid_arguments.stderr index 0e47c157071a6..c82b6e0ec9df8 100644 --- a/src/test/ui/argument-suggestions/invalid_arguments.stderr +++ b/src/test/ui/argument-suggestions/invalid_arguments.stderr @@ -1,10 +1,10 @@ -error[E0059]: arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:13:3 | LL | one_arg(1.0); | ^^^^^^^^---^ | | - | expected i32, found {float} + | expected `i32`, found `{float}` | note: function defined here --> $DIR/invalid_arguments.rs:5:4 @@ -16,13 +16,13 @@ help: provide an argument of the correct type LL | one_arg({i32}); | ^^^^^^^^^^^^^^ -error[E0059]: arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:16:3 | LL | two_arg_same(1, ""); | ^^^^^^^^^^^^^-^^^^^ | | - | expected i32, found i32 + | expected `i32`, found `i32` | note: function defined here --> $DIR/invalid_arguments.rs:6:4 @@ -34,13 +34,13 @@ help: provide an argument of the correct type LL | two_arg_same(1, {i32}); | ^^^^^^^^^^^^^^^^^^^^^^ -error[E0059]: arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:17:3 | LL | two_arg_same("", 1); | ^^^^^^^^^^^^^--^^^^ | | - | expected i32, found &'static str + | expected `i32`, found `&'static str` | note: function defined here --> $DIR/invalid_arguments.rs:6:4 @@ -52,14 +52,14 @@ help: provide an argument of the correct type LL | two_arg_same({i32}, 1); | ^^^^^^^^^^^^^^^^^^^^^^ -error[E0059]: multiple arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:18:3 | LL | two_arg_same("", ""); | ^^^^^^^^^^^^^--^^^^^ | | - | expected i32, found &'static str - | expected i32, found &'static str + | expected `i32`, found `&'static str` + | expected `i32`, found `&'static str` | note: function defined here --> $DIR/invalid_arguments.rs:6:4 @@ -71,13 +71,13 @@ help: did you mean LL | two_arg_same({i32}, {i32}); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0059]: arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:19:3 | LL | two_arg_diff(1, ""); | ^^^^^^^^^^^^^-^^^^^ | | - | expected f32, found i32 + | expected `f32`, found `i32` | note: function defined here --> $DIR/invalid_arguments.rs:7:4 @@ -89,13 +89,13 @@ help: provide an argument of the correct type LL | two_arg_diff(1, {f32}); | ^^^^^^^^^^^^^^^^^^^^^^ -error[E0059]: arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:20:3 | LL | two_arg_diff("", 1.0); | ^^^^^^^^^^^^^--^^^^^^ | | - | expected i32, found &'static str + | expected `i32`, found `&'static str` | note: function defined here --> $DIR/invalid_arguments.rs:7:4 @@ -107,14 +107,14 @@ help: provide an argument of the correct type LL | two_arg_diff({i32}, 1.0); | ^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0059]: multiple arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:21:3 | LL | two_arg_diff("", ""); | ^^^^^^^^^^^^^--^^^^^ | | - | expected i32, found &'static str - | expected f32, found &'static str + | expected `i32`, found `&'static str` + | expected `f32`, found `&'static str` | note: function defined here --> $DIR/invalid_arguments.rs:7:4 @@ -126,13 +126,13 @@ help: did you mean LL | two_arg_diff({i32}, {f32}); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0059]: arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:24:3 | LL | three_arg_diff(X{}, 1.0, ""); | ^^^^^^^^^^^^^^^---^^^^^^^^^^ | | - | expected i32, found X + | expected `i32`, found `X` | note: function defined here --> $DIR/invalid_arguments.rs:8:4 @@ -144,13 +144,13 @@ help: provide an argument of the correct type LL | three_arg_diff({i32}, 1.0, ""); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0059]: arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:25:3 | LL | three_arg_diff(1, X {}, ""); | ^^^^^^^^^^^^^^^-^^^^^^^^^^^ | | - | expected f32, found i32 + | expected `f32`, found `i32` | note: function defined here --> $DIR/invalid_arguments.rs:8:4 @@ -162,13 +162,13 @@ help: provide an argument of the correct type LL | three_arg_diff(1, {f32}, ""); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0059]: arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:26:3 | LL | three_arg_diff(1, 1.0, X {}); | ^^^^^^^^^^^^^^^-^^^^^^^^^^^^ | | - | expected &str, found i32 + | expected `&str`, found `i32` | note: function defined here --> $DIR/invalid_arguments.rs:8:4 @@ -180,14 +180,14 @@ help: provide an argument of the correct type LL | three_arg_diff(1, 1.0, {&str}); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0059]: multiple arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:28:3 | LL | three_arg_diff(X {}, X {}, ""); | ^^^^^^^^^^^^^^^----^^^^^^^^^^^ | | - | expected i32, found X - | expected f32, found X + | expected `i32`, found `X` + | expected `f32`, found `X` | note: function defined here --> $DIR/invalid_arguments.rs:8:4 @@ -199,14 +199,14 @@ help: did you mean LL | three_arg_diff({i32}, {f32}, ""); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0059]: multiple arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:29:3 | LL | three_arg_diff(X {}, 1.0, X {}); | ^^^^^^^^^^^^^^^----^^^^^^^^^^^^ | | - | expected i32, found X - | expected &str, found X + | expected `i32`, found `X` + | expected `&str`, found `X` | note: function defined here --> $DIR/invalid_arguments.rs:8:4 @@ -218,14 +218,14 @@ help: did you mean LL | three_arg_diff({i32}, 1.0, {&str}); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0059]: multiple arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:30:3 | LL | three_arg_diff(1, X {}, X {}); | ^^^^^^^^^^^^^^^-^^^^^^^^^^^^^ | | - | expected f32, found i32 - | expected &str, found i32 + | expected `f32`, found `i32` + | expected `&str`, found `i32` | note: function defined here --> $DIR/invalid_arguments.rs:8:4 @@ -237,15 +237,15 @@ help: did you mean LL | three_arg_diff(1, {f32}, {&str}); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0059]: multiple arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:32:3 | LL | three_arg_diff(X {}, X {}, X {}); | ^^^^^^^^^^^^^^^----^^^^^^^^^^^^^ | | - | expected i32, found X - | expected f32, found X - | expected &str, found X + | expected `i32`, found `X` + | expected `f32`, found `X` + | expected `&str`, found `X` | note: function defined here --> $DIR/invalid_arguments.rs:8:4 @@ -257,13 +257,13 @@ help: did you mean LL | three_arg_diff({i32}, {f32}, {&str}); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0059]: arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:34:3 | LL | three_arg_repeat(X {}, 1, ""); | ^^^^^^^^^^^^^^^^^----^^^^^^^^ | | - | expected i32, found X + | expected `i32`, found `X` | note: function defined here --> $DIR/invalid_arguments.rs:9:4 @@ -275,13 +275,13 @@ help: provide an argument of the correct type LL | three_arg_repeat({i32}, 1, ""); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0059]: arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:35:3 | LL | three_arg_repeat(1, X {}, ""); | ^^^^^^^^^^^^^^^^^-^^^^^^^^^^^ | | - | expected i32, found i32 + | expected `i32`, found `i32` | note: function defined here --> $DIR/invalid_arguments.rs:9:4 @@ -293,13 +293,13 @@ help: provide an argument of the correct type LL | three_arg_repeat(1, {i32}, ""); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0059]: arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:36:3 | LL | three_arg_repeat(1, 1, X {}); | ^^^^^^^^^^^^^^^^^-^^^^^^^^^^ | | - | expected &str, found i32 + | expected `&str`, found `i32` | note: function defined here --> $DIR/invalid_arguments.rs:9:4 @@ -311,14 +311,14 @@ help: provide an argument of the correct type LL | three_arg_repeat(1, 1, {&str}); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0059]: multiple arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:38:3 | LL | three_arg_repeat(X {}, X {}, ""); | ^^^^^^^^^^^^^^^^^----^^^^^^^^^^^ | | - | expected i32, found X - | expected i32, found X + | expected `i32`, found `X` + | expected `i32`, found `X` | note: function defined here --> $DIR/invalid_arguments.rs:9:4 @@ -330,14 +330,14 @@ help: did you mean LL | three_arg_repeat({i32}, {i32}, ""); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0059]: multiple arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:39:3 | LL | three_arg_repeat(X {}, 1, X {}); | ^^^^^^^^^^^^^^^^^----^^^^^^^^^^ | | - | expected i32, found X - | expected &str, found X + | expected `i32`, found `X` + | expected `&str`, found `X` | note: function defined here --> $DIR/invalid_arguments.rs:9:4 @@ -349,14 +349,14 @@ help: did you mean LL | three_arg_repeat({i32}, 1, {&str}); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0059]: multiple arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:40:3 | LL | three_arg_repeat(1, X {}, X{}); | ^^^^^^^^^^^^^^^^^-^^^^^^^^^^^^ | | - | expected i32, found i32 - | expected &str, found i32 + | expected `i32`, found `i32` + | expected `&str`, found `i32` | note: function defined here --> $DIR/invalid_arguments.rs:9:4 @@ -368,15 +368,15 @@ help: did you mean LL | three_arg_repeat(1, {i32}, {&str}); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0059]: multiple arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:42:3 | LL | three_arg_repeat(X {}, X {}, X {}); | ^^^^^^^^^^^^^^^^^----^^^^^^^^^^^^^ | | - | expected i32, found X - | expected i32, found X - | expected &str, found X + | expected `i32`, found `X` + | expected `i32`, found `X` + | expected `&str`, found `X` | note: function defined here --> $DIR/invalid_arguments.rs:9:4 @@ -390,4 +390,4 @@ LL | three_arg_repeat({i32}, {i32}, {&str}); error: aborting due to 21 previous errors -For more information about this error, try `rustc --explain E0059`. +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/argument-suggestions/missing_arguments.stderr b/src/test/ui/argument-suggestions/missing_arguments.stderr index c5f50a0e8f4cb..30cbcc08ed7e2 100644 --- a/src/test/ui/argument-suggestions/missing_arguments.stderr +++ b/src/test/ui/argument-suggestions/missing_arguments.stderr @@ -1,4 +1,4 @@ -error[E0059]: arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/missing_arguments.rs:10:3 | LL | one_arg(); @@ -14,7 +14,7 @@ help: provide the argument LL | one_arg({i32}); | ^^^^^^^^^^^^^^ -error[E0059]: multiple arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/missing_arguments.rs:14:3 | LL | two_same( ); @@ -33,7 +33,7 @@ help: did you mean LL | two_same({i32}, {i32}); | ^^^^^^^^^^^^^^^^^^^^^^ -error[E0059]: arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/missing_arguments.rs:15:3 | LL | two_same( 1 ); @@ -49,7 +49,7 @@ help: provide the argument LL | two_same(1, {i32}); | ^^^^^^^^^^^^^^^^^^ -error[E0059]: multiple arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/missing_arguments.rs:16:3 | LL | two_diff( ); @@ -68,7 +68,7 @@ help: did you mean LL | two_diff({i32}, {f32}); | ^^^^^^^^^^^^^^^^^^^^^^ -error[E0059]: arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/missing_arguments.rs:17:3 | LL | two_diff( 1 ); @@ -84,7 +84,7 @@ help: provide the argument LL | two_diff(1, {f32}); | ^^^^^^^^^^^^^^^^^^ -error[E0059]: arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/missing_arguments.rs:18:3 | LL | two_diff( 1.0 ); @@ -102,7 +102,7 @@ help: provide the argument LL | two_diff({i32}, 1.0); | ^^^^^^^^^^^^^^^^^^^^ -error[E0059]: multiple arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/missing_arguments.rs:21:3 | LL | three_same( ); @@ -122,7 +122,7 @@ help: did you mean LL | three_same({i32}, {i32}, {i32}); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0059]: multiple arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/missing_arguments.rs:22:3 | LL | three_same( 1 ); @@ -141,7 +141,7 @@ help: did you mean LL | three_same(1, {i32}, {i32}); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0059]: arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/missing_arguments.rs:23:3 | LL | three_same( 1, 1 ); @@ -157,7 +157,7 @@ help: provide the argument LL | three_same(1, 1, {i32}); | ^^^^^^^^^^^^^^^^^^^^^^^ -error[E0059]: arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/missing_arguments.rs:26:3 | LL | three_diff( 1.0, "" ); @@ -175,7 +175,7 @@ help: provide the argument LL | three_diff({i32}, 1.0, ""); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0059]: arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/missing_arguments.rs:27:3 | LL | three_diff( 1, "" ); @@ -193,7 +193,7 @@ help: provide the argument LL | three_diff(1, {f32}, ""); | ^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0059]: arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/missing_arguments.rs:28:3 | LL | three_diff( 1, 1.0 ); @@ -209,7 +209,7 @@ help: provide the argument LL | three_diff(1, 1.0, {&str}); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0059]: multiple arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/missing_arguments.rs:29:3 | LL | three_diff( "" ); @@ -228,7 +228,7 @@ help: did you mean LL | three_diff({i32}, {f32}, ""); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0059]: multiple arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/missing_arguments.rs:30:3 | LL | three_diff( 1.0 ); @@ -247,7 +247,7 @@ help: did you mean LL | three_diff({i32}, 1.0, {&str}); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0059]: multiple arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/missing_arguments.rs:31:3 | LL | three_diff( 1 ); @@ -266,7 +266,7 @@ help: did you mean LL | three_diff(1, {f32}, {&str}); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0059]: multiple arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/missing_arguments.rs:34:3 | LL | four_repeated( ); @@ -287,7 +287,7 @@ help: did you mean LL | four_repeated({i32}, {f32}, {f32}, {&str}); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0059]: multiple arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/missing_arguments.rs:35:3 | LL | four_repeated( 1, "" ); @@ -306,7 +306,7 @@ help: did you mean LL | four_repeated(1, {f32}, {f32}, ""); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0059]: multiple arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/missing_arguments.rs:38:3 | LL | complex( ); @@ -328,7 +328,7 @@ help: did you mean LL | complex({i32}, {f32}, {i32}, {f32}, {&str}); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0059]: multiple arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/missing_arguments.rs:39:3 | LL | complex( 1, "" ); @@ -350,4 +350,4 @@ LL | complex(1, {f32}, {i32}, {f32}, ""); error: aborting due to 19 previous errors -For more information about this error, try `rustc --explain E0059`. +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/argument-suggestions/mixed_cases.stderr b/src/test/ui/argument-suggestions/mixed_cases.stderr index fe221abc242af..f592ea5e804f9 100644 --- a/src/test/ui/argument-suggestions/mixed_cases.stderr +++ b/src/test/ui/argument-suggestions/mixed_cases.stderr @@ -1,10 +1,10 @@ -error[E0059]: multiple arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/mixed_cases.rs:10:3 | LL | two_args(1, "", X {}); | ^^^^^^^^^-^^^^^^^^^^^ | | - | expected f32, found i32 + | expected `f32`, found `i32` | argument of type i32 unexpected | note: function defined here @@ -17,7 +17,7 @@ help: did you mean LL | two_args(1, {f32}); | ^^^^^^^^^^^^^^^^^^ -error[E0059]: multiple arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/mixed_cases.rs:11:3 | LL | three_args(1, "", X {}, ""); @@ -37,13 +37,13 @@ help: did you mean LL | three_args(1, {f32}, ""); | ^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0059]: multiple arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/mixed_cases.rs:14:3 | LL | three_args(1, X {}); | ^^^^^^^^^^^-^^^^^^^ | | | - | | expected f32, found i32 + | | expected `f32`, found `i32` | an argument of type &str is missing | note: function defined here @@ -56,7 +56,7 @@ help: did you mean LL | three_args(1, {f32}, {&str}); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0059]: multiple arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/mixed_cases.rs:17:3 | LL | three_args(1, "", X {}); @@ -75,15 +75,15 @@ help: did you mean LL | three_args(1, {f32}, ""); | ^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0059]: multiple arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/mixed_cases.rs:20:3 | LL | three_args("", X {}, 1); | ^^^^^^^^^^^--^^^^^^^^-^ | | | - | | expected &str,found {integer} - | expected i32,found &'static str - | expected f32, found &'static str + | | expected `&str`,found `{integer}` + | expected `i32`,found `&'static str` + | expected `f32`, found `&'static str` | note: function defined here --> $DIR/mixed_cases.rs:6:4 @@ -95,15 +95,15 @@ help: did you mean LL | three_args(1, {f32}, ""); | ^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0059]: multiple arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/mixed_cases.rs:23:3 | LL | three_args("", 1); | ^^^^^^^^^^^--^^-^ | | | | | an argument of type f32 is missing - | | expected &str,found {integer} - | expected i32,found &'static str + | | expected `&str`,found `{integer}` + | expected `i32`,found `&'static str` | note: function defined here --> $DIR/mixed_cases.rs:6:4 @@ -117,4 +117,4 @@ LL | three_args(1, {f32}, ""); error: aborting due to 6 previous errors -For more information about this error, try `rustc --explain E0059`. +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/argument-suggestions/permuted_arguments.stderr b/src/test/ui/argument-suggestions/permuted_arguments.stderr index 85b6e86bb5c5b..241489f56a55e 100644 --- a/src/test/ui/argument-suggestions/permuted_arguments.stderr +++ b/src/test/ui/argument-suggestions/permuted_arguments.stderr @@ -1,12 +1,12 @@ -error[E0059]: multiple arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/permuted_arguments.rs:10:3 | LL | three_args(1.0, "", 1); | ^^^^^^^^^^^---^^--^^-^ | | | | - | | | expected &str,found {integer} - | | expected f32,found &'static str - | expected i32,found {float} + | | | expected `&str`,found `{integer}` + | | expected `f32`,found `&'static str` + | expected `i32`,found `{float}` | note: function defined here --> $DIR/permuted_arguments.rs:5:4 @@ -18,17 +18,17 @@ help: reorder these arguments LL | three_args(1, 1.0, ""); | ^^^^^^^^^^^^^^^^^^^^^^ -error[E0059]: multiple arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/permuted_arguments.rs:12:3 | LL | many_args(X {}, Y {}, 1, 1.0, ""); | ^^^^^^^^^^----^^----^^-^^---^^--^ | | | | | | - | | | | | expected Y,found &'static str - | | | | expected X,found {float} - | | | expected &str,found {integer} - | | expected f32,found Y - | expected i32,found X + | | | | | expected `Y`,found `&'static str` + | | | | expected `X`,found `{float}` + | | | expected `&str`,found `{integer}` + | | expected `f32`,found `Y` + | expected `i32`,found `X` | note: function defined here --> $DIR/permuted_arguments.rs:6:4 @@ -42,4 +42,4 @@ LL | many_args(1, 1.0, "", X {}, Y {}); error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0059`. +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/argument-suggestions/swapped_arguments.stderr b/src/test/ui/argument-suggestions/swapped_arguments.stderr index 9d0cae48641fa..7f318ae2c9d37 100644 --- a/src/test/ui/argument-suggestions/swapped_arguments.stderr +++ b/src/test/ui/argument-suggestions/swapped_arguments.stderr @@ -1,11 +1,11 @@ -error[E0059]: multiple arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/swapped_arguments.rs:8:3 | LL | two_args(1.0, 1); | ^^^^^^^^^---^^-^ | | | - | | expected f32,found {integer} - | expected i32,found {float} + | | expected `f32`,found `{integer}` + | expected `i32`,found `{float}` | note: function defined here --> $DIR/swapped_arguments.rs:3:4 @@ -17,14 +17,14 @@ help: swap these arguments LL | two_args(1, 1.0); | ^^^^^^^^^^^^^^^^ -error[E0059]: multiple arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/swapped_arguments.rs:9:3 | LL | three_args(1.0, 1, ""); | ^^^^^^^^^^^---^^^^-^^^^^^ | | | - | | expected f32,found {integer} - | expected i32,found {float} + | | expected `f32`,found `{integer}` + | expected `i32`,found `{float}` | note: function defined here --> $DIR/swapped_arguments.rs:4:4 @@ -36,14 +36,14 @@ help: swap these arguments LL | three_args(1, 1.0, ""); | ^^^^^^^^^^^^^^^^^^^^^^ -error[E0059]: multiple arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/swapped_arguments.rs:10:3 | LL | three_args( 1, "", 1.0); | ^^^^^^^^^^^^^^^^^--^^---^ | | | - | | expected &str,found {float} - | expected f32,found &'static str + | | expected `&str`,found `{float}` + | expected `f32`,found `&'static str` | note: function defined here --> $DIR/swapped_arguments.rs:4:4 @@ -55,14 +55,14 @@ help: swap these arguments LL | three_args(1, 1.0, ""); | ^^^^^^^^^^^^^^^^^^^^^^ -error[E0059]: multiple arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/swapped_arguments.rs:11:3 | LL | three_args( "", 1.0, 1); | ^^^^^^^^^^^^--^^^^^^^^^-^ | | | - | | expected &str,found {integer} - | expected i32,found &'static str + | | expected `&str`,found `{integer}` + | expected `i32`,found `&'static str` | note: function defined here --> $DIR/swapped_arguments.rs:4:4 @@ -74,16 +74,16 @@ help: swap these arguments LL | three_args(1, 1.0, ""); | ^^^^^^^^^^^^^^^^^^^^^^ -error[E0059]: multiple arguments to this function are incorrect +error[E0308]: arguments to this function are incorrect --> $DIR/swapped_arguments.rs:13:3 | LL | four_args(1.0, 1, X {}, ""); | ^^^^^^^^^^---^^-^^----^^--^ | | | | | - | | | | expected X,found &'static str - | | | expected &str,found X - | | expected f32,found {integer} - | expected i32,found {float} + | | | | expected `X`,found `&'static str` + | | | expected `&str`,found `X` + | | expected `f32`,found `{integer}` + | expected `i32`,found `{float}` | note: function defined here --> $DIR/swapped_arguments.rs:5:4 @@ -97,4 +97,4 @@ LL | four_args(1, 1.0, "", X {}); error: aborting due to 5 previous errors -For more information about this error, try `rustc --explain E0059`. +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/associated-types/associated-type-projection-from-supertrait.rs b/src/test/ui/associated-types/associated-type-projection-from-supertrait.rs index 7e05bcd309a4f..f807427bb09cf 100644 --- a/src/test/ui/associated-types/associated-type-projection-from-supertrait.rs +++ b/src/test/ui/associated-types/associated-type-projection-from-supertrait.rs @@ -24,13 +24,13 @@ impl Car for ModelU { } fn dent(c: C, color: C::Color) { c.chip_paint(color) } fn a() { dent(ModelT, Black); } -fn b() { dent(ModelT, Blue); } //~ ERROR mismatched types -fn c() { dent(ModelU, Black); } //~ ERROR mismatched types +fn b() { dent(ModelT, Blue); } //~ ERROR arguments to this function are incorrect +fn c() { dent(ModelU, Black); } //~ ERROR arguments to this function are incorrect fn d() { dent(ModelU, Blue); } fn e() { ModelT.chip_paint(Black); } -fn f() { ModelT.chip_paint(Blue); } //~ ERROR mismatched types -fn g() { ModelU.chip_paint(Black); } //~ ERROR mismatched types +fn f() { ModelT.chip_paint(Blue); } //~ ERROR arguments to this function are incorrect +fn g() { ModelU.chip_paint(Black); } //~ ERROR arguments to this function are incorrect fn h() { ModelU.chip_paint(Blue); } pub fn main() { } diff --git a/src/test/ui/associated-types/associated-type-projection-from-supertrait.stderr b/src/test/ui/associated-types/associated-type-projection-from-supertrait.stderr index 07f207627f4df..9b4bfe00f8bd5 100644 --- a/src/test/ui/associated-types/associated-type-projection-from-supertrait.stderr +++ b/src/test/ui/associated-types/associated-type-projection-from-supertrait.stderr @@ -1,26 +1,70 @@ -error[E0308]: mismatched types - --> $DIR/associated-type-projection-from-supertrait.rs:27:23 +error[E0308]: arguments to this function are incorrect + --> $DIR/associated-type-projection-from-supertrait.rs:27:10 | LL | fn b() { dent(ModelT, Blue); } - | ^^^^ expected struct `Black`, found struct `Blue` + | ^^^^^------^^^^^^^ + | | + | expected `_`, found `ModelT` + | +note: function defined here + --> $DIR/associated-type-projection-from-supertrait.rs:25:4 + | +LL | fn dent(c: C, color: C::Color) { c.chip_paint(color) } + | ^^^^ ---- --------------- +help: provide an argument of the correct type + | +LL | fn b() { dent(ModelT, {Black}); } + | ^^^^^^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/associated-type-projection-from-supertrait.rs:28:23 +error[E0308]: arguments to this function are incorrect + --> $DIR/associated-type-projection-from-supertrait.rs:28:10 | LL | fn c() { dent(ModelU, Black); } - | ^^^^^ expected struct `Blue`, found struct `Black` + | ^^^^^------^^^^^^^^ + | | + | expected `_`, found `ModelU` + | +note: function defined here + --> $DIR/associated-type-projection-from-supertrait.rs:25:4 + | +LL | fn dent(c: C, color: C::Color) { c.chip_paint(color) } + | ^^^^ ---- --------------- +help: provide an argument of the correct type + | +LL | fn c() { dent(ModelU, {Blue}); } + | ^^^^^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/associated-type-projection-from-supertrait.rs:32:28 +error[E0308]: arguments to this function are incorrect + --> $DIR/associated-type-projection-from-supertrait.rs:32:17 | LL | fn f() { ModelT.chip_paint(Blue); } - | ^^^^ expected struct `Black`, found struct `Blue` + | ^^^^^^^^^^ ---- expected `Black`, found `Blue` + | +note: associated function defined here + --> $DIR/associated-type-projection-from-supertrait.rs:12:8 + | +LL | fn chip_paint(&self, c: Self::Color) { } + | ^^^^^^^^^^ ----- -------------- +help: provide an argument of the correct type + | +LL | fn f() { ModelT.chip_paint({Black})(Blue); } + | ^^^^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/associated-type-projection-from-supertrait.rs:33:28 +error[E0308]: arguments to this function are incorrect + --> $DIR/associated-type-projection-from-supertrait.rs:33:17 | LL | fn g() { ModelU.chip_paint(Black); } - | ^^^^^ expected struct `Blue`, found struct `Black` + | ^^^^^^^^^^ ----- expected `Blue`, found `Black` + | +note: associated function defined here + --> $DIR/associated-type-projection-from-supertrait.rs:12:8 + | +LL | fn chip_paint(&self, c: Self::Color) { } + | ^^^^^^^^^^ ----- -------------- +help: provide an argument of the correct type + | +LL | fn g() { ModelU.chip_paint({Blue})(Black); } + | ^^^^^^^^^^^^^^^^^^ error: aborting due to 4 previous errors diff --git a/src/test/ui/associated-types/associated-types-path-2.rs b/src/test/ui/associated-types/associated-types-path-2.rs index c993e1d27202d..4d943389f4d97 100644 --- a/src/test/ui/associated-types/associated-types-path-2.rs +++ b/src/test/ui/associated-types/associated-types-path-2.rs @@ -17,7 +17,7 @@ pub fn f2(a: T) -> T::A { pub fn f1_int_int() { f1(2i32, 4i32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `u32`, found `i32` } diff --git a/src/test/ui/associated-types/associated-types-path-2.stderr b/src/test/ui/associated-types/associated-types-path-2.stderr index 0881258aca1ac..3eddc5078c59b 100644 --- a/src/test/ui/associated-types/associated-types-path-2.stderr +++ b/src/test/ui/associated-types/associated-types-path-2.stderr @@ -1,13 +1,20 @@ -error[E0308]: mismatched types - --> $DIR/associated-types-path-2.rs:19:14 +error[E0308]: arguments to this function are incorrect + --> $DIR/associated-types-path-2.rs:19:5 | LL | f1(2i32, 4i32); - | ^^^^ expected `u32`, found `i32` + | ^^^----^^^^^^^ + | | + | expected `_`, found `i32` + | +note: function defined here + --> $DIR/associated-types-path-2.rs:13:8 | -help: change the type of the numeric literal from `i32` to `u32` +LL | pub fn f1(a: T, x: T::A) {} + | ^^ ---- ------- +help: provide an argument of the correct type | -LL | f1(2i32, 4u32); - | ^^^^ +LL | f1(2i32, {u32}); + | ^^^^^^^^^^^^^^^ error[E0277]: the trait bound `u32: Foo` is not satisfied --> $DIR/associated-types-path-2.rs:29:5 diff --git a/src/test/ui/async-await/dont-suggest-missing-await.rs b/src/test/ui/async-await/dont-suggest-missing-await.rs index a8e5b38ec1dd8..c7d70c4bcf63b 100644 --- a/src/test/ui/async-await/dont-suggest-missing-await.rs +++ b/src/test/ui/async-await/dont-suggest-missing-await.rs @@ -12,7 +12,7 @@ async fn dont_suggest_await_in_closure() { || { let x = make_u32(); take_u32(x) - //~^ ERROR mismatched types [E0308] + //~^ ERROR arguments to this function are incorrect [E0308] }; } diff --git a/src/test/ui/async-await/dont-suggest-missing-await.stderr b/src/test/ui/async-await/dont-suggest-missing-await.stderr index 14e72c2b1e7e2..275d96cd0e992 100644 --- a/src/test/ui/async-await/dont-suggest-missing-await.stderr +++ b/src/test/ui/async-await/dont-suggest-missing-await.stderr @@ -1,18 +1,20 @@ -error[E0308]: mismatched types - --> $DIR/dont-suggest-missing-await.rs:14:18 +error[E0308]: arguments to this function are incorrect + --> $DIR/dont-suggest-missing-await.rs:14:9 | -LL | async fn make_u32() -> u32 { - | --- the `Output` of this `async fn`'s found opaque type -... LL | take_u32(x) - | ^ expected `u32`, found opaque type + | ^^^^^^^^^-^ + | | + | expected `u32`, found `impl Future` | - = note: expected type `u32` - found opaque type `impl Future` -help: consider `await`ing on the `Future` +note: function defined here + --> $DIR/dont-suggest-missing-await.rs:5:4 + | +LL | fn take_u32(x: u32) {} + | ^^^^^^^^ ------ +help: provide an argument of the correct type + | +LL | take_u32({u32}) | -LL | take_u32(x.await) - | ^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/async-await/suggest-missing-await-closure.fixed b/src/test/ui/async-await/suggest-missing-await-closure.fixed index febcd02184261..27e09082641f6 100644 --- a/src/test/ui/async-await/suggest-missing-await-closure.fixed +++ b/src/test/ui/async-await/suggest-missing-await-closure.fixed @@ -13,8 +13,8 @@ async fn make_u32() -> u32 { async fn suggest_await_in_async_closure() { async || { let x = make_u32(); - take_u32(x.await) - //~^ ERROR mismatched types [E0308] + take_u32({u32}) + //~^ ERROR arguments to this function are incorrect [E0308] //~| HELP consider `await`ing on the `Future` //~| SUGGESTION .await }; diff --git a/src/test/ui/async-await/suggest-missing-await-closure.rs b/src/test/ui/async-await/suggest-missing-await-closure.rs index faabf6ee3f16f..1d44d51c52690 100644 --- a/src/test/ui/async-await/suggest-missing-await-closure.rs +++ b/src/test/ui/async-await/suggest-missing-await-closure.rs @@ -14,7 +14,7 @@ async fn suggest_await_in_async_closure() { async || { let x = make_u32(); take_u32(x) - //~^ ERROR mismatched types [E0308] + //~^ ERROR arguments to this function are incorrect [E0308] //~| HELP consider `await`ing on the `Future` //~| SUGGESTION .await }; diff --git a/src/test/ui/async-await/suggest-missing-await-closure.stderr b/src/test/ui/async-await/suggest-missing-await-closure.stderr index 2151057aa7fc0..62e2b4e186b5a 100644 --- a/src/test/ui/async-await/suggest-missing-await-closure.stderr +++ b/src/test/ui/async-await/suggest-missing-await-closure.stderr @@ -1,18 +1,20 @@ -error[E0308]: mismatched types - --> $DIR/suggest-missing-await-closure.rs:16:18 +error[E0308]: arguments to this function are incorrect + --> $DIR/suggest-missing-await-closure.rs:16:9 | -LL | async fn make_u32() -> u32 { - | --- the `Output` of this `async fn`'s found opaque type -... LL | take_u32(x) - | ^ expected `u32`, found opaque type + | ^^^^^^^^^-^ + | | + | expected `u32`, found `impl Future` | - = note: expected type `u32` - found opaque type `impl Future` -help: consider `await`ing on the `Future` +note: function defined here + --> $DIR/suggest-missing-await-closure.rs:6:4 + | +LL | fn take_u32(_x: u32) {} + | ^^^^^^^^ ------- +help: provide an argument of the correct type + | +LL | take_u32({u32}) | -LL | take_u32(x.await) - | ^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/async-await/suggest-missing-await.rs b/src/test/ui/async-await/suggest-missing-await.rs index d629054911dac..eba53562fe3be 100644 --- a/src/test/ui/async-await/suggest-missing-await.rs +++ b/src/test/ui/async-await/suggest-missing-await.rs @@ -10,7 +10,7 @@ async fn make_u32() -> u32 { async fn suggest_await_in_async_fn() { let x = make_u32(); take_u32(x) - //~^ ERROR mismatched types [E0308] + //~^ ERROR arguments to this function are incorrect [E0308] //~| HELP consider `await`ing on the `Future` //~| SUGGESTION .await } @@ -20,7 +20,7 @@ async fn dummy() {} #[allow(unused)] async fn suggest_await_in_async_fn_return() { dummy() - //~^ ERROR mismatched types [E0308] + //~^ ERROR arguments to this function are incorrect [E0308] //~| HELP try adding a semicolon //~| HELP consider `await`ing on the `Future` //~| SUGGESTION .await diff --git a/src/test/ui/async-await/suggest-missing-await.stderr b/src/test/ui/async-await/suggest-missing-await.stderr index 46615dae7e2ba..691aa2f2cbae8 100644 --- a/src/test/ui/async-await/suggest-missing-await.stderr +++ b/src/test/ui/async-await/suggest-missing-await.stderr @@ -1,18 +1,20 @@ -error[E0308]: mismatched types - --> $DIR/suggest-missing-await.rs:12:14 +error[E0308]: arguments to this function are incorrect + --> $DIR/suggest-missing-await.rs:12:5 | -LL | async fn make_u32() -> u32 { - | --- the `Output` of this `async fn`'s found opaque type -... LL | take_u32(x) - | ^ expected `u32`, found opaque type + | ^^^^^^^^^-^ + | | + | expected `u32`, found `impl Future` | - = note: expected type `u32` - found opaque type `impl Future` -help: consider `await`ing on the `Future` +note: function defined here + --> $DIR/suggest-missing-await.rs:3:4 + | +LL | fn take_u32(_x: u32) {} + | ^^^^^^^^ ------- +help: provide an argument of the correct type + | +LL | take_u32({u32}) | -LL | take_u32(x.await) - | ^^^^^^ error[E0308]: mismatched types --> $DIR/suggest-missing-await.rs:22:5 diff --git a/src/test/ui/c-variadic/variadic-ffi-1.rs b/src/test/ui/c-variadic/variadic-ffi-1.rs index a7824d919674d..1f69521a9764b 100644 --- a/src/test/ui/c-variadic/variadic-ffi-1.rs +++ b/src/test/ui/c-variadic/variadic-ffi-1.rs @@ -17,8 +17,10 @@ fn main() { foo(); //~ ERROR this function takes at least 2 arguments but 0 arguments were supplied foo(1); //~ ERROR this function takes at least 2 arguments but 1 argument was supplied - let x: unsafe extern "C" fn(f: isize, x: u8) = foo; //~ ERROR mismatched types - let y: extern "C" fn(f: isize, x: u8, ...) = bar; //~ ERROR mismatched types + let x: unsafe extern "C" fn(f: isize, x: u8) = foo; + //~^ ERROR arguments to this function are incorrect + let y: extern "C" fn(f: isize, x: u8, ...) = bar; + //~^ ERROR arguments to this function are incorrect foo(1, 2, 3f32); //~ ERROR can't pass foo(1, 2, true); //~ ERROR can't pass diff --git a/src/test/ui/c-variadic/variadic-ffi-1.stderr b/src/test/ui/c-variadic/variadic-ffi-1.stderr index 6f2a6c359b537..ec8e53f97349a 100644 --- a/src/test/ui/c-variadic/variadic-ffi-1.stderr +++ b/src/test/ui/c-variadic/variadic-ffi-1.stderr @@ -4,33 +4,40 @@ error[E0045]: C-variadic function must have C or cdecl calling convention LL | fn printf(_: *const u8, ...); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadics require C or cdecl calling convention -error[E0060]: this function takes at least 2 arguments but 0 arguments were supplied +error[E0308]: arguments to this function are incorrect --> $DIR/variadic-ffi-1.rs:17:9 | LL | foo(); - | ^^^-- supplied 0 arguments + | ^^^^^ | | - | expected at least 2 arguments + | an argument of type isize is missing + | an argument of type u8 is missing | note: function defined here --> $DIR/variadic-ffi-1.rs:10:8 | LL | fn foo(f: isize, x: u8, ...); | ^^^ +help: did you mean + | +LL | foo({isize}, {u8}); + | ^^^^^^^^^^^^^^^^^^ -error[E0060]: this function takes at least 2 arguments but 1 argument was supplied +error[E0308]: arguments to this function are incorrect --> $DIR/variadic-ffi-1.rs:18:9 | LL | foo(1); - | ^^^ - supplied 1 argument - | | - | expected at least 2 arguments + | ^^^^^^ an argument of type u8 is missing | note: function defined here --> $DIR/variadic-ffi-1.rs:10:8 | LL | fn foo(f: isize, x: u8, ...); | ^^^ +help: provide the argument + | +LL | foo(1, {u8}); + | ^^^^^^^^^^^^ error[E0308]: mismatched types --> $DIR/variadic-ffi-1.rs:20:56 @@ -44,7 +51,7 @@ LL | let x: unsafe extern "C" fn(f: isize, x: u8) = foo; found fn item `unsafe extern "C" fn(_, _, ...) {foo}` error[E0308]: mismatched types - --> $DIR/variadic-ffi-1.rs:21:54 + --> $DIR/variadic-ffi-1.rs:22:54 | LL | let y: extern "C" fn(f: isize, x: u8, ...) = bar; | ----------------------------------- ^^^ expected variadic fn, found non-variadic function @@ -55,42 +62,42 @@ LL | let y: extern "C" fn(f: isize, x: u8, ...) = bar; found fn item `extern "C" fn(_, _) {bar}` error[E0617]: can't pass `f32` to variadic function - --> $DIR/variadic-ffi-1.rs:23:19 + --> $DIR/variadic-ffi-1.rs:25:19 | LL | foo(1, 2, 3f32); | ^^^^ help: cast the value to `c_double`: `3f32 as c_double` error[E0617]: can't pass `bool` to variadic function - --> $DIR/variadic-ffi-1.rs:24:19 + --> $DIR/variadic-ffi-1.rs:26:19 | LL | foo(1, 2, true); | ^^^^ help: cast the value to `c_int`: `true as c_int` error[E0617]: can't pass `i8` to variadic function - --> $DIR/variadic-ffi-1.rs:25:19 + --> $DIR/variadic-ffi-1.rs:27:19 | LL | foo(1, 2, 1i8); | ^^^ help: cast the value to `c_int`: `1i8 as c_int` error[E0617]: can't pass `u8` to variadic function - --> $DIR/variadic-ffi-1.rs:26:19 + --> $DIR/variadic-ffi-1.rs:28:19 | LL | foo(1, 2, 1u8); | ^^^ help: cast the value to `c_uint`: `1u8 as c_uint` error[E0617]: can't pass `i16` to variadic function - --> $DIR/variadic-ffi-1.rs:27:19 + --> $DIR/variadic-ffi-1.rs:29:19 | LL | foo(1, 2, 1i16); | ^^^^ help: cast the value to `c_int`: `1i16 as c_int` error[E0617]: can't pass `u16` to variadic function - --> $DIR/variadic-ffi-1.rs:28:19 + --> $DIR/variadic-ffi-1.rs:30:19 | LL | foo(1, 2, 1u16); | ^^^^ help: cast the value to `c_uint`: `1u16 as c_uint` error: aborting due to 11 previous errors -Some errors have detailed explanations: E0045, E0060, E0308, E0617. +Some errors have detailed explanations: E0045, E0308, E0617. For more information about an error, try `rustc --explain E0045`. diff --git a/src/test/ui/closures/closure-reform-bad.rs b/src/test/ui/closures/closure-reform-bad.rs index 0ba48ab518442..62103c50be330 100644 --- a/src/test/ui/closures/closure-reform-bad.rs +++ b/src/test/ui/closures/closure-reform-bad.rs @@ -8,5 +8,5 @@ fn call_bare(f: fn(&str)) { fn main() { let string = "world!"; let f = |s: &str| println!("{}{}", s, string); - call_bare(f) //~ ERROR mismatched types + call_bare(f) //~ ERROR arguments to this function are incorrect } diff --git a/src/test/ui/closures/closure-reform-bad.stderr b/src/test/ui/closures/closure-reform-bad.stderr index 77c8c7ab7948d..7382343f5d956 100644 --- a/src/test/ui/closures/closure-reform-bad.stderr +++ b/src/test/ui/closures/closure-reform-bad.stderr @@ -1,13 +1,20 @@ -error[E0308]: mismatched types - --> $DIR/closure-reform-bad.rs:11:15 +error[E0308]: arguments to this function are incorrect + --> $DIR/closure-reform-bad.rs:11:5 | -LL | let f = |s: &str| println!("{}{}", s, string); - | ------------------------------------- the found closure LL | call_bare(f) - | ^ expected fn pointer, found closure + | ^^^^^^^^^^-^ + | | + | expected `for<'r> fn(&'r str)`, found `[closure@$DIR/closure-reform-bad.rs:10:13: 10:50]` | - = note: expected fn pointer `for<'r> fn(&'r str)` - found closure `[closure@$DIR/closure-reform-bad.rs:10:13: 10:50]` +note: function defined here + --> $DIR/closure-reform-bad.rs:4:4 + | +LL | fn call_bare(f: fn(&str)) { + | ^^^^^^^^^ ----------- +help: provide an argument of the correct type + | +LL | call_bare({for<'r> fn(&'r str)}) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs b/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs index c139e823c2aef..6d2262d123925 100644 --- a/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs +++ b/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs @@ -6,24 +6,36 @@ use std::fmt::Debug; pub fn main() { - let _ = box { [1, 2, 3] }: Box<[i32]>; //~ ERROR mismatched types - let _ = box if true { [1, 2, 3] } else { [1, 3, 4] }: Box<[i32]>; //~ ERROR mismatched types + let _ = box { [1, 2, 3] }: Box<[i32]>; + //~^ ERROR mismatched types + let _ = box if true { [1, 2, 3] } else { [1, 3, 4] }: Box<[i32]>; + //~^ ERROR mismatched types let _ = box match true { true => [1, 2, 3], false => [1, 3, 4] }: Box<[i32]>; //~^ ERROR mismatched types - let _ = box { |x| (x as u8) }: Box _>; //~ ERROR mismatched types - let _ = box if true { false } else { true }: Box; //~ ERROR mismatched types - let _ = box match true { true => 'a', false => 'b' }: Box; //~ ERROR mismatched types + let _ = box { |x| (x as u8) }: Box _>; + //~^ ERROR mismatched types + let _ = box if true { false } else { true }: Box; + //~^ ERROR mismatched types + let _ = box match true { true => 'a', false => 'b' }: Box; + //~^ ERROR mismatched types - let _ = &{ [1, 2, 3] }: &[i32]; //~ ERROR mismatched types - let _ = &if true { [1, 2, 3] } else { [1, 3, 4] }: &[i32]; //~ ERROR mismatched types + let _ = &{ [1, 2, 3] }: &[i32]; + //~^ ERROR mismatched types + let _ = &if true { [1, 2, 3] } else { [1, 3, 4] }: &[i32]; + //~^ ERROR mismatched types let _ = &match true { true => [1, 2, 3], false => [1, 3, 4] }: &[i32]; //~^ ERROR mismatched types - let _ = &{ |x| (x as u8) }: &dyn Fn(i32) -> _; //~ ERROR mismatched types - let _ = &if true { false } else { true }: &dyn Debug; //~ ERROR mismatched types - let _ = &match true { true => 'a', false => 'b' }: &dyn Debug; //~ ERROR mismatched types + let _ = &{ |x| (x as u8) }: &dyn Fn(i32) -> _; + //~^ ERROR mismatched types + let _ = &if true { false } else { true }: &dyn Debug; + //~^ ERROR mismatched types + let _ = &match true { true => 'a', false => 'b' }: &dyn Debug; + //~^ ERROR mismatched types - let _ = Box::new([1, 2, 3]): Box<[i32]>; //~ ERROR mismatched types - let _ = Box::new(|x| (x as u8)): Box _>; //~ ERROR mismatched types + let _ = Box::new([1, 2, 3]): Box<[i32]>; + //~^ ERROR mismatched types + let _ = Box::new(|x| (x as u8)): Box _>; + //~^ ERROR mismatched types let _ = vec![ Box::new(|x| (x as u8)), diff --git a/src/test/ui/coercion/coerce-expect-unsized-ascribed.stderr b/src/test/ui/coercion/coerce-expect-unsized-ascribed.stderr index f0109f22a2bc1..d441fbf5c8b74 100644 --- a/src/test/ui/coercion/coerce-expect-unsized-ascribed.stderr +++ b/src/test/ui/coercion/coerce-expect-unsized-ascribed.stderr @@ -8,7 +8,7 @@ LL | let _ = box { [1, 2, 3] }: Box<[i32]>; found struct `Box<[i32; 3]>` error[E0308]: mismatched types - --> $DIR/coerce-expect-unsized-ascribed.rs:10:13 + --> $DIR/coerce-expect-unsized-ascribed.rs:11:13 | LL | let _ = box if true { [1, 2, 3] } else { [1, 3, 4] }: Box<[i32]>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected slice `[i32]`, found array `[i32; 3]` @@ -17,7 +17,7 @@ LL | let _ = box if true { [1, 2, 3] } else { [1, 3, 4] }: Box<[i32]>; found struct `Box<[i32; 3]>` error[E0308]: mismatched types - --> $DIR/coerce-expect-unsized-ascribed.rs:11:13 + --> $DIR/coerce-expect-unsized-ascribed.rs:13:13 | LL | let _ = box match true { true => [1, 2, 3], false => [1, 3, 4] }: Box<[i32]>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected slice `[i32]`, found array `[i32; 3]` @@ -26,16 +26,16 @@ LL | let _ = box match true { true => [1, 2, 3], false => [1, 3, 4] }: Box<[ found struct `Box<[i32; 3]>` error[E0308]: mismatched types - --> $DIR/coerce-expect-unsized-ascribed.rs:13:13 + --> $DIR/coerce-expect-unsized-ascribed.rs:15:13 | LL | let _ = box { |x| (x as u8) }: Box _>; | ^^^^^^^^^^^^^^^^^^^^^ expected trait object `dyn Fn`, found closure | = note: expected struct `Box u8>` - found struct `Box<[closure@$DIR/coerce-expect-unsized-ascribed.rs:13:19: 13:32]>` + found struct `Box<[closure@$DIR/coerce-expect-unsized-ascribed.rs:15:19: 15:32]>` error[E0308]: mismatched types - --> $DIR/coerce-expect-unsized-ascribed.rs:14:13 + --> $DIR/coerce-expect-unsized-ascribed.rs:17:13 | LL | let _ = box if true { false } else { true }: Box; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected trait object `dyn Debug`, found `bool` @@ -44,7 +44,7 @@ LL | let _ = box if true { false } else { true }: Box; found struct `Box` error[E0308]: mismatched types - --> $DIR/coerce-expect-unsized-ascribed.rs:15:13 + --> $DIR/coerce-expect-unsized-ascribed.rs:19:13 | LL | let _ = box match true { true => 'a', false => 'b' }: Box; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected trait object `dyn Debug`, found `char` @@ -53,7 +53,7 @@ LL | let _ = box match true { true => 'a', false => 'b' }: Box; found struct `Box` error[E0308]: mismatched types - --> $DIR/coerce-expect-unsized-ascribed.rs:17:13 + --> $DIR/coerce-expect-unsized-ascribed.rs:22:13 | LL | let _ = &{ [1, 2, 3] }: &[i32]; | ^^^^^^^^^^^^^^ expected slice `[i32]`, found array `[i32; 3]` @@ -62,7 +62,7 @@ LL | let _ = &{ [1, 2, 3] }: &[i32]; found reference `&[i32; 3]` error[E0308]: mismatched types - --> $DIR/coerce-expect-unsized-ascribed.rs:18:13 + --> $DIR/coerce-expect-unsized-ascribed.rs:24:13 | LL | let _ = &if true { [1, 2, 3] } else { [1, 3, 4] }: &[i32]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected slice `[i32]`, found array `[i32; 3]` @@ -71,7 +71,7 @@ LL | let _ = &if true { [1, 2, 3] } else { [1, 3, 4] }: &[i32]; found reference `&[i32; 3]` error[E0308]: mismatched types - --> $DIR/coerce-expect-unsized-ascribed.rs:19:13 + --> $DIR/coerce-expect-unsized-ascribed.rs:26:13 | LL | let _ = &match true { true => [1, 2, 3], false => [1, 3, 4] }: &[i32]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected slice `[i32]`, found array `[i32; 3]` @@ -80,16 +80,16 @@ LL | let _ = &match true { true => [1, 2, 3], false => [1, 3, 4] }: &[i32]; found reference `&[i32; 3]` error[E0308]: mismatched types - --> $DIR/coerce-expect-unsized-ascribed.rs:21:13 + --> $DIR/coerce-expect-unsized-ascribed.rs:28:13 | LL | let _ = &{ |x| (x as u8) }: &dyn Fn(i32) -> _; | ^^^^^^^^^^^^^^^^^^ expected trait object `dyn Fn`, found closure | = note: expected reference `&dyn Fn(i32) -> u8` - found reference `&[closure@$DIR/coerce-expect-unsized-ascribed.rs:21:16: 21:29]` + found reference `&[closure@$DIR/coerce-expect-unsized-ascribed.rs:28:16: 28:29]` error[E0308]: mismatched types - --> $DIR/coerce-expect-unsized-ascribed.rs:22:13 + --> $DIR/coerce-expect-unsized-ascribed.rs:30:13 | LL | let _ = &if true { false } else { true }: &dyn Debug; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected trait object `dyn Debug`, found `bool` @@ -98,7 +98,7 @@ LL | let _ = &if true { false } else { true }: &dyn Debug; found reference `&bool` error[E0308]: mismatched types - --> $DIR/coerce-expect-unsized-ascribed.rs:23:13 + --> $DIR/coerce-expect-unsized-ascribed.rs:32:13 | LL | let _ = &match true { true => 'a', false => 'b' }: &dyn Debug; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected trait object `dyn Debug`, found `char` @@ -107,7 +107,7 @@ LL | let _ = &match true { true => 'a', false => 'b' }: &dyn Debug; found reference `&char` error[E0308]: mismatched types - --> $DIR/coerce-expect-unsized-ascribed.rs:25:13 + --> $DIR/coerce-expect-unsized-ascribed.rs:35:13 | LL | let _ = Box::new([1, 2, 3]): Box<[i32]>; | ^^^^^^^^^^^^^^^^^^^ expected slice `[i32]`, found array `[i32; 3]` @@ -116,13 +116,13 @@ LL | let _ = Box::new([1, 2, 3]): Box<[i32]>; found struct `Box<[i32; 3]>` error[E0308]: mismatched types - --> $DIR/coerce-expect-unsized-ascribed.rs:26:13 + --> $DIR/coerce-expect-unsized-ascribed.rs:37:13 | LL | let _ = Box::new(|x| (x as u8)): Box _>; | ^^^^^^^^^^^^^^^^^^^^^^^ expected trait object `dyn Fn`, found closure | = note: expected struct `Box u8>` - found struct `Box<[closure@$DIR/coerce-expect-unsized-ascribed.rs:26:22: 26:35]>` + found struct `Box<[closure@$DIR/coerce-expect-unsized-ascribed.rs:37:22: 37:35]>` error: aborting due to 14 previous errors diff --git a/src/test/ui/coercion/coerce-mut.rs b/src/test/ui/coercion/coerce-mut.rs index 43f0b55856d3c..ee3756533c6e4 100644 --- a/src/test/ui/coercion/coerce-mut.rs +++ b/src/test/ui/coercion/coerce-mut.rs @@ -3,7 +3,7 @@ fn f(x: &mut i32) {} fn main() { let x = 0; f(&x); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected mutable reference `&mut i32` //~| found reference `&{integer}` //~| types differ in mutability diff --git a/src/test/ui/coercion/coerce-mut.stderr b/src/test/ui/coercion/coerce-mut.stderr index 2601ca5e91e5b..774db4e557108 100644 --- a/src/test/ui/coercion/coerce-mut.stderr +++ b/src/test/ui/coercion/coerce-mut.stderr @@ -1,11 +1,20 @@ -error[E0308]: mismatched types - --> $DIR/coerce-mut.rs:5:7 +error[E0308]: arguments to this function are incorrect + --> $DIR/coerce-mut.rs:5:5 | LL | f(&x); - | ^^ types differ in mutability + | ^^--^ + | | + | expected `&mut i32`, found `&{integer}` | - = note: expected mutable reference `&mut i32` - found reference `&{integer}` +note: function defined here + --> $DIR/coerce-mut.rs:1:4 + | +LL | fn f(x: &mut i32) {} + | ^ ----------- +help: provide an argument of the correct type + | +LL | f({&mut i32}); + | ^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/coercion/coerce-reborrow-multi-arg-fail.rs b/src/test/ui/coercion/coerce-reborrow-multi-arg-fail.rs index 48be2d3146b81..92b951b329f77 100644 --- a/src/test/ui/coercion/coerce-reborrow-multi-arg-fail.rs +++ b/src/test/ui/coercion/coerce-reborrow-multi-arg-fail.rs @@ -2,5 +2,5 @@ fn test(_a: T, _b: T) {} fn main() { test(&mut 7, &7); - //~^ mismatched types + //~^ ERROR arguments to this function are incorrect } diff --git a/src/test/ui/coercion/coerce-reborrow-multi-arg-fail.stderr b/src/test/ui/coercion/coerce-reborrow-multi-arg-fail.stderr index 59b0ec496f16f..6814ba0cdfe87 100644 --- a/src/test/ui/coercion/coerce-reborrow-multi-arg-fail.stderr +++ b/src/test/ui/coercion/coerce-reborrow-multi-arg-fail.stderr @@ -1,11 +1,20 @@ -error[E0308]: mismatched types - --> $DIR/coerce-reborrow-multi-arg-fail.rs:4:18 +error[E0308]: arguments to this function are incorrect + --> $DIR/coerce-reborrow-multi-arg-fail.rs:4:5 | LL | test(&mut 7, &7); - | ^^ types differ in mutability + | ^^^^^------^^^^^ + | | + | expected `_`, found `&mut {integer}` | - = note: expected mutable reference `&mut {integer}` - found reference `&{integer}` +note: function defined here + --> $DIR/coerce-reborrow-multi-arg-fail.rs:1:4 + | +LL | fn test(_a: T, _b: T) {} + | ^^^^ ----- ----- +help: provide an argument of the correct type + | +LL | test(&mut 7, {&mut {integer}}); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/coercion/coerce-to-bang.rs b/src/test/ui/coercion/coerce-to-bang.rs index 1e06934d09f9e..fac2bc8fe278d 100644 --- a/src/test/ui/coercion/coerce-to-bang.rs +++ b/src/test/ui/coercion/coerce-to-bang.rs @@ -4,7 +4,7 @@ fn foo(x: usize, y: !, z: usize) { } fn call_foo_a() { foo(return, 22, 44); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect } fn call_foo_b() { @@ -15,7 +15,7 @@ fn call_foo_b() { fn call_foo_c() { // This test fails because the divergence happens **after** the // coercion to `!`: - foo(22, 44, return); //~ ERROR mismatched types + foo(22, 44, return); //~ ERROR arguments to this function are incorrect } fn call_foo_d() { @@ -24,7 +24,7 @@ fn call_foo_d() { let b = 22; let c = 44; foo(a, b, c); // ... and hence a reference to `a` is expected to diverge. - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect } fn call_foo_e() { @@ -33,7 +33,7 @@ fn call_foo_e() { let a = return; let b = 22; let c = 44; - foo(a, b, c); //~ ERROR mismatched types + foo(a, b, c); //~ ERROR arguments to this function are incorrect } fn call_foo_f() { @@ -42,28 +42,29 @@ fn call_foo_f() { let a: usize = return; let b = 22; let c = 44; - foo(a, b, c); //~ ERROR mismatched types + foo(a, b, c); //~ ERROR arguments to this function are incorrect } fn array_a() { // Return is coerced to `!` just fine, but `22` cannot be. - let x: [!; 2] = [return, 22]; //~ ERROR mismatched types + let x: [!; 2] = [return, 22]; //~ ERROR arguments to this function are incorrect } fn array_b() { // Error: divergence has not yet occurred. - let x: [!; 2] = [22, return]; //~ ERROR mismatched types + let x: [!; 2] = [22, return]; //~ ERROR arguments to this function are incorrect } fn tuple_a() { // No divergence at all. - let x: (usize, !, usize) = (22, 44, 66); //~ ERROR mismatched types + let x: (usize, !, usize) = (22, 44, 66); + //~^ ERROR arguments to this function are incorrect } fn tuple_b() { // Divergence happens before coercion: OK let x: (usize, !, usize) = (return, 44, 66); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect } fn tuple_c() { @@ -73,7 +74,8 @@ fn tuple_c() { fn tuple_d() { // Error: divergence happens too late - let x: (usize, !, usize) = (22, 44, return); //~ ERROR mismatched types + let x: (usize, !, usize) = (22, 44, return); + //~^ ERROR arguments to this function are incorrect } fn main() { } diff --git a/src/test/ui/coercion/coerce-to-bang.stderr b/src/test/ui/coercion/coerce-to-bang.stderr index 390aa7c692d18..0f1a491503526 100644 --- a/src/test/ui/coercion/coerce-to-bang.stderr +++ b/src/test/ui/coercion/coerce-to-bang.stderr @@ -1,47 +1,92 @@ -error[E0308]: mismatched types - --> $DIR/coerce-to-bang.rs:6:17 +error[E0308]: arguments to this function are incorrect + --> $DIR/coerce-to-bang.rs:6:5 | LL | foo(return, 22, 44); - | ^^ expected `!`, found integer + | ^^^^------^^^^^^^^^ + | | + | expected `!`, found `!` | - = note: expected type `!` - found type `{integer}` +note: function defined here + --> $DIR/coerce-to-bang.rs:3:4 + | +LL | fn foo(x: usize, y: !, z: usize) { } + | ^^^ -------- ---- -------- +help: provide an argument of the correct type + | +LL | foo(return, {!}, 44); + | ^^^^^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/coerce-to-bang.rs:18:13 +error[E0308]: arguments to this function are incorrect + --> $DIR/coerce-to-bang.rs:18:5 | LL | foo(22, 44, return); - | ^^ expected `!`, found integer + | ^^^^--^^^^^^^^^^^^^ + | | + | expected `!`, found `usize` | - = note: expected type `!` - found type `{integer}` +note: function defined here + --> $DIR/coerce-to-bang.rs:3:4 + | +LL | fn foo(x: usize, y: !, z: usize) { } + | ^^^ -------- ---- -------- +help: provide an argument of the correct type + | +LL | foo(22, {!}, return); + | ^^^^^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/coerce-to-bang.rs:26:12 +error[E0308]: arguments to this function are incorrect + --> $DIR/coerce-to-bang.rs:26:5 | LL | foo(a, b, c); // ... and hence a reference to `a` is expected to diverge. - | ^ expected `!`, found integer + | ^^^^-^^^^^^^ + | | + | expected `!`, found `!` | - = note: expected type `!` - found type `{integer}` +note: function defined here + --> $DIR/coerce-to-bang.rs:3:4 + | +LL | fn foo(x: usize, y: !, z: usize) { } + | ^^^ -------- ---- -------- +help: provide an argument of the correct type + | +LL | foo(a, {!}, c); // ... and hence a reference to `a` is expected to diverge. + | ^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/coerce-to-bang.rs:36:12 +error[E0308]: arguments to this function are incorrect + --> $DIR/coerce-to-bang.rs:36:5 | LL | foo(a, b, c); - | ^ expected `!`, found integer + | ^^^^-^^^^^^^ + | | + | expected `!`, found `_` | - = note: expected type `!` - found type `{integer}` +note: function defined here + --> $DIR/coerce-to-bang.rs:3:4 + | +LL | fn foo(x: usize, y: !, z: usize) { } + | ^^^ -------- ---- -------- +help: provide an argument of the correct type + | +LL | foo(a, {!}, c); + | ^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/coerce-to-bang.rs:45:12 +error[E0308]: arguments to this function are incorrect + --> $DIR/coerce-to-bang.rs:45:5 | LL | foo(a, b, c); - | ^ expected `!`, found integer + | ^^^^-^^^^^^^ + | | + | expected `!`, found `usize` | - = note: expected type `!` - found type `{integer}` +note: function defined here + --> $DIR/coerce-to-bang.rs:3:4 + | +LL | fn foo(x: usize, y: !, z: usize) { } + | ^^^ -------- ---- -------- +help: provide an argument of the correct type + | +LL | foo(a, {!}, c); + | ^^^^^^^^^^^^^^ error[E0308]: mismatched types --> $DIR/coerce-to-bang.rs:50:21 @@ -73,7 +118,7 @@ LL | let x: (usize, !, usize) = (22, 44, 66); found type `{integer}` error[E0308]: mismatched types - --> $DIR/coerce-to-bang.rs:65:41 + --> $DIR/coerce-to-bang.rs:66:41 | LL | let x: (usize, !, usize) = (return, 44, 66); | ^^ expected `!`, found integer @@ -82,7 +127,7 @@ LL | let x: (usize, !, usize) = (return, 44, 66); found type `{integer}` error[E0308]: mismatched types - --> $DIR/coerce-to-bang.rs:76:37 + --> $DIR/coerce-to-bang.rs:77:37 | LL | let x: (usize, !, usize) = (22, 44, return); | ^^ expected `!`, found integer diff --git a/src/test/ui/const-generics/const-argument-cross-crate-mismatch.full.stderr b/src/test/ui/const-generics/const-argument-cross-crate-mismatch.full.stderr index a35c3abc113b9..e9854f0b9b53b 100644 --- a/src/test/ui/const-generics/const-argument-cross-crate-mismatch.full.stderr +++ b/src/test/ui/const-generics/const-argument-cross-crate-mismatch.full.stderr @@ -1,14 +1,28 @@ -error[E0308]: mismatched types - --> $DIR/const-argument-cross-crate-mismatch.rs:7:67 +error[E0308]: arguments to this function are incorrect + --> $DIR/const-argument-cross-crate-mismatch.rs:7:41 | LL | let _ = const_generic_lib::function(const_generic_lib::Struct([0u8, 1u8])); - | ^^^^^^^^^^ expected an array with a fixed size of 3 elements, found one with 2 elements + | ^^^^^^^^^^^^^^^^^^^^^^^^^^----------^ + | | + | expected `[u8; 3]`, found `[u8; 2]` + | +help: provide an argument of the correct type + | +LL | let _ = const_generic_lib::function(({[u8; 3]})); + | ^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/const-argument-cross-crate-mismatch.rs:9:65 +error[E0308]: arguments to this function are incorrect + --> $DIR/const-argument-cross-crate-mismatch.rs:9:39 | LL | let _: const_generic_lib::Alias = const_generic_lib::Struct([0u8, 1u8, 2u8]); - | ^^^^^^^^^^^^^^^ expected an array with a fixed size of 2 elements, found one with 3 elements + | ^^^^^^^^^^^^^^^^^^^^^^^^^^---------------^ + | | + | expected `[u8; 2]`, found `[u8; 3]` + | +help: provide an argument of the correct type + | +LL | let _: const_generic_lib::Alias = ({[u8; 2]}); + | ^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/const-generics/const-argument-cross-crate-mismatch.min.stderr b/src/test/ui/const-generics/const-argument-cross-crate-mismatch.min.stderr index a35c3abc113b9..e9854f0b9b53b 100644 --- a/src/test/ui/const-generics/const-argument-cross-crate-mismatch.min.stderr +++ b/src/test/ui/const-generics/const-argument-cross-crate-mismatch.min.stderr @@ -1,14 +1,28 @@ -error[E0308]: mismatched types - --> $DIR/const-argument-cross-crate-mismatch.rs:7:67 +error[E0308]: arguments to this function are incorrect + --> $DIR/const-argument-cross-crate-mismatch.rs:7:41 | LL | let _ = const_generic_lib::function(const_generic_lib::Struct([0u8, 1u8])); - | ^^^^^^^^^^ expected an array with a fixed size of 3 elements, found one with 2 elements + | ^^^^^^^^^^^^^^^^^^^^^^^^^^----------^ + | | + | expected `[u8; 3]`, found `[u8; 2]` + | +help: provide an argument of the correct type + | +LL | let _ = const_generic_lib::function(({[u8; 3]})); + | ^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/const-argument-cross-crate-mismatch.rs:9:65 +error[E0308]: arguments to this function are incorrect + --> $DIR/const-argument-cross-crate-mismatch.rs:9:39 | LL | let _: const_generic_lib::Alias = const_generic_lib::Struct([0u8, 1u8, 2u8]); - | ^^^^^^^^^^^^^^^ expected an array with a fixed size of 2 elements, found one with 3 elements + | ^^^^^^^^^^^^^^^^^^^^^^^^^^---------------^ + | | + | expected `[u8; 2]`, found `[u8; 3]` + | +help: provide an argument of the correct type + | +LL | let _: const_generic_lib::Alias = ({[u8; 2]}); + | ^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/const-generics/const-argument-cross-crate-mismatch.rs b/src/test/ui/const-generics/const-argument-cross-crate-mismatch.rs index 9ae2ae50ba0ab..f4fc6430b50bc 100644 --- a/src/test/ui/const-generics/const-argument-cross-crate-mismatch.rs +++ b/src/test/ui/const-generics/const-argument-cross-crate-mismatch.rs @@ -5,7 +5,7 @@ extern crate const_generic_lib; fn main() { let _ = const_generic_lib::function(const_generic_lib::Struct([0u8, 1u8])); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect let _: const_generic_lib::Alias = const_generic_lib::Struct([0u8, 1u8, 2u8]); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect } diff --git a/src/test/ui/const-generics/issues/issue-62504.min.stderr b/src/test/ui/const-generics/issues/issue-62504.min.stderr index 5d45e302888d4..5bb24aa203dd0 100644 --- a/src/test/ui/const-generics/issues/issue-62504.min.stderr +++ b/src/test/ui/const-generics/issues/issue-62504.min.stderr @@ -1,12 +1,3 @@ -error[E0308]: mismatched types - --> $DIR/issue-62504.rs:18:21 - | -LL | ArrayHolder([0; Self::SIZE]) - | ^^^^^^^^^^^^^^^ expected `X`, found `Self::SIZE` - | - = note: expected array `[u32; X]` - found array `[u32; _]` - error: constant expression depends on a generic parameter --> $DIR/issue-62504.rs:18:25 | @@ -15,6 +6,24 @@ LL | ArrayHolder([0; Self::SIZE]) | = note: this may fail depending on what value the parameter takes +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-62504.rs:18:9 + | +LL | ArrayHolder([0; Self::SIZE]) + | ^^^^^^^^^^^^---------------^ + | | + | expected `[u32; X]`, found `[u32; _]` + | +note: tuple struct defined here + --> $DIR/issue-62504.rs:14:1 + | +LL | struct ArrayHolder([u32; X]); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: provide an argument of the correct type + | +LL | struct ArrayHolder([u32; X]);({[u32; X]}) + | + error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/const-generics/issues/issue-62504.rs b/src/test/ui/const-generics/issues/issue-62504.rs index 0b95754cab45d..5de4fa2f97eb6 100644 --- a/src/test/ui/const-generics/issues/issue-62504.rs +++ b/src/test/ui/const-generics/issues/issue-62504.rs @@ -17,7 +17,7 @@ impl ArrayHolder { pub const fn new() -> Self { ArrayHolder([0; Self::SIZE]) //~^ ERROR constant expression depends on a generic parameter - //[min]~| ERROR mismatched types + //[min]~| ERROR arguments to this function are incorrect } } diff --git a/src/test/ui/conversion-methods.rs b/src/test/ui/conversion-methods.rs index 46c2e511f3381..68c0b0d09c36d 100644 --- a/src/test/ui/conversion-methods.rs +++ b/src/test/ui/conversion-methods.rs @@ -2,12 +2,14 @@ use std::path::{Path, PathBuf}; fn main() { - let _tis_an_instants_play: String = "'Tis a fond Ambush—"; //~ ERROR mismatched types + let _tis_an_instants_play: String = "'Tis a fond Ambush—"; + //~^ ERROR mismatched types let _just_to_make_bliss: PathBuf = Path::new("/ern/her/own/surprise"); //~^ ERROR mismatched types let _but_should_the_play: String = 2; // Perhaps surprisingly, we suggest .to_string() here //~^ ERROR mismatched types - let _prove_piercing_earnest: Vec = &[1, 2, 3]; //~ ERROR mismatched types + let _prove_piercing_earnest: Vec = &[1, 2, 3]; + //~^ ERROR mismatched types } diff --git a/src/test/ui/conversion-methods.stderr b/src/test/ui/conversion-methods.stderr index 4f47e1fd0ffe0..96ec85fe8f722 100644 --- a/src/test/ui/conversion-methods.stderr +++ b/src/test/ui/conversion-methods.stderr @@ -9,7 +9,7 @@ LL | let _tis_an_instants_play: String = "'Tis a fond Ambush—"; | expected due to this error[E0308]: mismatched types - --> $DIR/conversion-methods.rs:6:40 + --> $DIR/conversion-methods.rs:7:40 | LL | let _just_to_make_bliss: PathBuf = Path::new("/ern/her/own/surprise"); | ------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -19,7 +19,7 @@ LL | let _just_to_make_bliss: PathBuf = Path::new("/ern/her/own/surprise"); | expected due to this error[E0308]: mismatched types - --> $DIR/conversion-methods.rs:9:40 + --> $DIR/conversion-methods.rs:10:40 | LL | let _but_should_the_play: String = 2; // Perhaps surprisingly, we suggest .to_string() here | ------ ^ @@ -29,7 +29,7 @@ LL | let _but_should_the_play: String = 2; // Perhaps surprisingly, we sugge | expected due to this error[E0308]: mismatched types - --> $DIR/conversion-methods.rs:12:47 + --> $DIR/conversion-methods.rs:13:47 | LL | let _prove_piercing_earnest: Vec = &[1, 2, 3]; | ---------- ^^^^^^^^^^ diff --git a/src/test/ui/deref-suggestion.rs b/src/test/ui/deref-suggestion.rs index 580410aecf4f8..eb5f453634069 100644 --- a/src/test/ui/deref-suggestion.rs +++ b/src/test/ui/deref-suggestion.rs @@ -1,18 +1,18 @@ macro_rules! borrow { - ($x:expr) => { &$x } //~ ERROR mismatched types + ($x:expr) => { &$x } //~ ERROR arguments to this function are incorrect } fn foo(_: String) {} fn foo2(s: &String) { foo(s); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect } fn foo3(_: u32) {} fn foo4(u: &u32) { foo3(u); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect } struct S<'a> { @@ -28,13 +28,13 @@ fn main() { let r_s = &s; foo2(r_s); foo(&"aaa".to_owned()); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo(&mut "aaa".to_owned()); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo3(borrow!(0)); foo4(&0); assert_eq!(3i32, &3i32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect let u = 3; let s = S { u }; //~^ ERROR mismatched types diff --git a/src/test/ui/deref-suggestion.stderr b/src/test/ui/deref-suggestion.stderr index f59f05db9c047..03cbfeea65de8 100644 --- a/src/test/ui/deref-suggestion.stderr +++ b/src/test/ui/deref-suggestion.stderr @@ -1,49 +1,93 @@ -error[E0308]: mismatched types - --> $DIR/deref-suggestion.rs:8:9 +error[E0308]: arguments to this function are incorrect + --> $DIR/deref-suggestion.rs:8:5 | LL | foo(s); - | ^ + | ^^^^-^ | | - | expected struct `String`, found `&String` - | help: try using a conversion method: `s.to_string()` + | expected `String`, found `&String` + | +note: function defined here + --> $DIR/deref-suggestion.rs:5:4 + | +LL | fn foo(_: String) {} + | ^^^ --------- +help: provide an argument of the correct type + | +LL | foo({String}); + | ^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/deref-suggestion.rs:14:10 +error[E0308]: arguments to this function are incorrect + --> $DIR/deref-suggestion.rs:14:5 | LL | foo3(u); - | ^ + | ^^^^^-^ | | | expected `u32`, found `&u32` - | help: consider dereferencing the borrow: `*u` + | +note: function defined here + --> $DIR/deref-suggestion.rs:12:4 + | +LL | fn foo3(_: u32) {} + | ^^^^ ------ +help: provide an argument of the correct type + | +LL | foo3({u32}); + | ^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/deref-suggestion.rs:30:9 +error[E0308]: arguments to this function are incorrect + --> $DIR/deref-suggestion.rs:30:5 | LL | foo(&"aaa".to_owned()); - | ^^^^^^^^^^^^^^^^^ + | ^^^^-----------------^ | | - | expected struct `String`, found `&String` - | help: consider removing the borrow: `"aaa".to_owned()` + | expected `String`, found `&String` + | +note: function defined here + --> $DIR/deref-suggestion.rs:5:4 + | +LL | fn foo(_: String) {} + | ^^^ --------- +help: provide an argument of the correct type + | +LL | foo({String}); + | ^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/deref-suggestion.rs:32:9 +error[E0308]: arguments to this function are incorrect + --> $DIR/deref-suggestion.rs:32:5 | LL | foo(&mut "aaa".to_owned()); - | ^^^^^^^^^^^^^^^^^^^^^ + | ^^^^---------------------^ | | - | expected struct `String`, found `&mut String` - | help: consider removing the borrow: `"aaa".to_owned()` + | expected `String`, found `&mut String` + | +note: function defined here + --> $DIR/deref-suggestion.rs:5:4 + | +LL | fn foo(_: String) {} + | ^^^ --------- +help: provide an argument of the correct type + | +LL | foo({String}); + | ^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/deref-suggestion.rs:2:20 +error[E0308]: arguments to this function are incorrect + --> $DIR/deref-suggestion.rs:34:5 | LL | ($x:expr) => { &$x } - | ^^^ expected `u32`, found `&{integer}` + | --- expected `u32`, found `&{integer}` ... LL | foo3(borrow!(0)); - | ---------- in this macro invocation + | ^^^^^^^^^^^^^^^^ | - = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) +note: function defined here + --> $DIR/deref-suggestion.rs:12:4 + | +LL | fn foo3(_: u32) {} + | ^^^^ ------ +help: provide an argument of the correct type + | +LL | foo3({u32}); + | ^^^^^^^^^^^ error[E0308]: mismatched types --> $DIR/deref-suggestion.rs:36:5 diff --git a/src/test/ui/did_you_mean/issue-42764.stderr b/src/test/ui/did_you_mean/issue-42764.stderr index 16b80a6f41236..b1701797dd9dc 100644 --- a/src/test/ui/did_you_mean/issue-42764.stderr +++ b/src/test/ui/did_you_mean/issue-42764.stderr @@ -1,17 +1,20 @@ -error[E0308]: mismatched types - --> $DIR/issue-42764.rs:11:43 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-42764.rs:11:5 | LL | this_function_expects_a_double_option(n); - | ^ expected enum `DoubleOption`, found `usize` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-^ + | | + | expected `DoubleOption<_>`, found `usize` + | +note: function defined here + --> $DIR/issue-42764.rs:7:4 | - = note: expected enum `DoubleOption<_>` - found type `usize` -help: try using a variant of the expected enum +LL | fn this_function_expects_a_double_option(d: DoubleOption) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ------------------ +help: provide an argument of the correct type | -LL | this_function_expects_a_double_option(DoubleOption::FirstSome(n)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -LL | this_function_expects_a_double_option(DoubleOption::AlternativeSome(n)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | this_function_expects_a_double_option({DoubleOption<_>}); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types --> $DIR/issue-42764.rs:27:33 diff --git a/src/test/ui/disambiguate-identical-names.rs b/src/test/ui/disambiguate-identical-names.rs index 708d2cd76a1d9..eb0567032b5d3 100644 --- a/src/test/ui/disambiguate-identical-names.rs +++ b/src/test/ui/disambiguate-identical-names.rs @@ -11,5 +11,5 @@ fn main() { v.insert(3u8, 1u8); test(&v); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect } diff --git a/src/test/ui/disambiguate-identical-names.stderr b/src/test/ui/disambiguate-identical-names.stderr index 0c6bd9379f753..3355c7abb8962 100644 --- a/src/test/ui/disambiguate-identical-names.stderr +++ b/src/test/ui/disambiguate-identical-names.stderr @@ -1,11 +1,20 @@ -error[E0308]: mismatched types - --> $DIR/disambiguate-identical-names.rs:13:10 +error[E0308]: arguments to this function are incorrect + --> $DIR/disambiguate-identical-names.rs:13:5 | LL | test(&v); - | ^^ expected struct `std::vec::Vec`, found struct `HashMap` + | ^^^^^--^ + | | + | expected `&std::vec::Vec>`, found `&HashMap` | - = note: expected reference `&std::vec::Vec>` - found reference `&HashMap` +note: function defined here + --> $DIR/disambiguate-identical-names.rs:6:4 + | +LL | fn test(_v: &Vec>) { + | ^^^^ ------------------ +help: provide an argument of the correct type + | +LL | test({&std::vec::Vec>}); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/error-codes/E0057.stderr b/src/test/ui/error-codes/E0057.stderr index 31579e2828964..da379790557c4 100644 --- a/src/test/ui/error-codes/E0057.stderr +++ b/src/test/ui/error-codes/E0057.stderr @@ -1,19 +1,27 @@ -error[E0057]: this function takes 1 argument but 0 arguments were supplied +error[E0308]: arguments to this function are incorrect --> $DIR/E0057.rs:3:13 | LL | let a = f(); - | ^-- supplied 0 arguments - | | - | expected 1 argument + | ^^^ an argument of type _ is missing + | +help: provide the argument + | +LL | let a = ({_}); + | ^^^^^ -error[E0057]: this function takes 1 argument but 2 arguments were supplied +error[E0308]: arguments to this function are incorrect --> $DIR/E0057.rs:5:13 | LL | let c = f(2, 3); - | ^ - - supplied 2 arguments - | | - | expected 1 argument + | ^^-^^^^ + | | + | argument of type {integer} unexpected + | +help: remove the extra argument + | +LL | let c = (2); + | ^^^ error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0057`. +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/error-codes/E0060.stderr b/src/test/ui/error-codes/E0060.stderr index c80014d14763b..745f31611b162 100644 --- a/src/test/ui/error-codes/E0060.stderr +++ b/src/test/ui/error-codes/E0060.stderr @@ -1,17 +1,19 @@ -error[E0060]: this function takes at least 1 argument but 0 arguments were supplied +error[E0308]: arguments to this function are incorrect --> $DIR/E0060.rs:6:14 | LL | unsafe { printf(); } - | ^^^^^^-- supplied 0 arguments - | | - | expected at least 1 argument + | ^^^^^^^^ an argument of type *const u8 is missing | note: function defined here --> $DIR/E0060.rs:2:8 | LL | fn printf(_: *const u8, ...) -> u32; | ^^^^^^ +help: provide the argument + | +LL | unsafe { printf({*const u8}); } + | ^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error -For more information about this error, try `rustc --explain E0060`. +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/error-codes/E0061.stderr b/src/test/ui/error-codes/E0061.stderr index 98488a2d298b9..ea93562b8cc9c 100644 --- a/src/test/ui/error-codes/E0061.stderr +++ b/src/test/ui/error-codes/E0061.stderr @@ -1,31 +1,35 @@ -error[E0061]: this function takes 2 arguments but 1 argument was supplied +error[E0308]: arguments to this function are incorrect --> $DIR/E0061.rs:6:5 | LL | f(0); - | ^ - supplied 1 argument - | | - | expected 2 arguments + | ^^^^ an argument of type &str is missing | note: function defined here --> $DIR/E0061.rs:1:4 | LL | fn f(a: u16, b: &str) {} | ^ ------ ------- +help: provide the argument + | +LL | f(0, {&str}); + | ^^^^^^^^^^^^ -error[E0061]: this function takes 1 argument but 0 arguments were supplied +error[E0308]: arguments to this function are incorrect --> $DIR/E0061.rs:10:5 | LL | f2(); - | ^^-- supplied 0 arguments - | | - | expected 1 argument + | ^^^^ an argument of type u16 is missing | note: function defined here --> $DIR/E0061.rs:3:4 | LL | fn f2(a: u16) {} | ^^ ------ +help: provide the argument + | +LL | f2({u16}); + | ^^^^^^^^^ 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 E0308`. diff --git a/src/test/ui/estr-subtyping.rs b/src/test/ui/estr-subtyping.rs index 9c5825fff8552..f28fd1db68c06 100644 --- a/src/test/ui/estr-subtyping.rs +++ b/src/test/ui/estr-subtyping.rs @@ -7,7 +7,7 @@ fn has_uniq(x: String) { } fn has_slice(x: &str) { - wants_uniq(x); //~ ERROR mismatched types + wants_uniq(x); //~ ERROR arguments to this function are incorrect wants_slice(x); } diff --git a/src/test/ui/estr-subtyping.stderr b/src/test/ui/estr-subtyping.stderr index 268ec63a80dc6..a424615b45779 100644 --- a/src/test/ui/estr-subtyping.stderr +++ b/src/test/ui/estr-subtyping.stderr @@ -1,11 +1,20 @@ -error[E0308]: mismatched types - --> $DIR/estr-subtyping.rs:10:15 +error[E0308]: arguments to this function are incorrect + --> $DIR/estr-subtyping.rs:10:4 | LL | wants_uniq(x); - | ^ + | ^^^^^^^^^^^-^ | | - | expected struct `String`, found `&str` - | help: try using a conversion method: `x.to_string()` + | expected `String`, found `&str` + | +note: function defined here + --> $DIR/estr-subtyping.rs:1:4 + | +LL | fn wants_uniq(x: String) { } + | ^^^^^^^^^^ --------- +help: provide an argument of the correct type + | +LL | wants_uniq({String}); + | ^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/fmt/ifmt-bad-arg.stderr b/src/test/ui/fmt/ifmt-bad-arg.stderr index 0ff478826f728..c4c792f9114bc 100644 --- a/src/test/ui/fmt/ifmt-bad-arg.stderr +++ b/src/test/ui/fmt/ifmt-bad-arg.stderr @@ -302,25 +302,33 @@ LL | println!("{:.*}"); = note: positional arguments are zero-based = note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html -error[E0308]: mismatched types - --> $DIR/ifmt-bad-arg.rs:78:32 +error[E0308]: arguments to this function are incorrect + --> $DIR/ifmt-bad-arg.rs:78:5 | LL | println!("{} {:.*} {}", 1, 3.2, 4); - | ^^^ expected `usize`, found floating-point number + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^---^^^^^ + | | + | expected `&usize`, found `&{float}` | - = note: expected reference `&usize` - found reference `&{float}` = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) +help: provide an argument of the correct type + | +LL | $crate::io::_print(({&usize})); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/ifmt-bad-arg.rs:81:35 +error[E0308]: arguments to this function are incorrect + --> $DIR/ifmt-bad-arg.rs:81:5 | LL | println!("{} {:07$.*} {}", 1, 3.2, 4); - | ^^^ expected `usize`, found floating-point number + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---^^^^^ + | | + | expected `&usize`, found `&{float}` | - = note: expected reference `&usize` - found reference `&{float}` = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) +help: provide an argument of the correct type + | +LL | $crate::io::_print(({&usize})); + | ^^^^^^^^^^ error: aborting due to 36 previous errors diff --git a/src/test/ui/generator/type-mismatch-signature-deduction.rs b/src/test/ui/generator/type-mismatch-signature-deduction.rs index 7774ff48f56b7..d77d951a0c53f 100644 --- a/src/test/ui/generator/type-mismatch-signature-deduction.rs +++ b/src/test/ui/generator/type-mismatch-signature-deduction.rs @@ -10,7 +10,7 @@ fn foo() -> impl Generator { //~ ERROR type mismatch yield (); - 5 //~ ERROR mismatched types [E0308] + 5 //~ ERROR arguments to this function are incorrect [E0308] } } diff --git a/src/test/ui/generic-associated-types/missing-bounds.fixed b/src/test/ui/generic-associated-types/missing-bounds.fixed index 54478d1628245..0e8f2ed6649b2 100644 --- a/src/test/ui/generic-associated-types/missing-bounds.fixed +++ b/src/test/ui/generic-associated-types/missing-bounds.fixed @@ -4,21 +4,21 @@ use std::ops::Add; struct A(B); -impl Add for A where B: Add + Add { +impl Add for A where B: Add { type Output = Self; fn add(self, rhs: Self) -> Self { - A(self.0 + rhs.0) //~ ERROR mismatched types + struct A(B);({B}) //~ ERROR arguments to this function are incorrect } } struct C(B); -impl> Add for C { +impl Add for C { type Output = Self; fn add(self, rhs: Self) -> Self { - Self(self.0 + rhs.0) //~ ERROR mismatched types + struct C(B);({B}) //~ ERROR arguments to this function are incorrect } } diff --git a/src/test/ui/generic-associated-types/missing-bounds.rs b/src/test/ui/generic-associated-types/missing-bounds.rs index 962d2db9476bd..96fd6ba1d2d5d 100644 --- a/src/test/ui/generic-associated-types/missing-bounds.rs +++ b/src/test/ui/generic-associated-types/missing-bounds.rs @@ -8,7 +8,7 @@ impl Add for A where B: Add { type Output = Self; fn add(self, rhs: Self) -> Self { - A(self.0 + rhs.0) //~ ERROR mismatched types + A(self.0 + rhs.0) //~ ERROR arguments to this function are incorrect } } @@ -18,7 +18,7 @@ impl Add for C { type Output = Self; fn add(self, rhs: Self) -> Self { - Self(self.0 + rhs.0) //~ ERROR mismatched types + Self(self.0 + rhs.0) //~ ERROR arguments to this function are incorrect } } diff --git a/src/test/ui/generic-associated-types/missing-bounds.stderr b/src/test/ui/generic-associated-types/missing-bounds.stderr index 4d4f7e55873b9..e5a3bbad47f91 100644 --- a/src/test/ui/generic-associated-types/missing-bounds.stderr +++ b/src/test/ui/generic-associated-types/missing-bounds.stderr @@ -1,34 +1,38 @@ -error[E0308]: mismatched types - --> $DIR/missing-bounds.rs:11:11 +error[E0308]: arguments to this function are incorrect + --> $DIR/missing-bounds.rs:11:9 | -LL | impl Add for A where B: Add { - | - this type parameter -... LL | A(self.0 + rhs.0) - | ^^^^^^^^^^^^^^ expected type parameter `B`, found associated type + | ^^--------------^ + | | + | expected `B`, found `>::Output` | - = note: expected type parameter `B` - found associated type `::Output` -help: consider further restricting this bound +note: tuple struct defined here + --> $DIR/missing-bounds.rs:5:1 | -LL | impl Add for A where B: Add + Add { - | ^^^^^^^^^^^^^^^^^ +LL | struct A(B); + | ^^^^^^^^^^^^^^^ +help: provide an argument of the correct type + | +LL | struct A(B);({B}) + | ^^^^^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/missing-bounds.rs:21:14 +error[E0308]: arguments to this function are incorrect + --> $DIR/missing-bounds.rs:21:9 | -LL | impl Add for C { - | - this type parameter -... LL | Self(self.0 + rhs.0) - | ^^^^^^^^^^^^^^ expected type parameter `B`, found associated type + | ^^^^^--------------^ + | | + | expected `B`, found `>::Output` + | +note: tuple struct defined here + --> $DIR/missing-bounds.rs:15:1 | - = note: expected type parameter `B` - found associated type `::Output` -help: consider further restricting this bound +LL | struct C(B); + | ^^^^^^^^^^^^^^^ +help: provide an argument of the correct type | -LL | impl> Add for C { - | ^^^^^^^^^^^^^^^^^ +LL | struct C(B);({B}) + | ^^^^^^^^^^^^^^^^^^^^ error[E0369]: cannot add `B` to `B` --> $DIR/missing-bounds.rs:31:21 diff --git a/src/test/ui/hrtb/issue-58451.rs b/src/test/ui/hrtb/issue-58451.rs index f36d549e476b8..74ef71ed71e9c 100644 --- a/src/test/ui/hrtb/issue-58451.rs +++ b/src/test/ui/hrtb/issue-58451.rs @@ -9,5 +9,5 @@ where {} fn main() { - f(&[f()]); //~ ERROR this function takes 1 argument + f(&[f()]); //~ ERROR arguments to this function are incorrect } diff --git a/src/test/ui/hrtb/issue-58451.stderr b/src/test/ui/hrtb/issue-58451.stderr index 2cc1c7a2e7269..9e34c6cab76a0 100644 --- a/src/test/ui/hrtb/issue-58451.stderr +++ b/src/test/ui/hrtb/issue-58451.stderr @@ -1,17 +1,19 @@ -error[E0061]: this function takes 1 argument but 0 arguments were supplied +error[E0308]: arguments to this function are incorrect --> $DIR/issue-58451.rs:12:9 | LL | f(&[f()]); - | ^-- supplied 0 arguments - | | - | expected 1 argument + | ^^^ an argument of type _ is missing | note: function defined here --> $DIR/issue-58451.rs:5:4 | LL | fn f(i: I) | ^ ---- +help: provide the argument + | +LL | f(&[f({_})]); + | ^^^^^^ error: aborting due to previous error -For more information about this error, try `rustc --explain E0061`. +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/include-macros/mismatched-types.rs b/src/test/ui/include-macros/mismatched-types.rs index 83fa378a3ae05..b363661ebd0f9 100644 --- a/src/test/ui/include-macros/mismatched-types.rs +++ b/src/test/ui/include-macros/mismatched-types.rs @@ -1,4 +1,6 @@ fn main() { - let b: &[u8] = include_str!("file.txt"); //~ ERROR mismatched types - let s: &str = include_bytes!("file.txt"); //~ ERROR mismatched types + let b: &[u8] = include_str!("file.txt"); + //~^ ERROR mismatched types + let s: &str = include_bytes!("file.txt"); + //~^ ERROR mismatched types } diff --git a/src/test/ui/include-macros/mismatched-types.stderr b/src/test/ui/include-macros/mismatched-types.stderr index d035df8e5d83a..bfe3dbc4f1a88 100644 --- a/src/test/ui/include-macros/mismatched-types.stderr +++ b/src/test/ui/include-macros/mismatched-types.stderr @@ -11,7 +11,7 @@ LL | let b: &[u8] = include_str!("file.txt"); = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error[E0308]: mismatched types - --> $DIR/mismatched-types.rs:3:19 + --> $DIR/mismatched-types.rs:4:19 | LL | let s: &str = include_bytes!("file.txt"); | ---- ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `str`, found array `[u8; 0]` diff --git a/src/test/ui/indexing-requires-a-uint.rs b/src/test/ui/indexing-requires-a-uint.rs index dbe9b44a13890..01832c8595d1d 100644 --- a/src/test/ui/indexing-requires-a-uint.rs +++ b/src/test/ui/indexing-requires-a-uint.rs @@ -10,5 +10,5 @@ fn main() { let i = 0; // i is an IntVar [0][i]; // i should be locked to usize bar::(i); // i should not be re-coerced back to an isize - //~^ ERROR: mismatched types + //~^ ERROR: arguments to this function are incorrect } diff --git a/src/test/ui/indexing-requires-a-uint.stderr b/src/test/ui/indexing-requires-a-uint.stderr index 3152dec30a0e6..62aba9b280271 100644 --- a/src/test/ui/indexing-requires-a-uint.stderr +++ b/src/test/ui/indexing-requires-a-uint.stderr @@ -7,16 +7,23 @@ LL | [0][0u8]; = help: the trait `SliceIndex<[{integer}]>` is not implemented for `u8` = note: required because of the requirements on the impl of `Index` for `[{integer}]` -error[E0308]: mismatched types - --> $DIR/indexing-requires-a-uint.rs:12:18 +error[E0308]: arguments to this function are incorrect + --> $DIR/indexing-requires-a-uint.rs:12:5 | LL | bar::(i); // i should not be re-coerced back to an isize - | ^ expected `isize`, found `usize` + | ^^^^^^^^^^^^^-^ + | | + | expected `isize`, found `{integer}` | -help: you can convert a `usize` to an `isize` and panic if the converted value doesn't fit +note: function defined here + --> $DIR/indexing-requires-a-uint.rs:5:8 | -LL | bar::(i.try_into().unwrap()); // i should not be re-coerced back to an isize - | ^^^^^^^^^^^^^^^^^^^^^ +LL | fn bar(_: T) {} + | ^^^ ---- +help: provide an argument of the correct type + | +LL | bar({isize}); // i should not be re-coerced back to an isize + | ^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/integer-literal-suffix-inference.rs b/src/test/ui/integer-literal-suffix-inference.rs index c320f2bb7b446..32b6ae8c9fabe 100644 --- a/src/test/ui/integer-literal-suffix-inference.rs +++ b/src/test/ui/integer-literal-suffix-inference.rs @@ -36,185 +36,185 @@ fn main() { id_i8(a8); // ok id_i8(a16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `i8`, found `i16` id_i8(a32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `i8`, found `i32` id_i8(a64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `i8`, found `i64` id_i8(asize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `i8`, found `isize` id_i16(a8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `i16`, found `i8` id_i16(a16); // ok id_i16(a32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `i16`, found `i32` id_i16(a64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `i16`, found `i64` id_i16(asize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `i16`, found `isize` id_i32(a8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `i32`, found `i8` id_i32(a16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `i32`, found `i16` id_i32(a32); // ok id_i32(a64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `i32`, found `i64` id_i32(asize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `i32`, found `isize` id_i64(a8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `i64`, found `i8` id_i64(a16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `i64`, found `i16` id_i64(a32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `i64`, found `i32` id_i64(a64); // ok id_i64(asize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `i64`, found `isize` id_isize(a8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `isize`, found `i8` id_isize(a16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `isize`, found `i16` id_isize(a32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `isize`, found `i32` id_isize(a64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `isize`, found `i64` id_isize(asize); //ok id_i8(c8); // ok id_i8(c16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `i8`, found `i16` id_i8(c32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `i8`, found `i32` id_i8(c64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `i8`, found `i64` id_i16(c8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `i16`, found `i8` id_i16(c16); // ok id_i16(c32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `i16`, found `i32` id_i16(c64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `i16`, found `i64` id_i32(c8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `i32`, found `i8` id_i32(c16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `i32`, found `i16` id_i32(c32); // ok id_i32(c64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `i32`, found `i64` id_i64(a8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `i64`, found `i8` id_i64(a16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `i64`, found `i16` id_i64(a32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `i64`, found `i32` id_i64(a64); // ok id_u8(b8); // ok id_u8(b16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `u8`, found `u16` id_u8(b32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `u8`, found `u32` id_u8(b64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `u8`, found `u64` id_u8(bsize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `u8`, found `usize` id_u16(b8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `u16`, found `u8` id_u16(b16); // ok id_u16(b32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `u16`, found `u32` id_u16(b64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `u16`, found `u64` id_u16(bsize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `u16`, found `usize` id_u32(b8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `u32`, found `u8` id_u32(b16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `u32`, found `u16` id_u32(b32); // ok id_u32(b64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `u32`, found `u64` id_u32(bsize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `u32`, found `usize` id_u64(b8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `u64`, found `u8` id_u64(b16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `u64`, found `u16` id_u64(b32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `u64`, found `u32` id_u64(b64); // ok id_u64(bsize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `u64`, found `usize` id_usize(b8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `usize`, found `u8` id_usize(b16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `usize`, found `u16` id_usize(b32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `usize`, found `u32` id_usize(b64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `usize`, found `u64` id_usize(bsize); //ok } diff --git a/src/test/ui/integer-literal-suffix-inference.stderr b/src/test/ui/integer-literal-suffix-inference.stderr index bfb47515823a3..81ed01893f417 100644 --- a/src/test/ui/integer-literal-suffix-inference.stderr +++ b/src/test/ui/integer-literal-suffix-inference.stderr @@ -1,530 +1,938 @@ -error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:38:11 +error[E0308]: arguments to this function are incorrect + --> $DIR/integer-literal-suffix-inference.rs:38:5 | LL | id_i8(a16); - | ^^^ expected `i8`, found `i16` + | ^^^^^^---^ + | | + | expected `i8`, found `i16` | -help: you can convert an `i16` to an `i8` and panic if the converted value doesn't fit +note: function defined here + --> $DIR/integer-literal-suffix-inference.rs:15:8 | -LL | id_i8(a16.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn id_i8(n: i8) -> i8 { n } + | ^^^^^ ----- +help: provide an argument of the correct type + | +LL | id_i8({i8}); + | ^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:41:11 +error[E0308]: arguments to this function are incorrect + --> $DIR/integer-literal-suffix-inference.rs:41:5 | LL | id_i8(a32); - | ^^^ expected `i8`, found `i32` + | ^^^^^^---^ + | | + | expected `i8`, found `i32` + | +note: function defined here + --> $DIR/integer-literal-suffix-inference.rs:15:8 | -help: you can convert an `i32` to an `i8` and panic if the converted value doesn't fit +LL | fn id_i8(n: i8) -> i8 { n } + | ^^^^^ ----- +help: provide an argument of the correct type | -LL | id_i8(a32.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | id_i8({i8}); + | ^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:44:11 +error[E0308]: arguments to this function are incorrect + --> $DIR/integer-literal-suffix-inference.rs:44:5 | LL | id_i8(a64); - | ^^^ expected `i8`, found `i64` + | ^^^^^^---^ + | | + | expected `i8`, found `i64` | -help: you can convert an `i64` to an `i8` and panic if the converted value doesn't fit +note: function defined here + --> $DIR/integer-literal-suffix-inference.rs:15:8 | -LL | id_i8(a64.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn id_i8(n: i8) -> i8 { n } + | ^^^^^ ----- +help: provide an argument of the correct type + | +LL | id_i8({i8}); + | ^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:47:11 +error[E0308]: arguments to this function are incorrect + --> $DIR/integer-literal-suffix-inference.rs:47:5 | LL | id_i8(asize); - | ^^^^^ expected `i8`, found `isize` + | ^^^^^^-----^ + | | + | expected `i8`, found `isize` + | +note: function defined here + --> $DIR/integer-literal-suffix-inference.rs:15:8 | -help: you can convert an `isize` to an `i8` and panic if the converted value doesn't fit +LL | fn id_i8(n: i8) -> i8 { n } + | ^^^^^ ----- +help: provide an argument of the correct type | -LL | id_i8(asize.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | id_i8({i8}); + | ^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:51:12 +error[E0308]: arguments to this function are incorrect + --> $DIR/integer-literal-suffix-inference.rs:51:5 | LL | id_i16(a8); - | ^^ + | ^^^^^^^--^ | | | expected `i16`, found `i8` - | help: you can convert an `i8` to an `i16`: `a8.into()` + | +note: function defined here + --> $DIR/integer-literal-suffix-inference.rs:16:8 + | +LL | fn id_i16(n: i16) -> i16 { n } + | ^^^^^^ ------ +help: provide an argument of the correct type + | +LL | id_i16({i16}); + | ^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:55:12 +error[E0308]: arguments to this function are incorrect + --> $DIR/integer-literal-suffix-inference.rs:55:5 | LL | id_i16(a32); - | ^^^ expected `i16`, found `i32` + | ^^^^^^^---^ + | | + | expected `i16`, found `i32` | -help: you can convert an `i32` to an `i16` and panic if the converted value doesn't fit +note: function defined here + --> $DIR/integer-literal-suffix-inference.rs:16:8 | -LL | id_i16(a32.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn id_i16(n: i16) -> i16 { n } + | ^^^^^^ ------ +help: provide an argument of the correct type + | +LL | id_i16({i16}); + | ^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:58:12 +error[E0308]: arguments to this function are incorrect + --> $DIR/integer-literal-suffix-inference.rs:58:5 | LL | id_i16(a64); - | ^^^ expected `i16`, found `i64` + | ^^^^^^^---^ + | | + | expected `i16`, found `i64` | -help: you can convert an `i64` to an `i16` and panic if the converted value doesn't fit +note: function defined here + --> $DIR/integer-literal-suffix-inference.rs:16:8 | -LL | id_i16(a64.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn id_i16(n: i16) -> i16 { n } + | ^^^^^^ ------ +help: provide an argument of the correct type + | +LL | id_i16({i16}); + | ^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:61:12 +error[E0308]: arguments to this function are incorrect + --> $DIR/integer-literal-suffix-inference.rs:61:5 | LL | id_i16(asize); - | ^^^^^ expected `i16`, found `isize` + | ^^^^^^^-----^ + | | + | expected `i16`, found `isize` | -help: you can convert an `isize` to an `i16` and panic if the converted value doesn't fit +note: function defined here + --> $DIR/integer-literal-suffix-inference.rs:16:8 | -LL | id_i16(asize.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn id_i16(n: i16) -> i16 { n } + | ^^^^^^ ------ +help: provide an argument of the correct type + | +LL | id_i16({i16}); + | ^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:65:12 +error[E0308]: arguments to this function are incorrect + --> $DIR/integer-literal-suffix-inference.rs:65:5 | LL | id_i32(a8); - | ^^ + | ^^^^^^^--^ | | | expected `i32`, found `i8` - | help: you can convert an `i8` to an `i32`: `a8.into()` + | +note: function defined here + --> $DIR/integer-literal-suffix-inference.rs:17:8 + | +LL | fn id_i32(n: i32) -> i32 { n } + | ^^^^^^ ------ +help: provide an argument of the correct type + | +LL | id_i32({i32}); + | ^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:68:12 +error[E0308]: arguments to this function are incorrect + --> $DIR/integer-literal-suffix-inference.rs:68:5 | LL | id_i32(a16); - | ^^^ + | ^^^^^^^---^ | | | expected `i32`, found `i16` - | help: you can convert an `i16` to an `i32`: `a16.into()` + | +note: function defined here + --> $DIR/integer-literal-suffix-inference.rs:17:8 + | +LL | fn id_i32(n: i32) -> i32 { n } + | ^^^^^^ ------ +help: provide an argument of the correct type + | +LL | id_i32({i32}); + | ^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:72:12 +error[E0308]: arguments to this function are incorrect + --> $DIR/integer-literal-suffix-inference.rs:72:5 | LL | id_i32(a64); - | ^^^ expected `i32`, found `i64` + | ^^^^^^^---^ + | | + | expected `i32`, found `i64` + | +note: function defined here + --> $DIR/integer-literal-suffix-inference.rs:17:8 | -help: you can convert an `i64` to an `i32` and panic if the converted value doesn't fit +LL | fn id_i32(n: i32) -> i32 { n } + | ^^^^^^ ------ +help: provide an argument of the correct type | -LL | id_i32(a64.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | id_i32({i32}); + | ^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:75:12 +error[E0308]: arguments to this function are incorrect + --> $DIR/integer-literal-suffix-inference.rs:75:5 | LL | id_i32(asize); - | ^^^^^ expected `i32`, found `isize` + | ^^^^^^^-----^ + | | + | expected `i32`, found `isize` | -help: you can convert an `isize` to an `i32` and panic if the converted value doesn't fit +note: function defined here + --> $DIR/integer-literal-suffix-inference.rs:17:8 | -LL | id_i32(asize.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn id_i32(n: i32) -> i32 { n } + | ^^^^^^ ------ +help: provide an argument of the correct type + | +LL | id_i32({i32}); + | ^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:79:12 +error[E0308]: arguments to this function are incorrect + --> $DIR/integer-literal-suffix-inference.rs:79:5 | LL | id_i64(a8); - | ^^ + | ^^^^^^^--^ | | | expected `i64`, found `i8` - | help: you can convert an `i8` to an `i64`: `a8.into()` + | +note: function defined here + --> $DIR/integer-literal-suffix-inference.rs:18:8 + | +LL | fn id_i64(n: i64) -> i64 { n } + | ^^^^^^ ------ +help: provide an argument of the correct type + | +LL | id_i64({i64}); + | ^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:82:12 +error[E0308]: arguments to this function are incorrect + --> $DIR/integer-literal-suffix-inference.rs:82:5 | LL | id_i64(a16); - | ^^^ + | ^^^^^^^---^ | | | expected `i64`, found `i16` - | help: you can convert an `i16` to an `i64`: `a16.into()` + | +note: function defined here + --> $DIR/integer-literal-suffix-inference.rs:18:8 + | +LL | fn id_i64(n: i64) -> i64 { n } + | ^^^^^^ ------ +help: provide an argument of the correct type + | +LL | id_i64({i64}); + | ^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:85:12 +error[E0308]: arguments to this function are incorrect + --> $DIR/integer-literal-suffix-inference.rs:85:5 | LL | id_i64(a32); - | ^^^ + | ^^^^^^^---^ | | | expected `i64`, found `i32` - | help: you can convert an `i32` to an `i64`: `a32.into()` + | +note: function defined here + --> $DIR/integer-literal-suffix-inference.rs:18:8 + | +LL | fn id_i64(n: i64) -> i64 { n } + | ^^^^^^ ------ +help: provide an argument of the correct type + | +LL | id_i64({i64}); + | ^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:89:12 +error[E0308]: arguments to this function are incorrect + --> $DIR/integer-literal-suffix-inference.rs:89:5 | LL | id_i64(asize); - | ^^^^^ expected `i64`, found `isize` + | ^^^^^^^-----^ + | | + | expected `i64`, found `isize` | -help: you can convert an `isize` to an `i64` and panic if the converted value doesn't fit +note: function defined here + --> $DIR/integer-literal-suffix-inference.rs:18:8 | -LL | id_i64(asize.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn id_i64(n: i64) -> i64 { n } + | ^^^^^^ ------ +help: provide an argument of the correct type + | +LL | id_i64({i64}); + | ^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:93:14 +error[E0308]: arguments to this function are incorrect + --> $DIR/integer-literal-suffix-inference.rs:93:5 | LL | id_isize(a8); - | ^^ + | ^^^^^^^^^--^ | | | expected `isize`, found `i8` - | help: you can convert an `i8` to an `isize`: `a8.into()` + | +note: function defined here + --> $DIR/integer-literal-suffix-inference.rs:19:8 + | +LL | fn id_isize(n: isize) -> isize { n } + | ^^^^^^^^ -------- +help: provide an argument of the correct type + | +LL | id_isize({isize}); + | ^^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:96:14 +error[E0308]: arguments to this function are incorrect + --> $DIR/integer-literal-suffix-inference.rs:96:5 | LL | id_isize(a16); - | ^^^ + | ^^^^^^^^^---^ | | | expected `isize`, found `i16` - | help: you can convert an `i16` to an `isize`: `a16.into()` + | +note: function defined here + --> $DIR/integer-literal-suffix-inference.rs:19:8 + | +LL | fn id_isize(n: isize) -> isize { n } + | ^^^^^^^^ -------- +help: provide an argument of the correct type + | +LL | id_isize({isize}); + | ^^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:99:14 +error[E0308]: arguments to this function are incorrect + --> $DIR/integer-literal-suffix-inference.rs:99:5 | LL | id_isize(a32); - | ^^^ expected `isize`, found `i32` + | ^^^^^^^^^---^ + | | + | expected `isize`, found `i32` | -help: you can convert an `i32` to an `isize` and panic if the converted value doesn't fit +note: function defined here + --> $DIR/integer-literal-suffix-inference.rs:19:8 | -LL | id_isize(a32.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn id_isize(n: isize) -> isize { n } + | ^^^^^^^^ -------- +help: provide an argument of the correct type + | +LL | id_isize({isize}); + | ^^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:102:14 +error[E0308]: arguments to this function are incorrect + --> $DIR/integer-literal-suffix-inference.rs:102:5 | LL | id_isize(a64); - | ^^^ expected `isize`, found `i64` + | ^^^^^^^^^---^ + | | + | expected `isize`, found `i64` + | +note: function defined here + --> $DIR/integer-literal-suffix-inference.rs:19:8 | -help: you can convert an `i64` to an `isize` and panic if the converted value doesn't fit +LL | fn id_isize(n: isize) -> isize { n } + | ^^^^^^^^ -------- +help: provide an argument of the correct type | -LL | id_isize(a64.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | id_isize({isize}); + | ^^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:108:11 +error[E0308]: arguments to this function are incorrect + --> $DIR/integer-literal-suffix-inference.rs:108:5 | LL | id_i8(c16); - | ^^^ expected `i8`, found `i16` + | ^^^^^^---^ + | | + | expected `i8`, found `i16` | -help: you can convert an `i16` to an `i8` and panic if the converted value doesn't fit +note: function defined here + --> $DIR/integer-literal-suffix-inference.rs:15:8 | -LL | id_i8(c16.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn id_i8(n: i8) -> i8 { n } + | ^^^^^ ----- +help: provide an argument of the correct type + | +LL | id_i8({i8}); + | ^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:111:11 +error[E0308]: arguments to this function are incorrect + --> $DIR/integer-literal-suffix-inference.rs:111:5 | LL | id_i8(c32); - | ^^^ expected `i8`, found `i32` + | ^^^^^^---^ + | | + | expected `i8`, found `i32` + | +note: function defined here + --> $DIR/integer-literal-suffix-inference.rs:15:8 | -help: you can convert an `i32` to an `i8` and panic if the converted value doesn't fit +LL | fn id_i8(n: i8) -> i8 { n } + | ^^^^^ ----- +help: provide an argument of the correct type | -LL | id_i8(c32.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | id_i8({i8}); + | ^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:114:11 +error[E0308]: arguments to this function are incorrect + --> $DIR/integer-literal-suffix-inference.rs:114:5 | LL | id_i8(c64); - | ^^^ expected `i8`, found `i64` + | ^^^^^^---^ + | | + | expected `i8`, found `i64` | -help: you can convert an `i64` to an `i8` and panic if the converted value doesn't fit +note: function defined here + --> $DIR/integer-literal-suffix-inference.rs:15:8 | -LL | id_i8(c64.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn id_i8(n: i8) -> i8 { n } + | ^^^^^ ----- +help: provide an argument of the correct type + | +LL | id_i8({i8}); + | ^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:118:12 +error[E0308]: arguments to this function are incorrect + --> $DIR/integer-literal-suffix-inference.rs:118:5 | LL | id_i16(c8); - | ^^ + | ^^^^^^^--^ | | | expected `i16`, found `i8` - | help: you can convert an `i8` to an `i16`: `c8.into()` + | +note: function defined here + --> $DIR/integer-literal-suffix-inference.rs:16:8 + | +LL | fn id_i16(n: i16) -> i16 { n } + | ^^^^^^ ------ +help: provide an argument of the correct type + | +LL | id_i16({i16}); + | ^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:122:12 +error[E0308]: arguments to this function are incorrect + --> $DIR/integer-literal-suffix-inference.rs:122:5 | LL | id_i16(c32); - | ^^^ expected `i16`, found `i32` + | ^^^^^^^---^ + | | + | expected `i16`, found `i32` | -help: you can convert an `i32` to an `i16` and panic if the converted value doesn't fit +note: function defined here + --> $DIR/integer-literal-suffix-inference.rs:16:8 | -LL | id_i16(c32.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn id_i16(n: i16) -> i16 { n } + | ^^^^^^ ------ +help: provide an argument of the correct type + | +LL | id_i16({i16}); + | ^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:125:12 +error[E0308]: arguments to this function are incorrect + --> $DIR/integer-literal-suffix-inference.rs:125:5 | LL | id_i16(c64); - | ^^^ expected `i16`, found `i64` + | ^^^^^^^---^ + | | + | expected `i16`, found `i64` | -help: you can convert an `i64` to an `i16` and panic if the converted value doesn't fit +note: function defined here + --> $DIR/integer-literal-suffix-inference.rs:16:8 | -LL | id_i16(c64.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn id_i16(n: i16) -> i16 { n } + | ^^^^^^ ------ +help: provide an argument of the correct type + | +LL | id_i16({i16}); + | ^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:129:12 +error[E0308]: arguments to this function are incorrect + --> $DIR/integer-literal-suffix-inference.rs:129:5 | LL | id_i32(c8); - | ^^ + | ^^^^^^^--^ | | | expected `i32`, found `i8` - | help: you can convert an `i8` to an `i32`: `c8.into()` + | +note: function defined here + --> $DIR/integer-literal-suffix-inference.rs:17:8 + | +LL | fn id_i32(n: i32) -> i32 { n } + | ^^^^^^ ------ +help: provide an argument of the correct type + | +LL | id_i32({i32}); + | ^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:132:12 +error[E0308]: arguments to this function are incorrect + --> $DIR/integer-literal-suffix-inference.rs:132:5 | LL | id_i32(c16); - | ^^^ + | ^^^^^^^---^ | | | expected `i32`, found `i16` - | help: you can convert an `i16` to an `i32`: `c16.into()` + | +note: function defined here + --> $DIR/integer-literal-suffix-inference.rs:17:8 + | +LL | fn id_i32(n: i32) -> i32 { n } + | ^^^^^^ ------ +help: provide an argument of the correct type + | +LL | id_i32({i32}); + | ^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:136:12 +error[E0308]: arguments to this function are incorrect + --> $DIR/integer-literal-suffix-inference.rs:136:5 | LL | id_i32(c64); - | ^^^ expected `i32`, found `i64` + | ^^^^^^^---^ + | | + | expected `i32`, found `i64` + | +note: function defined here + --> $DIR/integer-literal-suffix-inference.rs:17:8 | -help: you can convert an `i64` to an `i32` and panic if the converted value doesn't fit +LL | fn id_i32(n: i32) -> i32 { n } + | ^^^^^^ ------ +help: provide an argument of the correct type | -LL | id_i32(c64.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | id_i32({i32}); + | ^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:140:12 +error[E0308]: arguments to this function are incorrect + --> $DIR/integer-literal-suffix-inference.rs:140:5 | LL | id_i64(a8); - | ^^ + | ^^^^^^^--^ | | | expected `i64`, found `i8` - | help: you can convert an `i8` to an `i64`: `a8.into()` + | +note: function defined here + --> $DIR/integer-literal-suffix-inference.rs:18:8 + | +LL | fn id_i64(n: i64) -> i64 { n } + | ^^^^^^ ------ +help: provide an argument of the correct type + | +LL | id_i64({i64}); + | ^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:143:12 +error[E0308]: arguments to this function are incorrect + --> $DIR/integer-literal-suffix-inference.rs:143:5 | LL | id_i64(a16); - | ^^^ + | ^^^^^^^---^ | | | expected `i64`, found `i16` - | help: you can convert an `i16` to an `i64`: `a16.into()` + | +note: function defined here + --> $DIR/integer-literal-suffix-inference.rs:18:8 + | +LL | fn id_i64(n: i64) -> i64 { n } + | ^^^^^^ ------ +help: provide an argument of the correct type + | +LL | id_i64({i64}); + | ^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:146:12 +error[E0308]: arguments to this function are incorrect + --> $DIR/integer-literal-suffix-inference.rs:146:5 | LL | id_i64(a32); - | ^^^ + | ^^^^^^^---^ | | | expected `i64`, found `i32` - | help: you can convert an `i32` to an `i64`: `a32.into()` + | +note: function defined here + --> $DIR/integer-literal-suffix-inference.rs:18:8 + | +LL | fn id_i64(n: i64) -> i64 { n } + | ^^^^^^ ------ +help: provide an argument of the correct type + | +LL | id_i64({i64}); + | ^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:152:11 +error[E0308]: arguments to this function are incorrect + --> $DIR/integer-literal-suffix-inference.rs:152:5 | LL | id_u8(b16); - | ^^^ expected `u8`, found `u16` + | ^^^^^^---^ + | | + | expected `u8`, found `u16` + | +note: function defined here + --> $DIR/integer-literal-suffix-inference.rs:27:8 | -help: you can convert a `u16` to a `u8` and panic if the converted value doesn't fit +LL | fn id_u8(n: u8) -> u8 { n } + | ^^^^^ ----- +help: provide an argument of the correct type | -LL | id_u8(b16.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | id_u8({u8}); + | ^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:155:11 +error[E0308]: arguments to this function are incorrect + --> $DIR/integer-literal-suffix-inference.rs:155:5 | LL | id_u8(b32); - | ^^^ expected `u8`, found `u32` + | ^^^^^^---^ + | | + | expected `u8`, found `u32` + | +note: function defined here + --> $DIR/integer-literal-suffix-inference.rs:27:8 | -help: you can convert a `u32` to a `u8` and panic if the converted value doesn't fit +LL | fn id_u8(n: u8) -> u8 { n } + | ^^^^^ ----- +help: provide an argument of the correct type | -LL | id_u8(b32.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | id_u8({u8}); + | ^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:158:11 +error[E0308]: arguments to this function are incorrect + --> $DIR/integer-literal-suffix-inference.rs:158:5 | LL | id_u8(b64); - | ^^^ expected `u8`, found `u64` + | ^^^^^^---^ + | | + | expected `u8`, found `u64` | -help: you can convert a `u64` to a `u8` and panic if the converted value doesn't fit +note: function defined here + --> $DIR/integer-literal-suffix-inference.rs:27:8 | -LL | id_u8(b64.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn id_u8(n: u8) -> u8 { n } + | ^^^^^ ----- +help: provide an argument of the correct type + | +LL | id_u8({u8}); + | ^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:161:11 +error[E0308]: arguments to this function are incorrect + --> $DIR/integer-literal-suffix-inference.rs:161:5 | LL | id_u8(bsize); - | ^^^^^ expected `u8`, found `usize` + | ^^^^^^-----^ + | | + | expected `u8`, found `usize` + | +note: function defined here + --> $DIR/integer-literal-suffix-inference.rs:27:8 | -help: you can convert a `usize` to a `u8` and panic if the converted value doesn't fit +LL | fn id_u8(n: u8) -> u8 { n } + | ^^^^^ ----- +help: provide an argument of the correct type | -LL | id_u8(bsize.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | id_u8({u8}); + | ^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:165:12 +error[E0308]: arguments to this function are incorrect + --> $DIR/integer-literal-suffix-inference.rs:165:5 | LL | id_u16(b8); - | ^^ + | ^^^^^^^--^ | | | expected `u16`, found `u8` - | help: you can convert a `u8` to a `u16`: `b8.into()` + | +note: function defined here + --> $DIR/integer-literal-suffix-inference.rs:28:8 + | +LL | fn id_u16(n: u16) -> u16 { n } + | ^^^^^^ ------ +help: provide an argument of the correct type + | +LL | id_u16({u16}); + | ^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:169:12 +error[E0308]: arguments to this function are incorrect + --> $DIR/integer-literal-suffix-inference.rs:169:5 | LL | id_u16(b32); - | ^^^ expected `u16`, found `u32` + | ^^^^^^^---^ + | | + | expected `u16`, found `u32` + | +note: function defined here + --> $DIR/integer-literal-suffix-inference.rs:28:8 | -help: you can convert a `u32` to a `u16` and panic if the converted value doesn't fit +LL | fn id_u16(n: u16) -> u16 { n } + | ^^^^^^ ------ +help: provide an argument of the correct type | -LL | id_u16(b32.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | id_u16({u16}); + | ^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:172:12 +error[E0308]: arguments to this function are incorrect + --> $DIR/integer-literal-suffix-inference.rs:172:5 | LL | id_u16(b64); - | ^^^ expected `u16`, found `u64` + | ^^^^^^^---^ + | | + | expected `u16`, found `u64` + | +note: function defined here + --> $DIR/integer-literal-suffix-inference.rs:28:8 | -help: you can convert a `u64` to a `u16` and panic if the converted value doesn't fit +LL | fn id_u16(n: u16) -> u16 { n } + | ^^^^^^ ------ +help: provide an argument of the correct type | -LL | id_u16(b64.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | id_u16({u16}); + | ^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:175:12 +error[E0308]: arguments to this function are incorrect + --> $DIR/integer-literal-suffix-inference.rs:175:5 | LL | id_u16(bsize); - | ^^^^^ expected `u16`, found `usize` + | ^^^^^^^-----^ + | | + | expected `u16`, found `usize` + | +note: function defined here + --> $DIR/integer-literal-suffix-inference.rs:28:8 | -help: you can convert a `usize` to a `u16` and panic if the converted value doesn't fit +LL | fn id_u16(n: u16) -> u16 { n } + | ^^^^^^ ------ +help: provide an argument of the correct type | -LL | id_u16(bsize.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | id_u16({u16}); + | ^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:179:12 +error[E0308]: arguments to this function are incorrect + --> $DIR/integer-literal-suffix-inference.rs:179:5 | LL | id_u32(b8); - | ^^ + | ^^^^^^^--^ | | | expected `u32`, found `u8` - | help: you can convert a `u8` to a `u32`: `b8.into()` + | +note: function defined here + --> $DIR/integer-literal-suffix-inference.rs:29:8 + | +LL | fn id_u32(n: u32) -> u32 { n } + | ^^^^^^ ------ +help: provide an argument of the correct type + | +LL | id_u32({u32}); + | ^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:182:12 +error[E0308]: arguments to this function are incorrect + --> $DIR/integer-literal-suffix-inference.rs:182:5 | LL | id_u32(b16); - | ^^^ + | ^^^^^^^---^ | | | expected `u32`, found `u16` - | help: you can convert a `u16` to a `u32`: `b16.into()` + | +note: function defined here + --> $DIR/integer-literal-suffix-inference.rs:29:8 + | +LL | fn id_u32(n: u32) -> u32 { n } + | ^^^^^^ ------ +help: provide an argument of the correct type + | +LL | id_u32({u32}); + | ^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:186:12 +error[E0308]: arguments to this function are incorrect + --> $DIR/integer-literal-suffix-inference.rs:186:5 | LL | id_u32(b64); - | ^^^ expected `u32`, found `u64` + | ^^^^^^^---^ + | | + | expected `u32`, found `u64` | -help: you can convert a `u64` to a `u32` and panic if the converted value doesn't fit +note: function defined here + --> $DIR/integer-literal-suffix-inference.rs:29:8 | -LL | id_u32(b64.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn id_u32(n: u32) -> u32 { n } + | ^^^^^^ ------ +help: provide an argument of the correct type + | +LL | id_u32({u32}); + | ^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:189:12 +error[E0308]: arguments to this function are incorrect + --> $DIR/integer-literal-suffix-inference.rs:189:5 | LL | id_u32(bsize); - | ^^^^^ expected `u32`, found `usize` + | ^^^^^^^-----^ + | | + | expected `u32`, found `usize` + | +note: function defined here + --> $DIR/integer-literal-suffix-inference.rs:29:8 | -help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit +LL | fn id_u32(n: u32) -> u32 { n } + | ^^^^^^ ------ +help: provide an argument of the correct type | -LL | id_u32(bsize.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | id_u32({u32}); + | ^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:193:12 +error[E0308]: arguments to this function are incorrect + --> $DIR/integer-literal-suffix-inference.rs:193:5 | LL | id_u64(b8); - | ^^ + | ^^^^^^^--^ | | | expected `u64`, found `u8` - | help: you can convert a `u8` to a `u64`: `b8.into()` + | +note: function defined here + --> $DIR/integer-literal-suffix-inference.rs:30:8 + | +LL | fn id_u64(n: u64) -> u64 { n } + | ^^^^^^ ------ +help: provide an argument of the correct type + | +LL | id_u64({u64}); + | ^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:196:12 +error[E0308]: arguments to this function are incorrect + --> $DIR/integer-literal-suffix-inference.rs:196:5 | LL | id_u64(b16); - | ^^^ + | ^^^^^^^---^ | | | expected `u64`, found `u16` - | help: you can convert a `u16` to a `u64`: `b16.into()` + | +note: function defined here + --> $DIR/integer-literal-suffix-inference.rs:30:8 + | +LL | fn id_u64(n: u64) -> u64 { n } + | ^^^^^^ ------ +help: provide an argument of the correct type + | +LL | id_u64({u64}); + | ^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:199:12 +error[E0308]: arguments to this function are incorrect + --> $DIR/integer-literal-suffix-inference.rs:199:5 | LL | id_u64(b32); - | ^^^ + | ^^^^^^^---^ | | | expected `u64`, found `u32` - | help: you can convert a `u32` to a `u64`: `b32.into()` + | +note: function defined here + --> $DIR/integer-literal-suffix-inference.rs:30:8 + | +LL | fn id_u64(n: u64) -> u64 { n } + | ^^^^^^ ------ +help: provide an argument of the correct type + | +LL | id_u64({u64}); + | ^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:203:12 +error[E0308]: arguments to this function are incorrect + --> $DIR/integer-literal-suffix-inference.rs:203:5 | LL | id_u64(bsize); - | ^^^^^ expected `u64`, found `usize` + | ^^^^^^^-----^ + | | + | expected `u64`, found `usize` + | +note: function defined here + --> $DIR/integer-literal-suffix-inference.rs:30:8 | -help: you can convert a `usize` to a `u64` and panic if the converted value doesn't fit +LL | fn id_u64(n: u64) -> u64 { n } + | ^^^^^^ ------ +help: provide an argument of the correct type | -LL | id_u64(bsize.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | id_u64({u64}); + | ^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:207:14 +error[E0308]: arguments to this function are incorrect + --> $DIR/integer-literal-suffix-inference.rs:207:5 | LL | id_usize(b8); - | ^^ + | ^^^^^^^^^--^ | | | expected `usize`, found `u8` - | help: you can convert a `u8` to a `usize`: `b8.into()` + | +note: function defined here + --> $DIR/integer-literal-suffix-inference.rs:31:8 + | +LL | fn id_usize(n: usize) -> usize { n } + | ^^^^^^^^ -------- +help: provide an argument of the correct type + | +LL | id_usize({usize}); + | ^^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:210:14 +error[E0308]: arguments to this function are incorrect + --> $DIR/integer-literal-suffix-inference.rs:210:5 | LL | id_usize(b16); - | ^^^ + | ^^^^^^^^^---^ | | | expected `usize`, found `u16` - | help: you can convert a `u16` to a `usize`: `b16.into()` + | +note: function defined here + --> $DIR/integer-literal-suffix-inference.rs:31:8 + | +LL | fn id_usize(n: usize) -> usize { n } + | ^^^^^^^^ -------- +help: provide an argument of the correct type + | +LL | id_usize({usize}); + | ^^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:213:14 +error[E0308]: arguments to this function are incorrect + --> $DIR/integer-literal-suffix-inference.rs:213:5 | LL | id_usize(b32); - | ^^^ expected `usize`, found `u32` + | ^^^^^^^^^---^ + | | + | expected `usize`, found `u32` | -help: you can convert a `u32` to a `usize` and panic if the converted value doesn't fit +note: function defined here + --> $DIR/integer-literal-suffix-inference.rs:31:8 | -LL | id_usize(b32.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn id_usize(n: usize) -> usize { n } + | ^^^^^^^^ -------- +help: provide an argument of the correct type + | +LL | id_usize({usize}); + | ^^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:216:14 +error[E0308]: arguments to this function are incorrect + --> $DIR/integer-literal-suffix-inference.rs:216:5 | LL | id_usize(b64); - | ^^^ expected `usize`, found `u64` + | ^^^^^^^^^---^ + | | + | expected `usize`, found `u64` + | +note: function defined here + --> $DIR/integer-literal-suffix-inference.rs:31:8 | -help: you can convert a `u64` to a `usize` and panic if the converted value doesn't fit +LL | fn id_usize(n: usize) -> usize { n } + | ^^^^^^^^ -------- +help: provide an argument of the correct type | -LL | id_usize(b64.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | id_usize({usize}); + | ^^^^^^^^^^^^^^^^^ error: aborting due to 52 previous errors diff --git a/src/test/ui/issues/issue-10764.rs b/src/test/ui/issues/issue-10764.rs index 8fa3607815ad5..9c3e2da2725fb 100644 --- a/src/test/ui/issues/issue-10764.rs +++ b/src/test/ui/issues/issue-10764.rs @@ -2,4 +2,4 @@ fn f(_: extern "Rust" fn()) {} extern fn bar() {} fn main() { f(bar) } -//~^ ERROR mismatched types +//~^ ERROR arguments to this function are incorrect diff --git a/src/test/ui/issues/issue-10764.stderr b/src/test/ui/issues/issue-10764.stderr index b0bafc9942ee9..1a22b5834c48d 100644 --- a/src/test/ui/issues/issue-10764.stderr +++ b/src/test/ui/issues/issue-10764.stderr @@ -1,11 +1,20 @@ -error[E0308]: mismatched types - --> $DIR/issue-10764.rs:4:15 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-10764.rs:4:13 | LL | fn main() { f(bar) } - | ^^^ expected "Rust" fn, found "C" fn + | ^^---^ + | | + | expected `fn()`, found `extern "C" fn() {bar}` | - = note: expected fn pointer `fn()` - found fn item `extern "C" fn() {bar}` +note: function defined here + --> $DIR/issue-10764.rs:1:4 + | +LL | fn f(_: extern "Rust" fn()) {} + | ^ --------------------- +help: provide an argument of the correct type + | +LL | fn main() { f({fn()}) } + | ^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-11374.stderr b/src/test/ui/issues/issue-11374.stderr index d6a3e758de84a..e858c38b7bb13 100644 --- a/src/test/ui/issues/issue-11374.stderr +++ b/src/test/ui/issues/issue-11374.stderr @@ -1,14 +1,18 @@ -error[E0308]: mismatched types - --> $DIR/issue-11374.rs:26:15 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-11374.rs:26:7 | LL | c.read_to(v); - | ^ - | | - | expected `&mut [u8]`, found struct `Vec` - | help: consider mutably borrowing here: `&mut v` + | ^^^^^^^ - expected `&mut [u8]`, found `Vec<_>` | - = note: expected mutable reference `&mut [u8]` - found struct `Vec<_>` +note: associated function defined here + --> $DIR/issue-11374.rs:13:12 + | +LL | pub fn read_to(&mut self, vec: &mut [u8]) { + | ^^^^^^^ --------- -------------- +help: provide an argument of the correct type + | +LL | c.read_to({&mut [u8]})(v); + | ^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-11515.rs b/src/test/ui/issues/issue-11515.rs index a7671b9282a99..803b7a0b42392 100644 --- a/src/test/ui/issues/issue-11515.rs +++ b/src/test/ui/issues/issue-11515.rs @@ -6,5 +6,6 @@ struct Test { fn main() { let closure: Box = Box::new(|| ()); - let test = box Test { func: closure }; //~ ERROR mismatched types + let test = box Test { func: closure }; + //~^ ERROR mismatched types } diff --git a/src/test/ui/issues/issue-12997-2.rs b/src/test/ui/issues/issue-12997-2.rs index 9df965315ab38..2defd4ea57fd1 100644 --- a/src/test/ui/issues/issue-12997-2.rs +++ b/src/test/ui/issues/issue-12997-2.rs @@ -6,4 +6,4 @@ #[bench] fn bar(x: isize) { } -//~^ ERROR mismatched types +//~^ ERROR arguments to this function are incorrect diff --git a/src/test/ui/issues/issue-12997-2.stderr b/src/test/ui/issues/issue-12997-2.stderr index 895b415a7e2e1..838ed76008d84 100644 --- a/src/test/ui/issues/issue-12997-2.stderr +++ b/src/test/ui/issues/issue-12997-2.stderr @@ -1,10 +1,19 @@ -error[E0308]: mismatched types +error[E0308]: arguments to this function are incorrect --> $DIR/issue-12997-2.rs:8:1 | LL | fn bar(x: isize) { } | ^^^^^^^^^^^^^^^^^^^^ expected `isize`, found `&mut Bencher` | +note: function defined here + --> $DIR/issue-12997-2.rs:8:4 + | +LL | fn bar(x: isize) { } + | ^^^ -------- = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info) +help: provide an argument of the correct type + | +LL | bar({isize}) + | error: aborting due to previous error diff --git a/src/test/ui/issues/issue-13359.rs b/src/test/ui/issues/issue-13359.rs index 9129790c501e3..213e9e9654951 100644 --- a/src/test/ui/issues/issue-13359.rs +++ b/src/test/ui/issues/issue-13359.rs @@ -4,10 +4,10 @@ fn bar(_s: u32) { } fn main() { foo(1*(1 as isize)); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `i16`, found `isize` bar(1*(1 as usize)); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `u32`, found `usize` } diff --git a/src/test/ui/issues/issue-13359.stderr b/src/test/ui/issues/issue-13359.stderr index 115b471e96b46..7556cb58671eb 100644 --- a/src/test/ui/issues/issue-13359.stderr +++ b/src/test/ui/issues/issue-13359.stderr @@ -1,24 +1,38 @@ -error[E0308]: mismatched types - --> $DIR/issue-13359.rs:6:9 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-13359.rs:6:5 | LL | foo(1*(1 as isize)); - | ^^^^^^^^^^^^^^ expected `i16`, found `isize` + | ^^^^--------------^ + | | + | expected `i16`, found `_` | -help: you can convert an `isize` to an `i16` and panic if the converted value doesn't fit +note: function defined here + --> $DIR/issue-13359.rs:1:4 | -LL | foo((1*(1 as isize)).try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn foo(_s: i16) { } + | ^^^ ------- +help: provide an argument of the correct type + | +LL | foo({i16}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/issue-13359.rs:10:9 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-13359.rs:10:5 | LL | bar(1*(1 as usize)); - | ^^^^^^^^^^^^^^ expected `u32`, found `usize` + | ^^^^--------------^ + | | + | expected `u32`, found `_` + | +note: function defined here + --> $DIR/issue-13359.rs:3:4 | -help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit +LL | fn bar(_s: u32) { } + | ^^^ ------- +help: provide an argument of the correct type | -LL | bar((1*(1 as usize)).try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | bar({u32}); + | ^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-13853.rs b/src/test/ui/issues/issue-13853.rs index ac9886d2e7249..383186b554a25 100644 --- a/src/test/ui/issues/issue-13853.rs +++ b/src/test/ui/issues/issue-13853.rs @@ -34,5 +34,5 @@ pub fn main() { graph.push(Stuff); - iterate(graph); //~ ERROR mismatched types + iterate(graph); //~ ERROR arguments to this function are incorrect } diff --git a/src/test/ui/issues/issue-13853.stderr b/src/test/ui/issues/issue-13853.stderr index 527e0225eb976..f428d33b538eb 100644 --- a/src/test/ui/issues/issue-13853.stderr +++ b/src/test/ui/issues/issue-13853.stderr @@ -16,17 +16,23 @@ error[E0599]: no method named `iter` found for reference `&G` in the current sco LL | for node in graph.iter() { | ^^^^ method not found in `&G` -error[E0308]: mismatched types - --> $DIR/issue-13853.rs:37:13 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-13853.rs:37:5 | LL | iterate(graph); - | ^^^^^ + | ^^^^^^^^-----^ | | - | expected reference, found struct `Vec` - | help: consider borrowing here: `&graph` + | expected `&_`, found `Vec` + | +note: function defined here + --> $DIR/issue-13853.rs:26:4 + | +LL | fn iterate>(graph: &G) { + | ^^^^^^^ --------- +help: provide an argument of the correct type | - = note: expected reference `&_` - found struct `Vec` +LL | iterate({&_}); + | ^^^^^^^^^^^^^ error: aborting due to 3 previous errors diff --git a/src/test/ui/issues/issue-1448-2.rs b/src/test/ui/issues/issue-1448-2.rs index 829e81b9c24b5..4fafb85dc57b4 100644 --- a/src/test/ui/issues/issue-1448-2.rs +++ b/src/test/ui/issues/issue-1448-2.rs @@ -3,5 +3,5 @@ fn foo(a: u32) -> u32 { a } fn main() { - println!("{}", foo(10i32)); //~ ERROR mismatched types + println!("{}", foo(10i32)); //~ ERROR arguments to this function are incorrect } diff --git a/src/test/ui/issues/issue-1448-2.stderr b/src/test/ui/issues/issue-1448-2.stderr index 9cf2f09e17747..baeb84533f237 100644 --- a/src/test/ui/issues/issue-1448-2.stderr +++ b/src/test/ui/issues/issue-1448-2.stderr @@ -1,13 +1,20 @@ -error[E0308]: mismatched types - --> $DIR/issue-1448-2.rs:6:24 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-1448-2.rs:6:20 | LL | println!("{}", foo(10i32)); - | ^^^^^ expected `u32`, found `i32` + | ^^^^-----^ + | | + | expected `u32`, found `i32` | -help: change the type of the numeric literal from `i32` to `u32` +note: function defined here + --> $DIR/issue-1448-2.rs:3:4 | -LL | println!("{}", foo(10u32)); - | ^^^^^ +LL | fn foo(a: u32) -> u32 { a } + | ^^^ ------ +help: provide an argument of the correct type + | +LL | println!("{}", foo({u32})); + | ^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-15783.rs b/src/test/ui/issues/issue-15783.rs index 0b1f4545e8804..bb0c2d5793613 100644 --- a/src/test/ui/issues/issue-15783.rs +++ b/src/test/ui/issues/issue-15783.rs @@ -6,7 +6,7 @@ fn main() { let name = "Foo"; let x = Some(&[name]); let msg = foo(x); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected enum `Option<&[&str]>` //~| found enum `Option<&[&str; 1]>` //~| expected slice `[&str]`, found array `[&str; 1]` diff --git a/src/test/ui/issues/issue-15783.stderr b/src/test/ui/issues/issue-15783.stderr index 0b09751676e9c..a683b891cddb5 100644 --- a/src/test/ui/issues/issue-15783.stderr +++ b/src/test/ui/issues/issue-15783.stderr @@ -1,11 +1,20 @@ -error[E0308]: mismatched types - --> $DIR/issue-15783.rs:8:19 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-15783.rs:8:15 | LL | let msg = foo(x); - | ^ expected slice `[&str]`, found array `[&str; 1]` + | ^^^^-^ + | | + | expected `Option<&[&str]>`, found `Option<&[&str; 1]>` | - = note: expected enum `Option<&[&str]>` - found enum `Option<&[&str; 1]>` +note: function defined here + --> $DIR/issue-15783.rs:1:8 + | +LL | pub fn foo(params: Option<&[&str]>) -> usize { + | ^^^ ----------------------- +help: provide an argument of the correct type + | +LL | let msg = foo({Option<&[&str]>}); + | ^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-16939.rs b/src/test/ui/issues/issue-16939.rs index ad7248343918d..e10eb048e4b55 100644 --- a/src/test/ui/issues/issue-16939.rs +++ b/src/test/ui/issues/issue-16939.rs @@ -2,7 +2,7 @@ // wrong arity. fn _foo (f: F) { - |t| f(t); //~ ERROR E0057 + |t| f(t); //~ ERROR arguments to this function are incorrect } fn main() {} diff --git a/src/test/ui/issues/issue-16939.stderr b/src/test/ui/issues/issue-16939.stderr index 103f56fa04dd3..ffac0e1c97d52 100644 --- a/src/test/ui/issues/issue-16939.stderr +++ b/src/test/ui/issues/issue-16939.stderr @@ -1,11 +1,16 @@ -error[E0057]: this function takes 0 arguments but 1 argument was supplied +error[E0308]: arguments to this function are incorrect --> $DIR/issue-16939.rs:5:9 | LL | |t| f(t); - | ^ - supplied 1 argument - | | - | expected 0 arguments + | ^^-^ + | | + | argument unexpected + | +help: remove the extra argument + | +LL | |t| (); + | ^^ error: aborting due to previous error -For more information about this error, try `rustc --explain E0057`. +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/issues/issue-17033.rs b/src/test/ui/issues/issue-17033.rs index 72a8cd9823a4b..f135819838f01 100644 --- a/src/test/ui/issues/issue-17033.rs +++ b/src/test/ui/issues/issue-17033.rs @@ -1,5 +1,5 @@ fn f<'r>(p: &'r mut fn(p: &mut ())) { - (*p)(()) //~ ERROR mismatched types + (*p)(()) //~ ERROR arguments to this function are incorrect //~| expected `&mut ()`, found `()` } diff --git a/src/test/ui/issues/issue-17033.stderr b/src/test/ui/issues/issue-17033.stderr index 518fc30142c94..7a22dedbda750 100644 --- a/src/test/ui/issues/issue-17033.stderr +++ b/src/test/ui/issues/issue-17033.stderr @@ -1,11 +1,15 @@ -error[E0308]: mismatched types - --> $DIR/issue-17033.rs:2:10 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-17033.rs:2:5 | LL | (*p)(()) - | ^^ + | ^^^^^--^ | | | expected `&mut ()`, found `()` - | help: consider mutably borrowing here: `&mut ()` + | +help: provide an argument of the correct type + | +LL | ({&mut ()}) + | ^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-18819.rs b/src/test/ui/issues/issue-18819.rs index e634c55f824fd..979038fb7b44e 100644 --- a/src/test/ui/issues/issue-18819.rs +++ b/src/test/ui/issues/issue-18819.rs @@ -14,5 +14,5 @@ fn print_x(_: &dyn Foo, extra: &str) { fn main() { print_x(X); - //~^ ERROR E0061 + //~^ ERROR arguments to this function are incorrect } diff --git a/src/test/ui/issues/issue-18819.stderr b/src/test/ui/issues/issue-18819.stderr index b10d26abe3485..00b8667f46c0d 100644 --- a/src/test/ui/issues/issue-18819.stderr +++ b/src/test/ui/issues/issue-18819.stderr @@ -1,17 +1,22 @@ -error[E0061]: this function takes 2 arguments but 1 argument was supplied +error[E0308]: arguments to this function are incorrect --> $DIR/issue-18819.rs:16:5 | LL | print_x(X); - | ^^^^^^^ - supplied 1 argument - | | - | expected 2 arguments + | ^^^^^^^^-^ + | | | + | | expected `&dyn Foo`, found `X` + | an argument of type &str is missing | note: function defined here --> $DIR/issue-18819.rs:11:4 | LL | fn print_x(_: &dyn Foo, extra: &str) { | ^^^^^^^ ---------------------- ----------- +help: did you mean + | +LL | print_x({&dyn Foo}, {&str}); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error -For more information about this error, try `rustc --explain E0061`. +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/issues/issue-24819.rs b/src/test/ui/issues/issue-24819.rs index 59c3f2cd114de..dbe05b88f182a 100644 --- a/src/test/ui/issues/issue-24819.rs +++ b/src/test/ui/issues/issue-24819.rs @@ -3,7 +3,7 @@ use std::collections::HashSet; fn main() { let mut v = Vec::new(); foo(&mut v); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected struct `HashSet`, found struct `Vec` } diff --git a/src/test/ui/issues/issue-24819.stderr b/src/test/ui/issues/issue-24819.stderr index 2f931e59d5942..2a2ed40f199bd 100644 --- a/src/test/ui/issues/issue-24819.stderr +++ b/src/test/ui/issues/issue-24819.stderr @@ -1,11 +1,20 @@ -error[E0308]: mismatched types - --> $DIR/issue-24819.rs:5:9 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-24819.rs:5:5 | LL | foo(&mut v); - | ^^^^^^ expected struct `HashSet`, found struct `Vec` + | ^^^^------^ + | | + | expected `&mut HashSet`, found `&mut Vec<_>` | - = note: expected mutable reference `&mut HashSet` - found mutable reference `&mut Vec<_>` +note: function defined here + --> $DIR/issue-24819.rs:10:4 + | +LL | fn foo(h: &mut HashSet) { + | ^^^ -------------------- +help: provide an argument of the correct type + | +LL | foo({&mut HashSet}); + | ^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-25439.stderr b/src/test/ui/issues/issue-25439.stderr index 325c28c15e272..4a4a8e8fc4da0 100644 --- a/src/test/ui/issues/issue-25439.stderr +++ b/src/test/ui/issues/issue-25439.stderr @@ -1,14 +1,21 @@ -error[E0644]: closure/generator type that references itself - --> $DIR/issue-25439.rs:8:9 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-25439.rs:8:5 | LL | fix(|_, x| x); - | ^^^^^^^^ cyclic type of infinite size + | ^^^^--------^ + | | + | expected `_` | - = note: closures cannot capture themselves or take themselves as argument; - this error may be the result of a recent compiler bug-fix, - see issue #46062 - for more information +note: function defined here + --> $DIR/issue-25439.rs:3:4 + | +LL | fn fix(f: F) -> i32 where F: Fn(Helper, i32) -> i32 { + | ^^^ ---- +help: provide an argument of the correct type + | +LL | fix({_}); + | ^^^^^^^^ error: aborting due to previous error -For more information about this error, try `rustc --explain E0644`. +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/issues/issue-26094.rs b/src/test/ui/issues/issue-26094.rs index 78fb0491d82dd..292851316935d 100644 --- a/src/test/ui/issues/issue-26094.rs +++ b/src/test/ui/issues/issue-26094.rs @@ -8,6 +8,6 @@ fn some_function() {} //~ NOTE defined here fn main() { some_macro!(some_function); - //~^ ERROR this function takes 0 arguments but 1 argument was supplied - //~| NOTE expected 0 arguments + //~^ ERROR arguments to this function are incorrect + //~| NOTE argument unexpected } diff --git a/src/test/ui/issues/issue-26094.stderr b/src/test/ui/issues/issue-26094.stderr index a6f1ac9286cda..32ab0fb06a8f6 100644 --- a/src/test/ui/issues/issue-26094.stderr +++ b/src/test/ui/issues/issue-26094.stderr @@ -1,18 +1,25 @@ -error[E0061]: this function takes 0 arguments but 1 argument was supplied - --> $DIR/issue-26094.rs:10:17 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-26094.rs:3:9 | LL | $other(None) - | ---- supplied 1 argument + | ^^^^^^^----^ + | | + | argument unexpected ... LL | some_macro!(some_function); - | ^^^^^^^^^^^^^ expected 0 arguments + | --------------------------- in this macro invocation | note: function defined here --> $DIR/issue-26094.rs:7:4 | LL | fn some_function() {} | ^^^^^^^^^^^^^ + = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) +help: remove the extra argument + | +LL | some_function() + | ^^^^^^^^^^^^^^^ error: aborting due to previous error -For more information about this error, try `rustc --explain E0061`. +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/issues/issue-29084.rs b/src/test/ui/issues/issue-29084.rs index d16252686698d..0c16e0f971f00 100644 --- a/src/test/ui/issues/issue-29084.rs +++ b/src/test/ui/issues/issue-29084.rs @@ -2,7 +2,7 @@ macro_rules! foo { ($d:expr) => {{ fn bar(d: u8) { } bar(&mut $d); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `u8`, found `&mut u8` }} } diff --git a/src/test/ui/issues/issue-29084.stderr b/src/test/ui/issues/issue-29084.stderr index bc22e9371395f..7eced45b00bc7 100644 --- a/src/test/ui/issues/issue-29084.stderr +++ b/src/test/ui/issues/issue-29084.stderr @@ -1,13 +1,27 @@ -error[E0308]: mismatched types - --> $DIR/issue-29084.rs:4:13 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-29084.rs:4:9 | LL | bar(&mut $d); - | ^^^^^^^ expected `u8`, found `&mut u8` + | ^^^^-------^ + | | + | expected `u8`, found `&mut u8` ... LL | foo!(0u8); | ---------- in this macro invocation | +note: function defined here + --> $DIR/issue-29084.rs:3:12 + | +LL | fn bar(d: u8) { } + | ^^^ ----- +... +LL | foo!(0u8); + | ---------- in this macro invocation = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) +help: provide an argument of the correct type + | +LL | bar({u8}); + | ^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-3044.rs b/src/test/ui/issues/issue-3044.rs index 81d76a90eb0ac..d67ffc27c24b3 100644 --- a/src/test/ui/issues/issue-3044.rs +++ b/src/test/ui/issues/issue-3044.rs @@ -2,5 +2,6 @@ fn main() { let needlesArr: Vec = vec!['a', 'f']; needlesArr.iter().fold(|x, y| { }); - //~^^ ERROR this function takes 2 arguments but 1 argument was supplied + //~^^ ERROR mismatched types + //~| ERROR arguments to this function are incorrect } diff --git a/src/test/ui/issues/issue-3044.stderr b/src/test/ui/issues/issue-3044.stderr index d2c010659edd0..a5456f4db9311 100644 --- a/src/test/ui/issues/issue-3044.stderr +++ b/src/test/ui/issues/issue-3044.stderr @@ -1,13 +1,26 @@ -error[E0061]: this function takes 2 arguments but 1 argument was supplied - --> $DIR/issue-3044.rs:3:23 +error[E0308]: mismatched types + --> $DIR/issue-3044.rs:3:35 | LL | needlesArr.iter().fold(|x, y| { - | _______________________^^^^_- - | | | - | | expected 2 arguments + | ___________________________________^ LL | | }); - | |_____- supplied 1 argument + | |_____^ expected closure, found `()` + | + = note: expected closure `[closure@$DIR/issue-3044.rs:3:28: 4:6]` + found unit type `()` + +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-3044.rs:3:23 + | +LL | needlesArr.iter().fold(|x, y| { + | ^^^^ an argument of type _ is missing + | +help: provide the argument + | +LL | needlesArr.iter().(|x, y| { +LL | }, {_})(|x, y| { + | -error: aborting due to previous error +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 E0308`. diff --git a/src/test/ui/issues/issue-43420-no-over-suggest.rs b/src/test/ui/issues/issue-43420-no-over-suggest.rs index 4365bff5af566..36715d3b218b1 100644 --- a/src/test/ui/issues/issue-43420-no-over-suggest.rs +++ b/src/test/ui/issues/issue-43420-no-over-suggest.rs @@ -5,5 +5,5 @@ fn foo(b: &[u16]) {} fn main() { let a: Vec = Vec::new(); - foo(&a); //~ ERROR mismatched types + foo(&a); //~ ERROR arguments to this function are incorrect } diff --git a/src/test/ui/issues/issue-43420-no-over-suggest.stderr b/src/test/ui/issues/issue-43420-no-over-suggest.stderr index 77d52f6ecab11..018d597babf46 100644 --- a/src/test/ui/issues/issue-43420-no-over-suggest.stderr +++ b/src/test/ui/issues/issue-43420-no-over-suggest.stderr @@ -1,11 +1,20 @@ -error[E0308]: mismatched types - --> $DIR/issue-43420-no-over-suggest.rs:8:9 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-43420-no-over-suggest.rs:8:5 | LL | foo(&a); - | ^^ expected slice `[u16]`, found struct `Vec` + | ^^^^--^ + | | + | expected `&[u16]`, found `&Vec` | - = note: expected reference `&[u16]` - found reference `&Vec` +note: function defined here + --> $DIR/issue-43420-no-over-suggest.rs:4:4 + | +LL | fn foo(b: &[u16]) {} + | ^^^ --------- +help: provide an argument of the correct type + | +LL | foo({&[u16]}); + | ^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-44023.rs b/src/test/ui/issues/issue-44023.rs index 4c38ddfcdf189..8cf791d367372 100644 --- a/src/test/ui/issues/issue-44023.rs +++ b/src/test/ui/issues/issue-44023.rs @@ -2,5 +2,6 @@ pub fn main () {} -fn საჭმელად_გემრიელი_სადილი ( ) -> isize { //~ ERROR mismatched types +fn საჭმელად_გემრიელი_სადილი ( ) -> isize { + //~^ ERROR mismatched types } diff --git a/src/test/ui/issues/issue-4517.rs b/src/test/ui/issues/issue-4517.rs index caf85d44aac5c..d0d3b14555cc7 100644 --- a/src/test/ui/issues/issue-4517.rs +++ b/src/test/ui/issues/issue-4517.rs @@ -3,6 +3,6 @@ fn bar(int_param: usize) {} fn main() { let foo: [u8; 4] = [1; 4]; bar(foo); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `usize`, found array `[u8; 4]` } diff --git a/src/test/ui/issues/issue-4517.stderr b/src/test/ui/issues/issue-4517.stderr index 1ae97b69c6cac..6853b3f65f991 100644 --- a/src/test/ui/issues/issue-4517.stderr +++ b/src/test/ui/issues/issue-4517.stderr @@ -1,8 +1,20 @@ -error[E0308]: mismatched types - --> $DIR/issue-4517.rs:5:9 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-4517.rs:5:5 | LL | bar(foo); - | ^^^ expected `usize`, found array `[u8; 4]` + | ^^^^---^ + | | + | expected `usize`, found `[u8; 4]` + | +note: function defined here + --> $DIR/issue-4517.rs:1:4 + | +LL | fn bar(int_param: usize) {} + | ^^^ ---------------- +help: provide an argument of the correct type + | +LL | bar({usize}); + | ^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-46112.rs b/src/test/ui/issues/issue-46112.rs index 0cdd2c27ff73e..9c3e5e3cc1e41 100644 --- a/src/test/ui/issues/issue-46112.rs +++ b/src/test/ui/issues/issue-46112.rs @@ -7,4 +7,4 @@ extern crate xcrate_issue_46112_rexport_core; fn test(r: Result, &'static str>) { } fn main() { test(Ok(())); } -//~^ mismatched types +//~^ arguments to this function are incorrect diff --git a/src/test/ui/issues/issue-46112.stderr b/src/test/ui/issues/issue-46112.stderr index ec05fbe580ede..af74de58595d4 100644 --- a/src/test/ui/issues/issue-46112.stderr +++ b/src/test/ui/issues/issue-46112.stderr @@ -1,14 +1,15 @@ -error[E0308]: mismatched types - --> $DIR/issue-46112.rs:9:21 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-46112.rs:9:18 | LL | fn main() { test(Ok(())); } - | ^^ + | ^^^--^ | | - | expected enum `Option`, found `()` - | help: try using a variant of the expected enum: `Some(())` + | expected `Option<()>`, found `()` | - = note: expected enum `Option<()>` - found unit type `()` +help: provide an argument of the correct type + | +LL | fn main() { test(({Option<()>})); } + | ^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-46756-consider-borrowing-cast-or-binexpr.fixed b/src/test/ui/issues/issue-46756-consider-borrowing-cast-or-binexpr.fixed index 8668d8acd5b30..79dc5dfdbf556 100644 --- a/src/test/ui/issues/issue-46756-consider-borrowing-cast-or-binexpr.fixed +++ b/src/test/ui/issues/issue-46756-consider-borrowing-cast-or-binexpr.fixed @@ -9,8 +9,8 @@ fn light_flows_our_war_of_mocking_words(and_yet: &usize) -> usize { fn main() { let behold: isize = 2; let with_tears: usize = 3; - light_flows_our_war_of_mocking_words(&(behold as usize)); - //~^ ERROR mismatched types [E0308] - light_flows_our_war_of_mocking_words(&(with_tears + 4)); - //~^ ERROR mismatched types [E0308] + light_flows_our_war_of_mocking_words({&usize}); + //~^ ERROR arguments to this function are incorrect [E0308] + light_flows_our_war_of_mocking_words({&usize}); + //~^ ERROR arguments to this function are incorrect [E0308] } diff --git a/src/test/ui/issues/issue-46756-consider-borrowing-cast-or-binexpr.rs b/src/test/ui/issues/issue-46756-consider-borrowing-cast-or-binexpr.rs index c8494612ca340..f714aa36cf8a9 100644 --- a/src/test/ui/issues/issue-46756-consider-borrowing-cast-or-binexpr.rs +++ b/src/test/ui/issues/issue-46756-consider-borrowing-cast-or-binexpr.rs @@ -10,7 +10,7 @@ fn main() { let behold: isize = 2; let with_tears: usize = 3; light_flows_our_war_of_mocking_words(behold as usize); - //~^ ERROR mismatched types [E0308] + //~^ ERROR arguments to this function are incorrect [E0308] light_flows_our_war_of_mocking_words(with_tears + 4); - //~^ ERROR mismatched types [E0308] + //~^ ERROR arguments to this function are incorrect [E0308] } diff --git a/src/test/ui/issues/issue-46756-consider-borrowing-cast-or-binexpr.stderr b/src/test/ui/issues/issue-46756-consider-borrowing-cast-or-binexpr.stderr index 2d666e2b66c25..6e2439602c43e 100644 --- a/src/test/ui/issues/issue-46756-consider-borrowing-cast-or-binexpr.stderr +++ b/src/test/ui/issues/issue-46756-consider-borrowing-cast-or-binexpr.stderr @@ -1,20 +1,38 @@ -error[E0308]: mismatched types - --> $DIR/issue-46756-consider-borrowing-cast-or-binexpr.rs:12:42 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-46756-consider-borrowing-cast-or-binexpr.rs:12:5 | LL | light_flows_our_war_of_mocking_words(behold as usize); - | ^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------^ | | | expected `&usize`, found `usize` - | help: consider borrowing here: `&(behold as usize)` + | +note: function defined here + --> $DIR/issue-46756-consider-borrowing-cast-or-binexpr.rs:5:4 + | +LL | fn light_flows_our_war_of_mocking_words(and_yet: &usize) -> usize { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ --------------- +help: provide an argument of the correct type + | +LL | light_flows_our_war_of_mocking_words({&usize}); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/issue-46756-consider-borrowing-cast-or-binexpr.rs:14:42 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-46756-consider-borrowing-cast-or-binexpr.rs:14:5 | LL | light_flows_our_war_of_mocking_words(with_tears + 4); - | ^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--------------^ | | - | expected `&usize`, found `usize` - | help: consider borrowing here: `&(with_tears + 4)` + | expected `&usize`, found `_` + | +note: function defined here + --> $DIR/issue-46756-consider-borrowing-cast-or-binexpr.rs:5:4 + | +LL | fn light_flows_our_war_of_mocking_words(and_yet: &usize) -> usize { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ --------------- +help: provide an argument of the correct type + | +LL | light_flows_our_war_of_mocking_words({&usize}); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-48364.rs b/src/test/ui/issues/issue-48364.rs index 14ee75e7c9cb6..6c6a6ca4bba01 100644 --- a/src/test/ui/issues/issue-48364.rs +++ b/src/test/ui/issues/issue-48364.rs @@ -1,6 +1,6 @@ fn foo() -> bool { b"".starts_with(stringify!(foo)) - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect } fn main() {} diff --git a/src/test/ui/issues/issue-48364.stderr b/src/test/ui/issues/issue-48364.stderr index 5ccede308a1c1..347c0aa8913e3 100644 --- a/src/test/ui/issues/issue-48364.stderr +++ b/src/test/ui/issues/issue-48364.stderr @@ -1,12 +1,13 @@ -error[E0308]: mismatched types - --> $DIR/issue-48364.rs:2:21 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-48364.rs:2:9 | LL | b"".starts_with(stringify!(foo)) - | ^^^^^^^^^^^^^^^ expected slice `[u8]`, found `str` + | ^^^^^^^^^^^ --------------- expected `&[u8]`, found `&'static str` | - = note: expected reference `&[u8]` - found reference `&'static str` - = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) +help: provide an argument of the correct type + | +LL | b"".({&[u8]})(stringify!(foo)) + | ^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-4935.rs b/src/test/ui/issues/issue-4935.rs index b342bbb1b8eab..27cfa7a728129 100644 --- a/src/test/ui/issues/issue-4935.rs +++ b/src/test/ui/issues/issue-4935.rs @@ -3,4 +3,4 @@ fn foo(a: usize) {} //~^ defined here fn main() { foo(5, 6) } -//~^ ERROR this function takes 1 argument but 2 arguments were supplied +//~^ ERROR arguments to this function are incorrect diff --git a/src/test/ui/issues/issue-4935.stderr b/src/test/ui/issues/issue-4935.stderr index 03b9b91edefb2..4de960e65a1da 100644 --- a/src/test/ui/issues/issue-4935.stderr +++ b/src/test/ui/issues/issue-4935.stderr @@ -1,17 +1,21 @@ -error[E0061]: this function takes 1 argument but 2 arguments were supplied +error[E0308]: arguments to this function are incorrect --> $DIR/issue-4935.rs:5:13 | LL | fn main() { foo(5, 6) } - | ^^^ - - supplied 2 arguments - | | - | expected 1 argument + | ^^^^-^^^^ + | | + | argument of type usize unexpected | 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 -For more information about this error, try `rustc --explain E0061`. +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/issues/issue-51154.rs b/src/test/ui/issues/issue-51154.rs index 12903f79010cb..ac5bd8aeea1b7 100644 --- a/src/test/ui/issues/issue-51154.rs +++ b/src/test/ui/issues/issue-51154.rs @@ -1,6 +1,6 @@ fn foo() { let _: Box = Box::new(|| ()); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect } fn main() {} diff --git a/src/test/ui/issues/issue-51154.stderr b/src/test/ui/issues/issue-51154.stderr index 3c3428f3096a8..aa4c89bb35c52 100644 --- a/src/test/ui/issues/issue-51154.stderr +++ b/src/test/ui/issues/issue-51154.stderr @@ -1,14 +1,15 @@ -error[E0308]: mismatched types - --> $DIR/issue-51154.rs:2:30 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-51154.rs:2:21 | -LL | fn foo() { - | - this type parameter LL | let _: Box = Box::new(|| ()); - | ^^^^^ expected type parameter `F`, found closure + | ^^^^^^^^^-----^ + | | + | expected `F` | - = note: expected type parameter `F` - found closure `[closure@$DIR/issue-51154.rs:2:30: 2:35]` - = help: every closure has a distinct type and so could not always match the caller-chosen type of parameter `F` +help: provide an argument of the correct type + | +LL | let _: Box = ({F}); + | ^^^^^ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-5216.rs b/src/test/ui/issues/issue-5216.rs index 35b343edfbdbe..1194832fdc710 100644 --- a/src/test/ui/issues/issue-5216.rs +++ b/src/test/ui/issues/issue-5216.rs @@ -1,6 +1,6 @@ fn f() { } struct S(Box); -pub static C: S = S(f); //~ ERROR mismatched types +pub static C: S = S(f); //~ ERROR arguments to this function are incorrect fn g() { } diff --git a/src/test/ui/issues/issue-5216.stderr b/src/test/ui/issues/issue-5216.stderr index 7a1f42adf65d4..095041566916d 100644 --- a/src/test/ui/issues/issue-5216.stderr +++ b/src/test/ui/issues/issue-5216.stderr @@ -1,11 +1,20 @@ -error[E0308]: mismatched types - --> $DIR/issue-5216.rs:3:21 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-5216.rs:3:19 | LL | pub static C: S = S(f); - | ^ expected struct `Box`, found fn item + | ^^-^ + | | + | expected `Box<(dyn FnMut() + 'static)>`, found `fn() {f}` | - = note: expected struct `Box<(dyn FnMut() + 'static)>` - found fn item `fn() {f}` +note: tuple struct defined here + --> $DIR/issue-5216.rs:2:1 + | +LL | struct S(Box); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: provide an argument of the correct type + | +LL | pub static C: S = struct S(Box);({Box<(dyn FnMut() + 'static)>}); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types --> $DIR/issue-5216.rs:8:19 diff --git a/src/test/ui/issues/issue-52533-1.rs b/src/test/ui/issues/issue-52533-1.rs index c80f43237fc76..3279977d83253 100644 --- a/src/test/ui/issues/issue-52533-1.rs +++ b/src/test/ui/issues/issue-52533-1.rs @@ -7,5 +7,5 @@ fn gimme(_: impl for<'a, 'b, 'c> FnOnce(&'a Foo<'a, 'b, u32>, fn main() { gimme(|x, y| y) - //~^ ERROR mismatched types [E0308] + //~^ ERROR mismatched types } diff --git a/src/test/ui/issues/issue-61106.rs b/src/test/ui/issues/issue-61106.rs index 308ef1de3ccc3..bcfa5489f5194 100644 --- a/src/test/ui/issues/issue-61106.rs +++ b/src/test/ui/issues/issue-61106.rs @@ -1,6 +1,6 @@ fn main() { let x = String::new(); - foo(x.clone()); //~ ERROR mismatched types + foo(x.clone()); //~ ERROR arguments to this function are incorrect } fn foo(_: &str) {} diff --git a/src/test/ui/issues/issue-61106.stderr b/src/test/ui/issues/issue-61106.stderr index 2d841d28ee26d..9730a5eb39d86 100644 --- a/src/test/ui/issues/issue-61106.stderr +++ b/src/test/ui/issues/issue-61106.stderr @@ -1,11 +1,20 @@ -error[E0308]: mismatched types - --> $DIR/issue-61106.rs:3:9 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-61106.rs:3:5 | LL | foo(x.clone()); - | ^^^^^^^^^ + | ^^^^---------^ | | - | expected `&str`, found struct `String` - | help: consider borrowing here: `&x` + | expected `&str`, found `String` + | +note: function defined here + --> $DIR/issue-61106.rs:6:4 + | +LL | fn foo(_: &str) {} + | ^^^ ------- +help: provide an argument of the correct type + | +LL | foo({&str}); + | ^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-61882.rs b/src/test/ui/issues/issue-61882.rs index 013398b4598a8..8ed4847da66a3 100644 --- a/src/test/ui/issues/issue-61882.rs +++ b/src/test/ui/issues/issue-61882.rs @@ -2,7 +2,7 @@ struct A(T); impl A { const B: A = Self(0); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| ERROR mismatched types } diff --git a/src/test/ui/issues/issue-61882.stderr b/src/test/ui/issues/issue-61882.stderr index 09ffe8e64b1b1..cf10532d68114 100644 --- a/src/test/ui/issues/issue-61882.stderr +++ b/src/test/ui/issues/issue-61882.stderr @@ -1,8 +1,20 @@ -error[E0308]: mismatched types - --> $DIR/issue-61882.rs:4:27 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-61882.rs:4:22 | LL | const B: A = Self(0); - | ^ expected `bool`, found integer + | ^^^^^-^ + | | + | expected `bool`, found `{integer}` + | +note: tuple struct defined here + --> $DIR/issue-61882.rs:1:1 + | +LL | struct A(T); + | ^^^^^^^^^^^^^^^ +help: provide an argument of the correct type + | +LL | const B: A = struct A(T);({bool}); + | ^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types --> $DIR/issue-61882.rs:4:22 diff --git a/src/test/ui/issues/issue-69306.rs b/src/test/ui/issues/issue-69306.rs index 85d60952ac823..da4f3162fc218 100644 --- a/src/test/ui/issues/issue-69306.rs +++ b/src/test/ui/issues/issue-69306.rs @@ -3,12 +3,12 @@ fn main() {} struct S0(T); impl S0 { const C: S0 = Self(0); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| ERROR mismatched types fn foo() { Self(0); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect } } @@ -24,14 +24,14 @@ trait Foo { } impl Foo for as Fun>::Out { fn foo() { - Self(0); //~ ERROR mismatched types + Self(0); //~ ERROR arguments to this function are incorrect } } struct S1(T, U); impl S1 { const C: S1 = Self(0, 1); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| ERROR mismatched types } @@ -39,7 +39,7 @@ struct S2(T); impl S2 { fn map(x: U) -> S2 { Self(x) - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| ERROR mismatched types } } diff --git a/src/test/ui/issues/issue-69306.stderr b/src/test/ui/issues/issue-69306.stderr index 58e85ec700d2d..5b84ff59283db 100644 --- a/src/test/ui/issues/issue-69306.stderr +++ b/src/test/ui/issues/issue-69306.stderr @@ -1,13 +1,20 @@ -error[E0308]: mismatched types - --> $DIR/issue-69306.rs:5:28 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-69306.rs:5:23 | -LL | impl S0 { - | - this type parameter LL | const C: S0 = Self(0); - | ^ expected type parameter `T`, found integer + | ^^^^^-^ + | | + | expected `T`, found `{integer}` | - = note: expected type parameter `T` - found type `{integer}` +note: tuple struct defined here + --> $DIR/issue-69306.rs:3:1 + | +LL | struct S0(T); + | ^^^^^^^^^^^^^^^^ +help: provide an argument of the correct type + | +LL | const C: S0 = struct S0(T);({T}); + | ^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types --> $DIR/issue-69306.rs:5:23 @@ -20,40 +27,59 @@ LL | const C: S0 = Self(0); = note: expected struct `S0` found struct `S0` -error[E0308]: mismatched types - --> $DIR/issue-69306.rs:10:14 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-69306.rs:10:9 | -LL | impl S0 { - | - this type parameter -... LL | Self(0); - | ^ expected type parameter `T`, found integer + | ^^^^^-^ + | | + | expected `T`, found `{integer}` + | +note: tuple struct defined here + --> $DIR/issue-69306.rs:3:1 | - = note: expected type parameter `T` - found type `{integer}` +LL | struct S0(T); + | ^^^^^^^^^^^^^^^^ +help: provide an argument of the correct type + | +LL | struct S0(T);({T}); + | ^^^^^^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/issue-69306.rs:27:14 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-69306.rs:27:9 | -LL | impl Foo for as Fun>::Out { - | - this type parameter -LL | fn foo() { LL | Self(0); - | ^ expected type parameter `T`, found integer + | ^^^^^-^ + | | + | expected `T`, found `{integer}` + | +note: tuple struct defined here + --> $DIR/issue-69306.rs:3:1 + | +LL | struct S0(T); + | ^^^^^^^^^^^^^^^^ +help: provide an argument of the correct type | - = note: expected type parameter `T` - found type `{integer}` +LL | struct S0(T);({T}); + | ^^^^^^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/issue-69306.rs:33:32 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-69306.rs:33:27 | -LL | impl S1 { - | - this type parameter LL | const C: S1 = Self(0, 1); - | ^ expected type parameter `T`, found integer + | ^^^^^-^^^^ + | | + | expected `T`, found `{integer}` | - = note: expected type parameter `T` - found type `{integer}` +note: tuple struct defined here + --> $DIR/issue-69306.rs:31:1 + | +LL | struct S1(T, U); + | ^^^^^^^^^^^^^^^^^^^^^^ +help: provide an argument of the correct type + | +LL | const C: S1 = struct S1(T, U);({T}, 1); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types --> $DIR/issue-69306.rs:33:27 @@ -66,20 +92,23 @@ LL | const C: S1 = Self(0, 1); = note: expected struct `S1` found struct `S1` -error[E0308]: mismatched types - --> $DIR/issue-69306.rs:41:14 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-69306.rs:41:9 | -LL | impl S2 { - | - expected type parameter -LL | fn map(x: U) -> S2 { - | - found type parameter LL | Self(x) - | ^ expected type parameter `T`, found type parameter `U` + | ^^^^^-^ + | | + | expected `T`, found `U` + | +note: tuple struct defined here + --> $DIR/issue-69306.rs:38:1 + | +LL | struct S2(T); + | ^^^^^^^^^^^^^^^^ +help: provide an argument of the correct type + | +LL | struct S2(T);({T}) | - = note: expected type parameter `T` - found type parameter `U` - = note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound - = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters error[E0308]: mismatched types --> $DIR/issue-69306.rs:41:9 diff --git a/src/test/ui/liveness/liveness-closure-require-ret.rs b/src/test/ui/liveness/liveness-closure-require-ret.rs index b86d1fe4a660c..1ccc64d2c283c 100644 --- a/src/test/ui/liveness/liveness-closure-require-ret.rs +++ b/src/test/ui/liveness/liveness-closure-require-ret.rs @@ -1,2 +1,3 @@ fn force(f: F) -> isize where F: FnOnce() -> isize { f() } -fn main() { println!("{}", force(|| {})); } //~ ERROR mismatched types +fn main() { println!("{}", force(|| {})); } +//~^ ERROR mismatched types diff --git a/src/test/ui/liveness/liveness-return-last-stmt-semi.rs b/src/test/ui/liveness/liveness-return-last-stmt-semi.rs index e8909c4a5ae9b..ad53644aed20d 100644 --- a/src/test/ui/liveness/liveness-return-last-stmt-semi.rs +++ b/src/test/ui/liveness/liveness-return-last-stmt-semi.rs @@ -2,7 +2,7 @@ // regression test for #8005 macro_rules! test { () => { fn foo() -> i32 { 1; } } } - //~^ ERROR mismatched types +//~^ ERROR mismatched types fn no_return() -> i32 {} //~ ERROR mismatched types diff --git a/src/test/ui/loops/loop-labeled-break-value.rs b/src/test/ui/loops/loop-labeled-break-value.rs index 3488b057bc5d2..92c07f56cebe3 100644 --- a/src/test/ui/loops/loop-labeled-break-value.rs +++ b/src/test/ui/loops/loop-labeled-break-value.rs @@ -3,9 +3,11 @@ fn main() { let _: i32 = loop { break }; //~ ERROR mismatched types } loop { - let _: i32 = 'inner: loop { break 'inner }; //~ ERROR mismatched types + let _: i32 = 'inner: loop { break 'inner }; + //~^ ERROR mismatched types } loop { - let _: i32 = 'inner2: loop { loop { break 'inner2 } }; //~ ERROR mismatched types + let _: i32 = 'inner2: loop { loop { break 'inner2 } }; + //~^ ERROR mismatched types } } diff --git a/src/test/ui/loops/loop-labeled-break-value.stderr b/src/test/ui/loops/loop-labeled-break-value.stderr index aa04d330f25d7..1b42fa8a74ba9 100644 --- a/src/test/ui/loops/loop-labeled-break-value.stderr +++ b/src/test/ui/loops/loop-labeled-break-value.stderr @@ -17,7 +17,7 @@ LL | let _: i32 = 'inner: loop { break 'inner }; | help: give it a value of the expected type: `break 'inner 42` error[E0308]: mismatched types - --> $DIR/loop-labeled-break-value.rs:9:45 + --> $DIR/loop-labeled-break-value.rs:10:45 | LL | let _: i32 = 'inner2: loop { loop { break 'inner2 } }; | ^^^^^^^^^^^^^ diff --git a/src/test/ui/match/match-tag-nullary.rs b/src/test/ui/match/match-tag-nullary.rs index bb2f599694499..d65f1bfd53887 100644 --- a/src/test/ui/match/match-tag-nullary.rs +++ b/src/test/ui/match/match-tag-nullary.rs @@ -1,4 +1,5 @@ enum A { A } enum B { B } -fn main() { let x: A = A::A; match x { B::B => { } } } //~ ERROR mismatched types +fn main() { let x: A = A::A; match x { B::B => { } } } +//~^ ERROR mismatched types diff --git a/src/test/ui/match/match-tag-unary.rs b/src/test/ui/match/match-tag-unary.rs index aedceafb4398e..487521bc4eb36 100644 --- a/src/test/ui/match/match-tag-unary.rs +++ b/src/test/ui/match/match-tag-unary.rs @@ -1,4 +1,5 @@ enum A { A(isize) } enum B { B(isize) } -fn main() { let x: A = A::A(0); match x { B::B(y) => { } } } //~ ERROR mismatched types +fn main() { let x: A = A::A(0); match x { B::B(y) => { } } } +//~^ ERROR mismatched types diff --git a/src/test/ui/methods/method-call-err-msg.rs b/src/test/ui/methods/method-call-err-msg.rs index 9bfacc7babf2e..ec6624f06ba49 100644 --- a/src/test/ui/methods/method-call-err-msg.rs +++ b/src/test/ui/methods/method-call-err-msg.rs @@ -10,13 +10,13 @@ impl Foo { fn main() { let x = Foo; - x.zero(0) //~ ERROR this function takes 0 arguments but 1 argument was supplied - .one() //~ ERROR this function takes 1 argument but 0 arguments were supplied - .two(0); //~ ERROR this function takes 2 arguments but 1 argument was supplied + x.zero(0) //~ ERROR arguments to this function are incorrect + .one() //~ ERROR arguments to this function are incorrect + .two(0); //~ ERROR arguments to this function are incorrect let y = Foo; y.zero() .take() //~ ERROR no method named `take` found .one(0); - y.three::(); //~ ERROR this function takes 3 arguments but 0 arguments were supplied + y.three::(); //~ ERROR arguments to this function are incorrect } diff --git a/src/test/ui/methods/method-call-err-msg.stderr b/src/test/ui/methods/method-call-err-msg.stderr index 60f9eeeca27fe..b636c3d3fe939 100644 --- a/src/test/ui/methods/method-call-err-msg.stderr +++ b/src/test/ui/methods/method-call-err-msg.stderr @@ -1,44 +1,50 @@ -error[E0061]: this function takes 0 arguments but 1 argument was supplied +error[E0308]: arguments to this function are incorrect --> $DIR/method-call-err-msg.rs:13:7 | LL | x.zero(0) - | ^^^^ - supplied 1 argument - | | - | expected 0 arguments + | ^^^^ - argument unexpected | 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()(0) + | ^^^^^^ -error[E0061]: this function takes 1 argument but 0 arguments were supplied +error[E0308]: arguments to this function are incorrect --> $DIR/method-call-err-msg.rs:14:7 | LL | .one() - | ^^^- supplied 0 arguments - | | - | expected 1 argument + | ^^^ an argument of type isize is missing | note: associated function defined here --> $DIR/method-call-err-msg.rs:6:8 | LL | fn one(self, _: isize) -> Foo { self } | ^^^ ---- -------- +help: provide the argument + | +LL | .one({isize})() + | ^^^^^^^^^^^^ -error[E0061]: this function takes 2 arguments but 1 argument was supplied +error[E0308]: arguments to this function are incorrect --> $DIR/method-call-err-msg.rs:15:7 | LL | .two(0); - | ^^^ - supplied 1 argument - | | - | expected 2 arguments + | ^^^ an argument of type isize is missing | note: associated function defined here --> $DIR/method-call-err-msg.rs:7:8 | LL | fn two(self, _: isize, _: isize) -> Foo { self } | ^^^ ---- -------- -------- +help: provide the argument + | +LL | .two(0, {isize})(0); + | ^^^^^^^^^^^^^^^ error[E0599]: no method named `take` found for struct `Foo` in the current scope --> $DIR/method-call-err-msg.rs:19:7 @@ -59,21 +65,27 @@ LL | .take() = note: the following trait defines an item `take`, perhaps you need to implement it: candidate #1: `Iterator` -error[E0061]: this function takes 3 arguments but 0 arguments were supplied +error[E0308]: arguments to this function are incorrect --> $DIR/method-call-err-msg.rs:21:7 | LL | y.three::(); - | ^^^^^--------- supplied 0 arguments + | ^^^^^ | | - | expected 3 arguments + | an argument of type usize is missing + | an argument of type usize is missing + | an argument of type usize is missing | note: associated function defined here --> $DIR/method-call-err-msg.rs:8:8 | LL | fn three(self, _: T, _: T, _: T) -> Foo { self } | ^^^^^ ---- ---- ---- ---- +help: did you mean + | +LL | y.three({usize}, {usize}, {usize})::(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 5 previous errors -Some errors have detailed explanations: E0061, E0599. -For more information about an error, try `rustc --explain E0061`. +Some errors have detailed explanations: E0308, E0599. +For more information about an error, try `rustc --explain E0308`. diff --git a/src/test/ui/methods/method-self-arg-1.rs b/src/test/ui/methods/method-self-arg-1.rs index f589f20d81ddf..0b43d530eb042 100644 --- a/src/test/ui/methods/method-self-arg-1.rs +++ b/src/test/ui/methods/method-self-arg-1.rs @@ -8,9 +8,9 @@ impl Foo { fn main() { let x = Foo; - Foo::bar(x); //~ ERROR mismatched types + Foo::bar(x); //~ ERROR arguments to this function are incorrect //~| expected `&Foo`, found struct `Foo` - Foo::bar(&42); //~ ERROR mismatched types + Foo::bar(&42); //~ ERROR arguments to this function are incorrect //~| expected struct `Foo`, found integer //~| expected reference `&Foo` //~| found reference `&{integer}` diff --git a/src/test/ui/methods/method-self-arg-1.stderr b/src/test/ui/methods/method-self-arg-1.stderr index 17ea61fc4bddb..3023cda9a0cd6 100644 --- a/src/test/ui/methods/method-self-arg-1.stderr +++ b/src/test/ui/methods/method-self-arg-1.stderr @@ -1,20 +1,38 @@ -error[E0308]: mismatched types - --> $DIR/method-self-arg-1.rs:11:14 +error[E0308]: arguments to this function are incorrect + --> $DIR/method-self-arg-1.rs:11:5 | LL | Foo::bar(x); - | ^ + | ^^^^^^^^^-^ | | - | expected `&Foo`, found struct `Foo` - | help: consider borrowing here: `&x` + | expected `&Foo`, found `Foo` + | +note: associated function defined here + --> $DIR/method-self-arg-1.rs:6:8 + | +LL | fn bar(&self) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | bar({&Foo}); + | ^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/method-self-arg-1.rs:13:14 +error[E0308]: arguments to this function are incorrect + --> $DIR/method-self-arg-1.rs:13:5 | LL | Foo::bar(&42); - | ^^^ expected struct `Foo`, found integer + | ^^^^^^^^^---^ + | | + | expected `&Foo`, found `&{integer}` + | +note: associated function defined here + --> $DIR/method-self-arg-1.rs:6:8 + | +LL | fn bar(&self) {} + | ^^^ ----- +help: provide an argument of the correct type | - = note: expected reference `&Foo` - found reference `&{integer}` +LL | bar({&Foo}); + | ^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/mismatched_types/issue-26480.rs b/src/test/ui/mismatched_types/issue-26480.rs index d140e12b04d38..2b1584d3aa3ee 100644 --- a/src/test/ui/mismatched_types/issue-26480.rs +++ b/src/test/ui/mismatched_types/issue-26480.rs @@ -13,7 +13,8 @@ macro_rules! write { const stdout: i32 = 1; unsafe { write(stdout, $arr.as_ptr() as *const i8, - $arr.len() * size_of($arr[0])); //~ ERROR mismatched types + $arr.len() * size_of($arr[0])); + //~^ ERROR mismatched types } }} } diff --git a/src/test/ui/mismatched_types/issue-35030.rs b/src/test/ui/mismatched_types/issue-35030.rs index 91ea7ea80c3d7..45bc2205433ea 100644 --- a/src/test/ui/mismatched_types/issue-35030.rs +++ b/src/test/ui/mismatched_types/issue-35030.rs @@ -6,7 +6,7 @@ trait Parser { impl Parser for bool { fn parse(text: &str) -> Option { - Some(true) //~ ERROR mismatched types + Some(true) //~ ERROR arguments to this function are incorrect } } diff --git a/src/test/ui/mismatched_types/issue-35030.stderr b/src/test/ui/mismatched_types/issue-35030.stderr index 9f4e4398984ae..bbc66ef64b5b3 100644 --- a/src/test/ui/mismatched_types/issue-35030.stderr +++ b/src/test/ui/mismatched_types/issue-35030.stderr @@ -1,14 +1,15 @@ -error[E0308]: mismatched types - --> $DIR/issue-35030.rs:9:14 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-35030.rs:9:9 | -LL | impl Parser for bool { - | ---- this type parameter -LL | fn parse(text: &str) -> Option { LL | Some(true) - | ^^^^ expected type parameter `bool`, found `bool` + | ^^^^^----^ + | | + | expected `bool`, found `bool` | - = note: expected type parameter `bool` (type parameter `bool`) - found type `bool` (`bool`) +help: provide an argument of the correct type + | +LL | ({bool}) + | ^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/mismatched_types/numeric-literal-cast.rs b/src/test/ui/mismatched_types/numeric-literal-cast.rs index 69cfe262fdf42..1f1caaaf7fa75 100644 --- a/src/test/ui/mismatched_types/numeric-literal-cast.rs +++ b/src/test/ui/mismatched_types/numeric-literal-cast.rs @@ -4,9 +4,9 @@ fn foo2(_: i32) {} fn main() { foo(1u8); -//~^ ERROR mismatched types +//~^ ERROR arguments to this function are incorrect foo1(2f32); -//~^ ERROR mismatched types +//~^ ERROR arguments to this function are incorrect foo2(3i16); -//~^ ERROR mismatched types +//~^ ERROR arguments to this function are incorrect } diff --git a/src/test/ui/mismatched_types/numeric-literal-cast.stderr b/src/test/ui/mismatched_types/numeric-literal-cast.stderr index 22a6df8902596..23a1cd8dc7d9a 100644 --- a/src/test/ui/mismatched_types/numeric-literal-cast.stderr +++ b/src/test/ui/mismatched_types/numeric-literal-cast.stderr @@ -1,35 +1,56 @@ -error[E0308]: mismatched types - --> $DIR/numeric-literal-cast.rs:6:9 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-literal-cast.rs:6:5 | LL | foo(1u8); - | ^^^ expected `u16`, found `u8` + | ^^^^---^ + | | + | expected `u16`, found `u8` | -help: change the type of the numeric literal from `u8` to `u16` +note: function defined here + --> $DIR/numeric-literal-cast.rs:1:4 | -LL | foo(1u16); - | ^^^^ +LL | fn foo(_: u16) {} + | ^^^ ------ +help: provide an argument of the correct type + | +LL | foo({u16}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-literal-cast.rs:8:10 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-literal-cast.rs:8:5 | LL | foo1(2f32); - | ^^^^ expected `f64`, found `f32` + | ^^^^^----^ + | | + | expected `f64`, found `f32` + | +note: function defined here + --> $DIR/numeric-literal-cast.rs:2:4 | -help: change the type of the numeric literal from `f32` to `f64` +LL | fn foo1(_: f64) {} + | ^^^^ ------ +help: provide an argument of the correct type | -LL | foo1(2f64); - | ^^^^ +LL | foo1({f64}); + | ^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-literal-cast.rs:10:10 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-literal-cast.rs:10:5 | LL | foo2(3i16); - | ^^^^ expected `i32`, found `i16` + | ^^^^^----^ + | | + | expected `i32`, found `i16` + | +note: function defined here + --> $DIR/numeric-literal-cast.rs:3:4 | -help: change the type of the numeric literal from `i16` to `i32` +LL | fn foo2(_: i32) {} + | ^^^^ ------ +help: provide an argument of the correct type | -LL | foo2(3i32); - | ^^^^ +LL | foo2({i32}); + | ^^^^^^^^^^^ error: aborting due to 3 previous errors diff --git a/src/test/ui/mismatched_types/overloaded-calls-bad.rs b/src/test/ui/mismatched_types/overloaded-calls-bad.rs index 902a6ec81d60b..21300467d5e6e 100644 --- a/src/test/ui/mismatched_types/overloaded-calls-bad.rs +++ b/src/test/ui/mismatched_types/overloaded-calls-bad.rs @@ -25,9 +25,9 @@ fn main() { x: 3, y: 3, }; - let ans = s("what"); //~ ERROR mismatched types + let ans = s("what"); //~ ERROR arguments to this function are incorrect let ans = s(); - //~^ ERROR this function takes 1 argument but 0 arguments were supplied + //~^ ERROR arguments to this function are incorrect let ans = s("burma", "shave"); - //~^ ERROR this function takes 1 argument but 2 arguments were supplied + //~^ ERROR arguments to this function are incorrect } diff --git a/src/test/ui/mismatched_types/overloaded-calls-bad.stderr b/src/test/ui/mismatched_types/overloaded-calls-bad.stderr index 706e25529bfaf..ae20d7a36b074 100644 --- a/src/test/ui/mismatched_types/overloaded-calls-bad.stderr +++ b/src/test/ui/mismatched_types/overloaded-calls-bad.stderr @@ -1,26 +1,41 @@ -error[E0308]: mismatched types - --> $DIR/overloaded-calls-bad.rs:28:17 +error[E0308]: arguments to this function are incorrect + --> $DIR/overloaded-calls-bad.rs:28:15 | LL | let ans = s("what"); - | ^^^^^^ expected `isize`, found `&str` + | ^^------^ + | | + | expected `isize`, found `&'static str` + | +help: provide an argument of the correct type + | +LL | let ans = ({isize}); + | ^^^^^^^^^ -error[E0057]: this function takes 1 argument but 0 arguments were supplied +error[E0308]: arguments to this function are incorrect --> $DIR/overloaded-calls-bad.rs:29:15 | LL | let ans = s(); - | ^-- supplied 0 arguments - | | - | expected 1 argument + | ^^^ an argument of type isize is missing + | +help: provide the argument + | +LL | let ans = ({isize}); + | ^^^^^^^^^ -error[E0057]: this function takes 1 argument but 2 arguments were supplied +error[E0308]: arguments to this function are incorrect --> $DIR/overloaded-calls-bad.rs:31:15 | LL | let ans = s("burma", "shave"); - | ^ ------- ------- supplied 2 arguments - | | - | expected 1 argument + | ^^-------^^^^^^^^^^ + | | + | expected `isize`, found `&'static str` + | argument of type isize unexpected + | +help: did you mean + | +LL | let ans = ({isize}); + | ^^^^^^^^^ error: aborting due to 3 previous errors -Some errors have detailed explanations: E0057, E0308. -For more information about an error, try `rustc --explain E0057`. +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/mismatched_types/trait-bounds-cant-coerce.rs b/src/test/ui/mismatched_types/trait-bounds-cant-coerce.rs index 882533992bd3c..b7ff461549b34 100644 --- a/src/test/ui/mismatched_types/trait-bounds-cant-coerce.rs +++ b/src/test/ui/mismatched_types/trait-bounds-cant-coerce.rs @@ -10,7 +10,7 @@ fn c(x: Box) { } fn d(x: Box) { - a(x); //~ ERROR mismatched types [E0308] + a(x); //~ ERROR arguments to this function are incorrect [E0308] } fn main() { } diff --git a/src/test/ui/mismatched_types/trait-bounds-cant-coerce.stderr b/src/test/ui/mismatched_types/trait-bounds-cant-coerce.stderr index 485fae6d4d9ff..41960825e7852 100644 --- a/src/test/ui/mismatched_types/trait-bounds-cant-coerce.stderr +++ b/src/test/ui/mismatched_types/trait-bounds-cant-coerce.stderr @@ -1,11 +1,20 @@ -error[E0308]: mismatched types - --> $DIR/trait-bounds-cant-coerce.rs:13:7 +error[E0308]: arguments to this function are incorrect + --> $DIR/trait-bounds-cant-coerce.rs:13:5 | LL | a(x); - | ^ expected trait `Foo + Send`, found trait `Foo` + | ^^-^ + | | + | expected `Box<(dyn Foo + Send + 'static)>`, found `Box<(dyn Foo + 'static)>` | - = note: expected struct `Box<(dyn Foo + Send + 'static)>` - found struct `Box<(dyn Foo + 'static)>` +note: function defined here + --> $DIR/trait-bounds-cant-coerce.rs:5:4 + | +LL | fn a(_x: Box) { + | ^ ----------------------- +help: provide an argument of the correct type + | +LL | a({Box<(dyn Foo + Send + 'static)>}); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/mut/mut-cross-borrowing.rs b/src/test/ui/mut/mut-cross-borrowing.rs index 63e49c292eac7..7f7e6d7e0d422 100644 --- a/src/test/ui/mut/mut-cross-borrowing.rs +++ b/src/test/ui/mut/mut-cross-borrowing.rs @@ -4,5 +4,5 @@ fn f(_: &mut isize) {} fn main() { let mut x: Box<_> = box 3; - f(x) //~ ERROR mismatched types + f(x) //~ ERROR arguments to this function are incorrect } diff --git a/src/test/ui/mut/mut-cross-borrowing.stderr b/src/test/ui/mut/mut-cross-borrowing.stderr index b77813f8af0b4..3d2fa1abfe54d 100644 --- a/src/test/ui/mut/mut-cross-borrowing.stderr +++ b/src/test/ui/mut/mut-cross-borrowing.stderr @@ -1,14 +1,20 @@ -error[E0308]: mismatched types - --> $DIR/mut-cross-borrowing.rs:7:7 +error[E0308]: arguments to this function are incorrect + --> $DIR/mut-cross-borrowing.rs:7:5 | LL | f(x) - | ^ + | ^^-^ | | - | expected `&mut isize`, found struct `Box` - | help: consider mutably borrowing here: `&mut x` + | expected `&mut isize`, found `Box<{integer}>` | - = note: expected mutable reference `&mut isize` - found struct `Box<{integer}>` +note: function defined here + --> $DIR/mut-cross-borrowing.rs:3:4 + | +LL | fn f(_: &mut isize) {} + | ^ ------------- +help: provide an argument of the correct type + | +LL | f({&mut isize}) + | ^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/never_type/call-fn-never-arg-wrong-type.rs b/src/test/ui/never_type/call-fn-never-arg-wrong-type.rs index d06637e74a2f2..3c5125bb6053a 100644 --- a/src/test/ui/never_type/call-fn-never-arg-wrong-type.rs +++ b/src/test/ui/never_type/call-fn-never-arg-wrong-type.rs @@ -7,5 +7,5 @@ fn foo(x: !) -> ! { } fn main() { - foo("wow"); //~ ERROR mismatched types + foo("wow"); //~ ERROR arguments to this function are incorrect } diff --git a/src/test/ui/never_type/call-fn-never-arg-wrong-type.stderr b/src/test/ui/never_type/call-fn-never-arg-wrong-type.stderr index eacef1dc3302d..de8b6e7115edb 100644 --- a/src/test/ui/never_type/call-fn-never-arg-wrong-type.stderr +++ b/src/test/ui/never_type/call-fn-never-arg-wrong-type.stderr @@ -1,11 +1,20 @@ -error[E0308]: mismatched types - --> $DIR/call-fn-never-arg-wrong-type.rs:10:9 +error[E0308]: arguments to this function are incorrect + --> $DIR/call-fn-never-arg-wrong-type.rs:10:5 | LL | foo("wow"); - | ^^^^^ expected `!`, found `&str` + | ^^^^-----^ + | | + | expected `!`, found `&'static str` | - = note: expected type `!` - found reference `&'static str` +note: function defined here + --> $DIR/call-fn-never-arg-wrong-type.rs:5:4 + | +LL | fn foo(x: !) -> ! { + | ^^^ ---- +help: provide an argument of the correct type + | +LL | foo({!}); + | ^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/not-enough-arguments.rs b/src/test/ui/not-enough-arguments.rs index 4247625518871..3bcdbbd4ac811 100644 --- a/src/test/ui/not-enough-arguments.rs +++ b/src/test/ui/not-enough-arguments.rs @@ -25,7 +25,7 @@ fn bar( fn main() { foo(1, 2, 3); - //~^ ERROR this function takes 4 arguments but 3 + //~^ ERROR arguments to this function are incorrect bar(1, 2, 3); - //~^ ERROR this function takes 6 arguments but 3 + //~^ ERROR arguments to this function are incorrect } diff --git a/src/test/ui/not-enough-arguments.stderr b/src/test/ui/not-enough-arguments.stderr index df95783724148..0e56123e91151 100644 --- a/src/test/ui/not-enough-arguments.stderr +++ b/src/test/ui/not-enough-arguments.stderr @@ -1,24 +1,28 @@ -error[E0061]: this function takes 4 arguments but 3 arguments were supplied +error[E0308]: arguments to this function are incorrect --> $DIR/not-enough-arguments.rs:27:3 | LL | foo(1, 2, 3); - | ^^^ - - - supplied 3 arguments - | | - | expected 4 arguments + | ^^^^^^^^^^^^ an argument of type isize is missing | note: function defined here --> $DIR/not-enough-arguments.rs:5:4 | LL | fn foo(a: isize, b: isize, c: isize, d:isize) { | ^^^ -------- -------- -------- ------- +help: provide the argument + | +LL | foo(1, 2, 3, {isize}); + | ^^^^^^^^^^^^^^^^^^^^^ -error[E0061]: this function takes 6 arguments but 3 arguments were supplied +error[E0308]: arguments to this function are incorrect --> $DIR/not-enough-arguments.rs:29:3 | LL | bar(1, 2, 3); - | ^^^ - - - supplied 3 arguments + | ^^^^^^^^^^^^ | | - | expected 6 arguments + | an argument of type i32 is missing + | an argument of type i32 is missing + | an argument of type i32 is missing | note: function defined here --> $DIR/not-enough-arguments.rs:10:4 @@ -37,7 +41,11 @@ LL | e: i32, | ------ LL | f: i32, | ------ +help: did you mean + | +LL | bar(1, 2, 3, {i32}, {i32}, {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 E0308`. diff --git a/src/test/ui/numeric/len.rs b/src/test/ui/numeric/len.rs index a725409882059..1f61d299cfbf9 100644 --- a/src/test/ui/numeric/len.rs +++ b/src/test/ui/numeric/len.rs @@ -1,6 +1,6 @@ fn main() { let array = [1, 2, 3]; - test(array.len()); //~ ERROR mismatched types + test(array.len()); //~ ERROR arguments to this function are incorrect } fn test(length: u32) { diff --git a/src/test/ui/numeric/len.stderr b/src/test/ui/numeric/len.stderr index 79b38b0698631..da8b252f2d21e 100644 --- a/src/test/ui/numeric/len.stderr +++ b/src/test/ui/numeric/len.stderr @@ -1,13 +1,20 @@ -error[E0308]: mismatched types - --> $DIR/len.rs:3:10 +error[E0308]: arguments to this function are incorrect + --> $DIR/len.rs:3:5 | LL | test(array.len()); - | ^^^^^^^^^^^ expected `u32`, found `usize` + | ^^^^^-----------^ + | | + | expected `u32`, found `usize` | -help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit +note: function defined here + --> $DIR/len.rs:6:4 | -LL | test(array.len().try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn test(length: u32) { + | ^^^^ ----------- +help: provide an argument of the correct type + | +LL | test({u32}); + | ^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/numeric/numeric-cast-without-suggestion.rs b/src/test/ui/numeric/numeric-cast-without-suggestion.rs index faf24a8c18efd..4d678e2474482 100644 --- a/src/test/ui/numeric/numeric-cast-without-suggestion.rs +++ b/src/test/ui/numeric/numeric-cast-without-suggestion.rs @@ -14,25 +14,25 @@ fn main() { let x_f64: f64 = 11.0; let x_f32: f32 = 12.0; - foo::(x_f64); //~ ERROR mismatched types - foo::(x_f32); //~ ERROR mismatched types - foo::(x_f64); //~ ERROR mismatched types - foo::(x_f32); //~ ERROR mismatched types - foo::(x_f64); //~ ERROR mismatched types - foo::(x_f32); //~ ERROR mismatched types - foo::(x_f64); //~ ERROR mismatched types - foo::(x_f32); //~ ERROR mismatched types - foo::(x_f64); //~ ERROR mismatched types - foo::(x_f32); //~ ERROR mismatched types - foo::(x_f64); //~ ERROR mismatched types - foo::(x_f32); //~ ERROR mismatched types - foo::(x_f64); //~ ERROR mismatched types - foo::(x_f32); //~ ERROR mismatched types - foo::(x_f64); //~ ERROR mismatched types - foo::(x_f32); //~ ERROR mismatched types - foo::(x_f64); //~ ERROR mismatched types - foo::(x_f32); //~ ERROR mismatched types - foo::(x_f64); //~ ERROR mismatched types - foo::(x_f32); //~ ERROR mismatched types - foo::(x_f64); //~ ERROR mismatched types + foo::(x_f64); //~ ERROR arguments to this function are incorrect + foo::(x_f32); //~ ERROR arguments to this function are incorrect + foo::(x_f64); //~ ERROR arguments to this function are incorrect + foo::(x_f32); //~ ERROR arguments to this function are incorrect + foo::(x_f64); //~ ERROR arguments to this function are incorrect + foo::(x_f32); //~ ERROR arguments to this function are incorrect + foo::(x_f64); //~ ERROR arguments to this function are incorrect + foo::(x_f32); //~ ERROR arguments to this function are incorrect + foo::(x_f64); //~ ERROR arguments to this function are incorrect + foo::(x_f32); //~ ERROR arguments to this function are incorrect + foo::(x_f64); //~ ERROR arguments to this function are incorrect + foo::(x_f32); //~ ERROR arguments to this function are incorrect + foo::(x_f64); //~ ERROR arguments to this function are incorrect + foo::(x_f32); //~ ERROR arguments to this function are incorrect + foo::(x_f64); //~ ERROR arguments to this function are incorrect + foo::(x_f32); //~ ERROR arguments to this function are incorrect + foo::(x_f64); //~ ERROR arguments to this function are incorrect + foo::(x_f32); //~ ERROR arguments to this function are incorrect + foo::(x_f64); //~ ERROR arguments to this function are incorrect + foo::(x_f32); //~ ERROR arguments to this function are incorrect + foo::(x_f64); //~ ERROR arguments to this function are incorrect } diff --git a/src/test/ui/numeric/numeric-cast-without-suggestion.stderr b/src/test/ui/numeric/numeric-cast-without-suggestion.stderr index a96518a34342d..85c7bdddee804 100644 --- a/src/test/ui/numeric/numeric-cast-without-suggestion.stderr +++ b/src/test/ui/numeric/numeric-cast-without-suggestion.stderr @@ -1,128 +1,380 @@ -error[E0308]: mismatched types - --> $DIR/numeric-cast-without-suggestion.rs:17:18 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast-without-suggestion.rs:17:5 | LL | foo::(x_f64); - | ^^^^^ expected `usize`, found `f64` + | ^^^^^^^^^^^^^-----^ + | | + | expected `usize`, found `f64` + | +note: function defined here + --> $DIR/numeric-cast-without-suggestion.rs:1:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({usize}); + | ^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast-without-suggestion.rs:18:18 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast-without-suggestion.rs:18:5 | LL | foo::(x_f32); - | ^^^^^ expected `usize`, found `f32` + | ^^^^^^^^^^^^^-----^ + | | + | expected `usize`, found `f32` + | +note: function defined here + --> $DIR/numeric-cast-without-suggestion.rs:1:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({usize}); + | ^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast-without-suggestion.rs:19:18 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast-without-suggestion.rs:19:5 | LL | foo::(x_f64); - | ^^^^^ expected `isize`, found `f64` + | ^^^^^^^^^^^^^-----^ + | | + | expected `isize`, found `f64` + | +note: function defined here + --> $DIR/numeric-cast-without-suggestion.rs:1:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({isize}); + | ^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast-without-suggestion.rs:20:18 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast-without-suggestion.rs:20:5 | LL | foo::(x_f32); - | ^^^^^ expected `isize`, found `f32` + | ^^^^^^^^^^^^^-----^ + | | + | expected `isize`, found `f32` + | +note: function defined here + --> $DIR/numeric-cast-without-suggestion.rs:1:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({isize}); + | ^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast-without-suggestion.rs:21:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast-without-suggestion.rs:21:5 | LL | foo::(x_f64); - | ^^^^^ expected `u64`, found `f64` + | ^^^^^^^^^^^-----^ + | | + | expected `u64`, found `f64` + | +note: function defined here + --> $DIR/numeric-cast-without-suggestion.rs:1:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({u64}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast-without-suggestion.rs:22:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast-without-suggestion.rs:22:5 | LL | foo::(x_f32); - | ^^^^^ expected `u64`, found `f32` + | ^^^^^^^^^^^-----^ + | | + | expected `u64`, found `f32` + | +note: function defined here + --> $DIR/numeric-cast-without-suggestion.rs:1:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({u64}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast-without-suggestion.rs:23:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast-without-suggestion.rs:23:5 | LL | foo::(x_f64); - | ^^^^^ expected `i64`, found `f64` + | ^^^^^^^^^^^-----^ + | | + | expected `i64`, found `f64` + | +note: function defined here + --> $DIR/numeric-cast-without-suggestion.rs:1:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({i64}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast-without-suggestion.rs:24:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast-without-suggestion.rs:24:5 | LL | foo::(x_f32); - | ^^^^^ expected `i64`, found `f32` + | ^^^^^^^^^^^-----^ + | | + | expected `i64`, found `f32` + | +note: function defined here + --> $DIR/numeric-cast-without-suggestion.rs:1:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({i64}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast-without-suggestion.rs:25:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast-without-suggestion.rs:25:5 | LL | foo::(x_f64); - | ^^^^^ expected `u32`, found `f64` + | ^^^^^^^^^^^-----^ + | | + | expected `u32`, found `f64` + | +note: function defined here + --> $DIR/numeric-cast-without-suggestion.rs:1:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({u32}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast-without-suggestion.rs:26:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast-without-suggestion.rs:26:5 | LL | foo::(x_f32); - | ^^^^^ expected `u32`, found `f32` + | ^^^^^^^^^^^-----^ + | | + | expected `u32`, found `f32` + | +note: function defined here + --> $DIR/numeric-cast-without-suggestion.rs:1:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({u32}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast-without-suggestion.rs:27:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast-without-suggestion.rs:27:5 | LL | foo::(x_f64); - | ^^^^^ expected `i32`, found `f64` + | ^^^^^^^^^^^-----^ + | | + | expected `i32`, found `f64` + | +note: function defined here + --> $DIR/numeric-cast-without-suggestion.rs:1:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({i32}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast-without-suggestion.rs:28:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast-without-suggestion.rs:28:5 | LL | foo::(x_f32); - | ^^^^^ expected `i32`, found `f32` + | ^^^^^^^^^^^-----^ + | | + | expected `i32`, found `f32` + | +note: function defined here + --> $DIR/numeric-cast-without-suggestion.rs:1:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({i32}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast-without-suggestion.rs:29:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast-without-suggestion.rs:29:5 | LL | foo::(x_f64); - | ^^^^^ expected `u16`, found `f64` + | ^^^^^^^^^^^-----^ + | | + | expected `u16`, found `f64` + | +note: function defined here + --> $DIR/numeric-cast-without-suggestion.rs:1:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({u16}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast-without-suggestion.rs:30:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast-without-suggestion.rs:30:5 | LL | foo::(x_f32); - | ^^^^^ expected `u16`, found `f32` + | ^^^^^^^^^^^-----^ + | | + | expected `u16`, found `f32` + | +note: function defined here + --> $DIR/numeric-cast-without-suggestion.rs:1:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({u16}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast-without-suggestion.rs:31:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast-without-suggestion.rs:31:5 | LL | foo::(x_f64); - | ^^^^^ expected `i16`, found `f64` + | ^^^^^^^^^^^-----^ + | | + | expected `i16`, found `f64` + | +note: function defined here + --> $DIR/numeric-cast-without-suggestion.rs:1:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({i16}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast-without-suggestion.rs:32:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast-without-suggestion.rs:32:5 | LL | foo::(x_f32); - | ^^^^^ expected `i16`, found `f32` + | ^^^^^^^^^^^-----^ + | | + | expected `i16`, found `f32` + | +note: function defined here + --> $DIR/numeric-cast-without-suggestion.rs:1:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({i16}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast-without-suggestion.rs:33:15 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast-without-suggestion.rs:33:5 | LL | foo::(x_f64); - | ^^^^^ expected `u8`, found `f64` + | ^^^^^^^^^^-----^ + | | + | expected `u8`, found `f64` + | +note: function defined here + --> $DIR/numeric-cast-without-suggestion.rs:1:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({u8}); + | ^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast-without-suggestion.rs:34:15 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast-without-suggestion.rs:34:5 | LL | foo::(x_f32); - | ^^^^^ expected `u8`, found `f32` + | ^^^^^^^^^^-----^ + | | + | expected `u8`, found `f32` + | +note: function defined here + --> $DIR/numeric-cast-without-suggestion.rs:1:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({u8}); + | ^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast-without-suggestion.rs:35:15 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast-without-suggestion.rs:35:5 | LL | foo::(x_f64); - | ^^^^^ expected `i8`, found `f64` + | ^^^^^^^^^^-----^ + | | + | expected `i8`, found `f64` + | +note: function defined here + --> $DIR/numeric-cast-without-suggestion.rs:1:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({i8}); + | ^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast-without-suggestion.rs:36:15 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast-without-suggestion.rs:36:5 | LL | foo::(x_f32); - | ^^^^^ expected `i8`, found `f32` + | ^^^^^^^^^^-----^ + | | + | expected `i8`, found `f32` + | +note: function defined here + --> $DIR/numeric-cast-without-suggestion.rs:1:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({i8}); + | ^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast-without-suggestion.rs:37:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast-without-suggestion.rs:37:5 | LL | foo::(x_f64); - | ^^^^^ expected `f32`, found `f64` + | ^^^^^^^^^^^-----^ + | | + | expected `f32`, found `f64` + | +note: function defined here + --> $DIR/numeric-cast-without-suggestion.rs:1:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({f32}); + | ^^^^^^^^^^ error: aborting due to 21 previous errors diff --git a/src/test/ui/numeric/numeric-cast.fixed b/src/test/ui/numeric/numeric-cast.fixed index cf0560a107772..591e8095b7a3f 100644 --- a/src/test/ui/numeric/numeric-cast.fixed +++ b/src/test/ui/numeric/numeric-cast.fixed @@ -20,274 +20,274 @@ fn main() { let x_f32: f32 = 12.0; foo::(x_usize); - foo::(x_u64.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_u32.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_u16.into()); - //~^ ERROR mismatched types - foo::(x_u8.into()); - //~^ ERROR mismatched types - foo::(x_isize.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_i64.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_i32.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_i16.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_i8.try_into().unwrap()); - //~^ ERROR mismatched types + foo({usize}); + //~^ ERROR arguments to this function are incorrect + foo({usize}); + //~^ ERROR arguments to this function are incorrect + foo({usize}); + //~^ ERROR arguments to this function are incorrect + foo({usize}); + //~^ ERROR arguments to this function are incorrect + foo({usize}); + //~^ ERROR arguments to this function are incorrect + foo({usize}); + //~^ ERROR arguments to this function are incorrect + foo({usize}); + //~^ ERROR arguments to this function are incorrect + foo({usize}); + //~^ ERROR arguments to this function are incorrect + foo({usize}); + //~^ ERROR arguments to this function are incorrect // foo::(x_f64); // foo::(x_f32); - foo::(x_usize.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_u64.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_u32.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_u16.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_u8.into()); - //~^ ERROR mismatched types + foo({isize}); + //~^ ERROR arguments to this function are incorrect + foo({isize}); + //~^ ERROR arguments to this function are incorrect + foo({isize}); + //~^ ERROR arguments to this function are incorrect + foo({isize}); + //~^ ERROR arguments to this function are incorrect + foo({isize}); + //~^ ERROR arguments to this function are incorrect foo::(x_isize); - foo::(x_i64.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_i32.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_i16.into()); - //~^ ERROR mismatched types - foo::(x_i8.into()); - //~^ ERROR mismatched types + foo({isize}); + //~^ ERROR arguments to this function are incorrect + foo({isize}); + //~^ ERROR arguments to this function are incorrect + foo({isize}); + //~^ ERROR arguments to this function are incorrect + foo({isize}); + //~^ ERROR arguments to this function are incorrect // foo::(x_f64); // foo::(x_f32); - foo::(x_usize.try_into().unwrap()); - //~^ ERROR mismatched types + foo({u64}); + //~^ ERROR arguments to this function are incorrect foo::(x_u64); - foo::(x_u32.into()); - //~^ ERROR mismatched types - foo::(x_u16.into()); - //~^ ERROR mismatched types - foo::(x_u8.into()); - //~^ ERROR mismatched types - foo::(x_isize.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_i64.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_i32.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_i16.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_i8.try_into().unwrap()); - //~^ ERROR mismatched types + foo({u64}); + //~^ ERROR arguments to this function are incorrect + foo({u64}); + //~^ ERROR arguments to this function are incorrect + foo({u64}); + //~^ ERROR arguments to this function are incorrect + foo({u64}); + //~^ ERROR arguments to this function are incorrect + foo({u64}); + //~^ ERROR arguments to this function are incorrect + foo({u64}); + //~^ ERROR arguments to this function are incorrect + foo({u64}); + //~^ ERROR arguments to this function are incorrect + foo({u64}); + //~^ ERROR arguments to this function are incorrect // foo::(x_f64); // foo::(x_f32); - foo::(x_usize.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_u64.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_u32.into()); - //~^ ERROR mismatched types - foo::(x_u16.into()); - //~^ ERROR mismatched types - foo::(x_u8.into()); - //~^ ERROR mismatched types - foo::(x_isize.try_into().unwrap()); - //~^ ERROR mismatched types + foo({i64}); + //~^ ERROR arguments to this function are incorrect + foo({i64}); + //~^ ERROR arguments to this function are incorrect + foo({i64}); + //~^ ERROR arguments to this function are incorrect + foo({i64}); + //~^ ERROR arguments to this function are incorrect + foo({i64}); + //~^ ERROR arguments to this function are incorrect + foo({i64}); + //~^ ERROR arguments to this function are incorrect foo::(x_i64); - foo::(x_i32.into()); - //~^ ERROR mismatched types - foo::(x_i16.into()); - //~^ ERROR mismatched types - foo::(x_i8.into()); - //~^ ERROR mismatched types + foo({i64}); + //~^ ERROR arguments to this function are incorrect + foo({i64}); + //~^ ERROR arguments to this function are incorrect + foo({i64}); + //~^ ERROR arguments to this function are incorrect // foo::(x_f64); // foo::(x_f32); - foo::(x_usize.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_u64.try_into().unwrap()); - //~^ ERROR mismatched types + foo({u32}); + //~^ ERROR arguments to this function are incorrect + foo({u32}); + //~^ ERROR arguments to this function are incorrect foo::(x_u32); - foo::(x_u16.into()); - //~^ ERROR mismatched types - foo::(x_u8.into()); - //~^ ERROR mismatched types - foo::(x_isize.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_i64.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_i32.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_i16.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_i8.try_into().unwrap()); - //~^ ERROR mismatched types + foo({u32}); + //~^ ERROR arguments to this function are incorrect + foo({u32}); + //~^ ERROR arguments to this function are incorrect + foo({u32}); + //~^ ERROR arguments to this function are incorrect + foo({u32}); + //~^ ERROR arguments to this function are incorrect + foo({u32}); + //~^ ERROR arguments to this function are incorrect + foo({u32}); + //~^ ERROR arguments to this function are incorrect + foo({u32}); + //~^ ERROR arguments to this function are incorrect // foo::(x_f64); // foo::(x_f32); - foo::(x_usize.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_u64.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_u32.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_u16.into()); - //~^ ERROR mismatched types - foo::(x_u8.into()); - //~^ ERROR mismatched types - foo::(x_isize.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_i64.try_into().unwrap()); - //~^ ERROR mismatched types + foo({i32}); + //~^ ERROR arguments to this function are incorrect + foo({i32}); + //~^ ERROR arguments to this function are incorrect + foo({i32}); + //~^ ERROR arguments to this function are incorrect + foo({i32}); + //~^ ERROR arguments to this function are incorrect + foo({i32}); + //~^ ERROR arguments to this function are incorrect + foo({i32}); + //~^ ERROR arguments to this function are incorrect + foo({i32}); + //~^ ERROR arguments to this function are incorrect foo::(x_i32); - foo::(x_i16.into()); - //~^ ERROR mismatched types - foo::(x_i8.into()); - //~^ ERROR mismatched types + foo({i32}); + //~^ ERROR arguments to this function are incorrect + foo({i32}); + //~^ ERROR arguments to this function are incorrect // foo::(x_f64); // foo::(x_f32); - foo::(x_usize.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_u64.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_u32.try_into().unwrap()); - //~^ ERROR mismatched types + foo({u16}); + //~^ ERROR arguments to this function are incorrect + foo({u16}); + //~^ ERROR arguments to this function are incorrect + foo({u16}); + //~^ ERROR arguments to this function are incorrect foo::(x_u16); - foo::(x_u8.into()); - //~^ ERROR mismatched types - foo::(x_isize.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_i64.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_i32.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_i16.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_i8.try_into().unwrap()); - //~^ ERROR mismatched types + foo({u16}); + //~^ ERROR arguments to this function are incorrect + foo({u16}); + //~^ ERROR arguments to this function are incorrect + foo({u16}); + //~^ ERROR arguments to this function are incorrect + foo({u16}); + //~^ ERROR arguments to this function are incorrect + foo({u16}); + //~^ ERROR arguments to this function are incorrect + foo({u16}); + //~^ ERROR arguments to this function are incorrect // foo::(x_f64); // foo::(x_f32); - foo::(x_usize.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_u64.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_u32.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_u16.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_u8.into()); - //~^ ERROR mismatched types - foo::(x_isize.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_i64.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_i32.try_into().unwrap()); - //~^ ERROR mismatched types + foo({i16}); + //~^ ERROR arguments to this function are incorrect + foo({i16}); + //~^ ERROR arguments to this function are incorrect + foo({i16}); + //~^ ERROR arguments to this function are incorrect + foo({i16}); + //~^ ERROR arguments to this function are incorrect + foo({i16}); + //~^ ERROR arguments to this function are incorrect + foo({i16}); + //~^ ERROR arguments to this function are incorrect + foo({i16}); + //~^ ERROR arguments to this function are incorrect + foo({i16}); + //~^ ERROR arguments to this function are incorrect foo::(x_i16); - foo::(x_i8.into()); - //~^ ERROR mismatched types + foo({i16}); + //~^ ERROR arguments to this function are incorrect // foo::(x_f64); // foo::(x_f32); - foo::(x_usize.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_u64.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_u32.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_u16.try_into().unwrap()); - //~^ ERROR mismatched types + foo({u8}); + //~^ ERROR arguments to this function are incorrect + foo({u8}); + //~^ ERROR arguments to this function are incorrect + foo({u8}); + //~^ ERROR arguments to this function are incorrect + foo({u8}); + //~^ ERROR arguments to this function are incorrect foo::(x_u8); - foo::(x_isize.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_i64.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_i32.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_i16.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_i8.try_into().unwrap()); - //~^ ERROR mismatched types + foo({u8}); + //~^ ERROR arguments to this function are incorrect + foo({u8}); + //~^ ERROR arguments to this function are incorrect + foo({u8}); + //~^ ERROR arguments to this function are incorrect + foo({u8}); + //~^ ERROR arguments to this function are incorrect + foo({u8}); + //~^ ERROR arguments to this function are incorrect // foo::(x_f64); // foo::(x_f32); - foo::(x_usize.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_u64.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_u32.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_u16.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_u8.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_isize.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_i64.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_i32.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_i16.try_into().unwrap()); - //~^ ERROR mismatched types + foo({i8}); + //~^ ERROR arguments to this function are incorrect + foo({i8}); + //~^ ERROR arguments to this function are incorrect + foo({i8}); + //~^ ERROR arguments to this function are incorrect + foo({i8}); + //~^ ERROR arguments to this function are incorrect + foo({i8}); + //~^ ERROR arguments to this function are incorrect + foo({i8}); + //~^ ERROR arguments to this function are incorrect + foo({i8}); + //~^ ERROR arguments to this function are incorrect + foo({i8}); + //~^ ERROR arguments to this function are incorrect + foo({i8}); + //~^ ERROR arguments to this function are incorrect foo::(x_i8); // foo::(x_f64); // foo::(x_f32); - foo::(x_usize as f64); - //~^ ERROR mismatched types - foo::(x_u64 as f64); - //~^ ERROR mismatched types - foo::(x_u32.into()); - //~^ ERROR mismatched types - foo::(x_u16.into()); - //~^ ERROR mismatched types - foo::(x_u8.into()); - //~^ ERROR mismatched types - foo::(x_isize as f64); - //~^ ERROR mismatched types - foo::(x_i64 as f64); - //~^ ERROR mismatched types - foo::(x_i32.into()); - //~^ ERROR mismatched types - foo::(x_i16.into()); - //~^ ERROR mismatched types - foo::(x_i8.into()); - //~^ ERROR mismatched types + foo({f64}); + //~^ ERROR arguments to this function are incorrect + foo({f64}); + //~^ ERROR arguments to this function are incorrect + foo({f64}); + //~^ ERROR arguments to this function are incorrect + foo({f64}); + //~^ ERROR arguments to this function are incorrect + foo({f64}); + //~^ ERROR arguments to this function are incorrect + foo({f64}); + //~^ ERROR arguments to this function are incorrect + foo({f64}); + //~^ ERROR arguments to this function are incorrect + foo({f64}); + //~^ ERROR arguments to this function are incorrect + foo({f64}); + //~^ ERROR arguments to this function are incorrect + foo({f64}); + //~^ ERROR arguments to this function are incorrect foo::(x_f64); - foo::(x_f32.into()); - //~^ ERROR mismatched types + foo({f64}); + //~^ ERROR arguments to this function are incorrect - foo::(x_usize as f32); - //~^ ERROR mismatched types - foo::(x_u64 as f32); - //~^ ERROR mismatched types - foo::(x_u32 as f32); - //~^ ERROR mismatched types - foo::(x_u16.into()); - //~^ ERROR mismatched types - foo::(x_u8.into()); - //~^ ERROR mismatched types - foo::(x_isize as f32); - //~^ ERROR mismatched types - foo::(x_i64 as f32); - //~^ ERROR mismatched types - foo::(x_i32 as f32); - //~^ ERROR mismatched types - foo::(x_i16.into()); - //~^ ERROR mismatched types - foo::(x_i8.into()); - //~^ ERROR mismatched types + foo({f32}); + //~^ ERROR arguments to this function are incorrect + foo({f32}); + //~^ ERROR arguments to this function are incorrect + foo({f32}); + //~^ ERROR arguments to this function are incorrect + foo({f32}); + //~^ ERROR arguments to this function are incorrect + foo({f32}); + //~^ ERROR arguments to this function are incorrect + foo({f32}); + //~^ ERROR arguments to this function are incorrect + foo({f32}); + //~^ ERROR arguments to this function are incorrect + foo({f32}); + //~^ ERROR arguments to this function are incorrect + foo({f32}); + //~^ ERROR arguments to this function are incorrect + foo({f32}); + //~^ ERROR arguments to this function are incorrect // foo::(x_f64); foo::(x_f32); - foo::((x_u8 as u16).into()); - //~^ ERROR mismatched types - foo::((-x_i8).into()); - //~^ ERROR mismatched types + foo({u32}); + //~^ ERROR arguments to this function are incorrect + foo({i32}); + //~^ ERROR arguments to this function are incorrect } diff --git a/src/test/ui/numeric/numeric-cast.rs b/src/test/ui/numeric/numeric-cast.rs index 7bddfc5090535..0306ed22c7e1b 100644 --- a/src/test/ui/numeric/numeric-cast.rs +++ b/src/test/ui/numeric/numeric-cast.rs @@ -21,273 +21,273 @@ fn main() { foo::(x_usize); foo::(x_u64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_u32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_u16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_u8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_isize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_i64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_i32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_i16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_i8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect // foo::(x_f64); // foo::(x_f32); foo::(x_usize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_u64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_u32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_u16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_u8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_isize); foo::(x_i64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_i32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_i16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_i8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect // foo::(x_f64); // foo::(x_f32); foo::(x_usize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_u64); foo::(x_u32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_u16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_u8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_isize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_i64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_i32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_i16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_i8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect // foo::(x_f64); // foo::(x_f32); foo::(x_usize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_u64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_u32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_u16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_u8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_isize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_i64); foo::(x_i32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_i16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_i8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect // foo::(x_f64); // foo::(x_f32); foo::(x_usize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_u64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_u32); foo::(x_u16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_u8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_isize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_i64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_i32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_i16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_i8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect // foo::(x_f64); // foo::(x_f32); foo::(x_usize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_u64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_u32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_u16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_u8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_isize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_i64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_i32); foo::(x_i16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_i8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect // foo::(x_f64); // foo::(x_f32); foo::(x_usize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_u64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_u32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_u16); foo::(x_u8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_isize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_i64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_i32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_i16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_i8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect // foo::(x_f64); // foo::(x_f32); foo::(x_usize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_u64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_u32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_u16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_u8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_isize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_i64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_i32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_i16); foo::(x_i8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect // foo::(x_f64); // foo::(x_f32); foo::(x_usize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_u64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_u32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_u16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_u8); foo::(x_isize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_i64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_i32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_i16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_i8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect // foo::(x_f64); // foo::(x_f32); foo::(x_usize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_u64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_u32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_u16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_u8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_isize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_i64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_i32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_i16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_i8); // foo::(x_f64); // foo::(x_f32); foo::(x_usize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_u64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_u32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_u16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_u8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_isize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_i64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_i32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_i16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_i8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_f64); foo::(x_f32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_usize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_u64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_u32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_u16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_u8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_isize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_i64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_i32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_i16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(x_i8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect // foo::(x_f64); foo::(x_f32); foo::(x_u8 as u16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(-x_i8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect } diff --git a/src/test/ui/numeric/numeric-cast.stderr b/src/test/ui/numeric/numeric-cast.stderr index ffd6368bac15f..a8873efb2540f 100644 --- a/src/test/ui/numeric/numeric-cast.stderr +++ b/src/test/ui/numeric/numeric-cast.stderr @@ -1,1193 +1,2036 @@ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:23:18 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:23:5 | LL | foo::(x_u64); - | ^^^^^ expected `usize`, found `u64` + | ^^^^^^^^^^^^^-----^ + | | + | expected `usize`, found `u64` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -help: you can convert a `u64` to a `usize` and panic if the converted value doesn't fit +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type | -LL | foo::(x_u64.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | foo({usize}); + | ^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:25:18 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:25:5 | LL | foo::(x_u32); - | ^^^^^ expected `usize`, found `u32` + | ^^^^^^^^^^^^^-----^ + | | + | expected `usize`, found `u32` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -help: you can convert a `u32` to a `usize` and panic if the converted value doesn't fit +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type | -LL | foo::(x_u32.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | foo({usize}); + | ^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:27:18 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:27:5 | LL | foo::(x_u16); - | ^^^^^ + | ^^^^^^^^^^^^^-----^ | | | expected `usize`, found `u16` - | help: you can convert a `u16` to a `usize`: `x_u16.into()` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({usize}); + | ^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:29:18 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:29:5 | LL | foo::(x_u8); - | ^^^^ + | ^^^^^^^^^^^^^----^ | | | expected `usize`, found `u8` - | help: you can convert a `u8` to a `usize`: `x_u8.into()` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({usize}); + | ^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:31:18 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:31:5 | LL | foo::(x_isize); - | ^^^^^^^ expected `usize`, found `isize` + | ^^^^^^^^^^^^^-------^ + | | + | expected `usize`, found `isize` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -help: you can convert an `isize` to a `usize` and panic if the converted value doesn't fit +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type | -LL | foo::(x_isize.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | foo({usize}); + | ^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:33:18 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:33:5 | LL | foo::(x_i64); - | ^^^^^ expected `usize`, found `i64` + | ^^^^^^^^^^^^^-----^ + | | + | expected `usize`, found `i64` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -help: you can convert an `i64` to a `usize` and panic if the converted value doesn't fit +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type | -LL | foo::(x_i64.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | foo({usize}); + | ^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:35:18 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:35:5 | LL | foo::(x_i32); - | ^^^^^ expected `usize`, found `i32` + | ^^^^^^^^^^^^^-----^ + | | + | expected `usize`, found `i32` | -help: you can convert an `i32` to a `usize` and panic if the converted value doesn't fit +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -LL | foo::(x_i32.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({usize}); + | ^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:37:18 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:37:5 | LL | foo::(x_i16); - | ^^^^^ expected `usize`, found `i16` + | ^^^^^^^^^^^^^-----^ + | | + | expected `usize`, found `i16` | -help: you can convert an `i16` to a `usize` and panic if the converted value doesn't fit +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -LL | foo::(x_i16.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({usize}); + | ^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:39:18 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:39:5 | LL | foo::(x_i8); - | ^^^^ expected `usize`, found `i8` + | ^^^^^^^^^^^^^----^ + | | + | expected `usize`, found `i8` | -help: you can convert an `i8` to a `usize` and panic if the converted value doesn't fit +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -LL | foo::(x_i8.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({usize}); + | ^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:44:18 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:44:5 | LL | foo::(x_usize); - | ^^^^^^^ expected `isize`, found `usize` + | ^^^^^^^^^^^^^-------^ + | | + | expected `isize`, found `usize` | -help: you can convert a `usize` to an `isize` and panic if the converted value doesn't fit +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -LL | foo::(x_usize.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({isize}); + | ^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:46:18 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:46:5 | LL | foo::(x_u64); - | ^^^^^ expected `isize`, found `u64` + | ^^^^^^^^^^^^^-----^ + | | + | expected `isize`, found `u64` | -help: you can convert a `u64` to an `isize` and panic if the converted value doesn't fit +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -LL | foo::(x_u64.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({isize}); + | ^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:48:18 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:48:5 | LL | foo::(x_u32); - | ^^^^^ expected `isize`, found `u32` + | ^^^^^^^^^^^^^-----^ + | | + | expected `isize`, found `u32` | -help: you can convert a `u32` to an `isize` and panic if the converted value doesn't fit +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -LL | foo::(x_u32.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({isize}); + | ^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:50:18 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:50:5 | LL | foo::(x_u16); - | ^^^^^ expected `isize`, found `u16` + | ^^^^^^^^^^^^^-----^ + | | + | expected `isize`, found `u16` | -help: you can convert a `u16` to an `isize` and panic if the converted value doesn't fit +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -LL | foo::(x_u16.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({isize}); + | ^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:52:18 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:52:5 | LL | foo::(x_u8); - | ^^^^ + | ^^^^^^^^^^^^^----^ | | | expected `isize`, found `u8` - | help: you can convert a `u8` to an `isize`: `x_u8.into()` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({isize}); + | ^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:55:18 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:55:5 | LL | foo::(x_i64); - | ^^^^^ expected `isize`, found `i64` + | ^^^^^^^^^^^^^-----^ + | | + | expected `isize`, found `i64` | -help: you can convert an `i64` to an `isize` and panic if the converted value doesn't fit +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -LL | foo::(x_i64.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({isize}); + | ^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:57:18 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:57:5 | LL | foo::(x_i32); - | ^^^^^ expected `isize`, found `i32` + | ^^^^^^^^^^^^^-----^ + | | + | expected `isize`, found `i32` | -help: you can convert an `i32` to an `isize` and panic if the converted value doesn't fit +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -LL | foo::(x_i32.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({isize}); + | ^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:59:18 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:59:5 | LL | foo::(x_i16); - | ^^^^^ + | ^^^^^^^^^^^^^-----^ | | | expected `isize`, found `i16` - | help: you can convert an `i16` to an `isize`: `x_i16.into()` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({isize}); + | ^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:61:18 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:61:5 | LL | foo::(x_i8); - | ^^^^ + | ^^^^^^^^^^^^^----^ | | | expected `isize`, found `i8` - | help: you can convert an `i8` to an `isize`: `x_i8.into()` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({isize}); + | ^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:66:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:66:5 | LL | foo::(x_usize); - | ^^^^^^^ expected `u64`, found `usize` + | ^^^^^^^^^^^-------^ + | | + | expected `u64`, found `usize` | -help: you can convert a `usize` to a `u64` and panic if the converted value doesn't fit +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -LL | foo::(x_usize.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({u64}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:69:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:69:5 | LL | foo::(x_u32); - | ^^^^^ + | ^^^^^^^^^^^-----^ | | | expected `u64`, found `u32` - | help: you can convert a `u32` to a `u64`: `x_u32.into()` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({u64}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:71:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:71:5 | LL | foo::(x_u16); - | ^^^^^ + | ^^^^^^^^^^^-----^ | | | expected `u64`, found `u16` - | help: you can convert a `u16` to a `u64`: `x_u16.into()` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({u64}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:73:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:73:5 | LL | foo::(x_u8); - | ^^^^ + | ^^^^^^^^^^^----^ | | | expected `u64`, found `u8` - | help: you can convert a `u8` to a `u64`: `x_u8.into()` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({u64}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:75:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:75:5 | LL | foo::(x_isize); - | ^^^^^^^ expected `u64`, found `isize` + | ^^^^^^^^^^^-------^ + | | + | expected `u64`, found `isize` | -help: you can convert an `isize` to a `u64` and panic if the converted value doesn't fit +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -LL | foo::(x_isize.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({u64}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:77:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:77:5 | LL | foo::(x_i64); - | ^^^^^ expected `u64`, found `i64` + | ^^^^^^^^^^^-----^ + | | + | expected `u64`, found `i64` | -help: you can convert an `i64` to a `u64` and panic if the converted value doesn't fit +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -LL | foo::(x_i64.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({u64}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:79:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:79:5 | LL | foo::(x_i32); - | ^^^^^ expected `u64`, found `i32` + | ^^^^^^^^^^^-----^ + | | + | expected `u64`, found `i32` | -help: you can convert an `i32` to a `u64` and panic if the converted value doesn't fit +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -LL | foo::(x_i32.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({u64}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:81:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:81:5 | LL | foo::(x_i16); - | ^^^^^ expected `u64`, found `i16` + | ^^^^^^^^^^^-----^ + | | + | expected `u64`, found `i16` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -help: you can convert an `i16` to a `u64` and panic if the converted value doesn't fit +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type | -LL | foo::(x_i16.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | foo({u64}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:83:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:83:5 | LL | foo::(x_i8); - | ^^^^ expected `u64`, found `i8` + | ^^^^^^^^^^^----^ + | | + | expected `u64`, found `i8` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -help: you can convert an `i8` to a `u64` and panic if the converted value doesn't fit +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type | -LL | foo::(x_i8.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^ +LL | foo({u64}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:88:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:88:5 | LL | foo::(x_usize); - | ^^^^^^^ expected `i64`, found `usize` + | ^^^^^^^^^^^-------^ + | | + | expected `i64`, found `usize` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -help: you can convert a `usize` to an `i64` and panic if the converted value doesn't fit +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type | -LL | foo::(x_usize.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | foo({i64}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:90:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:90:5 | LL | foo::(x_u64); - | ^^^^^ expected `i64`, found `u64` + | ^^^^^^^^^^^-----^ + | | + | expected `i64`, found `u64` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -help: you can convert a `u64` to an `i64` and panic if the converted value doesn't fit +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type | -LL | foo::(x_u64.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | foo({i64}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:92:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:92:5 | LL | foo::(x_u32); - | ^^^^^ + | ^^^^^^^^^^^-----^ | | | expected `i64`, found `u32` - | help: you can convert a `u32` to an `i64`: `x_u32.into()` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({i64}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:94:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:94:5 | LL | foo::(x_u16); - | ^^^^^ + | ^^^^^^^^^^^-----^ | | | expected `i64`, found `u16` - | help: you can convert a `u16` to an `i64`: `x_u16.into()` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({i64}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:96:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:96:5 | LL | foo::(x_u8); - | ^^^^ + | ^^^^^^^^^^^----^ | | | expected `i64`, found `u8` - | help: you can convert a `u8` to an `i64`: `x_u8.into()` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({i64}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:98:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:98:5 | LL | foo::(x_isize); - | ^^^^^^^ expected `i64`, found `isize` + | ^^^^^^^^^^^-------^ + | | + | expected `i64`, found `isize` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -help: you can convert an `isize` to an `i64` and panic if the converted value doesn't fit +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type | -LL | foo::(x_isize.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | foo({i64}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:101:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:101:5 | LL | foo::(x_i32); - | ^^^^^ + | ^^^^^^^^^^^-----^ | | | expected `i64`, found `i32` - | help: you can convert an `i32` to an `i64`: `x_i32.into()` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({i64}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:103:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:103:5 | LL | foo::(x_i16); - | ^^^^^ + | ^^^^^^^^^^^-----^ | | | expected `i64`, found `i16` - | help: you can convert an `i16` to an `i64`: `x_i16.into()` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({i64}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:105:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:105:5 | LL | foo::(x_i8); - | ^^^^ + | ^^^^^^^^^^^----^ | | | expected `i64`, found `i8` - | help: you can convert an `i8` to an `i64`: `x_i8.into()` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({i64}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:110:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:110:5 | LL | foo::(x_usize); - | ^^^^^^^ expected `u32`, found `usize` + | ^^^^^^^^^^^-------^ + | | + | expected `u32`, found `usize` | -help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -LL | foo::(x_usize.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({u32}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:112:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:112:5 | LL | foo::(x_u64); - | ^^^^^ expected `u32`, found `u64` + | ^^^^^^^^^^^-----^ + | | + | expected `u32`, found `u64` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -help: you can convert a `u64` to a `u32` and panic if the converted value doesn't fit +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type | -LL | foo::(x_u64.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | foo({u32}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:115:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:115:5 | LL | foo::(x_u16); - | ^^^^^ + | ^^^^^^^^^^^-----^ | | | expected `u32`, found `u16` - | help: you can convert a `u16` to a `u32`: `x_u16.into()` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({u32}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:117:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:117:5 | LL | foo::(x_u8); - | ^^^^ + | ^^^^^^^^^^^----^ | | | expected `u32`, found `u8` - | help: you can convert a `u8` to a `u32`: `x_u8.into()` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({u32}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:119:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:119:5 | LL | foo::(x_isize); - | ^^^^^^^ expected `u32`, found `isize` + | ^^^^^^^^^^^-------^ + | | + | expected `u32`, found `isize` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -help: you can convert an `isize` to a `u32` and panic if the converted value doesn't fit +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type | -LL | foo::(x_isize.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | foo({u32}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:121:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:121:5 | LL | foo::(x_i64); - | ^^^^^ expected `u32`, found `i64` + | ^^^^^^^^^^^-----^ + | | + | expected `u32`, found `i64` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -help: you can convert an `i64` to a `u32` and panic if the converted value doesn't fit +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type | -LL | foo::(x_i64.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | foo({u32}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:123:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:123:5 | LL | foo::(x_i32); - | ^^^^^ expected `u32`, found `i32` + | ^^^^^^^^^^^-----^ + | | + | expected `u32`, found `i32` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -help: you can convert an `i32` to a `u32` and panic if the converted value doesn't fit +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type | -LL | foo::(x_i32.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | foo({u32}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:125:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:125:5 | LL | foo::(x_i16); - | ^^^^^ expected `u32`, found `i16` + | ^^^^^^^^^^^-----^ + | | + | expected `u32`, found `i16` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -help: you can convert an `i16` to a `u32` and panic if the converted value doesn't fit +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type | -LL | foo::(x_i16.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | foo({u32}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:127:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:127:5 | LL | foo::(x_i8); - | ^^^^ expected `u32`, found `i8` + | ^^^^^^^^^^^----^ + | | + | expected `u32`, found `i8` | -help: you can convert an `i8` to a `u32` and panic if the converted value doesn't fit +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -LL | foo::(x_i8.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({u32}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:132:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:132:5 | LL | foo::(x_usize); - | ^^^^^^^ expected `i32`, found `usize` + | ^^^^^^^^^^^-------^ + | | + | expected `i32`, found `usize` | -help: you can convert a `usize` to an `i32` and panic if the converted value doesn't fit +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -LL | foo::(x_usize.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({i32}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:134:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:134:5 | LL | foo::(x_u64); - | ^^^^^ expected `i32`, found `u64` + | ^^^^^^^^^^^-----^ + | | + | expected `i32`, found `u64` | -help: you can convert a `u64` to an `i32` and panic if the converted value doesn't fit +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -LL | foo::(x_u64.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({i32}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:136:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:136:5 | LL | foo::(x_u32); - | ^^^^^ expected `i32`, found `u32` + | ^^^^^^^^^^^-----^ + | | + | expected `i32`, found `u32` | -help: you can convert a `u32` to an `i32` and panic if the converted value doesn't fit +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -LL | foo::(x_u32.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({i32}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:138:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:138:5 | LL | foo::(x_u16); - | ^^^^^ + | ^^^^^^^^^^^-----^ | | | expected `i32`, found `u16` - | help: you can convert a `u16` to an `i32`: `x_u16.into()` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({i32}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:140:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:140:5 | LL | foo::(x_u8); - | ^^^^ + | ^^^^^^^^^^^----^ | | | expected `i32`, found `u8` - | help: you can convert a `u8` to an `i32`: `x_u8.into()` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({i32}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:142:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:142:5 | LL | foo::(x_isize); - | ^^^^^^^ expected `i32`, found `isize` + | ^^^^^^^^^^^-------^ + | | + | expected `i32`, found `isize` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -help: you can convert an `isize` to an `i32` and panic if the converted value doesn't fit +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type | -LL | foo::(x_isize.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | foo({i32}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:144:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:144:5 | LL | foo::(x_i64); - | ^^^^^ expected `i32`, found `i64` + | ^^^^^^^^^^^-----^ + | | + | expected `i32`, found `i64` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -help: you can convert an `i64` to an `i32` and panic if the converted value doesn't fit +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type | -LL | foo::(x_i64.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | foo({i32}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:147:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:147:5 | LL | foo::(x_i16); - | ^^^^^ + | ^^^^^^^^^^^-----^ | | | expected `i32`, found `i16` - | help: you can convert an `i16` to an `i32`: `x_i16.into()` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({i32}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:149:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:149:5 | LL | foo::(x_i8); - | ^^^^ + | ^^^^^^^^^^^----^ | | | expected `i32`, found `i8` - | help: you can convert an `i8` to an `i32`: `x_i8.into()` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({i32}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:154:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:154:5 | LL | foo::(x_usize); - | ^^^^^^^ expected `u16`, found `usize` + | ^^^^^^^^^^^-------^ + | | + | expected `u16`, found `usize` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -help: you can convert a `usize` to a `u16` and panic if the converted value doesn't fit +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type | -LL | foo::(x_usize.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | foo({u16}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:156:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:156:5 | LL | foo::(x_u64); - | ^^^^^ expected `u16`, found `u64` + | ^^^^^^^^^^^-----^ + | | + | expected `u16`, found `u64` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -help: you can convert a `u64` to a `u16` and panic if the converted value doesn't fit +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type | -LL | foo::(x_u64.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | foo({u16}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:158:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:158:5 | LL | foo::(x_u32); - | ^^^^^ expected `u16`, found `u32` + | ^^^^^^^^^^^-----^ + | | + | expected `u16`, found `u32` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -help: you can convert a `u32` to a `u16` and panic if the converted value doesn't fit +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type | -LL | foo::(x_u32.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | foo({u16}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:161:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:161:5 | LL | foo::(x_u8); - | ^^^^ + | ^^^^^^^^^^^----^ | | | expected `u16`, found `u8` - | help: you can convert a `u8` to a `u16`: `x_u8.into()` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({u16}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:163:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:163:5 | LL | foo::(x_isize); - | ^^^^^^^ expected `u16`, found `isize` + | ^^^^^^^^^^^-------^ + | | + | expected `u16`, found `isize` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -help: you can convert an `isize` to a `u16` and panic if the converted value doesn't fit +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type | -LL | foo::(x_isize.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | foo({u16}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:165:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:165:5 | LL | foo::(x_i64); - | ^^^^^ expected `u16`, found `i64` + | ^^^^^^^^^^^-----^ + | | + | expected `u16`, found `i64` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -help: you can convert an `i64` to a `u16` and panic if the converted value doesn't fit +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type | -LL | foo::(x_i64.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | foo({u16}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:167:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:167:5 | LL | foo::(x_i32); - | ^^^^^ expected `u16`, found `i32` + | ^^^^^^^^^^^-----^ + | | + | expected `u16`, found `i32` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -help: you can convert an `i32` to a `u16` and panic if the converted value doesn't fit +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type | -LL | foo::(x_i32.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | foo({u16}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:169:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:169:5 | LL | foo::(x_i16); - | ^^^^^ expected `u16`, found `i16` + | ^^^^^^^^^^^-----^ + | | + | expected `u16`, found `i16` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -help: you can convert an `i16` to a `u16` and panic if the converted value doesn't fit +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type | -LL | foo::(x_i16.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | foo({u16}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:171:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:171:5 | LL | foo::(x_i8); - | ^^^^ expected `u16`, found `i8` + | ^^^^^^^^^^^----^ + | | + | expected `u16`, found `i8` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -help: you can convert an `i8` to a `u16` and panic if the converted value doesn't fit +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type | -LL | foo::(x_i8.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^ +LL | foo({u16}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:176:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:176:5 | LL | foo::(x_usize); - | ^^^^^^^ expected `i16`, found `usize` + | ^^^^^^^^^^^-------^ + | | + | expected `i16`, found `usize` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -help: you can convert a `usize` to an `i16` and panic if the converted value doesn't fit +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type | -LL | foo::(x_usize.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | foo({i16}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:178:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:178:5 | LL | foo::(x_u64); - | ^^^^^ expected `i16`, found `u64` + | ^^^^^^^^^^^-----^ + | | + | expected `i16`, found `u64` | -help: you can convert a `u64` to an `i16` and panic if the converted value doesn't fit +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -LL | foo::(x_u64.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({i16}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:180:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:180:5 | LL | foo::(x_u32); - | ^^^^^ expected `i16`, found `u32` + | ^^^^^^^^^^^-----^ + | | + | expected `i16`, found `u32` | -help: you can convert a `u32` to an `i16` and panic if the converted value doesn't fit +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -LL | foo::(x_u32.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({i16}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:182:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:182:5 | LL | foo::(x_u16); - | ^^^^^ expected `i16`, found `u16` + | ^^^^^^^^^^^-----^ + | | + | expected `i16`, found `u16` | -help: you can convert a `u16` to an `i16` and panic if the converted value doesn't fit +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -LL | foo::(x_u16.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({i16}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:184:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:184:5 | LL | foo::(x_u8); - | ^^^^ + | ^^^^^^^^^^^----^ | | | expected `i16`, found `u8` - | help: you can convert a `u8` to an `i16`: `x_u8.into()` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({i16}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:186:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:186:5 | LL | foo::(x_isize); - | ^^^^^^^ expected `i16`, found `isize` + | ^^^^^^^^^^^-------^ + | | + | expected `i16`, found `isize` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -help: you can convert an `isize` to an `i16` and panic if the converted value doesn't fit +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type | -LL | foo::(x_isize.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | foo({i16}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:188:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:188:5 | LL | foo::(x_i64); - | ^^^^^ expected `i16`, found `i64` + | ^^^^^^^^^^^-----^ + | | + | expected `i16`, found `i64` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -help: you can convert an `i64` to an `i16` and panic if the converted value doesn't fit +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type | -LL | foo::(x_i64.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | foo({i16}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:190:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:190:5 | LL | foo::(x_i32); - | ^^^^^ expected `i16`, found `i32` + | ^^^^^^^^^^^-----^ + | | + | expected `i16`, found `i32` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -help: you can convert an `i32` to an `i16` and panic if the converted value doesn't fit +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type | -LL | foo::(x_i32.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | foo({i16}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:193:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:193:5 | LL | foo::(x_i8); - | ^^^^ + | ^^^^^^^^^^^----^ | | | expected `i16`, found `i8` - | help: you can convert an `i8` to an `i16`: `x_i8.into()` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({i16}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:198:15 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:198:5 | LL | foo::(x_usize); - | ^^^^^^^ expected `u8`, found `usize` + | ^^^^^^^^^^-------^ + | | + | expected `u8`, found `usize` | -help: you can convert a `usize` to a `u8` and panic if the converted value doesn't fit +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -LL | foo::(x_usize.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({u8}); + | ^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:200:15 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:200:5 | LL | foo::(x_u64); - | ^^^^^ expected `u8`, found `u64` + | ^^^^^^^^^^-----^ + | | + | expected `u8`, found `u64` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -help: you can convert a `u64` to a `u8` and panic if the converted value doesn't fit +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type | -LL | foo::(x_u64.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | foo({u8}); + | ^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:202:15 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:202:5 | LL | foo::(x_u32); - | ^^^^^ expected `u8`, found `u32` + | ^^^^^^^^^^-----^ + | | + | expected `u8`, found `u32` | -help: you can convert a `u32` to a `u8` and panic if the converted value doesn't fit +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -LL | foo::(x_u32.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({u8}); + | ^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:204:15 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:204:5 | LL | foo::(x_u16); - | ^^^^^ expected `u8`, found `u16` + | ^^^^^^^^^^-----^ + | | + | expected `u8`, found `u16` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -help: you can convert a `u16` to a `u8` and panic if the converted value doesn't fit +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type | -LL | foo::(x_u16.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | foo({u8}); + | ^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:207:15 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:207:5 | LL | foo::(x_isize); - | ^^^^^^^ expected `u8`, found `isize` + | ^^^^^^^^^^-------^ + | | + | expected `u8`, found `isize` | -help: you can convert an `isize` to a `u8` and panic if the converted value doesn't fit +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -LL | foo::(x_isize.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({u8}); + | ^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:209:15 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:209:5 | LL | foo::(x_i64); - | ^^^^^ expected `u8`, found `i64` + | ^^^^^^^^^^-----^ + | | + | expected `u8`, found `i64` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -help: you can convert an `i64` to a `u8` and panic if the converted value doesn't fit +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type | -LL | foo::(x_i64.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | foo({u8}); + | ^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:211:15 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:211:5 | LL | foo::(x_i32); - | ^^^^^ expected `u8`, found `i32` + | ^^^^^^^^^^-----^ + | | + | expected `u8`, found `i32` | -help: you can convert an `i32` to a `u8` and panic if the converted value doesn't fit +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -LL | foo::(x_i32.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({u8}); + | ^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:213:15 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:213:5 | LL | foo::(x_i16); - | ^^^^^ expected `u8`, found `i16` + | ^^^^^^^^^^-----^ + | | + | expected `u8`, found `i16` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -help: you can convert an `i16` to a `u8` and panic if the converted value doesn't fit +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type | -LL | foo::(x_i16.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | foo({u8}); + | ^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:215:15 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:215:5 | LL | foo::(x_i8); - | ^^^^ expected `u8`, found `i8` + | ^^^^^^^^^^----^ + | | + | expected `u8`, found `i8` | -help: you can convert an `i8` to a `u8` and panic if the converted value doesn't fit +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -LL | foo::(x_i8.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({u8}); + | ^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:220:15 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:220:5 | LL | foo::(x_usize); - | ^^^^^^^ expected `i8`, found `usize` + | ^^^^^^^^^^-------^ + | | + | expected `i8`, found `usize` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -help: you can convert a `usize` to an `i8` and panic if the converted value doesn't fit +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type | -LL | foo::(x_usize.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | foo({i8}); + | ^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:222:15 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:222:5 | LL | foo::(x_u64); - | ^^^^^ expected `i8`, found `u64` + | ^^^^^^^^^^-----^ + | | + | expected `i8`, found `u64` | -help: you can convert a `u64` to an `i8` and panic if the converted value doesn't fit +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -LL | foo::(x_u64.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({i8}); + | ^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:224:15 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:224:5 | LL | foo::(x_u32); - | ^^^^^ expected `i8`, found `u32` + | ^^^^^^^^^^-----^ + | | + | expected `i8`, found `u32` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -help: you can convert a `u32` to an `i8` and panic if the converted value doesn't fit +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type | -LL | foo::(x_u32.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | foo({i8}); + | ^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:226:15 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:226:5 | LL | foo::(x_u16); - | ^^^^^ expected `i8`, found `u16` + | ^^^^^^^^^^-----^ + | | + | expected `i8`, found `u16` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -help: you can convert a `u16` to an `i8` and panic if the converted value doesn't fit +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type | -LL | foo::(x_u16.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | foo({i8}); + | ^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:228:15 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:228:5 | LL | foo::(x_u8); - | ^^^^ expected `i8`, found `u8` + | ^^^^^^^^^^----^ + | | + | expected `i8`, found `u8` | -help: you can convert a `u8` to an `i8` and panic if the converted value doesn't fit +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -LL | foo::(x_u8.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({i8}); + | ^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:230:15 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:230:5 | LL | foo::(x_isize); - | ^^^^^^^ expected `i8`, found `isize` + | ^^^^^^^^^^-------^ + | | + | expected `i8`, found `isize` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -help: you can convert an `isize` to an `i8` and panic if the converted value doesn't fit +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type | -LL | foo::(x_isize.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | foo({i8}); + | ^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:232:15 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:232:5 | LL | foo::(x_i64); - | ^^^^^ expected `i8`, found `i64` + | ^^^^^^^^^^-----^ + | | + | expected `i8`, found `i64` | -help: you can convert an `i64` to an `i8` and panic if the converted value doesn't fit +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -LL | foo::(x_i64.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({i8}); + | ^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:234:15 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:234:5 | LL | foo::(x_i32); - | ^^^^^ expected `i8`, found `i32` + | ^^^^^^^^^^-----^ + | | + | expected `i8`, found `i32` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -help: you can convert an `i32` to an `i8` and panic if the converted value doesn't fit +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type | -LL | foo::(x_i32.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | foo({i8}); + | ^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:236:15 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:236:5 | LL | foo::(x_i16); - | ^^^^^ expected `i8`, found `i16` + | ^^^^^^^^^^-----^ + | | + | expected `i8`, found `i16` | -help: you can convert an `i16` to an `i8` and panic if the converted value doesn't fit +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -LL | foo::(x_i16.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({i8}); + | ^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:242:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:242:5 | LL | foo::(x_usize); - | ^^^^^^^ expected `f64`, found `usize` + | ^^^^^^^^^^^-------^ + | | + | expected `f64`, found `usize` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type | -help: you can cast a `usize` to an `f64`, producing the floating point representation of the integer, - | rounded if necessary -LL | foo::(x_usize as f64); - | ^^^^^^^^^^^^^^ +LL | foo({f64}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:244:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:244:5 | LL | foo::(x_u64); - | ^^^^^ expected `f64`, found `u64` + | ^^^^^^^^^^^-----^ + | | + | expected `f64`, found `u64` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -help: you can cast a `u64` to an `f64`, producing the floating point representation of the integer, - | rounded if necessary -LL | foo::(x_u64 as f64); - | ^^^^^^^^^^^^ +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({f64}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:246:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:246:5 | LL | foo::(x_u32); - | ^^^^^ expected `f64`, found `u32` + | ^^^^^^^^^^^-----^ + | | + | expected `f64`, found `u32` | -help: you can convert a `u32` to an `f64`, producing the floating point representation of the integer +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -LL | foo::(x_u32.into()); - | ^^^^^^^^^^^^ +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({f64}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:248:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:248:5 | LL | foo::(x_u16); - | ^^^^^ expected `f64`, found `u16` + | ^^^^^^^^^^^-----^ + | | + | expected `f64`, found `u16` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -help: you can convert a `u16` to an `f64`, producing the floating point representation of the integer +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type | -LL | foo::(x_u16.into()); - | ^^^^^^^^^^^^ +LL | foo({f64}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:250:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:250:5 | LL | foo::(x_u8); - | ^^^^ expected `f64`, found `u8` + | ^^^^^^^^^^^----^ + | | + | expected `f64`, found `u8` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -help: you can convert a `u8` to an `f64`, producing the floating point representation of the integer +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type | -LL | foo::(x_u8.into()); - | ^^^^^^^^^^^ +LL | foo({f64}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:252:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:252:5 | LL | foo::(x_isize); - | ^^^^^^^ expected `f64`, found `isize` + | ^^^^^^^^^^^-------^ + | | + | expected `f64`, found `isize` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -help: you can convert an `isize` to an `f64`, producing the floating point representation of the integer, rounded if necessary +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type | -LL | foo::(x_isize as f64); - | ^^^^^^^^^^^^^^ +LL | foo({f64}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:254:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:254:5 | LL | foo::(x_i64); - | ^^^^^ expected `f64`, found `i64` + | ^^^^^^^^^^^-----^ + | | + | expected `f64`, found `i64` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -help: you can convert an `i64` to an `f64`, producing the floating point representation of the integer, rounded if necessary +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type | -LL | foo::(x_i64 as f64); - | ^^^^^^^^^^^^ +LL | foo({f64}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:256:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:256:5 | LL | foo::(x_i32); - | ^^^^^ expected `f64`, found `i32` + | ^^^^^^^^^^^-----^ + | | + | expected `f64`, found `i32` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -help: you can convert an `i32` to an `f64`, producing the floating point representation of the integer +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type | -LL | foo::(x_i32.into()); - | ^^^^^^^^^^^^ +LL | foo({f64}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:258:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:258:5 | LL | foo::(x_i16); - | ^^^^^ expected `f64`, found `i16` + | ^^^^^^^^^^^-----^ + | | + | expected `f64`, found `i16` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -help: you can convert an `i16` to an `f64`, producing the floating point representation of the integer +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type | -LL | foo::(x_i16.into()); - | ^^^^^^^^^^^^ +LL | foo({f64}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:260:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:260:5 | LL | foo::(x_i8); - | ^^^^ expected `f64`, found `i8` + | ^^^^^^^^^^^----^ + | | + | expected `f64`, found `i8` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -help: you can convert an `i8` to an `f64`, producing the floating point representation of the integer +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type | -LL | foo::(x_i8.into()); - | ^^^^^^^^^^^ +LL | foo({f64}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:263:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:263:5 | LL | foo::(x_f32); - | ^^^^^ + | ^^^^^^^^^^^-----^ | | | expected `f64`, found `f32` - | help: you can convert an `f32` to an `f64`: `x_f32.into()` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({f64}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:266:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:266:5 | LL | foo::(x_usize); - | ^^^^^^^ expected `f32`, found `usize` + | ^^^^^^^^^^^-------^ + | | + | expected `f32`, found `usize` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -help: you can cast a `usize` to an `f32`, producing the floating point representation of the integer, - | rounded if necessary -LL | foo::(x_usize as f32); - | ^^^^^^^^^^^^^^ +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({f32}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:268:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:268:5 | LL | foo::(x_u64); - | ^^^^^ expected `f32`, found `u64` + | ^^^^^^^^^^^-----^ + | | + | expected `f32`, found `u64` | -help: you can cast a `u64` to an `f32`, producing the floating point representation of the integer, - | rounded if necessary -LL | foo::(x_u64 as f32); - | ^^^^^^^^^^^^ +note: function defined here + --> $DIR/numeric-cast.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({f32}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:270:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:270:5 | LL | foo::(x_u32); - | ^^^^^ expected `f32`, found `u32` + | ^^^^^^^^^^^-----^ + | | + | expected `f32`, found `u32` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -help: you can cast a `u32` to an `f32`, producing the floating point representation of the integer, - | rounded if necessary -LL | foo::(x_u32 as f32); - | ^^^^^^^^^^^^ +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({f32}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:272:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:272:5 | LL | foo::(x_u16); - | ^^^^^ expected `f32`, found `u16` + | ^^^^^^^^^^^-----^ + | | + | expected `f32`, found `u16` | -help: you can convert a `u16` to an `f32`, producing the floating point representation of the integer +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -LL | foo::(x_u16.into()); - | ^^^^^^^^^^^^ +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({f32}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:274:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:274:5 | LL | foo::(x_u8); - | ^^^^ expected `f32`, found `u8` + | ^^^^^^^^^^^----^ + | | + | expected `f32`, found `u8` | -help: you can convert a `u8` to an `f32`, producing the floating point representation of the integer +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -LL | foo::(x_u8.into()); - | ^^^^^^^^^^^ +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({f32}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:276:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:276:5 | LL | foo::(x_isize); - | ^^^^^^^ expected `f32`, found `isize` + | ^^^^^^^^^^^-------^ + | | + | expected `f32`, found `isize` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -help: you can convert an `isize` to an `f32`, producing the floating point representation of the integer, rounded if necessary +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type | -LL | foo::(x_isize as f32); - | ^^^^^^^^^^^^^^ +LL | foo({f32}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:278:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:278:5 | LL | foo::(x_i64); - | ^^^^^ expected `f32`, found `i64` + | ^^^^^^^^^^^-----^ + | | + | expected `f32`, found `i64` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -help: you can convert an `i64` to an `f32`, producing the floating point representation of the integer, rounded if necessary +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type | -LL | foo::(x_i64 as f32); - | ^^^^^^^^^^^^ +LL | foo({f32}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:280:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:280:5 | LL | foo::(x_i32); - | ^^^^^ expected `f32`, found `i32` + | ^^^^^^^^^^^-----^ + | | + | expected `f32`, found `i32` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -help: you can convert an `i32` to an `f32`, producing the floating point representation of the integer, rounded if necessary +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type | -LL | foo::(x_i32 as f32); - | ^^^^^^^^^^^^ +LL | foo({f32}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:282:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:282:5 | LL | foo::(x_i16); - | ^^^^^ expected `f32`, found `i16` + | ^^^^^^^^^^^-----^ + | | + | expected `f32`, found `i16` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -help: you can convert an `i16` to an `f32`, producing the floating point representation of the integer +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type | -LL | foo::(x_i16.into()); - | ^^^^^^^^^^^^ +LL | foo({f32}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:284:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:284:5 | LL | foo::(x_i8); - | ^^^^ expected `f32`, found `i8` + | ^^^^^^^^^^^----^ + | | + | expected `f32`, found `i8` | -help: you can convert an `i8` to an `f32`, producing the floating point representation of the integer +note: function defined here + --> $DIR/numeric-cast.rs:6:4 | -LL | foo::(x_i8.into()); - | ^^^^^^^^^^^ +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({f32}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:289:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:289:5 | LL | foo::(x_u8 as u16); - | ^^^^^^^^^^^ + | ^^^^^^^^^^^-----------^ | | | expected `u32`, found `u16` - | help: you can convert a `u16` to a `u32`: `(x_u8 as u16).into()` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({u32}); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:291:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/numeric-cast.rs:291:5 | LL | foo::(-x_i8); - | ^^^^^ + | ^^^^^^^^^^^-----^ | | | expected `i32`, found `i8` - | help: you can convert an `i8` to an `i32`: `(-x_i8).into()` + | +note: function defined here + --> $DIR/numeric-cast.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: provide an argument of the correct type + | +LL | foo({i32}); + | ^^^^^^^^^^ error: aborting due to 113 previous errors diff --git a/src/test/ui/numeric/numeric-suffix.fixed b/src/test/ui/numeric/numeric-suffix.fixed index 53c5fe0f435f9..24f0745b2b5f5 100644 --- a/src/test/ui/numeric/numeric-suffix.fixed +++ b/src/test/ui/numeric/numeric-suffix.fixed @@ -5,294 +5,294 @@ fn foo(_x: N) {} fn main() { foo::(42_usize); foo::(42_usize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_usize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_usize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_usize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_usize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_usize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_usize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_usize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_usize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42usize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42usize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_isize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_isize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_isize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_isize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_isize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_isize); foo::(42_isize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_isize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_isize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_isize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42isize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42isize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u64); foo::(42_u64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42u64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42u64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i64); foo::(42_i64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42i64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42i64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u32); foo::(42_u32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42u32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42u32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i32); foo::(42_i32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42i32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42i32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u16); foo::(42_u16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42u16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42u16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i16); foo::(42_i16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42i16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42i16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u8); foo::(42_u8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42u8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42u8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i8); foo::(42i8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42i8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_f64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_f64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u32.into()); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u16.into()); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u8.into()); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_f64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_f64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i32.into()); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i16.into()); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i8.into()); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42.0_f64); foo::(42.0_f64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_f32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_f32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_f32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u16.into()); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u8.into()); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_f32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_f32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_f32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i16.into()); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i8.into()); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42.0_f32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42.0_f32); foo::((42_u8 as u16).into()); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::((-42_i8).into()); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect } diff --git a/src/test/ui/numeric/numeric-suffix.rs b/src/test/ui/numeric/numeric-suffix.rs index ca38ed82220b2..cfccf308b42c4 100644 --- a/src/test/ui/numeric/numeric-suffix.rs +++ b/src/test/ui/numeric/numeric-suffix.rs @@ -5,294 +5,294 @@ fn foo(_x: N) {} fn main() { foo::(42_usize); foo::(42_u64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_isize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42.0_f64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42.0_f32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_usize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_isize); foo::(42_i64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42.0_f64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42.0_f32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_usize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u64); foo::(42_u32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_isize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42.0_f64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42.0_f32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_usize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_isize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i64); foo::(42_i32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42.0_f64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42.0_f32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_usize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u32); foo::(42_u16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_isize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42.0_f64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42.0_f32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_usize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_isize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i32); foo::(42_i16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42.0_f64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42.0_f32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_usize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u16); foo::(42_u8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_isize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42.0_f64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42.0_f32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_usize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_isize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i16); foo::(42_i8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42.0_f64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42.0_f32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_usize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u8); foo::(42_isize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42.0_f64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42.0_f32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_usize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_isize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i8); foo::(42.0_f64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42.0_f32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_usize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_isize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42.0_f64); foo::(42.0_f32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_usize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_u8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_isize); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42_i8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42.0_f64); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(42.0_f32); foo::(42_u8 as u16); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect foo::(-42_i8); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect } diff --git a/src/test/ui/or-patterns/issue-64879-trailing-before-guard.rs b/src/test/ui/or-patterns/issue-64879-trailing-before-guard.rs index 181c770096a5f..d68ad9545768d 100644 --- a/src/test/ui/or-patterns/issue-64879-trailing-before-guard.rs +++ b/src/test/ui/or-patterns/issue-64879-trailing-before-guard.rs @@ -9,7 +9,8 @@ fn main() { E::A | E::B | //~ ERROR a trailing `|` is not allowed in an or-pattern if true => { - let recovery_witness: bool = 0; //~ ERROR mismatched types + let recovery_witness: bool = 0; + //~^ ERROR mismatched types } } } diff --git a/src/test/ui/or-patterns/or-patterns-binding-type-mismatch.rs b/src/test/ui/or-patterns/or-patterns-binding-type-mismatch.rs index 5ec7dc6962c18..53e6e01cb4162 100644 --- a/src/test/ui/or-patterns/or-patterns-binding-type-mismatch.rs +++ b/src/test/ui/or-patterns/or-patterns-binding-type-mismatch.rs @@ -10,11 +10,13 @@ fn main() { } match Blah::A(1, 1, 2) { - Blah::A(_, x, y) | Blah::B(x, y) => {} //~ ERROR mismatched types + Blah::A(_, x, y) | Blah::B(x, y) => {} + //~^ ERROR mismatched types } match Some(Blah::A(1, 1, 2)) { - Some(Blah::A(_, x, y) | Blah::B(x, y)) => {} //~ ERROR mismatched types + Some(Blah::A(_, x, y) | Blah::B(x, y)) => {} + //~^ ERROR mismatched types } match (0u8, 1u16) { diff --git a/src/test/ui/or-patterns/or-patterns-binding-type-mismatch.stderr b/src/test/ui/or-patterns/or-patterns-binding-type-mismatch.stderr index 00dba053a59d3..3f19cfd2164e0 100644 --- a/src/test/ui/or-patterns/or-patterns-binding-type-mismatch.stderr +++ b/src/test/ui/or-patterns/or-patterns-binding-type-mismatch.stderr @@ -11,7 +11,7 @@ LL | Blah::A(_, x, y) | Blah::B(x, y) => {} = note: in the same arm, a binding must have the same type in all alternatives error[E0308]: mismatched types - --> $DIR/or-patterns-binding-type-mismatch.rs:17:44 + --> $DIR/or-patterns-binding-type-mismatch.rs:18:44 | LL | match Some(Blah::A(1, 1, 2)) { | ---------------------- this expression has type `Option` @@ -23,7 +23,7 @@ LL | Some(Blah::A(_, x, y) | Blah::B(x, y)) => {} = note: in the same arm, a binding must have the same type in all alternatives error[E0308]: mismatched types - --> $DIR/or-patterns-binding-type-mismatch.rs:21:19 + --> $DIR/or-patterns-binding-type-mismatch.rs:23:19 | LL | match (0u8, 1u16) { | ----------- this expression has type `(u8, u16)` @@ -35,7 +35,7 @@ LL | (x, y) | (y, x) => {} = note: in the same arm, a binding must have the same type in all alternatives error[E0308]: mismatched types - --> $DIR/or-patterns-binding-type-mismatch.rs:21:22 + --> $DIR/or-patterns-binding-type-mismatch.rs:23:22 | LL | match (0u8, 1u16) { | ----------- this expression has type `(u8, u16)` @@ -47,7 +47,7 @@ LL | (x, y) | (y, x) => {} = note: in the same arm, a binding must have the same type in all alternatives error[E0308]: mismatched types - --> $DIR/or-patterns-binding-type-mismatch.rs:26:41 + --> $DIR/or-patterns-binding-type-mismatch.rs:28:41 | LL | match Some((0u8, Some((1u16, 2u32)))) { | ------------------------------- this expression has type `Option<(u8, Option<(u16, u32)>)>` @@ -59,7 +59,7 @@ LL | Some((x, Some((y, z)))) | Some((y, Some((x, z) | (z, x)))) => {} = note: in the same arm, a binding must have the same type in all alternatives error[E0308]: mismatched types - --> $DIR/or-patterns-binding-type-mismatch.rs:26:50 + --> $DIR/or-patterns-binding-type-mismatch.rs:28:50 | LL | match Some((0u8, Some((1u16, 2u32)))) { | ------------------------------- this expression has type `Option<(u8, Option<(u16, u32)>)>` @@ -71,7 +71,7 @@ LL | Some((x, Some((y, z)))) | Some((y, Some((x, z) | (z, x)))) => {} = note: in the same arm, a binding must have the same type in all alternatives error[E0308]: mismatched types - --> $DIR/or-patterns-binding-type-mismatch.rs:26:59 + --> $DIR/or-patterns-binding-type-mismatch.rs:28:59 | LL | match Some((0u8, Some((1u16, 2u32)))) { | ------------------------------- this expression has type `Option<(u8, Option<(u16, u32)>)>` @@ -83,7 +83,7 @@ LL | Some((x, Some((y, z)))) | Some((y, Some((x, z) | (z, x)))) => {} = note: in the same arm, a binding must have the same type in all alternatives error[E0308]: mismatched types - --> $DIR/or-patterns-binding-type-mismatch.rs:26:62 + --> $DIR/or-patterns-binding-type-mismatch.rs:28:62 | LL | match Some((0u8, Some((1u16, 2u32)))) { | ------------------------------- this expression has type `Option<(u8, Option<(u16, u32)>)>` @@ -93,7 +93,7 @@ LL | Some((x, Some((y, z)))) | Some((y, Some((x, z) | (z, x)))) => {} = note: in the same arm, a binding must have the same type in all alternatives error[E0308]: mismatched types - --> $DIR/or-patterns-binding-type-mismatch.rs:34:42 + --> $DIR/or-patterns-binding-type-mismatch.rs:36:42 | LL | if let Blah::A(_, x, y) | Blah::B(x, y) = Blah::A(1, 1, 2) { | - ^ ---------------- this expression has type `Blah` @@ -104,7 +104,7 @@ LL | if let Blah::A(_, x, y) | Blah::B(x, y) = Blah::A(1, 1, 2) { = note: a binding must have the same type in all alternatives error[E0308]: mismatched types - --> $DIR/or-patterns-binding-type-mismatch.rs:38:47 + --> $DIR/or-patterns-binding-type-mismatch.rs:40:47 | LL | if let Some(Blah::A(_, x, y) | Blah::B(x, y)) = Some(Blah::A(1, 1, 2)) { | - ^ ---------------------- this expression has type `Option` @@ -115,7 +115,7 @@ LL | if let Some(Blah::A(_, x, y) | Blah::B(x, y)) = Some(Blah::A(1, 1, 2)) = note: a binding must have the same type in all alternatives error[E0308]: mismatched types - --> $DIR/or-patterns-binding-type-mismatch.rs:42:22 + --> $DIR/or-patterns-binding-type-mismatch.rs:44:22 | LL | if let (x, y) | (y, x) = (0u8, 1u16) { | - ^ ----------- this expression has type `(u8, u16)` @@ -126,7 +126,7 @@ LL | if let (x, y) | (y, x) = (0u8, 1u16) { = note: a binding must have the same type in all alternatives error[E0308]: mismatched types - --> $DIR/or-patterns-binding-type-mismatch.rs:42:25 + --> $DIR/or-patterns-binding-type-mismatch.rs:44:25 | LL | if let (x, y) | (y, x) = (0u8, 1u16) { | - ^ ----------- this expression has type `(u8, u16)` @@ -137,7 +137,7 @@ LL | if let (x, y) | (y, x) = (0u8, 1u16) { = note: a binding must have the same type in all alternatives error[E0308]: mismatched types - --> $DIR/or-patterns-binding-type-mismatch.rs:47:44 + --> $DIR/or-patterns-binding-type-mismatch.rs:49:44 | LL | if let Some((x, Some((y, z)))) | Some((y, Some((x, z) | (z, x)))) | - ^ expected `u16`, found `u8` @@ -150,7 +150,7 @@ LL | = Some((0u8, Some((1u16, 2u32)))) = note: a binding must have the same type in all alternatives error[E0308]: mismatched types - --> $DIR/or-patterns-binding-type-mismatch.rs:47:53 + --> $DIR/or-patterns-binding-type-mismatch.rs:49:53 | LL | if let Some((x, Some((y, z)))) | Some((y, Some((x, z) | (z, x)))) | - ^ expected `u8`, found `u16` @@ -163,7 +163,7 @@ LL | = Some((0u8, Some((1u16, 2u32)))) = note: a binding must have the same type in all alternatives error[E0308]: mismatched types - --> $DIR/or-patterns-binding-type-mismatch.rs:47:62 + --> $DIR/or-patterns-binding-type-mismatch.rs:49:62 | LL | if let Some((x, Some((y, z)))) | Some((y, Some((x, z) | (z, x)))) | - ^ expected `u32`, found `u16` @@ -176,7 +176,7 @@ LL | = Some((0u8, Some((1u16, 2u32)))) = note: a binding must have the same type in all alternatives error[E0308]: mismatched types - --> $DIR/or-patterns-binding-type-mismatch.rs:47:65 + --> $DIR/or-patterns-binding-type-mismatch.rs:49:65 | LL | if let Some((x, Some((y, z)))) | Some((y, Some((x, z) | (z, x)))) | - first introduced with type `u8` here ^ expected `u8`, found `u32` @@ -187,7 +187,7 @@ LL | = Some((0u8, Some((1u16, 2u32)))) = note: a binding must have the same type in all alternatives error[E0308]: mismatched types - --> $DIR/or-patterns-binding-type-mismatch.rs:55:39 + --> $DIR/or-patterns-binding-type-mismatch.rs:57:39 | LL | let Blah::A(_, x, y) | Blah::B(x, y) = Blah::A(1, 1, 2); | - ^ ---------------- this expression has type `Blah` @@ -198,7 +198,7 @@ LL | let Blah::A(_, x, y) | Blah::B(x, y) = Blah::A(1, 1, 2); = note: a binding must have the same type in all alternatives error[E0308]: mismatched types - --> $DIR/or-patterns-binding-type-mismatch.rs:58:19 + --> $DIR/or-patterns-binding-type-mismatch.rs:60:19 | LL | let (x, y) | (y, x) = (0u8, 1u16); | - ^ ----------- this expression has type `(u8, u16)` @@ -209,7 +209,7 @@ LL | let (x, y) | (y, x) = (0u8, 1u16); = note: a binding must have the same type in all alternatives error[E0308]: mismatched types - --> $DIR/or-patterns-binding-type-mismatch.rs:58:22 + --> $DIR/or-patterns-binding-type-mismatch.rs:60:22 | LL | let (x, y) | (y, x) = (0u8, 1u16); | - ^ ----------- this expression has type `(u8, u16)` @@ -220,7 +220,7 @@ LL | let (x, y) | (y, x) = (0u8, 1u16); = note: a binding must have the same type in all alternatives error[E0308]: mismatched types - --> $DIR/or-patterns-binding-type-mismatch.rs:62:42 + --> $DIR/or-patterns-binding-type-mismatch.rs:64:42 | LL | fn f1((Blah::A(_, x, y) | Blah::B(x, y)): Blah) {} | - ^ ---- expected due to this @@ -231,7 +231,7 @@ LL | fn f1((Blah::A(_, x, y) | Blah::B(x, y)): Blah) {} = note: a binding must have the same type in all alternatives error[E0308]: mismatched types - --> $DIR/or-patterns-binding-type-mismatch.rs:65:22 + --> $DIR/or-patterns-binding-type-mismatch.rs:67:22 | LL | fn f2(((x, y) | (y, x)): (u8, u16)) {} | - ^ --------- expected due to this @@ -242,7 +242,7 @@ LL | fn f2(((x, y) | (y, x)): (u8, u16)) {} = note: a binding must have the same type in all alternatives error[E0308]: mismatched types - --> $DIR/or-patterns-binding-type-mismatch.rs:65:25 + --> $DIR/or-patterns-binding-type-mismatch.rs:67:25 | LL | fn f2(((x, y) | (y, x)): (u8, u16)) {} | - ^ --------- expected due to this diff --git a/src/test/ui/overloaded-calls-nontuple.stderr b/src/test/ui/overloaded-calls-nontuple.stderr index bdadb95db2947..808f934d7e8ea 100644 --- a/src/test/ui/overloaded-calls-nontuple.stderr +++ b/src/test/ui/overloaded-calls-nontuple.stderr @@ -10,12 +10,5 @@ error: A function with the "rust-call" ABI must take a single non-self argument LL | extern "rust-call" fn call_once(mut self, z: isize) -> isize { self.call_mut(z) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0059]: cannot use call notation; the first type parameter for the function trait is neither a tuple nor unit - --> $DIR/overloaded-calls-nontuple.rs:28:10 - | -LL | drop(s(3)) - | ^^^^ - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0059`. diff --git a/src/test/ui/parser/fn-arg-doc-comment.rs b/src/test/ui/parser/fn-arg-doc-comment.rs index 2d1554183cccc..9249318609a44 100644 --- a/src/test/ui/parser/fn-arg-doc-comment.rs +++ b/src/test/ui/parser/fn-arg-doc-comment.rs @@ -16,11 +16,11 @@ fn bar(id: #[allow(dead_code)] i32) {} fn main() { // verify that the parser recovered and properly typechecked the args f("", ""); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| NOTE expected `u8`, found `&str` //~| ERROR mismatched types //~| NOTE expected `u8`, found `&str` bar(""); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| NOTE expected `i32`, found `&str` } diff --git a/src/test/ui/parser/fn-arg-doc-comment.stderr b/src/test/ui/parser/fn-arg-doc-comment.stderr index 41f2c080b9465..0653e7d162436 100644 --- a/src/test/ui/parser/fn-arg-doc-comment.stderr +++ b/src/test/ui/parser/fn-arg-doc-comment.stderr @@ -16,24 +16,53 @@ error: documentation comments cannot be applied to function parameters LL | /// Other | ^^^^^^^^^ doc comments are not allowed here -error[E0308]: mismatched types - --> $DIR/fn-arg-doc-comment.rs:18:7 +error[E0308]: arguments to this function are incorrect + --> $DIR/fn-arg-doc-comment.rs:18:5 | LL | f("", ""); - | ^^ expected `u8`, found `&str` - -error[E0308]: mismatched types - --> $DIR/fn-arg-doc-comment.rs:18:11 + | ^^--^^^^^ + | | + | expected `u8`, found `&'static str` + | expected `u8`, found `&'static str` | -LL | f("", ""); - | ^^ expected `u8`, found `&str` +note: function defined here + --> $DIR/fn-arg-doc-comment.rs:1:8 + | +LL | pub fn f( + | ^ +LL | / /// Comment +LL | | +LL | | +LL | | id: u8, + | |__________- +LL | / /// Other +LL | | +LL | | +LL | | a: u8, + | |_________- +help: did you mean + | +LL | f({u8}, {u8}); + | ^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/fn-arg-doc-comment.rs:23:9 +error[E0308]: arguments to this function are incorrect + --> $DIR/fn-arg-doc-comment.rs:23:5 | LL | bar(""); - | ^^ expected `i32`, found `&str` + | ^^^^--^ + | | + | expected `i32`, found `&'static str` + | +note: function defined here + --> $DIR/fn-arg-doc-comment.rs:12:4 + | +LL | fn bar(id: #[allow(dead_code)] i32) {} + | ^^^ --------------------------- +help: provide an argument of the correct type + | +LL | bar({i32}); + | ^^^^^^^^^^ -error: aborting due to 6 previous errors +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/pattern/pattern-error-continue.rs b/src/test/ui/pattern/pattern-error-continue.rs index 0702a9986fc1c..3a2c0d5cc08d7 100644 --- a/src/test/ui/pattern/pattern-error-continue.rs +++ b/src/test/ui/pattern/pattern-error-continue.rs @@ -26,7 +26,7 @@ fn main() { _ => () } f(true); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `char`, found `bool` match () { diff --git a/src/test/ui/pattern/pattern-error-continue.stderr b/src/test/ui/pattern/pattern-error-continue.stderr index 497c93b29497c..d2fce1bceae17 100644 --- a/src/test/ui/pattern/pattern-error-continue.stderr +++ b/src/test/ui/pattern/pattern-error-continue.stderr @@ -32,11 +32,23 @@ LL | match 'c' { LL | S { .. } => (), | ^^^^^^^^ expected `char`, found struct `S` -error[E0308]: mismatched types - --> $DIR/pattern-error-continue.rs:28:7 +error[E0308]: arguments to this function are incorrect + --> $DIR/pattern-error-continue.rs:28:5 | LL | f(true); - | ^^^^ expected `char`, found `bool` + | ^^----^ + | | + | expected `char`, found `bool` + | +note: function defined here + --> $DIR/pattern-error-continue.rs:13:4 + | +LL | fn f(_c: char) {} + | ^ -------- +help: provide an argument of the correct type + | +LL | f({char}); + | ^^^^^^^^^ error: aborting due to 5 previous errors diff --git a/src/test/ui/proc-macro/signature.rs b/src/test/ui/proc-macro/signature.rs index dbc1577172f03..36eab0c70c101 100644 --- a/src/test/ui/proc-macro/signature.rs +++ b/src/test/ui/proc-macro/signature.rs @@ -8,6 +8,6 @@ extern crate proc_macro; #[proc_macro_derive(A)] pub unsafe extern fn foo(a: i32, b: u32) -> u32 { - //~^ ERROR: mismatched types + //~^ ERROR: arguments to this function are incorrect loop {} } diff --git a/src/test/ui/proc-macro/signature.stderr b/src/test/ui/proc-macro/signature.stderr index 6ebc99601c41f..9816eb52d663f 100644 --- a/src/test/ui/proc-macro/signature.stderr +++ b/src/test/ui/proc-macro/signature.stderr @@ -1,14 +1,12 @@ -error[E0308]: mismatched types - --> $DIR/signature.rs:10:1 +error[E0308]: arguments to this function are incorrect | -LL | / pub unsafe extern fn foo(a: i32, b: u32) -> u32 { -LL | | -LL | | loop {} -LL | | } - | |_^ expected normal fn, found unsafe fn +help: provide an argument of the correct type + | +LL | (pub unsafe extern fn foo(a: i32, b: u32) -> u32 { +LL | +LL | loop {} +LL | }, , {fn(proc_macro::TokenStream) -> proc_macro::TokenStream})// force-host | - = note: expected fn pointer `fn(proc_macro::TokenStream) -> proc_macro::TokenStream` - found fn item `unsafe extern "C" fn(i32, u32) -> u32 {foo}` error: aborting due to previous error diff --git a/src/test/ui/range/issue-54505-no-literals.fixed b/src/test/ui/range/issue-54505-no-literals.fixed index 4d8f67182b9ac..061a4c2a60043 100644 --- a/src/test/ui/range/issue-54505-no-literals.fixed +++ b/src/test/ui/range/issue-54505-no-literals.fixed @@ -13,63 +13,63 @@ fn take_range(_r: &impl RangeBounds) {} fn main() { - take_range(&std::ops::Range { start: 0, end: 1 }); - //~^ ERROR mismatched types [E0308] + take_range({&_}); + //~^ ERROR arguments to this function are incorrect [E0308] //~| HELP consider borrowing here //~| SUGGESTION &std::ops::Range { start: 0, end: 1 } - take_range(&::std::ops::Range { start: 0, end: 1 }); - //~^ ERROR mismatched types [E0308] + take_range({&_}); + //~^ ERROR arguments to this function are incorrect [E0308] //~| HELP consider borrowing here //~| SUGGESTION &::std::ops::Range { start: 0, end: 1 } - take_range(&std::ops::RangeFrom { start: 1 }); - //~^ ERROR mismatched types [E0308] + take_range({&_}); + //~^ ERROR arguments to this function are incorrect [E0308] //~| HELP consider borrowing here //~| SUGGESTION &std::ops::RangeFrom { start: 1 } - take_range(&::std::ops::RangeFrom { start: 1 }); - //~^ ERROR mismatched types [E0308] + take_range({&_}); + //~^ ERROR arguments to this function are incorrect [E0308] //~| HELP consider borrowing here //~| SUGGESTION &::std::ops::RangeFrom { start: 1 } - take_range(&std::ops::RangeFull {}); - //~^ ERROR mismatched types [E0308] + take_range({&_}); + //~^ ERROR arguments to this function are incorrect [E0308] //~| HELP consider borrowing here //~| SUGGESTION &std::ops::RangeFull {} - take_range(&::std::ops::RangeFull {}); - //~^ ERROR mismatched types [E0308] + take_range({&_}); + //~^ ERROR arguments to this function are incorrect [E0308] //~| HELP consider borrowing here //~| SUGGESTION &::std::ops::RangeFull {} - take_range(&std::ops::RangeInclusive::new(0, 1)); - //~^ ERROR mismatched types [E0308] + take_range({&_}); + //~^ ERROR arguments to this function are incorrect [E0308] //~| HELP consider borrowing here //~| SUGGESTION &std::ops::RangeInclusive::new(0, 1) - take_range(&::std::ops::RangeInclusive::new(0, 1)); - //~^ ERROR mismatched types [E0308] + take_range({&_}); + //~^ ERROR arguments to this function are incorrect [E0308] //~| HELP consider borrowing here //~| SUGGESTION &::std::ops::RangeInclusive::new(0, 1) - take_range(&std::ops::RangeTo { end: 5 }); - //~^ ERROR mismatched types [E0308] + take_range({&_}); + //~^ ERROR arguments to this function are incorrect [E0308] //~| HELP consider borrowing here //~| SUGGESTION &std::ops::RangeTo { end: 5 } - take_range(&::std::ops::RangeTo { end: 5 }); - //~^ ERROR mismatched types [E0308] + take_range({&_}); + //~^ ERROR arguments to this function are incorrect [E0308] //~| HELP consider borrowing here //~| SUGGESTION &::std::ops::RangeTo { end: 5 } - take_range(&std::ops::RangeToInclusive { end: 5 }); - //~^ ERROR mismatched types [E0308] + take_range({&_}); + //~^ ERROR arguments to this function are incorrect [E0308] //~| HELP consider borrowing here //~| SUGGESTION &std::ops::RangeToInclusive { end: 5 } - take_range(&::std::ops::RangeToInclusive { end: 5 }); - //~^ ERROR mismatched types [E0308] + take_range({&_}); + //~^ ERROR arguments to this function are incorrect [E0308] //~| HELP consider borrowing here //~| SUGGESTION &::std::ops::RangeToInclusive { end: 5 } } diff --git a/src/test/ui/range/issue-54505-no-literals.rs b/src/test/ui/range/issue-54505-no-literals.rs index dc21dcbc2db41..b7c154dc201a8 100644 --- a/src/test/ui/range/issue-54505-no-literals.rs +++ b/src/test/ui/range/issue-54505-no-literals.rs @@ -14,62 +14,62 @@ fn take_range(_r: &impl RangeBounds) {} fn main() { take_range(std::ops::Range { start: 0, end: 1 }); - //~^ ERROR mismatched types [E0308] + //~^ ERROR arguments to this function are incorrect [E0308] //~| HELP consider borrowing here //~| SUGGESTION &std::ops::Range { start: 0, end: 1 } take_range(::std::ops::Range { start: 0, end: 1 }); - //~^ ERROR mismatched types [E0308] + //~^ ERROR arguments to this function are incorrect [E0308] //~| HELP consider borrowing here //~| SUGGESTION &::std::ops::Range { start: 0, end: 1 } take_range(std::ops::RangeFrom { start: 1 }); - //~^ ERROR mismatched types [E0308] + //~^ ERROR arguments to this function are incorrect [E0308] //~| HELP consider borrowing here //~| SUGGESTION &std::ops::RangeFrom { start: 1 } take_range(::std::ops::RangeFrom { start: 1 }); - //~^ ERROR mismatched types [E0308] + //~^ ERROR arguments to this function are incorrect [E0308] //~| HELP consider borrowing here //~| SUGGESTION &::std::ops::RangeFrom { start: 1 } take_range(std::ops::RangeFull {}); - //~^ ERROR mismatched types [E0308] + //~^ ERROR arguments to this function are incorrect [E0308] //~| HELP consider borrowing here //~| SUGGESTION &std::ops::RangeFull {} take_range(::std::ops::RangeFull {}); - //~^ ERROR mismatched types [E0308] + //~^ ERROR arguments to this function are incorrect [E0308] //~| HELP consider borrowing here //~| SUGGESTION &::std::ops::RangeFull {} take_range(std::ops::RangeInclusive::new(0, 1)); - //~^ ERROR mismatched types [E0308] + //~^ ERROR arguments to this function are incorrect [E0308] //~| HELP consider borrowing here //~| SUGGESTION &std::ops::RangeInclusive::new(0, 1) take_range(::std::ops::RangeInclusive::new(0, 1)); - //~^ ERROR mismatched types [E0308] + //~^ ERROR arguments to this function are incorrect [E0308] //~| HELP consider borrowing here //~| SUGGESTION &::std::ops::RangeInclusive::new(0, 1) take_range(std::ops::RangeTo { end: 5 }); - //~^ ERROR mismatched types [E0308] + //~^ ERROR arguments to this function are incorrect [E0308] //~| HELP consider borrowing here //~| SUGGESTION &std::ops::RangeTo { end: 5 } take_range(::std::ops::RangeTo { end: 5 }); - //~^ ERROR mismatched types [E0308] + //~^ ERROR arguments to this function are incorrect [E0308] //~| HELP consider borrowing here //~| SUGGESTION &::std::ops::RangeTo { end: 5 } take_range(std::ops::RangeToInclusive { end: 5 }); - //~^ ERROR mismatched types [E0308] + //~^ ERROR arguments to this function are incorrect [E0308] //~| HELP consider borrowing here //~| SUGGESTION &std::ops::RangeToInclusive { end: 5 } take_range(::std::ops::RangeToInclusive { end: 5 }); - //~^ ERROR mismatched types [E0308] + //~^ ERROR arguments to this function are incorrect [E0308] //~| HELP consider borrowing here //~| SUGGESTION &::std::ops::RangeToInclusive { end: 5 } } diff --git a/src/test/ui/range/issue-54505-no-literals.stderr b/src/test/ui/range/issue-54505-no-literals.stderr index 065e16a8227ca..a5e7380c3b7ea 100644 --- a/src/test/ui/range/issue-54505-no-literals.stderr +++ b/src/test/ui/range/issue-54505-no-literals.stderr @@ -1,146 +1,218 @@ -error[E0308]: mismatched types - --> $DIR/issue-54505-no-literals.rs:16:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-54505-no-literals.rs:16:5 | LL | take_range(std::ops::Range { start: 0, end: 1 }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^------------------------------------^ | | - | expected reference, found struct `std::ops::Range` - | help: consider borrowing here: `&std::ops::Range { start: 0, end: 1 }` + | expected `&_`, found `std::ops::Range<_>` | - = note: expected reference `&_` - found struct `std::ops::Range<{integer}>` +note: function defined here + --> $DIR/issue-54505-no-literals.rs:12:4 + | +LL | fn take_range(_r: &impl RangeBounds) {} + | ^^^^^^^^^^ ------------------------- +help: provide an argument of the correct type + | +LL | take_range({&_}); + | ^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/issue-54505-no-literals.rs:21:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-54505-no-literals.rs:21:5 | LL | take_range(::std::ops::Range { start: 0, end: 1 }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^--------------------------------------^ | | - | expected reference, found struct `std::ops::Range` - | help: consider borrowing here: `&::std::ops::Range { start: 0, end: 1 }` + | expected `&_`, found `std::ops::Range<_>` + | +note: function defined here + --> $DIR/issue-54505-no-literals.rs:12:4 | - = note: expected reference `&_` - found struct `std::ops::Range<{integer}>` +LL | fn take_range(_r: &impl RangeBounds) {} + | ^^^^^^^^^^ ------------------------- +help: provide an argument of the correct type + | +LL | take_range({&_}); + | ^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/issue-54505-no-literals.rs:26:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-54505-no-literals.rs:26:5 | LL | take_range(std::ops::RangeFrom { start: 1 }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^--------------------------------^ | | - | expected reference, found struct `RangeFrom` - | help: consider borrowing here: `&std::ops::RangeFrom { start: 1 }` + | expected `&_`, found `RangeFrom<_>` + | +note: function defined here + --> $DIR/issue-54505-no-literals.rs:12:4 + | +LL | fn take_range(_r: &impl RangeBounds) {} + | ^^^^^^^^^^ ------------------------- +help: provide an argument of the correct type | - = note: expected reference `&_` - found struct `RangeFrom<{integer}>` +LL | take_range({&_}); + | ^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/issue-54505-no-literals.rs:31:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-54505-no-literals.rs:31:5 | LL | take_range(::std::ops::RangeFrom { start: 1 }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^----------------------------------^ | | - | expected reference, found struct `RangeFrom` - | help: consider borrowing here: `&::std::ops::RangeFrom { start: 1 }` + | expected `&_`, found `RangeFrom<_>` | - = note: expected reference `&_` - found struct `RangeFrom<{integer}>` +note: function defined here + --> $DIR/issue-54505-no-literals.rs:12:4 + | +LL | fn take_range(_r: &impl RangeBounds) {} + | ^^^^^^^^^^ ------------------------- +help: provide an argument of the correct type + | +LL | take_range({&_}); + | ^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/issue-54505-no-literals.rs:36:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-54505-no-literals.rs:36:5 | LL | take_range(std::ops::RangeFull {}); - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^----------------------^ | | - | expected reference, found struct `RangeFull` - | help: consider borrowing here: `&std::ops::RangeFull {}` + | expected `&_`, found `RangeFull` + | +note: function defined here + --> $DIR/issue-54505-no-literals.rs:12:4 | - = note: expected reference `&_` - found struct `RangeFull` +LL | fn take_range(_r: &impl RangeBounds) {} + | ^^^^^^^^^^ ------------------------- +help: provide an argument of the correct type + | +LL | take_range({&_}); + | ^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/issue-54505-no-literals.rs:41:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-54505-no-literals.rs:41:5 | LL | take_range(::std::ops::RangeFull {}); - | ^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^------------------------^ | | - | expected reference, found struct `RangeFull` - | help: consider borrowing here: `&::std::ops::RangeFull {}` + | expected `&_`, found `RangeFull` + | +note: function defined here + --> $DIR/issue-54505-no-literals.rs:12:4 + | +LL | fn take_range(_r: &impl RangeBounds) {} + | ^^^^^^^^^^ ------------------------- +help: provide an argument of the correct type | - = note: expected reference `&_` - found struct `RangeFull` +LL | take_range({&_}); + | ^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/issue-54505-no-literals.rs:46:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-54505-no-literals.rs:46:5 | LL | take_range(std::ops::RangeInclusive::new(0, 1)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^-----------------------------------^ | | - | expected reference, found struct `RangeInclusive` - | help: consider borrowing here: `&std::ops::RangeInclusive::new(0, 1)` + | expected `&_`, found `RangeInclusive<_>` | - = note: expected reference `&_` - found struct `RangeInclusive<{integer}>` +note: function defined here + --> $DIR/issue-54505-no-literals.rs:12:4 + | +LL | fn take_range(_r: &impl RangeBounds) {} + | ^^^^^^^^^^ ------------------------- +help: provide an argument of the correct type + | +LL | take_range({&_}); + | ^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/issue-54505-no-literals.rs:51:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-54505-no-literals.rs:51:5 | LL | take_range(::std::ops::RangeInclusive::new(0, 1)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^-------------------------------------^ | | - | expected reference, found struct `RangeInclusive` - | help: consider borrowing here: `&::std::ops::RangeInclusive::new(0, 1)` + | expected `&_`, found `RangeInclusive<_>` + | +note: function defined here + --> $DIR/issue-54505-no-literals.rs:12:4 | - = note: expected reference `&_` - found struct `RangeInclusive<{integer}>` +LL | fn take_range(_r: &impl RangeBounds) {} + | ^^^^^^^^^^ ------------------------- +help: provide an argument of the correct type + | +LL | take_range({&_}); + | ^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/issue-54505-no-literals.rs:56:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-54505-no-literals.rs:56:5 | LL | take_range(std::ops::RangeTo { end: 5 }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^----------------------------^ | | - | expected reference, found struct `RangeTo` - | help: consider borrowing here: `&std::ops::RangeTo { end: 5 }` + | expected `&_`, found `RangeTo<_>` + | +note: function defined here + --> $DIR/issue-54505-no-literals.rs:12:4 + | +LL | fn take_range(_r: &impl RangeBounds) {} + | ^^^^^^^^^^ ------------------------- +help: provide an argument of the correct type | - = note: expected reference `&_` - found struct `RangeTo<{integer}>` +LL | take_range({&_}); + | ^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/issue-54505-no-literals.rs:61:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-54505-no-literals.rs:61:5 | LL | take_range(::std::ops::RangeTo { end: 5 }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^------------------------------^ | | - | expected reference, found struct `RangeTo` - | help: consider borrowing here: `&::std::ops::RangeTo { end: 5 }` + | expected `&_`, found `RangeTo<_>` | - = note: expected reference `&_` - found struct `RangeTo<{integer}>` +note: function defined here + --> $DIR/issue-54505-no-literals.rs:12:4 + | +LL | fn take_range(_r: &impl RangeBounds) {} + | ^^^^^^^^^^ ------------------------- +help: provide an argument of the correct type + | +LL | take_range({&_}); + | ^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/issue-54505-no-literals.rs:66:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-54505-no-literals.rs:66:5 | LL | take_range(std::ops::RangeToInclusive { end: 5 }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^-------------------------------------^ | | - | expected reference, found struct `RangeToInclusive` - | help: consider borrowing here: `&std::ops::RangeToInclusive { end: 5 }` + | expected `&_`, found `RangeToInclusive<_>` + | +note: function defined here + --> $DIR/issue-54505-no-literals.rs:12:4 | - = note: expected reference `&_` - found struct `RangeToInclusive<{integer}>` +LL | fn take_range(_r: &impl RangeBounds) {} + | ^^^^^^^^^^ ------------------------- +help: provide an argument of the correct type + | +LL | take_range({&_}); + | ^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/issue-54505-no-literals.rs:71:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-54505-no-literals.rs:71:5 | LL | take_range(::std::ops::RangeToInclusive { end: 5 }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^---------------------------------------^ | | - | expected reference, found struct `RangeToInclusive` - | help: consider borrowing here: `&::std::ops::RangeToInclusive { end: 5 }` + | expected `&_`, found `RangeToInclusive<_>` + | +note: function defined here + --> $DIR/issue-54505-no-literals.rs:12:4 + | +LL | fn take_range(_r: &impl RangeBounds) {} + | ^^^^^^^^^^ ------------------------- +help: provide an argument of the correct type | - = note: expected reference `&_` - found struct `RangeToInclusive<{integer}>` +LL | take_range({&_}); + | ^^^^^^^^^^^^^^^^ error: aborting due to 12 previous errors diff --git a/src/test/ui/range/issue-54505-no-std.rs b/src/test/ui/range/issue-54505-no-std.rs index f5d5823e468b0..4f6d69252232f 100644 --- a/src/test/ui/range/issue-54505-no-std.rs +++ b/src/test/ui/range/issue-54505-no-std.rs @@ -25,32 +25,32 @@ fn take_range(_r: &impl RangeBounds) {} fn main() { take_range(0..1); - //~^ ERROR mismatched types [E0308] + //~^ ERROR arguments to this function are incorrect [E0308] //~| HELP consider borrowing here //~| SUGGESTION &(0..1) take_range(1..); - //~^ ERROR mismatched types [E0308] + //~^ ERROR arguments to this function are incorrect [E0308] //~| HELP consider borrowing here //~| SUGGESTION &(1..) take_range(..); - //~^ ERROR mismatched types [E0308] + //~^ ERROR arguments to this function are incorrect [E0308] //~| HELP consider borrowing here //~| SUGGESTION &(..) take_range(0..=1); - //~^ ERROR mismatched types [E0308] + //~^ ERROR arguments to this function are incorrect [E0308] //~| HELP consider borrowing here //~| SUGGESTION &(0..=1) take_range(..5); - //~^ ERROR mismatched types [E0308] + //~^ ERROR arguments to this function are incorrect [E0308] //~| HELP consider borrowing here //~| SUGGESTION &(..5) take_range(..=42); - //~^ ERROR mismatched types [E0308] + //~^ ERROR arguments to this function are incorrect [E0308] //~| HELP consider borrowing here //~| SUGGESTION &(..=42) } diff --git a/src/test/ui/range/issue-54505-no-std.stderr b/src/test/ui/range/issue-54505-no-std.stderr index 73507f4836b23..a64cccd179b0f 100644 --- a/src/test/ui/range/issue-54505-no-std.stderr +++ b/src/test/ui/range/issue-54505-no-std.stderr @@ -1,76 +1,112 @@ error: `#[panic_handler]` function required, but not found -error[E0308]: mismatched types - --> $DIR/issue-54505-no-std.rs:27:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-54505-no-std.rs:27:5 | LL | take_range(0..1); - | ^^^^ + | ^^^^^^^^^^^----^ | | - | expected reference, found struct `Range` - | help: consider borrowing here: `&(0..1)` + | expected `&_`, found `Range<_>` | - = note: expected reference `&_` - found struct `Range<{integer}>` +note: function defined here + --> $DIR/issue-54505-no-std.rs:23:4 + | +LL | fn take_range(_r: &impl RangeBounds) {} + | ^^^^^^^^^^ ------------------------- +help: provide an argument of the correct type + | +LL | take_range({&_}); + | ^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/issue-54505-no-std.rs:32:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-54505-no-std.rs:32:5 | LL | take_range(1..); - | ^^^ + | ^^^^^^^^^^^---^ | | - | expected reference, found struct `RangeFrom` - | help: consider borrowing here: `&(1..)` + | expected `&_`, found `RangeFrom<_>` + | +note: function defined here + --> $DIR/issue-54505-no-std.rs:23:4 | - = note: expected reference `&_` - found struct `RangeFrom<{integer}>` +LL | fn take_range(_r: &impl RangeBounds) {} + | ^^^^^^^^^^ ------------------------- +help: provide an argument of the correct type + | +LL | take_range({&_}); + | ^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/issue-54505-no-std.rs:37:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-54505-no-std.rs:37:5 | LL | take_range(..); - | ^^ + | ^^^^^^^^^^^--^ | | - | expected reference, found struct `RangeFull` - | help: consider borrowing here: `&(..)` + | expected `&_`, found `RangeFull` + | +note: function defined here + --> $DIR/issue-54505-no-std.rs:23:4 + | +LL | fn take_range(_r: &impl RangeBounds) {} + | ^^^^^^^^^^ ------------------------- +help: provide an argument of the correct type | - = note: expected reference `&_` - found struct `RangeFull` +LL | take_range({&_}); + | ^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/issue-54505-no-std.rs:42:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-54505-no-std.rs:42:5 | LL | take_range(0..=1); - | ^^^^^ + | ^^^^^^^^^^^-----^ | | - | expected reference, found struct `RangeInclusive` - | help: consider borrowing here: `&(0..=1)` + | expected `&_`, found `RangeInclusive<_>` | - = note: expected reference `&_` - found struct `RangeInclusive<{integer}>` +note: function defined here + --> $DIR/issue-54505-no-std.rs:23:4 + | +LL | fn take_range(_r: &impl RangeBounds) {} + | ^^^^^^^^^^ ------------------------- +help: provide an argument of the correct type + | +LL | take_range({&_}); + | ^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/issue-54505-no-std.rs:47:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-54505-no-std.rs:47:5 | LL | take_range(..5); - | ^^^ + | ^^^^^^^^^^^---^ | | - | expected reference, found struct `RangeTo` - | help: consider borrowing here: `&(..5)` + | expected `&_`, found `RangeTo<_>` + | +note: function defined here + --> $DIR/issue-54505-no-std.rs:23:4 | - = note: expected reference `&_` - found struct `RangeTo<{integer}>` +LL | fn take_range(_r: &impl RangeBounds) {} + | ^^^^^^^^^^ ------------------------- +help: provide an argument of the correct type + | +LL | take_range({&_}); + | ^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/issue-54505-no-std.rs:52:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-54505-no-std.rs:52:5 | LL | take_range(..=42); - | ^^^^^ + | ^^^^^^^^^^^-----^ | | - | expected reference, found struct `RangeToInclusive` - | help: consider borrowing here: `&(..=42)` + | expected `&_`, found `RangeToInclusive<_>` + | +note: function defined here + --> $DIR/issue-54505-no-std.rs:23:4 + | +LL | fn take_range(_r: &impl RangeBounds) {} + | ^^^^^^^^^^ ------------------------- +help: provide an argument of the correct type | - = note: expected reference `&_` - found struct `RangeToInclusive<{integer}>` +LL | take_range({&_}); + | ^^^^^^^^^^^^^^^^ error: aborting due to 7 previous errors diff --git a/src/test/ui/range/issue-54505.fixed b/src/test/ui/range/issue-54505.fixed index f8298c0b5ceff..d1d55e77bab7f 100644 --- a/src/test/ui/range/issue-54505.fixed +++ b/src/test/ui/range/issue-54505.fixed @@ -11,33 +11,33 @@ fn take_range(_r: &impl RangeBounds) {} fn main() { - take_range(&(0..1)); - //~^ ERROR mismatched types [E0308] + take_range({&_}); + //~^ ERROR arguments to this function are incorrect [E0308] //~| HELP consider borrowing here //~| SUGGESTION &(0..1) - take_range(&(1..)); - //~^ ERROR mismatched types [E0308] + take_range({&_}); + //~^ ERROR arguments to this function are incorrect [E0308] //~| HELP consider borrowing here //~| SUGGESTION &(1..) - take_range(&(..)); - //~^ ERROR mismatched types [E0308] + take_range({&_}); + //~^ ERROR arguments to this function are incorrect [E0308] //~| HELP consider borrowing here //~| SUGGESTION &(..) - take_range(&(0..=1)); - //~^ ERROR mismatched types [E0308] + take_range({&_}); + //~^ ERROR arguments to this function are incorrect [E0308] //~| HELP consider borrowing here //~| SUGGESTION &(0..=1) - take_range(&(..5)); - //~^ ERROR mismatched types [E0308] + take_range({&_}); + //~^ ERROR arguments to this function are incorrect [E0308] //~| HELP consider borrowing here //~| SUGGESTION &(..5) - take_range(&(..=42)); - //~^ ERROR mismatched types [E0308] + take_range({&_}); + //~^ ERROR arguments to this function are incorrect [E0308] //~| HELP consider borrowing here //~| SUGGESTION &(..=42) } diff --git a/src/test/ui/range/issue-54505.rs b/src/test/ui/range/issue-54505.rs index 03673252dd3ba..6790b4cb9c1ec 100644 --- a/src/test/ui/range/issue-54505.rs +++ b/src/test/ui/range/issue-54505.rs @@ -12,32 +12,32 @@ fn take_range(_r: &impl RangeBounds) {} fn main() { take_range(0..1); - //~^ ERROR mismatched types [E0308] + //~^ ERROR arguments to this function are incorrect [E0308] //~| HELP consider borrowing here //~| SUGGESTION &(0..1) take_range(1..); - //~^ ERROR mismatched types [E0308] + //~^ ERROR arguments to this function are incorrect [E0308] //~| HELP consider borrowing here //~| SUGGESTION &(1..) take_range(..); - //~^ ERROR mismatched types [E0308] + //~^ ERROR arguments to this function are incorrect [E0308] //~| HELP consider borrowing here //~| SUGGESTION &(..) take_range(0..=1); - //~^ ERROR mismatched types [E0308] + //~^ ERROR arguments to this function are incorrect [E0308] //~| HELP consider borrowing here //~| SUGGESTION &(0..=1) take_range(..5); - //~^ ERROR mismatched types [E0308] + //~^ ERROR arguments to this function are incorrect [E0308] //~| HELP consider borrowing here //~| SUGGESTION &(..5) take_range(..=42); - //~^ ERROR mismatched types [E0308] + //~^ ERROR arguments to this function are incorrect [E0308] //~| HELP consider borrowing here //~| SUGGESTION &(..=42) } diff --git a/src/test/ui/range/issue-54505.stderr b/src/test/ui/range/issue-54505.stderr index 121af29834d87..636ac22311e6d 100644 --- a/src/test/ui/range/issue-54505.stderr +++ b/src/test/ui/range/issue-54505.stderr @@ -1,74 +1,110 @@ -error[E0308]: mismatched types - --> $DIR/issue-54505.rs:14:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-54505.rs:14:5 | LL | take_range(0..1); - | ^^^^ + | ^^^^^^^^^^^----^ | | - | expected reference, found struct `std::ops::Range` - | help: consider borrowing here: `&(0..1)` + | expected `&_`, found `std::ops::Range<_>` | - = note: expected reference `&_` - found struct `std::ops::Range<{integer}>` +note: function defined here + --> $DIR/issue-54505.rs:10:4 + | +LL | fn take_range(_r: &impl RangeBounds) {} + | ^^^^^^^^^^ ------------------------- +help: provide an argument of the correct type + | +LL | take_range({&_}); + | ^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/issue-54505.rs:19:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-54505.rs:19:5 | LL | take_range(1..); - | ^^^ + | ^^^^^^^^^^^---^ | | - | expected reference, found struct `RangeFrom` - | help: consider borrowing here: `&(1..)` + | expected `&_`, found `RangeFrom<_>` + | +note: function defined here + --> $DIR/issue-54505.rs:10:4 | - = note: expected reference `&_` - found struct `RangeFrom<{integer}>` +LL | fn take_range(_r: &impl RangeBounds) {} + | ^^^^^^^^^^ ------------------------- +help: provide an argument of the correct type + | +LL | take_range({&_}); + | ^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/issue-54505.rs:24:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-54505.rs:24:5 | LL | take_range(..); - | ^^ + | ^^^^^^^^^^^--^ | | - | expected reference, found struct `RangeFull` - | help: consider borrowing here: `&(..)` + | expected `&_`, found `RangeFull` + | +note: function defined here + --> $DIR/issue-54505.rs:10:4 + | +LL | fn take_range(_r: &impl RangeBounds) {} + | ^^^^^^^^^^ ------------------------- +help: provide an argument of the correct type | - = note: expected reference `&_` - found struct `RangeFull` +LL | take_range({&_}); + | ^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/issue-54505.rs:29:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-54505.rs:29:5 | LL | take_range(0..=1); - | ^^^^^ + | ^^^^^^^^^^^-----^ | | - | expected reference, found struct `RangeInclusive` - | help: consider borrowing here: `&(0..=1)` + | expected `&_`, found `RangeInclusive<_>` | - = note: expected reference `&_` - found struct `RangeInclusive<{integer}>` +note: function defined here + --> $DIR/issue-54505.rs:10:4 + | +LL | fn take_range(_r: &impl RangeBounds) {} + | ^^^^^^^^^^ ------------------------- +help: provide an argument of the correct type + | +LL | take_range({&_}); + | ^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/issue-54505.rs:34:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-54505.rs:34:5 | LL | take_range(..5); - | ^^^ + | ^^^^^^^^^^^---^ | | - | expected reference, found struct `RangeTo` - | help: consider borrowing here: `&(..5)` + | expected `&_`, found `RangeTo<_>` + | +note: function defined here + --> $DIR/issue-54505.rs:10:4 | - = note: expected reference `&_` - found struct `RangeTo<{integer}>` +LL | fn take_range(_r: &impl RangeBounds) {} + | ^^^^^^^^^^ ------------------------- +help: provide an argument of the correct type + | +LL | take_range({&_}); + | ^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/issue-54505.rs:39:16 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-54505.rs:39:5 | LL | take_range(..=42); - | ^^^^^ + | ^^^^^^^^^^^-----^ | | - | expected reference, found struct `RangeToInclusive` - | help: consider borrowing here: `&(..=42)` + | expected `&_`, found `RangeToInclusive<_>` + | +note: function defined here + --> $DIR/issue-54505.rs:10:4 + | +LL | fn take_range(_r: &impl RangeBounds) {} + | ^^^^^^^^^^ ------------------------- +help: provide an argument of the correct type | - = note: expected reference `&_` - found struct `RangeToInclusive<{integer}>` +LL | take_range({&_}); + | ^^^^^^^^^^^^^^^^ error: aborting due to 6 previous errors diff --git a/src/test/ui/range/issue-73553-misinterp-range-literal.rs b/src/test/ui/range/issue-73553-misinterp-range-literal.rs index e65dba0a03821..5db5ff4d59626 100644 --- a/src/test/ui/range/issue-73553-misinterp-range-literal.rs +++ b/src/test/ui/range/issue-73553-misinterp-range-literal.rs @@ -10,7 +10,7 @@ fn tell(x: usize) -> usize { fn main() { demo(tell(1)..tell(10)); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect demo(1..10); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect } diff --git a/src/test/ui/range/issue-73553-misinterp-range-literal.stderr b/src/test/ui/range/issue-73553-misinterp-range-literal.stderr index 5167b87fd27b8..ca8ed5470d799 100644 --- a/src/test/ui/range/issue-73553-misinterp-range-literal.stderr +++ b/src/test/ui/range/issue-73553-misinterp-range-literal.stderr @@ -1,26 +1,38 @@ -error[E0308]: mismatched types - --> $DIR/issue-73553-misinterp-range-literal.rs:12:10 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-73553-misinterp-range-literal.rs:12:5 | LL | demo(tell(1)..tell(10)); - | ^^^^^^^^^^^^^^^^^ + | ^^^^^-----------------^ | | - | expected reference, found struct `std::ops::Range` - | help: consider borrowing here: `&(tell(1)..tell(10))` + | expected `&std::ops::Range`, found `std::ops::Range<_>` | - = note: expected reference `&std::ops::Range` - found struct `std::ops::Range` +note: function defined here + --> $DIR/issue-73553-misinterp-range-literal.rs:3:4 + | +LL | fn demo(r: &Range) { + | ^^^^ --------- +help: provide an argument of the correct type + | +LL | demo({&std::ops::Range}); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/issue-73553-misinterp-range-literal.rs:14:10 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-73553-misinterp-range-literal.rs:14:5 | LL | demo(1..10); - | ^^^^^ + | ^^^^^-----^ | | - | expected reference, found struct `std::ops::Range` - | help: consider borrowing here: `&(1..10)` + | expected `&std::ops::Range`, found `std::ops::Range<_>` + | +note: function defined here + --> $DIR/issue-73553-misinterp-range-literal.rs:3:4 + | +LL | fn demo(r: &Range) { + | ^^^^ --------- +help: provide an argument of the correct type | - = note: expected reference `&std::ops::Range` - found struct `std::ops::Range<{integer}>` +LL | demo({&std::ops::Range}); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.rs b/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.rs index ab4c6d9cf9198..71faf818cfbd8 100644 --- a/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.rs +++ b/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.rs @@ -17,7 +17,8 @@ fn c<'a,'b>(x: &mut &'a isize, y: &mut &'b isize) { fn d() { // 'a and 'b are early bound in the function `a` because they appear // inconstraints: - let _: fn(&mut &isize, &mut &isize) = a; //~ ERROR mismatched types + let _: fn(&mut &isize, &mut &isize) = a; + //~^ ERROR mismatched types } fn e() { diff --git a/src/test/ui/regions/regions-infer-not-param.rs b/src/test/ui/regions/regions-infer-not-param.rs index 7643be64d5b23..ce3c7edc4fbf9 100644 --- a/src/test/ui/regions/regions-infer-not-param.rs +++ b/src/test/ui/regions/regions-infer-not-param.rs @@ -12,11 +12,13 @@ struct Indirect2<'a> { g: Box) + 'static> } -fn take_direct<'a,'b>(p: Direct<'a>) -> Direct<'b> { p } //~ ERROR mismatched types +fn take_direct<'a,'b>(p: Direct<'a>) -> Direct<'b> { p } +//~^ ERROR mismatched types fn take_indirect1(p: Indirect1) -> Indirect1 { p } -fn take_indirect2<'a,'b>(p: Indirect2<'a>) -> Indirect2<'b> { p } //~ ERROR mismatched types +fn take_indirect2<'a,'b>(p: Indirect2<'a>) -> Indirect2<'b> { p } +//~^ ERROR mismatched types //~| expected struct `Indirect2<'b>` //~| found struct `Indirect2<'a>` //~| ERROR mismatched types diff --git a/src/test/ui/regions/regions-infer-not-param.stderr b/src/test/ui/regions/regions-infer-not-param.stderr index a6e2047559cce..2440bf34e21f5 100644 --- a/src/test/ui/regions/regions-infer-not-param.stderr +++ b/src/test/ui/regions/regions-infer-not-param.stderr @@ -18,39 +18,39 @@ LL | fn take_direct<'a,'b>(p: Direct<'a>) -> Direct<'b> { p } | ^^ error[E0308]: mismatched types - --> $DIR/regions-infer-not-param.rs:19:63 + --> $DIR/regions-infer-not-param.rs:20:63 | LL | fn take_indirect2<'a,'b>(p: Indirect2<'a>) -> Indirect2<'b> { p } | ^ lifetime mismatch | = note: expected struct `Indirect2<'b>` found struct `Indirect2<'a>` -note: the lifetime `'a` as defined on the function body at 19:19... - --> $DIR/regions-infer-not-param.rs:19:19 +note: the lifetime `'a` as defined on the function body at 20:19... + --> $DIR/regions-infer-not-param.rs:20:19 | LL | fn take_indirect2<'a,'b>(p: Indirect2<'a>) -> Indirect2<'b> { p } | ^^ -note: ...does not necessarily outlive the lifetime `'b` as defined on the function body at 19:22 - --> $DIR/regions-infer-not-param.rs:19:22 +note: ...does not necessarily outlive the lifetime `'b` as defined on the function body at 20:22 + --> $DIR/regions-infer-not-param.rs:20:22 | LL | fn take_indirect2<'a,'b>(p: Indirect2<'a>) -> Indirect2<'b> { p } | ^^ error[E0308]: mismatched types - --> $DIR/regions-infer-not-param.rs:19:63 + --> $DIR/regions-infer-not-param.rs:20:63 | LL | fn take_indirect2<'a,'b>(p: Indirect2<'a>) -> Indirect2<'b> { p } | ^ lifetime mismatch | = note: expected struct `Indirect2<'b>` found struct `Indirect2<'a>` -note: the lifetime `'b` as defined on the function body at 19:22... - --> $DIR/regions-infer-not-param.rs:19:22 +note: the lifetime `'b` as defined on the function body at 20:22... + --> $DIR/regions-infer-not-param.rs:20:22 | LL | fn take_indirect2<'a,'b>(p: Indirect2<'a>) -> Indirect2<'b> { p } | ^^ -note: ...does not necessarily outlive the lifetime `'a` as defined on the function body at 19:19 - --> $DIR/regions-infer-not-param.rs:19:19 +note: ...does not necessarily outlive the lifetime `'a` as defined on the function body at 20:19 + --> $DIR/regions-infer-not-param.rs:20:19 | LL | fn take_indirect2<'a,'b>(p: Indirect2<'a>) -> Indirect2<'b> { p } | ^^ diff --git a/src/test/ui/resolve/resolve-primitive-fallback.rs b/src/test/ui/resolve/resolve-primitive-fallback.rs index 992bcd7977fcf..dee0f4782766b 100644 --- a/src/test/ui/resolve/resolve-primitive-fallback.rs +++ b/src/test/ui/resolve/resolve-primitive-fallback.rs @@ -2,7 +2,7 @@ fn main() { // Make sure primitive type fallback doesn't work in value namespace std::mem::size_of(u16); //~^ ERROR expected value, found builtin type `u16` - //~| ERROR this function takes 0 arguments but 1 argument was supplied + //~| ERROR arguments to this function are incorrect // Make sure primitive type fallback doesn't work with global paths let _: ::u8; diff --git a/src/test/ui/resolve/resolve-primitive-fallback.stderr b/src/test/ui/resolve/resolve-primitive-fallback.stderr index 8611306e82d03..1a7552a976f9d 100644 --- a/src/test/ui/resolve/resolve-primitive-fallback.stderr +++ b/src/test/ui/resolve/resolve-primitive-fallback.stderr @@ -15,15 +15,20 @@ help: consider importing this builtin type LL | use std::primitive::u8; | -error[E0061]: this function takes 0 arguments but 1 argument was supplied +error[E0308]: arguments to this function are incorrect --> $DIR/resolve-primitive-fallback.rs:3:5 | LL | std::mem::size_of(u16); - | ^^^^^^^^^^^^^^^^^ --- supplied 1 argument - | | - | expected 0 arguments + | ^^^^^^^^^^^^^^^^^^---^ + | | + | argument unexpected + | +help: remove the extra argument + | +LL | (); + | ^^ error: aborting due to 3 previous errors -Some errors have detailed explanations: E0061, E0412, E0423. -For more information about an error, try `rustc --explain E0061`. +Some errors have detailed explanations: E0308, E0412, E0423. +For more information about an error, try `rustc --explain E0308`. diff --git a/src/test/ui/short-error-format.stderr b/src/test/ui/short-error-format.stderr index 8a22d673b9821..29619f7ca6391 100644 --- a/src/test/ui/short-error-format.stderr +++ b/src/test/ui/short-error-format.stderr @@ -1,3 +1,3 @@ -$DIR/short-error-format.rs:6:9: error[E0308]: mismatched types +$DIR/short-error-format.rs:6:5: error[E0308]: arguments to this function are incorrect $DIR/short-error-format.rs:8:7: error[E0599]: no method named `salut` found for type `u32` in the current scope error: aborting due to 2 previous errors diff --git a/src/test/ui/span/E0057.stderr b/src/test/ui/span/E0057.stderr index 31579e2828964..da379790557c4 100644 --- a/src/test/ui/span/E0057.stderr +++ b/src/test/ui/span/E0057.stderr @@ -1,19 +1,27 @@ -error[E0057]: this function takes 1 argument but 0 arguments were supplied +error[E0308]: arguments to this function are incorrect --> $DIR/E0057.rs:3:13 | LL | let a = f(); - | ^-- supplied 0 arguments - | | - | expected 1 argument + | ^^^ an argument of type _ is missing + | +help: provide the argument + | +LL | let a = ({_}); + | ^^^^^ -error[E0057]: this function takes 1 argument but 2 arguments were supplied +error[E0308]: arguments to this function are incorrect --> $DIR/E0057.rs:5:13 | LL | let c = f(2, 3); - | ^ - - supplied 2 arguments - | | - | expected 1 argument + | ^^-^^^^ + | | + | argument of type {integer} unexpected + | +help: remove the extra argument + | +LL | let c = (2); + | ^^^ error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0057`. +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/span/coerce-suggestions.stderr b/src/test/ui/span/coerce-suggestions.stderr index 857c3081c62ef..8da1522d25386 100644 --- a/src/test/ui/span/coerce-suggestions.stderr +++ b/src/test/ui/span/coerce-suggestions.stderr @@ -16,23 +16,41 @@ LL | let x: &str = String::new(); | | help: consider borrowing here: `&String::new()` | expected due to this -error[E0308]: mismatched types - --> $DIR/coerce-suggestions.rs:12:10 +error[E0308]: arguments to this function are incorrect + --> $DIR/coerce-suggestions.rs:12:5 | LL | test(&y); - | ^^ types differ in mutability + | ^^^^^--^ + | | + | expected `&mut String`, found `&String` + | +note: function defined here + --> $DIR/coerce-suggestions.rs:3:4 + | +LL | fn test(_x: &mut String) {} + | ^^^^ --------------- +help: provide an argument of the correct type | - = note: expected mutable reference `&mut String` - found reference `&String` +LL | test({&mut String}); + | ^^^^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/coerce-suggestions.rs:14:11 +error[E0308]: arguments to this function are incorrect + --> $DIR/coerce-suggestions.rs:14:5 | LL | test2(&y); - | ^^ types differ in mutability + | ^^^^^^--^ + | | + | expected `&mut i32`, found `&String` + | +note: function defined here + --> $DIR/coerce-suggestions.rs:4:4 + | +LL | fn test2(_x: &mut i32) {} + | ^^^^^ ------------ +help: provide an argument of the correct type | - = note: expected mutable reference `&mut i32` - found reference `&String` +LL | test2({&mut i32}); + | ^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types --> $DIR/coerce-suggestions.rs:17:9 diff --git a/src/test/ui/span/issue-34264.rs b/src/test/ui/span/issue-34264.rs index 5b8fc71384efe..9506ae69cf4cc 100644 --- a/src/test/ui/span/issue-34264.rs +++ b/src/test/ui/span/issue-34264.rs @@ -4,8 +4,8 @@ fn bar(x, y: usize) {} //~ ERROR expected one of fn main() { foo(Some(42), 2); - foo(Some(42), 2, ""); //~ ERROR this function takes - bar("", ""); //~ ERROR mismatched types + foo(Some(42), 2, ""); //~ ERROR arguments to this function are incorrect + bar("", ""); //~ ERROR arguments to this function are incorrect bar(1, 2); - bar(1, 2, 3); //~ ERROR this function takes + bar(1, 2, 3); //~ ERROR arguments to this function are incorrect } diff --git a/src/test/ui/span/issue-34264.stderr b/src/test/ui/span/issue-34264.stderr index 5cda17fd6a1fc..78e60885b345a 100644 --- a/src/test/ui/span/issue-34264.stderr +++ b/src/test/ui/span/issue-34264.stderr @@ -50,41 +50,60 @@ help: if this is a type, explicitly ignore the parameter name LL | fn bar(_: x, y: usize) {} | ^^^^ -error[E0061]: this function takes 2 arguments but 3 arguments were supplied +error[E0308]: arguments to this function are incorrect --> $DIR/issue-34264.rs:7:5 | LL | foo(Some(42), 2, ""); - | ^^^ -------- - -- supplied 3 arguments - | | - | expected 2 arguments + | ^^^^--------^^^^^^^^ + | | + | argument of type [type error] unexpected | note: function defined here --> $DIR/issue-34264.rs:1:4 | LL | fn foo(Option, String) {} | ^^^ ----------- ------ +help: remove the extra argument + | +LL | foo(Some(42), 2); + | ^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/issue-34264.rs:8:13 +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-34264.rs:8:5 | LL | bar("", ""); - | ^^ expected `usize`, found `&str` + | ^^^^--^^^^^ + | | + | expected `usize`, found `&'static str` + | +note: function defined here + --> $DIR/issue-34264.rs:3:4 + | +LL | fn bar(x, y: usize) {} + | ^^^ - -------- +help: provide an argument of the correct type + | +LL | bar("", {usize}); + | ^^^^^^^^^^^^^^^^ -error[E0061]: this function takes 2 arguments but 3 arguments were supplied +error[E0308]: arguments to this function are incorrect --> $DIR/issue-34264.rs:10:5 | LL | bar(1, 2, 3); - | ^^^ - - - supplied 3 arguments - | | - | expected 2 arguments + | ^^^^-^^^^^^^ + | | + | argument of type [type error] unexpected | 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 -Some errors have detailed explanations: E0061, E0308. -For more information about an error, try `rustc --explain E0061`. +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/span/missing-unit-argument.rs b/src/test/ui/span/missing-unit-argument.rs index b8fb332120a4e..52967d0f2a9fc 100644 --- a/src/test/ui/span/missing-unit-argument.rs +++ b/src/test/ui/span/missing-unit-argument.rs @@ -8,10 +8,10 @@ impl S { } fn main() { - let _: Result<(), String> = Ok(); //~ ERROR this function takes - foo(); //~ ERROR this function takes - foo(()); //~ ERROR this function takes - bar(); //~ ERROR this function takes - S.baz(); //~ ERROR this function takes - S.generic::<()>(); //~ ERROR this function takes + let _: Result<(), String> = Ok(); //~ ERROR arguments to this function are incorrect + foo(); //~ ERROR arguments to this function are incorrect + foo(()); //~ ERROR arguments to this function are incorrect + bar(); //~ ERROR arguments to this function are incorrect + S.baz(); //~ ERROR arguments to this function are incorrect + S.generic::<()>(); //~ ERROR arguments to this function are incorrect } diff --git a/src/test/ui/span/missing-unit-argument.stderr b/src/test/ui/span/missing-unit-argument.stderr index b15da2cb47955..70505261b3a53 100644 --- a/src/test/ui/span/missing-unit-argument.stderr +++ b/src/test/ui/span/missing-unit-argument.stderr @@ -1,90 +1,97 @@ -error[E0061]: this function takes 1 argument but 0 arguments were supplied +error[E0308]: arguments to this function are incorrect --> $DIR/missing-unit-argument.rs:11:33 | LL | let _: Result<(), String> = Ok(); - | ^^-- supplied 0 arguments + | ^^^^ an argument of type () is missing | -help: expected the unit value `()`; create it with empty parentheses +help: provide the argument | -LL | let _: Result<(), String> = Ok(()); - | ^^ +LL | let _: Result<(), String> = (()); + | ^^^^ -error[E0061]: this function takes 2 arguments but 0 arguments were supplied +error[E0308]: arguments to this function are incorrect --> $DIR/missing-unit-argument.rs:12:5 | LL | foo(); - | ^^^-- supplied 0 arguments + | ^^^^^ | | - | expected 2 arguments + | an argument of type () is missing + | an argument of type () is missing | note: function defined here --> $DIR/missing-unit-argument.rs:1:4 | LL | fn foo(():(), ():()) {} | ^^^ ----- ----- +help: did you mean + | +LL | foo((), ()); + | ^^^^^^^^^^^ -error[E0061]: this function takes 2 arguments but 1 argument was supplied +error[E0308]: arguments to this function are incorrect --> $DIR/missing-unit-argument.rs:13:5 | LL | foo(()); - | ^^^ -- supplied 1 argument - | | - | expected 2 arguments + | ^^^^^^^ an argument of type () is missing | note: function defined here --> $DIR/missing-unit-argument.rs:1:4 | LL | fn foo(():(), ():()) {} | ^^^ ----- ----- +help: provide the argument + | +LL | foo((), ()); + | ^^^^^^^^^^^ -error[E0061]: this function takes 1 argument but 0 arguments were supplied +error[E0308]: arguments to this function are incorrect --> $DIR/missing-unit-argument.rs:14:5 | LL | bar(); - | ^^^-- supplied 0 arguments + | ^^^^^ an argument of type () is missing | 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: provide the argument | LL | bar(()); - | ^^ + | ^^^^^^^ -error[E0061]: this function takes 1 argument but 0 arguments were supplied +error[E0308]: arguments to this function are incorrect --> $DIR/missing-unit-argument.rs:15:7 | LL | S.baz(); - | ^^^- supplied 0 arguments + | ^^^ an argument of type () is missing | 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: provide the argument | -LL | S.baz(()); - | ^^ +LL | S.baz(())(); + | ^^^^^^^ -error[E0061]: this function takes 1 argument but 0 arguments were supplied +error[E0308]: arguments to this function are incorrect --> $DIR/missing-unit-argument.rs:16:7 | LL | S.generic::<()>(); - | ^^^^^^^------ supplied 0 arguments + | ^^^^^^^ an argument of type () is missing | note: associated function defined here --> $DIR/missing-unit-argument.rs:7:8 | LL | fn generic(self, _: T) { } | ^^^^^^^ ---- ---- -help: expected the unit value `()`; create it with empty parentheses +help: provide the argument | -LL | S.generic::<()>(()); - | ^^ +LL | S.generic(())::<()>(); + | ^^^^^^^^^^^ error: aborting due to 6 previous errors -For more information about this error, try `rustc --explain E0061`. +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/suggestions/as-ref.rs b/src/test/ui/suggestions/as-ref.rs index 03f04c389f1f3..d5471b3c5c2fb 100644 --- a/src/test/ui/suggestions/as-ref.rs +++ b/src/test/ui/suggestions/as-ref.rs @@ -4,14 +4,14 @@ fn takes_ref(_: &Foo) {} fn main() { let ref opt = Some(Foo); opt.map(|arg| takes_ref(arg)); - //~^ ERROR mismatched types [E0308] + //~^ ERROR arguments to this function are incorrect [E0308] opt.and_then(|arg| Some(takes_ref(arg))); - //~^ ERROR mismatched types [E0308] + //~^ ERROR arguments to this function are incorrect [E0308] let ref opt: Result<_, ()> = Ok(Foo); opt.map(|arg| takes_ref(arg)); - //~^ ERROR mismatched types [E0308] + //~^ ERROR arguments to this function are incorrect [E0308] opt.and_then(|arg| Ok(takes_ref(arg))); - //~^ ERROR mismatched types [E0308] + //~^ ERROR arguments to this function are incorrect [E0308] let x: &Option = &Some(3); let y: Option<&usize> = x; //~^ ERROR mismatched types [E0308] diff --git a/src/test/ui/suggestions/as-ref.stderr b/src/test/ui/suggestions/as-ref.stderr index 4b5a9be7e5b4d..4d832d5ea0876 100644 --- a/src/test/ui/suggestions/as-ref.stderr +++ b/src/test/ui/suggestions/as-ref.stderr @@ -1,34 +1,74 @@ -error[E0308]: mismatched types - --> $DIR/as-ref.rs:6:27 +error[E0308]: arguments to this function are incorrect + --> $DIR/as-ref.rs:6:17 | LL | opt.map(|arg| takes_ref(arg)); - | --- ^^^ expected `&Foo`, found struct `Foo` - | | - | help: consider using `as_ref` instead: `as_ref().map` + | ^^^^^^^^^^---^ + | | + | expected `&Foo`, found `Foo` + | +note: function defined here + --> $DIR/as-ref.rs:2:4 + | +LL | fn takes_ref(_: &Foo) {} + | ^^^^^^^^^ ------- +help: provide an argument of the correct type + | +LL | opt.map(|arg| takes_ref({&Foo})); + | ^^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/as-ref.rs:8:37 +error[E0308]: arguments to this function are incorrect + --> $DIR/as-ref.rs:8:27 | LL | opt.and_then(|arg| Some(takes_ref(arg))); - | -------- ^^^ expected `&Foo`, found struct `Foo` - | | - | help: consider using `as_ref` instead: `as_ref().and_then` + | ^^^^^^^^^^---^ + | | + | expected `&Foo`, found `Foo` + | +note: function defined here + --> $DIR/as-ref.rs:2:4 + | +LL | fn takes_ref(_: &Foo) {} + | ^^^^^^^^^ ------- +help: provide an argument of the correct type + | +LL | opt.and_then(|arg| Some(takes_ref({&Foo}))); + | ^^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/as-ref.rs:11:27 +error[E0308]: arguments to this function are incorrect + --> $DIR/as-ref.rs:11:17 | LL | opt.map(|arg| takes_ref(arg)); - | --- ^^^ expected `&Foo`, found struct `Foo` - | | - | help: consider using `as_ref` instead: `as_ref().map` + | ^^^^^^^^^^---^ + | | + | expected `&Foo`, found `Foo` + | +note: function defined here + --> $DIR/as-ref.rs:2:4 + | +LL | fn takes_ref(_: &Foo) {} + | ^^^^^^^^^ ------- +help: provide an argument of the correct type + | +LL | opt.map(|arg| takes_ref({&Foo})); + | ^^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/as-ref.rs:13:35 +error[E0308]: arguments to this function are incorrect + --> $DIR/as-ref.rs:13:25 | LL | opt.and_then(|arg| Ok(takes_ref(arg))); - | -------- ^^^ expected `&Foo`, found struct `Foo` - | | - | help: consider using `as_ref` instead: `as_ref().and_then` + | ^^^^^^^^^^---^ + | | + | expected `&Foo`, found `Foo` + | +note: function defined here + --> $DIR/as-ref.rs:2:4 + | +LL | fn takes_ref(_: &Foo) {} + | ^^^^^^^^^ ------- +help: provide an argument of the correct type + | +LL | opt.and_then(|arg| Ok(takes_ref({&Foo}))); + | ^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types --> $DIR/as-ref.rs:16:27 diff --git a/src/test/ui/suggestions/expected-boxed-future-isnt-pinned.rs b/src/test/ui/suggestions/expected-boxed-future-isnt-pinned.rs index 5dee0f5dae0b0..2658e9a1f0dd3 100644 --- a/src/test/ui/suggestions/expected-boxed-future-isnt-pinned.rs +++ b/src/test/ui/suggestions/expected-boxed-future-isnt-pinned.rs @@ -19,7 +19,7 @@ fn bar + Send + 'static>(x: F) -> BoxFuture<'static, i32> } fn baz + Send + 'static>(x: F) -> BoxFuture<'static, i32> { - Pin::new(x) //~ ERROR mismatched types + Pin::new(x) //~ ERROR arguments to this function are incorrect //~^ ERROR E0277 } diff --git a/src/test/ui/suggestions/expected-boxed-future-isnt-pinned.stderr b/src/test/ui/suggestions/expected-boxed-future-isnt-pinned.stderr index 32961b7f87be0..a04db1c69e64f 100644 --- a/src/test/ui/suggestions/expected-boxed-future-isnt-pinned.stderr +++ b/src/test/ui/suggestions/expected-boxed-future-isnt-pinned.stderr @@ -25,28 +25,26 @@ LL | Box::new(x) found struct `Box` = help: use `Box::pin` -error[E0308]: mismatched types - --> $DIR/expected-boxed-future-isnt-pinned.rs:22:14 +error[E0277]: `dyn Future + Send` cannot be unpinned + --> $DIR/expected-boxed-future-isnt-pinned.rs:22:5 | -LL | fn baz + Send + 'static>(x: F) -> BoxFuture<'static, i32> { - | - this type parameter LL | Pin::new(x) - | ^ - | | - | expected struct `Box`, found type parameter `F` - | help: store this in the heap by calling `Box::new`: `Box::new(x)` + | ^^^^^^^^ the trait `Unpin` is not implemented for `dyn Future + Send` | - = note: expected struct `Box + Send>` - found type parameter `F` - = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html + = note: required by `Pin::

::new` -error[E0277]: `dyn Future + Send` cannot be unpinned +error[E0308]: arguments to this function are incorrect --> $DIR/expected-boxed-future-isnt-pinned.rs:22:5 | LL | Pin::new(x) - | ^^^^^^^^ the trait `Unpin` is not implemented for `dyn Future + Send` + | ^^^^^^^^^-^ + | | + | expected `Box + Send>`, found `F` | - = note: required by `Pin::

::new` +help: provide an argument of the correct type + | +LL | ({Box + Send>}) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: `dyn Future + Send` cannot be unpinned --> $DIR/expected-boxed-future-isnt-pinned.rs:27:5 diff --git a/src/test/ui/suggestions/recover-from-semicolon-trailing-item.rs b/src/test/ui/suggestions/recover-from-semicolon-trailing-item.rs index 82935af0a81d2..189de8a2c14c7 100644 --- a/src/test/ui/suggestions/recover-from-semicolon-trailing-item.rs +++ b/src/test/ui/suggestions/recover-from-semicolon-trailing-item.rs @@ -12,5 +12,5 @@ fn main() { let _: usize = X {}; //~^ ERROR mismatched types foo(""); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect } diff --git a/src/test/ui/suggestions/recover-from-semicolon-trailing-item.stderr b/src/test/ui/suggestions/recover-from-semicolon-trailing-item.stderr index aa621111c00c5..f276af53af39d 100644 --- a/src/test/ui/suggestions/recover-from-semicolon-trailing-item.stderr +++ b/src/test/ui/suggestions/recover-from-semicolon-trailing-item.stderr @@ -34,11 +34,23 @@ LL | let _: usize = X {}; | | | expected due to this -error[E0308]: mismatched types - --> $DIR/recover-from-semicolon-trailing-item.rs:14:9 +error[E0308]: arguments to this function are incorrect + --> $DIR/recover-from-semicolon-trailing-item.rs:14:5 | LL | foo(""); - | ^^ expected `usize`, found `&str` + | ^^^^--^ + | | + | expected `usize`, found `&'static str` + | +note: function defined here + --> $DIR/recover-from-semicolon-trailing-item.rs:6:4 + | +LL | fn foo(a: usize) {}; + | ^^^ -------- +help: provide an argument of the correct type + | +LL | foo({usize}); + | ^^^^^^^^^^^^ error: aborting due to 6 previous errors diff --git a/src/test/ui/suggestions/suggest-box.fixed b/src/test/ui/suggestions/suggest-box.fixed index 3de02cd0bd481..001505f335721 100644 --- a/src/test/ui/suggestions/suggest-box.fixed +++ b/src/test/ui/suggestions/suggest-box.fixed @@ -1,7 +1,8 @@ // run-rustfix fn main() { - let _x: Box Result<(), ()>> = Box::new(|| { //~ ERROR mismatched types + let _x: Box Result<(), ()>> = Box::new(|| { + //~^ ERROR mismatched types Err(())?; Ok(()) }); diff --git a/src/test/ui/suggestions/suggest-box.rs b/src/test/ui/suggestions/suggest-box.rs index e680a61db3b17..60d9350dc0024 100644 --- a/src/test/ui/suggestions/suggest-box.rs +++ b/src/test/ui/suggestions/suggest-box.rs @@ -1,7 +1,8 @@ // run-rustfix fn main() { - let _x: Box Result<(), ()>> = || { //~ ERROR mismatched types + let _x: Box Result<(), ()>> = || { + //~^ ERROR mismatched types Err(())?; Ok(()) }; diff --git a/src/test/ui/suggestions/suggest-box.stderr b/src/test/ui/suggestions/suggest-box.stderr index 57c83baf4f831..0e831d65447bf 100644 --- a/src/test/ui/suggestions/suggest-box.stderr +++ b/src/test/ui/suggestions/suggest-box.stderr @@ -5,17 +5,19 @@ LL | let _x: Box Result<(), ()>> = || { | _____________-------------------------------___^ | | | | | expected due to this +LL | | LL | | Err(())?; LL | | Ok(()) LL | | }; | |_____^ expected struct `Box`, found closure | = note: expected struct `Box std::result::Result<(), ()>>` - found closure `[closure@$DIR/suggest-box.rs:4:47: 7:6]` + found closure `[closure@$DIR/suggest-box.rs:4:47: 8:6]` = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html help: store this in the heap by calling `Box::new` | LL | let _x: Box Result<(), ()>> = Box::new(|| { +LL | LL | Err(())?; LL | Ok(()) LL | }); diff --git a/src/test/ui/suggestions/trait-with-missing-associated-type-restriction-fixable.fixed b/src/test/ui/suggestions/trait-with-missing-associated-type-restriction-fixable.fixed index 8ef7e34ab3050..2afd28f7431e6 100644 --- a/src/test/ui/suggestions/trait-with-missing-associated-type-restriction-fixable.fixed +++ b/src/test/ui/suggestions/trait-with-missing-associated-type-restriction-fixable.fixed @@ -9,33 +9,33 @@ trait Trait { struct S(T); impl S { - fn foo<'a, T: Trait + 'a>(&self, _: impl Trait, x: impl Trait, _: T) { - qux(x.func()) //~ ERROR mismatched types + fn foo<'a, T: Trait + 'a>(&self, _: impl Trait, x: impl Trait, _: T) { + qux({usize}) //~ ERROR arguments to this function are incorrect } - fn ban(x: T) where T: Trait { - qux(x.func()) //~ ERROR mismatched types + fn ban(x: T) where T: Trait { + qux({usize}) //~ ERROR arguments to this function are incorrect } } -fn foo<'a, T: Trait + 'a>(_: impl Trait, x: impl Trait, _: T) { - qux(x.func()) //~ ERROR mismatched types +fn foo<'a, T: Trait + 'a>(_: impl Trait, x: impl Trait, _: T) { + qux({usize}) //~ ERROR arguments to this function are incorrect } -fn bar>(x: T) { - qux(x.func()) //~ ERROR mismatched types +fn bar(x: T) { + qux({usize}) //~ ERROR arguments to this function are incorrect } -fn foo2(x: impl Trait) { - qux(x.func()) //~ ERROR mismatched types +fn foo2(x: impl Trait) { + qux({usize}) //~ ERROR arguments to this function are incorrect } -fn bar2>(x: T) { - qux(x.func()) //~ ERROR mismatched types +fn bar2>(x: T) { + qux({usize}) //~ ERROR arguments to this function are incorrect } -fn ban(x: T) where T: Trait { - qux(x.func()) //~ ERROR mismatched types +fn ban(x: T) where T: Trait { + qux({usize}) //~ ERROR arguments to this function are incorrect } fn qux(_: usize) {} diff --git a/src/test/ui/suggestions/trait-with-missing-associated-type-restriction-fixable.rs b/src/test/ui/suggestions/trait-with-missing-associated-type-restriction-fixable.rs index 7bd38d0d45d90..8560feaec85ed 100644 --- a/src/test/ui/suggestions/trait-with-missing-associated-type-restriction-fixable.rs +++ b/src/test/ui/suggestions/trait-with-missing-associated-type-restriction-fixable.rs @@ -10,32 +10,32 @@ trait Trait { struct S(T); impl S { fn foo<'a, T: Trait + 'a>(&self, _: impl Trait, x: impl Trait, _: T) { - qux(x.func()) //~ ERROR mismatched types + qux(x.func()) //~ ERROR arguments to this function are incorrect } fn ban(x: T) where T: Trait { - qux(x.func()) //~ ERROR mismatched types + qux(x.func()) //~ ERROR arguments to this function are incorrect } } fn foo<'a, T: Trait + 'a>(_: impl Trait, x: impl Trait, _: T) { - qux(x.func()) //~ ERROR mismatched types + qux(x.func()) //~ ERROR arguments to this function are incorrect } fn bar(x: T) { - qux(x.func()) //~ ERROR mismatched types + qux(x.func()) //~ ERROR arguments to this function are incorrect } fn foo2(x: impl Trait) { - qux(x.func()) //~ ERROR mismatched types + qux(x.func()) //~ ERROR arguments to this function are incorrect } fn bar2>(x: T) { - qux(x.func()) //~ ERROR mismatched types + qux(x.func()) //~ ERROR arguments to this function are incorrect } fn ban(x: T) where T: Trait { - qux(x.func()) //~ ERROR mismatched types + qux(x.func()) //~ ERROR arguments to this function are incorrect } fn qux(_: usize) {} diff --git a/src/test/ui/suggestions/trait-with-missing-associated-type-restriction-fixable.stderr b/src/test/ui/suggestions/trait-with-missing-associated-type-restriction-fixable.stderr index f785f7b84a76f..bb98e280b1035 100644 --- a/src/test/ui/suggestions/trait-with-missing-associated-type-restriction-fixable.stderr +++ b/src/test/ui/suggestions/trait-with-missing-associated-type-restriction-fixable.stderr @@ -1,93 +1,128 @@ -error[E0308]: mismatched types - --> $DIR/trait-with-missing-associated-type-restriction-fixable.rs:13:13 +error[E0308]: arguments to this function are incorrect + --> $DIR/trait-with-missing-associated-type-restriction-fixable.rs:13:9 | LL | qux(x.func()) - | ^^^^^^^^ expected `usize`, found associated type + | ^^^^--------^ + | | + | expected `usize`, found `::A` | - = note: expected type `usize` - found associated type `::A` -help: consider constraining the associated type `::A` to `usize` +note: function defined here + --> $DIR/trait-with-missing-associated-type-restriction-fixable.rs:41:4 | -LL | fn foo<'a, T: Trait + 'a>(&self, _: impl Trait, x: impl Trait, _: T) { - | ^^^^^^^^^^^ +LL | fn qux(_: usize) {} + | ^^^ -------- +help: provide an argument of the correct type + | +LL | qux({usize}) + | ^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/trait-with-missing-associated-type-restriction-fixable.rs:17:13 +error[E0308]: arguments to this function are incorrect + --> $DIR/trait-with-missing-associated-type-restriction-fixable.rs:17:9 | LL | qux(x.func()) - | ^^^^^^^^ expected `usize`, found associated type + | ^^^^--------^ + | | + | expected `usize`, found `::A` + | +note: function defined here + --> $DIR/trait-with-missing-associated-type-restriction-fixable.rs:41:4 | - = note: expected type `usize` - found associated type `::A` -help: consider constraining the associated type `::A` to `usize` +LL | fn qux(_: usize) {} + | ^^^ -------- +help: provide an argument of the correct type | -LL | fn ban(x: T) where T: Trait { - | ^^^^^^^^^^^ +LL | qux({usize}) + | ^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/trait-with-missing-associated-type-restriction-fixable.rs:22:9 +error[E0308]: arguments to this function are incorrect + --> $DIR/trait-with-missing-associated-type-restriction-fixable.rs:22:5 | LL | qux(x.func()) - | ^^^^^^^^ expected `usize`, found associated type + | ^^^^--------^ + | | + | expected `usize`, found `::A` | - = note: expected type `usize` - found associated type `::A` -help: consider constraining the associated type `::A` to `usize` +note: function defined here + --> $DIR/trait-with-missing-associated-type-restriction-fixable.rs:41:4 | -LL | fn foo<'a, T: Trait + 'a>(_: impl Trait, x: impl Trait, _: T) { - | ^^^^^^^^^^^ +LL | fn qux(_: usize) {} + | ^^^ -------- +help: provide an argument of the correct type + | +LL | qux({usize}) + | ^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/trait-with-missing-associated-type-restriction-fixable.rs:26:9 +error[E0308]: arguments to this function are incorrect + --> $DIR/trait-with-missing-associated-type-restriction-fixable.rs:26:5 | LL | qux(x.func()) - | ^^^^^^^^ expected `usize`, found associated type + | ^^^^--------^ + | | + | expected `usize`, found `::A` + | +note: function defined here + --> $DIR/trait-with-missing-associated-type-restriction-fixable.rs:41:4 | - = note: expected type `usize` - found associated type `::A` -help: consider constraining the associated type `::A` to `usize` +LL | fn qux(_: usize) {} + | ^^^ -------- +help: provide an argument of the correct type | -LL | fn bar>(x: T) { - | ^^^^^^^^^^^ +LL | qux({usize}) + | ^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/trait-with-missing-associated-type-restriction-fixable.rs:30:9 +error[E0308]: arguments to this function are incorrect + --> $DIR/trait-with-missing-associated-type-restriction-fixable.rs:30:5 | LL | qux(x.func()) - | ^^^^^^^^ expected `usize`, found associated type + | ^^^^--------^ + | | + | expected `usize`, found ` as Trait>::A` | - = note: expected type `usize` - found associated type ` as Trait>::A` -help: consider constraining the associated type ` as Trait>::A` to `usize` +note: function defined here + --> $DIR/trait-with-missing-associated-type-restriction-fixable.rs:41:4 | -LL | fn foo2(x: impl Trait) { - | ^^^^^^^^^^^ +LL | fn qux(_: usize) {} + | ^^^ -------- +help: provide an argument of the correct type + | +LL | qux({usize}) + | ^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/trait-with-missing-associated-type-restriction-fixable.rs:34:9 +error[E0308]: arguments to this function are incorrect + --> $DIR/trait-with-missing-associated-type-restriction-fixable.rs:34:5 | LL | qux(x.func()) - | ^^^^^^^^ expected `usize`, found associated type + | ^^^^--------^ + | | + | expected `usize`, found `>::A` + | +note: function defined here + --> $DIR/trait-with-missing-associated-type-restriction-fixable.rs:41:4 | - = note: expected type `usize` - found associated type `>::A` -help: consider constraining the associated type `>::A` to `usize` +LL | fn qux(_: usize) {} + | ^^^ -------- +help: provide an argument of the correct type | -LL | fn bar2>(x: T) { - | ^^^^^^^^^^^ +LL | qux({usize}) + | ^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/trait-with-missing-associated-type-restriction-fixable.rs:38:9 +error[E0308]: arguments to this function are incorrect + --> $DIR/trait-with-missing-associated-type-restriction-fixable.rs:38:5 | LL | qux(x.func()) - | ^^^^^^^^ expected `usize`, found associated type + | ^^^^--------^ + | | + | expected `usize`, found `::A` + | +note: function defined here + --> $DIR/trait-with-missing-associated-type-restriction-fixable.rs:41:4 | - = note: expected type `usize` - found associated type `::A` -help: consider constraining the associated type `::A` to `usize` +LL | fn qux(_: usize) {} + | ^^^ -------- +help: provide an argument of the correct type | -LL | fn ban(x: T) where T: Trait { - | ^^^^^^^^^^^ +LL | qux({usize}) + | ^^^^^^^^^^^^ error: aborting due to 7 previous errors diff --git a/src/test/ui/suggestions/trait-with-missing-associated-type-restriction.rs b/src/test/ui/suggestions/trait-with-missing-associated-type-restriction.rs index 0d90e449523a3..9f2e4ece80b3d 100644 --- a/src/test/ui/suggestions/trait-with-missing-associated-type-restriction.rs +++ b/src/test/ui/suggestions/trait-with-missing-associated-type-restriction.rs @@ -11,32 +11,32 @@ trait Trait { } fn foo(_: impl Trait, x: impl Trait) { - qux(x.func()) //~ ERROR mismatched types + qux(x.func()) //~ ERROR arguments to this function are incorrect } fn bar(x: T) { - qux(x.func()) //~ ERROR mismatched types + qux(x.func()) //~ ERROR arguments to this function are incorrect } fn foo2(x: impl Trait) { - qux(x.func()) //~ ERROR mismatched types + qux(x.func()) //~ ERROR arguments to this function are incorrect } fn bar2>(x: T) { - x.funk(3); //~ ERROR mismatched types - qux(x.func()) //~ ERROR mismatched types + x.funk(3); //~ ERROR arguments to this function are incorrect + qux(x.func()) //~ ERROR arguments to this function are incorrect } fn baz>(x: T) { - qux(x.func()) //~ ERROR mismatched types + qux(x.func()) //~ ERROR arguments to this function are incorrect } fn bat(x: &mut dyn Trait<(), A = ()>) { - qux(x.func()) //~ ERROR mismatched types + qux(x.func()) //~ ERROR arguments to this function are incorrect } fn ban(x: T) where T: Trait { - qux(x.func()) //~ ERROR mismatched types + qux(x.func()) //~ ERROR arguments to this function are incorrect } fn qux(_: usize) {} diff --git a/src/test/ui/suggestions/trait-with-missing-associated-type-restriction.stderr b/src/test/ui/suggestions/trait-with-missing-associated-type-restriction.stderr index e629f8f970d32..3588322d6142d 100644 --- a/src/test/ui/suggestions/trait-with-missing-associated-type-restriction.stderr +++ b/src/test/ui/suggestions/trait-with-missing-associated-type-restriction.stderr @@ -12,108 +12,147 @@ help: a method is available that returns `>::A` LL | fn func(&self) -> Self::A; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ consider calling `Trait::func` -error[E0308]: mismatched types - --> $DIR/trait-with-missing-associated-type-restriction.rs:14:9 +error[E0308]: arguments to this function are incorrect + --> $DIR/trait-with-missing-associated-type-restriction.rs:14:5 | LL | qux(x.func()) - | ^^^^^^^^ expected `usize`, found associated type + | ^^^^--------^ + | | + | expected `usize`, found `::A` + | +note: function defined here + --> $DIR/trait-with-missing-associated-type-restriction.rs:42:4 | - = note: expected type `usize` - found associated type `::A` -help: consider constraining the associated type `::A` to `usize` +LL | fn qux(_: usize) {} + | ^^^ -------- +help: provide an argument of the correct type | -LL | fn foo(_: impl Trait, x: impl Trait) { - | ^^^^^^^^^^^ +LL | qux({usize}) + | ^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/trait-with-missing-associated-type-restriction.rs:18:9 +error[E0308]: arguments to this function are incorrect + --> $DIR/trait-with-missing-associated-type-restriction.rs:18:5 | LL | qux(x.func()) - | ^^^^^^^^ expected `usize`, found associated type + | ^^^^--------^ + | | + | expected `usize`, found `::A` | - = note: expected type `usize` - found associated type `::A` -help: consider constraining the associated type `::A` to `usize` +note: function defined here + --> $DIR/trait-with-missing-associated-type-restriction.rs:42:4 | -LL | fn bar>(x: T) { - | ^^^^^^^^^^^ +LL | fn qux(_: usize) {} + | ^^^ -------- +help: provide an argument of the correct type + | +LL | qux({usize}) + | ^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/trait-with-missing-associated-type-restriction.rs:22:9 +error[E0308]: arguments to this function are incorrect + --> $DIR/trait-with-missing-associated-type-restriction.rs:22:5 | LL | qux(x.func()) - | ^^^^^^^^ expected `usize`, found associated type + | ^^^^--------^ + | | + | expected `usize`, found ` as Trait>::A` + | +note: function defined here + --> $DIR/trait-with-missing-associated-type-restriction.rs:42:4 | - = note: expected type `usize` - found associated type ` as Trait>::A` -help: consider constraining the associated type ` as Trait>::A` to `usize` +LL | fn qux(_: usize) {} + | ^^^ -------- +help: provide an argument of the correct type | -LL | fn foo2(x: impl Trait) { - | ^^^^^^^^^^^ +LL | qux({usize}) + | ^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/trait-with-missing-associated-type-restriction.rs:26:12 +error[E0308]: arguments to this function are incorrect + --> $DIR/trait-with-missing-associated-type-restriction.rs:26:7 | LL | x.funk(3); - | ^ expected associated type, found integer + | ^^^^ - expected `>::A`, found `{integer}` | - = note: expected associated type `>::A` - found type `{integer}` -help: some methods are available that return `>::A` - --> $DIR/trait-with-missing-associated-type-restriction.rs:8:5 +note: associated function defined here + --> $DIR/trait-with-missing-associated-type-restriction.rs:9:8 | -LL | fn func(&self) -> Self::A; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ consider calling `Trait::func` LL | fn funk(&self, _: Self::A); -LL | fn funq(&self) -> Self::A {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ consider calling `Trait::funq` -help: consider constraining the associated type `>::A` to `{integer}` + | ^^^^ +help: provide an argument of the correct type | -LL | fn bar2>(x: T) { - | ^^^^^^^^^^^^^^^ +LL | x.funk({>::A})(3); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/trait-with-missing-associated-type-restriction.rs:27:9 +error[E0308]: arguments to this function are incorrect + --> $DIR/trait-with-missing-associated-type-restriction.rs:27:5 | LL | qux(x.func()) - | ^^^^^^^^ expected `usize`, found associated type + | ^^^^--------^ + | | + | expected `usize`, found `>::A` + | +note: function defined here + --> $DIR/trait-with-missing-associated-type-restriction.rs:42:4 | - = note: expected type `usize` - found associated type `>::A` -help: consider constraining the associated type `>::A` to `usize` +LL | fn qux(_: usize) {} + | ^^^ -------- +help: provide an argument of the correct type | -LL | fn bar2>(x: T) { - | ^^^^^^^^^^^ +LL | qux({usize}) + | ^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/trait-with-missing-associated-type-restriction.rs:31:9 +error[E0308]: arguments to this function are incorrect + --> $DIR/trait-with-missing-associated-type-restriction.rs:31:5 | -LL | fn baz>(x: T) { - | - this type parameter LL | qux(x.func()) - | ^^^^^^^^ expected `usize`, found type parameter `D` + | ^^^^--------^ + | | + | expected `usize`, found `D` | - = note: expected type `usize` - found type parameter `D` +note: function defined here + --> $DIR/trait-with-missing-associated-type-restriction.rs:42:4 + | +LL | fn qux(_: usize) {} + | ^^^ -------- +help: provide an argument of the correct type + | +LL | qux({usize}) + | ^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/trait-with-missing-associated-type-restriction.rs:35:9 +error[E0308]: arguments to this function are incorrect + --> $DIR/trait-with-missing-associated-type-restriction.rs:35:5 | LL | qux(x.func()) - | ^^^^^^^^ expected `usize`, found `()` + | ^^^^--------^ + | | + | expected `usize`, found `()` + | +note: function defined here + --> $DIR/trait-with-missing-associated-type-restriction.rs:42:4 + | +LL | fn qux(_: usize) {} + | ^^^ -------- +help: provide an argument of the correct type + | +LL | qux({usize}) + | ^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/trait-with-missing-associated-type-restriction.rs:39:9 +error[E0308]: arguments to this function are incorrect + --> $DIR/trait-with-missing-associated-type-restriction.rs:39:5 | LL | qux(x.func()) - | ^^^^^^^^ expected `usize`, found associated type + | ^^^^--------^ + | | + | expected `usize`, found `::A` + | +note: function defined here + --> $DIR/trait-with-missing-associated-type-restriction.rs:42:4 | - = note: expected type `usize` - found associated type `::A` -help: consider constraining the associated type `::A` to `usize` +LL | fn qux(_: usize) {} + | ^^^ -------- +help: provide an argument of the correct type | -LL | fn ban(x: T) where T: Trait { - | ^^^^^^^^^^^ +LL | qux({usize}) + | ^^^^^^^^^^^^ error: aborting due to 9 previous errors diff --git a/src/test/ui/switched-expectations.rs b/src/test/ui/switched-expectations.rs index c5bc84de54c48..792cc53d3a2ed 100644 --- a/src/test/ui/switched-expectations.rs +++ b/src/test/ui/switched-expectations.rs @@ -1,4 +1,5 @@ fn main() { let var = 10i32; - let ref string: String = var; //~ ERROR mismatched types [E0308] + let ref string: String = var; + //~^ ERROR mismatched types [E0308] } diff --git a/src/test/ui/terminal-width/flag-json.rs b/src/test/ui/terminal-width/flag-json.rs index eabdc59ddedd5..3d2530e204b33 100644 --- a/src/test/ui/terminal-width/flag-json.rs +++ b/src/test/ui/terminal-width/flag-json.rs @@ -5,5 +5,5 @@ fn main() { let _: () = 42; - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect } diff --git a/src/test/ui/terr-in-field.rs b/src/test/ui/terr-in-field.rs index aa801fd0a6c64..908d1bcdbd617 100644 --- a/src/test/ui/terr-in-field.rs +++ b/src/test/ui/terr-in-field.rs @@ -10,7 +10,7 @@ struct Bar { fn want_foo(f: Foo) {} fn have_bar(b: Bar) { - want_foo(b); //~ ERROR mismatched types + want_foo(b); //~ ERROR arguments to this function are incorrect //~| expected struct `Foo`, found struct `Bar` } diff --git a/src/test/ui/terr-in-field.stderr b/src/test/ui/terr-in-field.stderr index 5c6859a0efe98..4c2020e15ecbc 100644 --- a/src/test/ui/terr-in-field.stderr +++ b/src/test/ui/terr-in-field.stderr @@ -1,8 +1,20 @@ -error[E0308]: mismatched types - --> $DIR/terr-in-field.rs:13:14 +error[E0308]: arguments to this function are incorrect + --> $DIR/terr-in-field.rs:13:5 | LL | want_foo(b); - | ^ expected struct `Foo`, found struct `Bar` + | ^^^^^^^^^-^ + | | + | expected `Foo`, found `Bar` + | +note: function defined here + --> $DIR/terr-in-field.rs:11:4 + | +LL | fn want_foo(f: Foo) {} + | ^^^^^^^^ ------ +help: provide an argument of the correct type + | +LL | want_foo({Foo}); + | ^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/terr-sorts.rs b/src/test/ui/terr-sorts.rs index c1e2f7daee5ec..5734d6817bfd4 100644 --- a/src/test/ui/terr-sorts.rs +++ b/src/test/ui/terr-sorts.rs @@ -7,7 +7,7 @@ type Bar = Box; fn want_foo(f: Foo) {} fn have_bar(b: Bar) { - want_foo(b); //~ ERROR mismatched types + want_foo(b); //~ ERROR arguments to this function are incorrect //~| expected struct `Foo` //~| found struct `Box` } diff --git a/src/test/ui/terr-sorts.stderr b/src/test/ui/terr-sorts.stderr index 869b372965966..97557f80b7985 100644 --- a/src/test/ui/terr-sorts.stderr +++ b/src/test/ui/terr-sorts.stderr @@ -1,11 +1,20 @@ -error[E0308]: mismatched types - --> $DIR/terr-sorts.rs:10:14 +error[E0308]: arguments to this function are incorrect + --> $DIR/terr-sorts.rs:10:5 | LL | want_foo(b); - | ^ expected struct `Foo`, found struct `Box` + | ^^^^^^^^^-^ + | | + | expected `Foo`, found `Box` | - = note: expected struct `Foo` - found struct `Box` +note: function defined here + --> $DIR/terr-sorts.rs:8:4 + | +LL | fn want_foo(f: Foo) {} + | ^^^^^^^^ ------ +help: provide an argument of the correct type + | +LL | want_foo({Foo}); + | ^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/traits/trait-bounds-sugar.rs b/src/test/ui/traits/trait-bounds-sugar.rs index 65b6f6faa4250..eaf2adfeb157d 100644 --- a/src/test/ui/traits/trait-bounds-sugar.rs +++ b/src/test/ui/traits/trait-bounds-sugar.rs @@ -9,7 +9,7 @@ fn b(_x: &'static (dyn Foo + 'static)) { } fn c(x: Box) { - a(x); //~ ERROR mismatched types + a(x); //~ ERROR arguments to this function are incorrect } fn d(x: &'static (dyn Foo + Sync)) { diff --git a/src/test/ui/traits/trait-bounds-sugar.stderr b/src/test/ui/traits/trait-bounds-sugar.stderr index 6bd335fe4739a..aab1290d1613b 100644 --- a/src/test/ui/traits/trait-bounds-sugar.stderr +++ b/src/test/ui/traits/trait-bounds-sugar.stderr @@ -1,11 +1,20 @@ -error[E0308]: mismatched types - --> $DIR/trait-bounds-sugar.rs:12:7 +error[E0308]: arguments to this function are incorrect + --> $DIR/trait-bounds-sugar.rs:12:5 | LL | a(x); - | ^ expected trait `Foo + Send`, found trait `Foo + Sync` + | ^^-^ + | | + | expected `Box<(dyn Foo + Send + 'static)>`, found `Box<(dyn Foo + Sync + 'static)>` | - = note: expected struct `Box<(dyn Foo + Send + 'static)>` - found struct `Box<(dyn Foo + Sync + 'static)>` +note: function defined here + --> $DIR/trait-bounds-sugar.rs:5:4 + | +LL | fn a(_x: Box) { + | ^ ----------------------- +help: provide an argument of the correct type + | +LL | a({Box<(dyn Foo + Send + 'static)>}); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/traits/traits-multidispatch-bad.rs b/src/test/ui/traits/traits-multidispatch-bad.rs index b625b96159025..86fc2cbdd041e 100644 --- a/src/test/ui/traits/traits-multidispatch-bad.rs +++ b/src/test/ui/traits/traits-multidispatch-bad.rs @@ -16,7 +16,7 @@ where T : Convert } fn a() { - test(22i32, 44i32); //~ ERROR mismatched types + test(22i32, 44i32); //~ ERROR arguments to this function are incorrect } fn main() {} diff --git a/src/test/ui/traits/traits-multidispatch-bad.stderr b/src/test/ui/traits/traits-multidispatch-bad.stderr index 671faf45178f9..902d8967f49e9 100644 --- a/src/test/ui/traits/traits-multidispatch-bad.stderr +++ b/src/test/ui/traits/traits-multidispatch-bad.stderr @@ -1,13 +1,20 @@ -error[E0308]: mismatched types - --> $DIR/traits-multidispatch-bad.rs:19:17 +error[E0308]: arguments to this function are incorrect + --> $DIR/traits-multidispatch-bad.rs:19:5 | LL | test(22i32, 44i32); - | ^^^^^ expected `u32`, found `i32` + | ^^^^^-----^^^^^^^^ + | | + | expected `_`, found `i32` | -help: change the type of the numeric literal from `i32` to `u32` +note: function defined here + --> $DIR/traits-multidispatch-bad.rs:13:4 | -LL | test(22i32, 44u32); - | ^^^^^ +LL | fn test(_: T, _: U) + | ^^^^ ---- ---- +help: provide an argument of the correct type + | +LL | test(22i32, {u32}); + | ^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/tuple/tuple-arity-mismatch.rs b/src/test/ui/tuple/tuple-arity-mismatch.rs index f1e525c93e17f..97cdbb3c9b819 100644 --- a/src/test/ui/tuple/tuple-arity-mismatch.rs +++ b/src/test/ui/tuple/tuple-arity-mismatch.rs @@ -4,13 +4,13 @@ fn first((value, _): (isize, f64)) -> isize { value } fn main() { let y = first ((1,2.0,3)); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected tuple `(isize, f64)` //~| found tuple `(isize, f64, {integer})` //~| expected a tuple with 2 elements, found one with 3 elements let y = first ((1,)); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected tuple `(isize, f64)` //~| found tuple `(isize,)` //~| expected a tuple with 2 elements, found one with 1 element diff --git a/src/test/ui/tuple/tuple-arity-mismatch.stderr b/src/test/ui/tuple/tuple-arity-mismatch.stderr index 10bcedaf4aa9a..c943070773b81 100644 --- a/src/test/ui/tuple/tuple-arity-mismatch.stderr +++ b/src/test/ui/tuple/tuple-arity-mismatch.stderr @@ -1,20 +1,38 @@ -error[E0308]: mismatched types - --> $DIR/tuple-arity-mismatch.rs:6:20 +error[E0308]: arguments to this function are incorrect + --> $DIR/tuple-arity-mismatch.rs:6:13 | LL | let y = first ((1,2.0,3)); - | ^^^^^^^^^ expected a tuple with 2 elements, found one with 3 elements + | ^^^^^^^---------^ + | | + | expected `(isize, f64)`, found `(isize, f64, {integer})` | - = note: expected tuple `(isize, f64)` - found tuple `(isize, f64, {integer})` +note: function defined here + --> $DIR/tuple-arity-mismatch.rs:3:4 + | +LL | fn first((value, _): (isize, f64)) -> isize { value } + | ^^^^^ ------------------------ +help: provide an argument of the correct type + | +LL | let y = first({(isize, f64)}); + | ^^^^^^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/tuple-arity-mismatch.rs:12:20 +error[E0308]: arguments to this function are incorrect + --> $DIR/tuple-arity-mismatch.rs:12:13 | LL | let y = first ((1,)); - | ^^^^ expected a tuple with 2 elements, found one with 1 element + | ^^^^^^^----^ + | | + | expected `(isize, f64)`, found `(isize,)` + | +note: function defined here + --> $DIR/tuple-arity-mismatch.rs:3:4 + | +LL | fn first((value, _): (isize, f64)) -> isize { value } + | ^^^^^ ------------------------ +help: provide an argument of the correct type | - = note: expected tuple `(isize, f64)` - found tuple `(isize,)` +LL | let y = first({(isize, f64)}); + | ^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/tutorial-suffix-inference-test.rs b/src/test/ui/tutorial-suffix-inference-test.rs index 849adfd53686b..3ab4e9dd5f096 100644 --- a/src/test/ui/tutorial-suffix-inference-test.rs +++ b/src/test/ui/tutorial-suffix-inference-test.rs @@ -7,10 +7,10 @@ fn main() { identity_u8(x); // after this, `x` is assumed to have type `u8` identity_u16(x); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `u16`, found `u8` identity_u16(y); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `u16`, found `i32` let a = 3; @@ -19,6 +19,6 @@ fn main() { identity_i(a); // ok identity_u16(a); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| expected `u16`, found `isize` } diff --git a/src/test/ui/tutorial-suffix-inference-test.stderr b/src/test/ui/tutorial-suffix-inference-test.stderr index f9974acfb7071..0c752d5e8848b 100644 --- a/src/test/ui/tutorial-suffix-inference-test.stderr +++ b/src/test/ui/tutorial-suffix-inference-test.stderr @@ -1,33 +1,56 @@ -error[E0308]: mismatched types - --> $DIR/tutorial-suffix-inference-test.rs:9:18 +error[E0308]: arguments to this function are incorrect + --> $DIR/tutorial-suffix-inference-test.rs:9:5 | LL | identity_u16(x); - | ^ + | ^^^^^^^^^^^^^-^ | | | expected `u16`, found `u8` - | help: you can convert a `u8` to a `u16`: `x.into()` + | +note: function defined here + --> $DIR/tutorial-suffix-inference-test.rs:6:8 + | +LL | fn identity_u16(n: u16) -> u16 { n } + | ^^^^^^^^^^^^ ------ +help: provide an argument of the correct type + | +LL | identity_u16({u16}); + | ^^^^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/tutorial-suffix-inference-test.rs:12:18 +error[E0308]: arguments to this function are incorrect + --> $DIR/tutorial-suffix-inference-test.rs:12:5 | LL | identity_u16(y); - | ^ expected `u16`, found `i32` + | ^^^^^^^^^^^^^-^ + | | + | expected `u16`, found `i32` | -help: you can convert an `i32` to a `u16` and panic if the converted value doesn't fit +note: function defined here + --> $DIR/tutorial-suffix-inference-test.rs:6:8 | -LL | identity_u16(y.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^ +LL | fn identity_u16(n: u16) -> u16 { n } + | ^^^^^^^^^^^^ ------ +help: provide an argument of the correct type + | +LL | identity_u16({u16}); + | ^^^^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/tutorial-suffix-inference-test.rs:21:18 +error[E0308]: arguments to this function are incorrect + --> $DIR/tutorial-suffix-inference-test.rs:21:5 | LL | identity_u16(a); - | ^ expected `u16`, found `isize` + | ^^^^^^^^^^^^^-^ + | | + | expected `u16`, found `isize` + | +note: function defined here + --> $DIR/tutorial-suffix-inference-test.rs:6:8 | -help: you can convert an `isize` to a `u16` and panic if the converted value doesn't fit +LL | fn identity_u16(n: u16) -> u16 { n } + | ^^^^^^^^^^^^ ------ +help: provide an argument of the correct type | -LL | identity_u16(a.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^ +LL | identity_u16({u16}); + | ^^^^^^^^^^^^^^^^^^^ error: aborting due to 3 previous errors diff --git a/src/test/ui/type-alias-enum-variants/enum-variant-generic-args.rs b/src/test/ui/type-alias-enum-variants/enum-variant-generic-args.rs index f182c3ba8c798..1ec98a398ee20 100644 --- a/src/test/ui/type-alias-enum-variants/enum-variant-generic-args.rs +++ b/src/test/ui/type-alias-enum-variants/enum-variant-generic-args.rs @@ -11,12 +11,12 @@ type AliasFixed = Enum<()>; impl Enum { fn ts_variant() { Self::TSVariant(()); - //~^ ERROR mismatched types [E0308] + //~^ ERROR arguments to this function are incorrect [E0308] Self::TSVariant::<()>(()); //~^ ERROR type arguments are not allowed for this type [E0109] Self::<()>::TSVariant(()); //~^ ERROR type arguments are not allowed for this type [E0109] - //~^^ ERROR mismatched types [E0308] + //~^^ ERROR arguments to this function are incorrect [E0308] Self::<()>::TSVariant::<()>(()); //~^ ERROR type arguments are not allowed for this type [E0109] //~^^ ERROR type arguments are not allowed for this type [E0109] diff --git a/src/test/ui/type-alias-enum-variants/enum-variant-generic-args.stderr b/src/test/ui/type-alias-enum-variants/enum-variant-generic-args.stderr index caea791e6536b..094ab75d379fb 100644 --- a/src/test/ui/type-alias-enum-variants/enum-variant-generic-args.stderr +++ b/src/test/ui/type-alias-enum-variants/enum-variant-generic-args.stderr @@ -1,14 +1,20 @@ -error[E0308]: mismatched types - --> $DIR/enum-variant-generic-args.rs:13:25 +error[E0308]: arguments to this function are incorrect + --> $DIR/enum-variant-generic-args.rs:13:9 | -LL | impl Enum { - | - this type parameter -LL | fn ts_variant() { LL | Self::TSVariant(()); - | ^^ expected type parameter `T`, found `()` + | ^^^^^^^^^^^^^^^^--^ + | | + | expected `T`, found `()` | - = note: expected type parameter `T` - found unit type `()` +note: tuple variant defined here + --> $DIR/enum-variant-generic-args.rs:7:16 + | +LL | enum Enum { TSVariant(T), SVariant { v: T }, UVariant } + | ^^^^^^^^^^^^ +help: provide an argument of the correct type + | +LL | TSVariant(T)({T}); + | ^^^^^^^^^^^^^^^^^ error[E0109]: type arguments are not allowed for this type --> $DIR/enum-variant-generic-args.rs:15:27 @@ -22,17 +28,23 @@ error[E0109]: type arguments are not allowed for this type LL | Self::<()>::TSVariant(()); | ^^ type argument not allowed -error[E0308]: mismatched types - --> $DIR/enum-variant-generic-args.rs:17:31 +error[E0308]: arguments to this function are incorrect + --> $DIR/enum-variant-generic-args.rs:17:9 | -LL | impl Enum { - | - this type parameter -... LL | Self::<()>::TSVariant(()); - | ^^ expected type parameter `T`, found `()` + | ^^^^^^^^^^^^^^^^^^^^^^--^ + | | + | expected `T`, found `()` | - = note: expected type parameter `T` - found unit type `()` +note: tuple variant defined here + --> $DIR/enum-variant-generic-args.rs:7:16 + | +LL | enum Enum { TSVariant(T), SVariant { v: T }, UVariant } + | ^^^^^^^^^^^^ +help: provide an argument of the correct type + | +LL | TSVariant(T)({T}); + | ^^^^^^^^^^^^^^^^^ error[E0109]: type arguments are not allowed for this type --> $DIR/enum-variant-generic-args.rs:20:16 diff --git a/src/test/ui/type-alias-enum-variants/enum-variant-priority-higher-than-other-inherent.rs b/src/test/ui/type-alias-enum-variants/enum-variant-priority-higher-than-other-inherent.rs index d012687533bbe..8d5c0b23f0f41 100644 --- a/src/test/ui/type-alias-enum-variants/enum-variant-priority-higher-than-other-inherent.rs +++ b/src/test/ui/type-alias-enum-variants/enum-variant-priority-higher-than-other-inherent.rs @@ -18,6 +18,6 @@ impl E2 { } fn main() { - ::V(); //~ ERROR this function takes 1 argument but 0 arguments were supplied + ::V(); //~ ERROR arguments to this function are incorrect let _: u8 = ::V; //~ ERROR mismatched types } diff --git a/src/test/ui/type-alias-enum-variants/enum-variant-priority-higher-than-other-inherent.stderr b/src/test/ui/type-alias-enum-variants/enum-variant-priority-higher-than-other-inherent.stderr index 20e260584513a..e162993f68f9f 100644 --- a/src/test/ui/type-alias-enum-variants/enum-variant-priority-higher-than-other-inherent.stderr +++ b/src/test/ui/type-alias-enum-variants/enum-variant-priority-higher-than-other-inherent.stderr @@ -1,16 +1,18 @@ -error[E0061]: this function takes 1 argument but 0 arguments were supplied +error[E0308]: arguments to this function are incorrect --> $DIR/enum-variant-priority-higher-than-other-inherent.rs:21:5 | LL | ::V(); - | ^^^^^^-- supplied 0 arguments - | | - | expected 1 argument + | ^^^^^^^^ an argument of type u8 is missing | note: tuple variant defined here --> $DIR/enum-variant-priority-higher-than-other-inherent.rs:5:5 | LL | V(u8) | ^^^^^ +help: provide the argument + | +LL | V(u8)({u8}); + | ^^^^^^^^^^^ error[E0308]: mismatched types --> $DIR/enum-variant-priority-higher-than-other-inherent.rs:22:17 @@ -22,5 +24,4 @@ LL | let _: u8 = ::V; error: aborting due to 2 previous errors -Some errors have detailed explanations: E0061, E0308. -For more information about an error, try `rustc --explain E0061`. +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/type/type-ascription-instead-of-initializer.rs b/src/test/ui/type/type-ascription-instead-of-initializer.rs index 9f9b6f06bbc24..6e510e357984d 100644 --- a/src/test/ui/type/type-ascription-instead-of-initializer.rs +++ b/src/test/ui/type/type-ascription-instead-of-initializer.rs @@ -1,4 +1,4 @@ fn main() { let x: Vec::with_capacity(10, 20); //~ ERROR expected type, found `10` - //~^ ERROR this function takes 1 argument + //~^ ERROR arguments to this function are incorrect } diff --git a/src/test/ui/type/type-ascription-instead-of-initializer.stderr b/src/test/ui/type/type-ascription-instead-of-initializer.stderr index 530f77e5ae9b9..e7b453027b244 100644 --- a/src/test/ui/type/type-ascription-instead-of-initializer.stderr +++ b/src/test/ui/type/type-ascription-instead-of-initializer.stderr @@ -7,14 +7,19 @@ LL | let x: Vec::with_capacity(10, 20); | |help: use `=` if you meant to assign | while parsing the type for `x` -error[E0061]: this function takes 1 argument but 2 arguments were supplied +error[E0308]: arguments to this function are incorrect --> $DIR/type-ascription-instead-of-initializer.rs:2:12 | LL | let x: Vec::with_capacity(10, 20); - | ^^^^^^^^^^^^^^^^^^ -- -- supplied 2 arguments - | | - | expected 1 argument + | ^^^^^^^^^^^^^^^^^^^--^^^^^ + | | + | argument of type usize unexpected + | +help: remove the extra argument + | +LL | let x: (10); + | ^^^^ 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 E0308`. diff --git a/src/test/ui/type/type-mismatch-same-crate-name.rs b/src/test/ui/type/type-mismatch-same-crate-name.rs index c9cdc874c02ea..cf05b188900b7 100644 --- a/src/test/ui/type/type-mismatch-same-crate-name.rs +++ b/src/test/ui/type/type-mismatch-same-crate-name.rs @@ -14,11 +14,11 @@ fn main() { { extern crate crate_a1 as a; a::try_foo(foo2); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| perhaps two different versions of crate `crate_a1` //~| expected struct `main::a::Foo` a::try_bar(bar2); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect //~| perhaps two different versions of crate `crate_a1` //~| expected trait `main::a::Bar` //~| expected struct `Box<(dyn main::a::Bar + 'static)>` diff --git a/src/test/ui/type/type-mismatch-same-crate-name.stderr b/src/test/ui/type/type-mismatch-same-crate-name.stderr index 49d40ebed130c..93f1b6c6d581e 100644 --- a/src/test/ui/type/type-mismatch-same-crate-name.stderr +++ b/src/test/ui/type/type-mismatch-same-crate-name.stderr @@ -1,20 +1,28 @@ -error[E0308]: mismatched types - --> $DIR/type-mismatch-same-crate-name.rs:16:20 +error[E0308]: arguments to this function are incorrect + --> $DIR/type-mismatch-same-crate-name.rs:16:9 | LL | a::try_foo(foo2); - | ^^^^ expected struct `main::a::Foo`, found a different struct `main::a::Foo` + | ^^^^^^^^^^^----^ + | | + | expected `main::a::Foo`, found `main::a::Foo` | - = note: perhaps two different versions of crate `crate_a1` are being used? +help: provide an argument of the correct type + | +LL | ({main::a::Foo}); + | ^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/type-mismatch-same-crate-name.rs:20:20 +error[E0308]: arguments to this function are incorrect + --> $DIR/type-mismatch-same-crate-name.rs:20:9 | LL | a::try_bar(bar2); - | ^^^^ expected trait `main::a::Bar`, found a different trait `main::a::Bar` + | ^^^^^^^^^^^----^ + | | + | expected `Box<(dyn main::a::Bar + 'static)>`, found `Box` + | +help: provide an argument of the correct type | - = note: expected struct `Box<(dyn main::a::Bar + 'static)>` - found struct `Box` - = note: perhaps two different versions of crate `crate_a1` are being used? +LL | ({Box<(dyn main::a::Bar + 'static)>}); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/type/type-mismatch.rs b/src/test/ui/type/type-mismatch.rs index 11bfa3a72d98b..87950c275e344 100644 --- a/src/test/ui/type/type-mismatch.rs +++ b/src/test/ui/type/type-mismatch.rs @@ -14,65 +14,65 @@ struct bar; fn want(t: T) {} fn have_usize(f: usize) { - want::(f); //~ ERROR mismatched types - want::(f); //~ ERROR mismatched types - want::>(f); //~ ERROR mismatched types - want::>(f); //~ ERROR mismatched types - want::>(f); //~ ERROR mismatched types - want::>(f); //~ ERROR mismatched types - want::>(f); //~ ERROR mismatched types - want::>(f); //~ ERROR mismatched types + want::(f); //~ ERROR arguments to this function are incorrect + want::(f); //~ ERROR arguments to this function are incorrect + want::>(f); //~ ERROR arguments to this function are incorrect + want::>(f); //~ ERROR arguments to this function are incorrect + want::>(f); //~ ERROR arguments to this function are incorrect + want::>(f); //~ ERROR arguments to this function are incorrect + want::>(f); //~ ERROR arguments to this function are incorrect + want::>(f); //~ ERROR arguments to this function are incorrect } fn have_foo(f: foo) { - want::(f); //~ ERROR mismatched types - want::(f); //~ ERROR mismatched types - want::>(f); //~ ERROR mismatched types - want::>(f); //~ ERROR mismatched types - want::>(f); //~ ERROR mismatched types - want::>(f); //~ ERROR mismatched types - want::>(f); //~ ERROR mismatched types - want::>(f); //~ ERROR mismatched types + want::(f); //~ ERROR arguments to this function are incorrect + want::(f); //~ ERROR arguments to this function are incorrect + want::>(f); //~ ERROR arguments to this function are incorrect + want::>(f); //~ ERROR arguments to this function are incorrect + want::>(f); //~ ERROR arguments to this function are incorrect + want::>(f); //~ ERROR arguments to this function are incorrect + want::>(f); //~ ERROR arguments to this function are incorrect + want::>(f); //~ ERROR arguments to this function are incorrect } fn have_foo_foo(f: Foo) { - want::(f); //~ ERROR mismatched types - want::(f); //~ ERROR mismatched types - want::(f); //~ ERROR mismatched types - want::>(f); //~ ERROR mismatched types - want::>(f); //~ ERROR mismatched types - want::>(f); //~ ERROR mismatched types - want::>(f); //~ ERROR mismatched types - want::>(f); //~ ERROR mismatched types - want::<&Foo>(f); //~ ERROR mismatched types - want::<&Foo>(f); //~ ERROR mismatched types + want::(f); //~ ERROR arguments to this function are incorrect + want::(f); //~ ERROR arguments to this function are incorrect + want::(f); //~ ERROR arguments to this function are incorrect + want::>(f); //~ ERROR arguments to this function are incorrect + want::>(f); //~ ERROR arguments to this function are incorrect + want::>(f); //~ ERROR arguments to this function are incorrect + want::>(f); //~ ERROR arguments to this function are incorrect + want::>(f); //~ ERROR arguments to this function are incorrect + want::<&Foo>(f); //~ ERROR arguments to this function are incorrect + want::<&Foo>(f); //~ ERROR arguments to this function are incorrect } fn have_foo_foo_b(f: Foo) { - want::(f); //~ ERROR mismatched types - want::(f); //~ ERROR mismatched types - want::(f); //~ ERROR mismatched types - want::>(f); //~ ERROR mismatched types - want::>(f); //~ ERROR mismatched types - want::>(f); //~ ERROR mismatched types - want::>(f); //~ ERROR mismatched types - want::>(f); //~ ERROR mismatched types - want::<&Foo>(f); //~ ERROR mismatched types - want::<&Foo>(f); //~ ERROR mismatched types + want::(f); //~ ERROR arguments to this function are incorrect + want::(f); //~ ERROR arguments to this function are incorrect + want::(f); //~ ERROR arguments to this function are incorrect + want::>(f); //~ ERROR arguments to this function are incorrect + want::>(f); //~ ERROR arguments to this function are incorrect + want::>(f); //~ ERROR arguments to this function are incorrect + want::>(f); //~ ERROR arguments to this function are incorrect + want::>(f); //~ ERROR arguments to this function are incorrect + want::<&Foo>(f); //~ ERROR arguments to this function are incorrect + want::<&Foo>(f); //~ ERROR arguments to this function are incorrect } fn have_foo_foo_b_a(f: Foo) { - want::(f); //~ ERROR mismatched types - want::(f); //~ ERROR mismatched types - want::(f); //~ ERROR mismatched types - want::>(f); //~ ERROR mismatched types - want::>(f); //~ ERROR mismatched types - want::>(f); //~ ERROR mismatched types - want::>(f); //~ ERROR mismatched types - want::>(f); //~ ERROR mismatched types - want::>(f); //~ ERROR mismatched types - want::<&Foo>(f); //~ ERROR mismatched types - want::<&Foo>(f); //~ ERROR mismatched types + want::(f); //~ ERROR arguments to this function are incorrect + want::(f); //~ ERROR arguments to this function are incorrect + want::(f); //~ ERROR arguments to this function are incorrect + want::>(f); //~ ERROR arguments to this function are incorrect + want::>(f); //~ ERROR arguments to this function are incorrect + want::>(f); //~ ERROR arguments to this function are incorrect + want::>(f); //~ ERROR arguments to this function are incorrect + want::>(f); //~ ERROR arguments to this function are incorrect + want::>(f); //~ ERROR arguments to this function are incorrect + want::<&Foo>(f); //~ ERROR arguments to this function are incorrect + want::<&Foo>(f); //~ ERROR arguments to this function are incorrect } fn main() {} diff --git a/src/test/ui/type/type-mismatch.stderr b/src/test/ui/type/type-mismatch.stderr index 24c71c63103d3..972eba85d3c73 100644 --- a/src/test/ui/type/type-mismatch.stderr +++ b/src/test/ui/type/type-mismatch.stderr @@ -1,419 +1,848 @@ -error[E0308]: mismatched types - --> $DIR/type-mismatch.rs:17:17 +error[E0308]: arguments to this function are incorrect + --> $DIR/type-mismatch.rs:17:5 | LL | want::(f); - | ^ expected struct `foo`, found `usize` + | ^^^^^^^^^^^^-^ + | | + | expected `foo`, found `usize` + | +note: function defined here + --> $DIR/type-mismatch.rs:14:4 + | +LL | fn want(t: T) {} + | ^^^^ ---- +help: provide an argument of the correct type + | +LL | want({foo}); + | ^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/type-mismatch.rs:18:17 +error[E0308]: arguments to this function are incorrect + --> $DIR/type-mismatch.rs:18:5 | LL | want::(f); - | ^ expected struct `bar`, found `usize` + | ^^^^^^^^^^^^-^ + | | + | expected `bar`, found `usize` + | +note: function defined here + --> $DIR/type-mismatch.rs:14:4 + | +LL | fn want(t: T) {} + | ^^^^ ---- +help: provide an argument of the correct type + | +LL | want({bar}); + | ^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/type-mismatch.rs:19:24 +error[E0308]: arguments to this function are incorrect + --> $DIR/type-mismatch.rs:19:5 | LL | want::>(f); - | ^ expected struct `Foo`, found `usize` + | ^^^^^^^^^^^^^^^^^^^-^ + | | + | expected `Foo`, found `usize` + | +note: function defined here + --> $DIR/type-mismatch.rs:14:4 | - = note: expected struct `Foo` - found type `usize` +LL | fn want(t: T) {} + | ^^^^ ---- +help: provide an argument of the correct type + | +LL | want({Foo}); + | ^^^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/type-mismatch.rs:20:27 +error[E0308]: arguments to this function are incorrect + --> $DIR/type-mismatch.rs:20:5 | LL | want::>(f); - | ^ expected struct `Foo`, found `usize` + | ^^^^^^^^^^^^^^^^^^^^^^-^ + | | + | expected `Foo`, found `usize` + | +note: function defined here + --> $DIR/type-mismatch.rs:14:4 + | +LL | fn want(t: T) {} + | ^^^^ ---- +help: provide an argument of the correct type | - = note: expected struct `Foo` - found type `usize` +LL | want({Foo}); + | ^^^^^^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/type-mismatch.rs:21:22 +error[E0308]: arguments to this function are incorrect + --> $DIR/type-mismatch.rs:21:5 | LL | want::>(f); - | ^ expected struct `Foo`, found `usize` + | ^^^^^^^^^^^^^^^^^-^ + | | + | expected `Foo`, found `usize` | - = note: expected struct `Foo` - found type `usize` +note: function defined here + --> $DIR/type-mismatch.rs:14:4 + | +LL | fn want(t: T) {} + | ^^^^ ---- +help: provide an argument of the correct type + | +LL | want({Foo}); + | ^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/type-mismatch.rs:22:25 +error[E0308]: arguments to this function are incorrect + --> $DIR/type-mismatch.rs:22:5 | LL | want::>(f); - | ^ expected struct `Foo`, found `usize` + | ^^^^^^^^^^^^^^^^^^^^-^ + | | + | expected `Foo`, found `usize` + | +note: function defined here + --> $DIR/type-mismatch.rs:14:4 | - = note: expected struct `Foo` - found type `usize` +LL | fn want(t: T) {} + | ^^^^ ---- +help: provide an argument of the correct type + | +LL | want({Foo}); + | ^^^^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/type-mismatch.rs:23:22 +error[E0308]: arguments to this function are incorrect + --> $DIR/type-mismatch.rs:23:5 | LL | want::>(f); - | ^ expected struct `Foo`, found `usize` + | ^^^^^^^^^^^^^^^^^-^ + | | + | expected `Foo`, found `usize` + | +note: function defined here + --> $DIR/type-mismatch.rs:14:4 | - = note: expected struct `Foo` - found type `usize` +LL | fn want(t: T) {} + | ^^^^ ---- +help: provide an argument of the correct type + | +LL | want({Foo}); + | ^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/type-mismatch.rs:24:25 +error[E0308]: arguments to this function are incorrect + --> $DIR/type-mismatch.rs:24:5 | LL | want::>(f); - | ^ expected struct `Foo`, found `usize` + | ^^^^^^^^^^^^^^^^^^^^-^ + | | + | expected `Foo`, found `usize` + | +note: function defined here + --> $DIR/type-mismatch.rs:14:4 | - = note: expected struct `Foo` - found type `usize` +LL | fn want(t: T) {} + | ^^^^ ---- +help: provide an argument of the correct type + | +LL | want({Foo}); + | ^^^^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/type-mismatch.rs:28:19 +error[E0308]: arguments to this function are incorrect + --> $DIR/type-mismatch.rs:28:5 | LL | want::(f); - | ^ expected `usize`, found struct `foo` + | ^^^^^^^^^^^^^^-^ + | | + | expected `usize`, found `foo` + | +note: function defined here + --> $DIR/type-mismatch.rs:14:4 + | +LL | fn want(t: T) {} + | ^^^^ ---- +help: provide an argument of the correct type + | +LL | want({usize}); + | ^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/type-mismatch.rs:29:17 +error[E0308]: arguments to this function are incorrect + --> $DIR/type-mismatch.rs:29:5 | LL | want::(f); - | ^ expected struct `bar`, found struct `foo` + | ^^^^^^^^^^^^-^ + | | + | expected `bar`, found `foo` + | +note: function defined here + --> $DIR/type-mismatch.rs:14:4 + | +LL | fn want(t: T) {} + | ^^^^ ---- +help: provide an argument of the correct type + | +LL | want({bar}); + | ^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/type-mismatch.rs:30:24 +error[E0308]: arguments to this function are incorrect + --> $DIR/type-mismatch.rs:30:5 | LL | want::>(f); - | ^ expected struct `Foo`, found struct `foo` + | ^^^^^^^^^^^^^^^^^^^-^ + | | + | expected `Foo`, found `foo` + | +note: function defined here + --> $DIR/type-mismatch.rs:14:4 + | +LL | fn want(t: T) {} + | ^^^^ ---- +help: provide an argument of the correct type | - = note: expected struct `Foo` - found struct `foo` +LL | want({Foo}); + | ^^^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/type-mismatch.rs:31:27 +error[E0308]: arguments to this function are incorrect + --> $DIR/type-mismatch.rs:31:5 | LL | want::>(f); - | ^ expected struct `Foo`, found struct `foo` + | ^^^^^^^^^^^^^^^^^^^^^^-^ + | | + | expected `Foo`, found `foo` | - = note: expected struct `Foo` - found struct `foo` +note: function defined here + --> $DIR/type-mismatch.rs:14:4 + | +LL | fn want(t: T) {} + | ^^^^ ---- +help: provide an argument of the correct type + | +LL | want({Foo}); + | ^^^^^^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/type-mismatch.rs:32:22 +error[E0308]: arguments to this function are incorrect + --> $DIR/type-mismatch.rs:32:5 | LL | want::>(f); - | ^ expected struct `Foo`, found struct `foo` + | ^^^^^^^^^^^^^^^^^-^ + | | + | expected `Foo`, found `foo` + | +note: function defined here + --> $DIR/type-mismatch.rs:14:4 + | +LL | fn want(t: T) {} + | ^^^^ ---- +help: provide an argument of the correct type | - = note: expected struct `Foo` - found struct `foo` +LL | want({Foo}); + | ^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/type-mismatch.rs:33:25 +error[E0308]: arguments to this function are incorrect + --> $DIR/type-mismatch.rs:33:5 | LL | want::>(f); - | ^ expected struct `Foo`, found struct `foo` + | ^^^^^^^^^^^^^^^^^^^^-^ + | | + | expected `Foo`, found `foo` | - = note: expected struct `Foo` - found struct `foo` +note: function defined here + --> $DIR/type-mismatch.rs:14:4 + | +LL | fn want(t: T) {} + | ^^^^ ---- +help: provide an argument of the correct type + | +LL | want({Foo}); + | ^^^^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/type-mismatch.rs:34:22 +error[E0308]: arguments to this function are incorrect + --> $DIR/type-mismatch.rs:34:5 | LL | want::>(f); - | ^ expected struct `Foo`, found struct `foo` + | ^^^^^^^^^^^^^^^^^-^ + | | + | expected `Foo`, found `foo` + | +note: function defined here + --> $DIR/type-mismatch.rs:14:4 | - = note: expected struct `Foo` - found struct `foo` +LL | fn want(t: T) {} + | ^^^^ ---- +help: provide an argument of the correct type + | +LL | want({Foo}); + | ^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/type-mismatch.rs:35:25 +error[E0308]: arguments to this function are incorrect + --> $DIR/type-mismatch.rs:35:5 | LL | want::>(f); - | ^ expected struct `Foo`, found struct `foo` + | ^^^^^^^^^^^^^^^^^^^^-^ + | | + | expected `Foo`, found `foo` + | +note: function defined here + --> $DIR/type-mismatch.rs:14:4 + | +LL | fn want(t: T) {} + | ^^^^ ---- +help: provide an argument of the correct type | - = note: expected struct `Foo` - found struct `foo` +LL | want({Foo}); + | ^^^^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/type-mismatch.rs:39:19 +error[E0308]: arguments to this function are incorrect + --> $DIR/type-mismatch.rs:39:5 | LL | want::(f); - | ^ expected `usize`, found struct `Foo` + | ^^^^^^^^^^^^^^-^ + | | + | expected `usize`, found `Foo` | - = note: expected type `usize` - found struct `Foo` +note: function defined here + --> $DIR/type-mismatch.rs:14:4 + | +LL | fn want(t: T) {} + | ^^^^ ---- +help: provide an argument of the correct type + | +LL | want({usize}); + | ^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/type-mismatch.rs:40:17 +error[E0308]: arguments to this function are incorrect + --> $DIR/type-mismatch.rs:40:5 | LL | want::(f); - | ^ expected struct `foo`, found struct `Foo` + | ^^^^^^^^^^^^-^ + | | + | expected `foo`, found `Foo` + | +note: function defined here + --> $DIR/type-mismatch.rs:14:4 | - = note: expected struct `foo` - found struct `Foo` +LL | fn want(t: T) {} + | ^^^^ ---- +help: provide an argument of the correct type + | +LL | want({foo}); + | ^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/type-mismatch.rs:41:17 +error[E0308]: arguments to this function are incorrect + --> $DIR/type-mismatch.rs:41:5 | LL | want::(f); - | ^ expected struct `bar`, found struct `Foo` + | ^^^^^^^^^^^^-^ + | | + | expected `bar`, found `Foo` + | +note: function defined here + --> $DIR/type-mismatch.rs:14:4 + | +LL | fn want(t: T) {} + | ^^^^ ---- +help: provide an argument of the correct type | - = note: expected struct `bar` - found struct `Foo` +LL | want({bar}); + | ^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/type-mismatch.rs:42:24 +error[E0308]: arguments to this function are incorrect + --> $DIR/type-mismatch.rs:42:5 | LL | want::>(f); - | ^ expected `usize`, found struct `foo` + | ^^^^^^^^^^^^^^^^^^^-^ + | | + | expected `Foo`, found `Foo` | - = note: expected struct `Foo` - found struct `Foo` +note: function defined here + --> $DIR/type-mismatch.rs:14:4 + | +LL | fn want(t: T) {} + | ^^^^ ---- +help: provide an argument of the correct type + | +LL | want({Foo}); + | ^^^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/type-mismatch.rs:43:27 +error[E0308]: arguments to this function are incorrect + --> $DIR/type-mismatch.rs:43:5 | LL | want::>(f); - | ^ expected `usize`, found struct `foo` + | ^^^^^^^^^^^^^^^^^^^^^^-^ + | | + | expected `Foo`, found `Foo` + | +note: function defined here + --> $DIR/type-mismatch.rs:14:4 | - = note: expected struct `Foo` - found struct `Foo` +LL | fn want(t: T) {} + | ^^^^ ---- +help: provide an argument of the correct type + | +LL | want({Foo}); + | ^^^^^^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/type-mismatch.rs:44:25 +error[E0308]: arguments to this function are incorrect + --> $DIR/type-mismatch.rs:44:5 | LL | want::>(f); - | ^ expected struct `B`, found struct `A` + | ^^^^^^^^^^^^^^^^^^^^-^ + | | + | expected `Foo`, found `Foo` + | +note: function defined here + --> $DIR/type-mismatch.rs:14:4 + | +LL | fn want(t: T) {} + | ^^^^ ---- +help: provide an argument of the correct type | - = note: expected struct `Foo<_, B>` - found struct `Foo<_, A>` +LL | want({Foo}); + | ^^^^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/type-mismatch.rs:45:22 +error[E0308]: arguments to this function are incorrect + --> $DIR/type-mismatch.rs:45:5 | LL | want::>(f); - | ^ expected struct `bar`, found struct `foo` + | ^^^^^^^^^^^^^^^^^-^ + | | + | expected `Foo`, found `Foo` | - = note: expected struct `Foo` - found struct `Foo` +note: function defined here + --> $DIR/type-mismatch.rs:14:4 + | +LL | fn want(t: T) {} + | ^^^^ ---- +help: provide an argument of the correct type + | +LL | want({Foo}); + | ^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/type-mismatch.rs:46:25 +error[E0308]: arguments to this function are incorrect + --> $DIR/type-mismatch.rs:46:5 | LL | want::>(f); - | ^ expected struct `bar`, found struct `foo` + | ^^^^^^^^^^^^^^^^^^^^-^ + | | + | expected `Foo`, found `Foo` + | +note: function defined here + --> $DIR/type-mismatch.rs:14:4 | - = note: expected struct `Foo` - found struct `Foo` +LL | fn want(t: T) {} + | ^^^^ ---- +help: provide an argument of the correct type + | +LL | want({Foo}); + | ^^^^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/type-mismatch.rs:47:23 +error[E0308]: arguments to this function are incorrect + --> $DIR/type-mismatch.rs:47:5 | LL | want::<&Foo>(f); - | ^ + | ^^^^^^^^^^^^^^^^^^-^ | | - | expected `&Foo`, found struct `Foo` - | help: consider borrowing here: `&f` + | expected `&Foo`, found `Foo` + | +note: function defined here + --> $DIR/type-mismatch.rs:14:4 | - = note: expected reference `&Foo` - found struct `Foo` +LL | fn want(t: T) {} + | ^^^^ ---- +help: provide an argument of the correct type + | +LL | want({&Foo}); + | ^^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/type-mismatch.rs:48:26 +error[E0308]: arguments to this function are incorrect + --> $DIR/type-mismatch.rs:48:5 | LL | want::<&Foo>(f); - | ^ expected `&Foo`, found struct `Foo` + | ^^^^^^^^^^^^^^^^^^^^^-^ + | | + | expected `&Foo`, found `Foo` | - = note: expected reference `&Foo` - found struct `Foo` +note: function defined here + --> $DIR/type-mismatch.rs:14:4 + | +LL | fn want(t: T) {} + | ^^^^ ---- +help: provide an argument of the correct type + | +LL | want({&Foo}); + | ^^^^^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/type-mismatch.rs:52:19 +error[E0308]: arguments to this function are incorrect + --> $DIR/type-mismatch.rs:52:5 | LL | want::(f); - | ^ expected `usize`, found struct `Foo` + | ^^^^^^^^^^^^^^-^ + | | + | expected `usize`, found `Foo` + | +note: function defined here + --> $DIR/type-mismatch.rs:14:4 | - = note: expected type `usize` - found struct `Foo` +LL | fn want(t: T) {} + | ^^^^ ---- +help: provide an argument of the correct type + | +LL | want({usize}); + | ^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/type-mismatch.rs:53:17 +error[E0308]: arguments to this function are incorrect + --> $DIR/type-mismatch.rs:53:5 | LL | want::(f); - | ^ expected struct `foo`, found struct `Foo` + | ^^^^^^^^^^^^-^ + | | + | expected `foo`, found `Foo` + | +note: function defined here + --> $DIR/type-mismatch.rs:14:4 + | +LL | fn want(t: T) {} + | ^^^^ ---- +help: provide an argument of the correct type | - = note: expected struct `foo` - found struct `Foo` +LL | want({foo}); + | ^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/type-mismatch.rs:54:17 +error[E0308]: arguments to this function are incorrect + --> $DIR/type-mismatch.rs:54:5 | LL | want::(f); - | ^ expected struct `bar`, found struct `Foo` + | ^^^^^^^^^^^^-^ + | | + | expected `bar`, found `Foo` | - = note: expected struct `bar` - found struct `Foo` +note: function defined here + --> $DIR/type-mismatch.rs:14:4 + | +LL | fn want(t: T) {} + | ^^^^ ---- +help: provide an argument of the correct type + | +LL | want({bar}); + | ^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/type-mismatch.rs:55:24 +error[E0308]: arguments to this function are incorrect + --> $DIR/type-mismatch.rs:55:5 | LL | want::>(f); - | ^ expected `usize`, found struct `foo` + | ^^^^^^^^^^^^^^^^^^^-^ + | | + | expected `Foo`, found `Foo` + | +note: function defined here + --> $DIR/type-mismatch.rs:14:4 | - = note: expected struct `Foo` - found struct `Foo` +LL | fn want(t: T) {} + | ^^^^ ---- +help: provide an argument of the correct type + | +LL | want({Foo}); + | ^^^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/type-mismatch.rs:56:27 +error[E0308]: arguments to this function are incorrect + --> $DIR/type-mismatch.rs:56:5 | LL | want::>(f); - | ^ expected `usize`, found struct `foo` + | ^^^^^^^^^^^^^^^^^^^^^^-^ + | | + | expected `Foo`, found `Foo` + | +note: function defined here + --> $DIR/type-mismatch.rs:14:4 | - = note: expected struct `Foo` - found struct `Foo` +LL | fn want(t: T) {} + | ^^^^ ---- +help: provide an argument of the correct type + | +LL | want({Foo}); + | ^^^^^^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/type-mismatch.rs:57:22 +error[E0308]: arguments to this function are incorrect + --> $DIR/type-mismatch.rs:57:5 | LL | want::>(f); - | ^ expected struct `A`, found struct `B` + | ^^^^^^^^^^^^^^^^^-^ + | | + | expected `Foo`, found `Foo` + | +note: function defined here + --> $DIR/type-mismatch.rs:14:4 | - = note: expected struct `Foo<_, A>` - found struct `Foo<_, B>` +LL | fn want(t: T) {} + | ^^^^ ---- +help: provide an argument of the correct type + | +LL | want({Foo}); + | ^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/type-mismatch.rs:58:22 +error[E0308]: arguments to this function are incorrect + --> $DIR/type-mismatch.rs:58:5 | LL | want::>(f); - | ^ expected struct `bar`, found struct `foo` + | ^^^^^^^^^^^^^^^^^-^ + | | + | expected `Foo`, found `Foo` + | +note: function defined here + --> $DIR/type-mismatch.rs:14:4 + | +LL | fn want(t: T) {} + | ^^^^ ---- +help: provide an argument of the correct type | - = note: expected struct `Foo` - found struct `Foo` +LL | want({Foo}); + | ^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/type-mismatch.rs:59:25 +error[E0308]: arguments to this function are incorrect + --> $DIR/type-mismatch.rs:59:5 | LL | want::>(f); - | ^ expected struct `bar`, found struct `foo` + | ^^^^^^^^^^^^^^^^^^^^-^ + | | + | expected `Foo`, found `Foo` | - = note: expected struct `Foo` - found struct `Foo` +note: function defined here + --> $DIR/type-mismatch.rs:14:4 + | +LL | fn want(t: T) {} + | ^^^^ ---- +help: provide an argument of the correct type + | +LL | want({Foo}); + | ^^^^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/type-mismatch.rs:60:23 +error[E0308]: arguments to this function are incorrect + --> $DIR/type-mismatch.rs:60:5 | LL | want::<&Foo>(f); - | ^ expected `&Foo`, found struct `Foo` + | ^^^^^^^^^^^^^^^^^^-^ + | | + | expected `&Foo`, found `Foo` | - = note: expected reference `&Foo` - found struct `Foo` +note: function defined here + --> $DIR/type-mismatch.rs:14:4 + | +LL | fn want(t: T) {} + | ^^^^ ---- +help: provide an argument of the correct type + | +LL | want({&Foo}); + | ^^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/type-mismatch.rs:61:26 +error[E0308]: arguments to this function are incorrect + --> $DIR/type-mismatch.rs:61:5 | LL | want::<&Foo>(f); - | ^ + | ^^^^^^^^^^^^^^^^^^^^^-^ | | - | expected `&Foo`, found struct `Foo` - | help: consider borrowing here: `&f` + | expected `&Foo`, found `Foo` + | +note: function defined here + --> $DIR/type-mismatch.rs:14:4 | - = note: expected reference `&Foo` - found struct `Foo` +LL | fn want(t: T) {} + | ^^^^ ---- +help: provide an argument of the correct type + | +LL | want({&Foo}); + | ^^^^^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/type-mismatch.rs:65:19 +error[E0308]: arguments to this function are incorrect + --> $DIR/type-mismatch.rs:65:5 | LL | want::(f); - | ^ expected `usize`, found struct `Foo` + | ^^^^^^^^^^^^^^-^ + | | + | expected `usize`, found `Foo` + | +note: function defined here + --> $DIR/type-mismatch.rs:14:4 | - = note: expected type `usize` - found struct `Foo` +LL | fn want(t: T) {} + | ^^^^ ---- +help: provide an argument of the correct type + | +LL | want({usize}); + | ^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/type-mismatch.rs:66:17 +error[E0308]: arguments to this function are incorrect + --> $DIR/type-mismatch.rs:66:5 | LL | want::(f); - | ^ expected struct `foo`, found struct `Foo` + | ^^^^^^^^^^^^-^ + | | + | expected `foo`, found `Foo` + | +note: function defined here + --> $DIR/type-mismatch.rs:14:4 | - = note: expected struct `foo` - found struct `Foo` +LL | fn want(t: T) {} + | ^^^^ ---- +help: provide an argument of the correct type + | +LL | want({foo}); + | ^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/type-mismatch.rs:67:17 +error[E0308]: arguments to this function are incorrect + --> $DIR/type-mismatch.rs:67:5 | LL | want::(f); - | ^ expected struct `bar`, found struct `Foo` + | ^^^^^^^^^^^^-^ + | | + | expected `bar`, found `Foo` + | +note: function defined here + --> $DIR/type-mismatch.rs:14:4 + | +LL | fn want(t: T) {} + | ^^^^ ---- +help: provide an argument of the correct type | - = note: expected struct `bar` - found struct `Foo` +LL | want({bar}); + | ^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/type-mismatch.rs:68:24 +error[E0308]: arguments to this function are incorrect + --> $DIR/type-mismatch.rs:68:5 | LL | want::>(f); - | ^ expected `usize`, found struct `foo` + | ^^^^^^^^^^^^^^^^^^^-^ + | | + | expected `Foo`, found `Foo` | - = note: expected struct `Foo` - found struct `Foo` +note: function defined here + --> $DIR/type-mismatch.rs:14:4 + | +LL | fn want(t: T) {} + | ^^^^ ---- +help: provide an argument of the correct type + | +LL | want({Foo}); + | ^^^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/type-mismatch.rs:69:27 +error[E0308]: arguments to this function are incorrect + --> $DIR/type-mismatch.rs:69:5 | LL | want::>(f); - | ^ expected `usize`, found struct `foo` + | ^^^^^^^^^^^^^^^^^^^^^^-^ + | | + | expected `Foo`, found `Foo` + | +note: function defined here + --> $DIR/type-mismatch.rs:14:4 | - = note: expected struct `Foo` - found struct `Foo` +LL | fn want(t: T) {} + | ^^^^ ---- +help: provide an argument of the correct type + | +LL | want({Foo}); + | ^^^^^^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/type-mismatch.rs:70:22 +error[E0308]: arguments to this function are incorrect + --> $DIR/type-mismatch.rs:70:5 | LL | want::>(f); - | ^ expected struct `A`, found struct `B` + | ^^^^^^^^^^^^^^^^^-^ + | | + | expected `Foo`, found `Foo` + | +note: function defined here + --> $DIR/type-mismatch.rs:14:4 + | +LL | fn want(t: T) {} + | ^^^^ ---- +help: provide an argument of the correct type | - = note: expected struct `Foo<_, A, B>` - found struct `Foo<_, B, A>` +LL | want({Foo}); + | ^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/type-mismatch.rs:71:25 +error[E0308]: arguments to this function are incorrect + --> $DIR/type-mismatch.rs:71:5 | LL | want::>(f); - | ^ expected struct `B`, found struct `A` + | ^^^^^^^^^^^^^^^^^^^^-^ + | | + | expected `Foo`, found `Foo` | - = note: expected struct `Foo<_, _, B>` - found struct `Foo<_, _, A>` +note: function defined here + --> $DIR/type-mismatch.rs:14:4 + | +LL | fn want(t: T) {} + | ^^^^ ---- +help: provide an argument of the correct type + | +LL | want({Foo}); + | ^^^^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/type-mismatch.rs:72:22 +error[E0308]: arguments to this function are incorrect + --> $DIR/type-mismatch.rs:72:5 | LL | want::>(f); - | ^ expected struct `bar`, found struct `foo` + | ^^^^^^^^^^^^^^^^^-^ + | | + | expected `Foo`, found `Foo` + | +note: function defined here + --> $DIR/type-mismatch.rs:14:4 | - = note: expected struct `Foo` - found struct `Foo` +LL | fn want(t: T) {} + | ^^^^ ---- +help: provide an argument of the correct type + | +LL | want({Foo}); + | ^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/type-mismatch.rs:73:25 +error[E0308]: arguments to this function are incorrect + --> $DIR/type-mismatch.rs:73:5 | LL | want::>(f); - | ^ expected struct `bar`, found struct `foo` + | ^^^^^^^^^^^^^^^^^^^^-^ + | | + | expected `Foo`, found `Foo` + | +note: function defined here + --> $DIR/type-mismatch.rs:14:4 + | +LL | fn want(t: T) {} + | ^^^^ ---- +help: provide an argument of the correct type | - = note: expected struct `Foo` - found struct `Foo` +LL | want({Foo}); + | ^^^^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/type-mismatch.rs:74:23 +error[E0308]: arguments to this function are incorrect + --> $DIR/type-mismatch.rs:74:5 | LL | want::<&Foo>(f); - | ^ expected `&Foo`, found struct `Foo` + | ^^^^^^^^^^^^^^^^^^-^ + | | + | expected `&Foo`, found `Foo` + | +note: function defined here + --> $DIR/type-mismatch.rs:14:4 + | +LL | fn want(t: T) {} + | ^^^^ ---- +help: provide an argument of the correct type | - = note: expected reference `&Foo` - found struct `Foo` +LL | want({&Foo}); + | ^^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/type-mismatch.rs:75:26 +error[E0308]: arguments to this function are incorrect + --> $DIR/type-mismatch.rs:75:5 | LL | want::<&Foo>(f); - | ^ expected `&Foo`, found struct `Foo` + | ^^^^^^^^^^^^^^^^^^^^^-^ + | | + | expected `&Foo`, found `Foo` + | +note: function defined here + --> $DIR/type-mismatch.rs:14:4 + | +LL | fn want(t: T) {} + | ^^^^ ---- +help: provide an argument of the correct type | - = note: expected reference `&Foo` - found struct `Foo` +LL | want({&Foo}); + | ^^^^^^^^^^^^^^^^^^^^ error: aborting due to 47 previous errors diff --git a/src/test/ui/ufcs/ufcs-qpath-self-mismatch.rs b/src/test/ui/ufcs/ufcs-qpath-self-mismatch.rs index 939b3c5223c48..3ac7ee9e25fc8 100644 --- a/src/test/ui/ufcs/ufcs-qpath-self-mismatch.rs +++ b/src/test/ui/ufcs/ufcs-qpath-self-mismatch.rs @@ -4,7 +4,7 @@ fn main() { >::add(1, 2); //~^ ERROR cannot add `u32` to `i32` >::add(1u32, 2); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect >::add(1, 2u32); - //~^ ERROR mismatched types + //~^ ERROR arguments to this function are incorrect } diff --git a/src/test/ui/ufcs/ufcs-qpath-self-mismatch.stderr b/src/test/ui/ufcs/ufcs-qpath-self-mismatch.stderr index a2bf963044582..f9d479836ea1b 100644 --- a/src/test/ui/ufcs/ufcs-qpath-self-mismatch.stderr +++ b/src/test/ui/ufcs/ufcs-qpath-self-mismatch.stderr @@ -7,27 +7,31 @@ LL | >::add(1, 2); = help: the trait `Add` is not implemented for `i32` = note: required by `add` -error[E0308]: mismatched types - --> $DIR/ufcs-qpath-self-mismatch.rs:6:28 +error[E0308]: arguments to this function are incorrect + --> $DIR/ufcs-qpath-self-mismatch.rs:6:5 | LL | >::add(1u32, 2); - | ^^^^ expected `i32`, found `u32` + | ^^^^^^^^^^^^^^^^^^^^^^^----^^^^ + | | + | expected `i32`, found `u32` | -help: change the type of the numeric literal from `u32` to `i32` +help: provide an argument of the correct type | -LL | >::add(1i32, 2); - | ^^^^ +LL | ({i32}, 2); + | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/ufcs-qpath-self-mismatch.rs:8:31 +error[E0308]: arguments to this function are incorrect + --> $DIR/ufcs-qpath-self-mismatch.rs:8:5 | LL | >::add(1, 2u32); - | ^^^^ expected `i32`, found `u32` + | ^^^^^^^^^^^^^^^^^^^^^^^-^^^^^^^ + | | + | expected `i32`, found `i32` | -help: change the type of the numeric literal from `u32` to `i32` +help: provide an argument of the correct type | -LL | >::add(1, 2i32); - | ^^^^ +LL | (1, {i32}); + | ^^^^^^^^^^ error: aborting due to 3 previous errors diff --git a/src/test/ui/unboxed-closures/unboxed-closure-no-cyclic-sig.stderr b/src/test/ui/unboxed-closures/unboxed-closure-no-cyclic-sig.stderr index 167479270b546..b12b7759ec498 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-no-cyclic-sig.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closure-no-cyclic-sig.stderr @@ -1,14 +1,21 @@ -error[E0644]: closure/generator type that references itself - --> $DIR/unboxed-closure-no-cyclic-sig.rs:8:7 +error[E0308]: arguments to this function are incorrect + --> $DIR/unboxed-closure-no-cyclic-sig.rs:8:5 | LL | g(|_| { }); - | ^^^^^^^^ cyclic type of infinite size + | ^^--------^ + | | + | expected `_` | - = note: closures cannot capture themselves or take themselves as argument; - this error may be the result of a recent compiler bug-fix, - see issue #46062 - for more information +note: function defined here + --> $DIR/unboxed-closure-no-cyclic-sig.rs:5:4 + | +LL | fn g(_: F) where F: FnOnce(Option) {} + | ^ ---- +help: provide an argument of the correct type + | +LL | g({_}); + | ^^^^^^ error: aborting due to previous error -For more information about this error, try `rustc --explain E0644`. +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/unboxed-closures/unboxed-closures-type-mismatch.rs b/src/test/ui/unboxed-closures/unboxed-closures-type-mismatch.rs index 9f76849e5fbff..bf5d77dcc1576 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-type-mismatch.rs +++ b/src/test/ui/unboxed-closures/unboxed-closures-type-mismatch.rs @@ -2,6 +2,6 @@ use std::ops::FnMut; pub fn main() { let mut f = |x: isize, y: isize| -> isize { x + y }; - let z = f(1_usize, 2); //~ ERROR mismatched types + let z = f(1_usize, 2); //~ ERROR arguments to this function are incorrect println!("{}", z); } diff --git a/src/test/ui/unboxed-closures/unboxed-closures-type-mismatch.stderr b/src/test/ui/unboxed-closures/unboxed-closures-type-mismatch.stderr index 482b3ace65b4a..1298684566a86 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-type-mismatch.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closures-type-mismatch.stderr @@ -1,13 +1,15 @@ -error[E0308]: mismatched types - --> $DIR/unboxed-closures-type-mismatch.rs:5:15 +error[E0308]: arguments to this function are incorrect + --> $DIR/unboxed-closures-type-mismatch.rs:5:13 | LL | let z = f(1_usize, 2); - | ^^^^^^^ expected `isize`, found `usize` + | ^^-------^^^^ + | | + | expected `isize`, found `usize` | -help: change the type of the numeric literal from `usize` to `isize` +help: provide an argument of the correct type | -LL | let z = f(1_isize, 2); - | ^^^^^^^ +LL | let z = ({isize}, 2); + | ^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/variance/variance-associated-types2.rs b/src/test/ui/variance/variance-associated-types2.rs index 6a095fce7abfa..3feb110ad679e 100644 --- a/src/test/ui/variance/variance-associated-types2.rs +++ b/src/test/ui/variance/variance-associated-types2.rs @@ -11,7 +11,7 @@ fn make() -> Box> { fn take<'a>(_: &'a u32) { let _: Box> = make(); - //~^ ERROR mismatched types [E0308] + //~^ ERROR mismatched types } fn main() {}