diff --git a/compiler/rustc_ast_lowering/src/path.rs b/compiler/rustc_ast_lowering/src/path.rs index 8eb84c036a084..2640a6dbfbcec 100644 --- a/compiler/rustc_ast_lowering/src/path.rs +++ b/compiler/rustc_ast_lowering/src/path.rs @@ -288,10 +288,15 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { segment_ident_span.find_ancestor_inside(path_span).unwrap_or(path_span) } else if generic_args.is_empty() { // If there are brackets, but not generic arguments, then use the opening bracket - generic_args.span.with_hi(generic_args.span.lo() + BytePos(1)) + self.tcx + .mark_span_for_resize(generic_args.span) + .with_hi(generic_args.span.lo() + BytePos(1)) } else { // Else use an empty span right after the opening bracket. - generic_args.span.with_lo(generic_args.span.lo() + BytePos(1)).shrink_to_lo() + self.tcx + .mark_span_for_resize(generic_args.span) + .with_lo(generic_args.span.lo() + BytePos(1)) + .shrink_to_lo() }; generic_args.args.insert_many( diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs index 5db0f72919d03..c7395d4aaf630 100644 --- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs @@ -2250,12 +2250,18 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { Ok(string) => { if string.starts_with("async ") { let pos = args_span.lo() + BytePos(6); - (args_span.with_lo(pos).with_hi(pos), "move ") + ( + self.infcx.tcx.mark_span_for_resize(args_span).with_lo(pos).with_hi(pos), + "move ", + ) } else if string.starts_with("async|") { let pos = args_span.lo() + BytePos(5); - (args_span.with_lo(pos).with_hi(pos), " move") + ( + self.infcx.tcx.mark_span_for_resize(args_span).with_lo(pos).with_hi(pos), + " move", + ) } else { - (args_span.shrink_to_lo(), "move ") + (self.infcx.tcx.mark_span_for_resize(args_span).shrink_to_lo(), "move ") } } Err(_) => (args_span, "move || "), diff --git a/compiler/rustc_borrowck/src/diagnostics/move_errors.rs b/compiler/rustc_borrowck/src/diagnostics/move_errors.rs index 67af96a71e30d..259c7ce717ba8 100644 --- a/compiler/rustc_borrowck/src/diagnostics/move_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/move_errors.rs @@ -470,7 +470,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { match self.infcx.tcx.sess.source_map().span_to_snippet(span) { Ok(snippet) if snippet.starts_with('*') => { err.span_suggestion_verbose( - span.with_hi(span.lo() + BytePos(1)), + self.infcx.tcx.mark_span_for_resize(span).with_hi(span.lo() + BytePos(1)), "consider removing the dereference here", String::new(), Applicability::MaybeIncorrect, @@ -478,7 +478,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { } _ => { err.span_suggestion_verbose( - span.shrink_to_lo(), + self.infcx.tcx.mark_span_for_resize(span).shrink_to_lo(), "consider borrowing here", '&', Applicability::MaybeIncorrect, diff --git a/compiler/rustc_builtin_macros/src/alloc_error_handler.rs b/compiler/rustc_builtin_macros/src/alloc_error_handler.rs index 82bae9157e79d..ddeb14f90faea 100644 --- a/compiler/rustc_builtin_macros/src/alloc_error_handler.rs +++ b/compiler/rustc_builtin_macros/src/alloc_error_handler.rs @@ -21,16 +21,16 @@ pub fn expand( // Allow using `#[alloc_error_handler]` on an item statement // FIXME - if we get deref patterns, use them to reduce duplication here - let (item, is_stmt, sig_span) = + let (item, is_stmt, sig) = if let Annotatable::Item(item) = &item && let ItemKind::Fn(fn_kind) = &item.kind { - (item, false, ecx.with_def_site_ctxt(fn_kind.sig.span)) + (item, false, &fn_kind.sig) } else if let Annotatable::Stmt(stmt) = &item && let StmtKind::Item(item) = &stmt.kind && let ItemKind::Fn(fn_kind) = &item.kind { - (item, true, ecx.with_def_site_ctxt(fn_kind.sig.span)) + (item, true, &fn_kind.sig) } else { ecx.sess.parse_sess.span_diagnostic.emit_err(errors::AllocErrorMustBeFn {span: item.span() }); return vec![orig_item]; @@ -40,10 +40,10 @@ pub fn expand( let span = ecx.with_def_site_ctxt(item.span); // Generate item statements for the allocator methods. - let stmts = thin_vec![generate_handler(ecx, item.ident, span, sig_span)]; + let stmts = thin_vec![generate_handler(ecx, item.ident, span, sig)]; // Generate anonymous constant serving as container for the allocator methods. - let const_ty = ecx.ty(sig_span, TyKind::Tup(ThinVec::new())); + let const_ty = ecx.ty(ecx.with_def_site_ctxt(sig.span), TyKind::Tup(ThinVec::new())); let const_body = ecx.expr_block(ecx.block(span, stmts)); let const_item = ecx.item_const(span, Ident::new(kw::Underscore, span), const_ty, const_body); let const_item = if is_stmt { @@ -60,27 +60,31 @@ pub fn expand( // unsafe fn __rg_oom(size: usize, align: usize) -> ! { // handler(core::alloc::Layout::from_size_align_unchecked(size, align)) // } -fn generate_handler(cx: &ExtCtxt<'_>, handler: Ident, span: Span, sig_span: Span) -> Stmt { +fn generate_handler(cx: &ExtCtxt<'_>, handler: Ident, span: Span, sig: &FnSig) -> Stmt { let usize = cx.path_ident(span, Ident::new(sym::usize, span)); let ty_usize = cx.ty_path(usize); let size = Ident::from_str_and_span("size", span); let align = Ident::from_str_and_span("align", span); + let sig_span = cx.with_def_site_ctxt(sig.span); + let ret_sp = cx.with_def_site_ctxt(sig.decl.output.span()); + + // core::alloc::Layout::from_size_align_unchecked(size, align) let layout_new = cx.std_path(&[sym::alloc, sym::Layout, sym::from_size_align_unchecked]); let layout_new = cx.expr_path(cx.path(span, layout_new)); let layout = cx.expr_call( - span, + cx.with_def_site_ctxt(sig.decl.inputs.get(0).map_or(span, |p| p.span)), layout_new, thin_vec![cx.expr_ident(span, size), cx.expr_ident(span, align)], ); - - let call = cx.expr_call_ident(sig_span, handler, thin_vec![layout]); + let call = + cx.expr(ret_sp, ast::ExprKind::Call(cx.expr_ident(span, handler), thin_vec![layout])); let never = ast::FnRetTy::Ty(cx.ty(span, TyKind::Never)); let params = thin_vec![cx.param(span, size, ty_usize.clone()), cx.param(span, align, ty_usize)]; let decl = cx.fn_decl(params, never); let header = FnHeader { unsafety: Unsafe::Yes(span), ..FnHeader::default() }; - let sig = FnSig { decl, header, span: span }; + let sig = FnSig { decl, header, span }; let body = Some(cx.block_expr(call)); let kind = ItemKind::Fn(Box::new(Fn { diff --git a/compiler/rustc_const_eval/src/transform/check_consts/ops.rs b/compiler/rustc_const_eval/src/transform/check_consts/ops.rs index 6c11edb742c0d..3492832c25ead 100644 --- a/compiler/rustc_const_eval/src/transform/check_consts/ops.rs +++ b/compiler/rustc_const_eval/src/transform/check_consts/ops.rs @@ -256,11 +256,17 @@ impl<'tcx> NonConstOp<'tcx> for FnCallNonConst<'tcx> { { let rhs_pos = span.lo() + BytePos::from_usize(eq_idx + 2 + rhs_idx); - let rhs_span = span.with_lo(rhs_pos).with_hi(rhs_pos); + let rhs_span = tcx + .mark_span_for_resize(span) + .with_lo(rhs_pos) + .with_hi(rhs_pos); err.multipart_suggestion( "consider dereferencing here", vec![ - (span.shrink_to_lo(), deref.clone()), + ( + tcx.mark_span_for_resize(span).shrink_to_lo(), + deref.clone(), + ), (rhs_span, deref), ], Applicability::MachineApplicable, diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs index 29c692128bcf9..f5f56d49986a9 100644 --- a/compiler/rustc_errors/src/diagnostic.rs +++ b/compiler/rustc_errors/src/diagnostic.rs @@ -621,6 +621,10 @@ impl Diagnostic { .map(|(span, snippet)| SubstitutionPart { snippet, span }) .collect::>(); + if !parts.iter().all(|sub| sub.span.can_be_used_for_suggestions()) { + return self; + } + parts.sort_unstable_by_key(|part| part.span); assert!(!parts.is_empty()); @@ -711,6 +715,9 @@ impl Diagnostic { !(sp.is_empty() && suggestion.to_string().is_empty()), "Span must not be empty and have no suggestion" ); + if !sp.can_be_used_for_suggestions() { + return self; + } self.push_suggestion(CodeSuggestion { substitutions: vec![Substitution { parts: vec![SubstitutionPart { snippet: suggestion.to_string(), span: sp }], @@ -774,6 +781,9 @@ impl Diagnostic { !(sp.is_empty() && suggestions.iter().any(|suggestion| suggestion.is_empty())), "Span must not be empty and have no suggestion" ); + if !sp.can_be_used_for_suggestions() { + return self; + } let substitutions = suggestions .into_iter() @@ -799,12 +809,16 @@ impl Diagnostic { ) -> &mut Self { let substitutions = suggestions .into_iter() - .map(|sugg| { + .filter_map(|sugg| { let mut parts = sugg .into_iter() .map(|(span, snippet)| SubstitutionPart { snippet, span }) .collect::>(); + if !parts.iter().all(|sub| sub.span.can_be_used_for_suggestions()) { + return None; + } + parts.sort_unstable_by_key(|part| part.span); assert!(!parts.is_empty()); @@ -819,7 +833,7 @@ impl Diagnostic { "suggestion must not have overlapping parts", ); - Substitution { parts } + Some(Substitution { parts }) }) .collect(); diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index 2498ae2b7bce5..28e79b44dafd9 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -10,7 +10,8 @@ use Destination::*; use rustc_span::source_map::SourceMap; -use rustc_span::{FileLines, SourceFile, Span}; +use rustc_span::{DesugaringKind, FileLines, SourceFile, Span}; +// use rustc_span::{FileLines, SourceFile, Span}; use crate::snippet::{ Annotation, AnnotationColumn, AnnotationType, Line, MultilineAnnotation, Style, StyledString, @@ -402,12 +403,13 @@ pub trait Emitter: Translate { // entries we don't want to print, to make sure the indices being // printed are contiguous (or omitted if there's only one entry). let macro_backtrace: Vec<_> = sp.macro_backtrace().collect(); - for (i, trace) in macro_backtrace.iter().rev().enumerate() { - if trace.def_site.is_dummy() { - continue; - } - - if always_backtrace && !matches!(trace.kind, ExpnKind::Inlined) { + for (i, trace) in macro_backtrace.iter().rev().enumerate().filter(|(_, trace)| { + !matches!( + trace.kind, + ExpnKind::Inlined | ExpnKind::Desugaring(DesugaringKind::Resize) + ) && !trace.def_site.is_dummy() + }) { + if always_backtrace { new_labels.push(( trace.def_site, format!( diff --git a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs index 48214b899a4b8..1c9f80f1f0be9 100644 --- a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs +++ b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs @@ -1355,7 +1355,8 @@ fn compare_number_of_method_arguments<'tcx>( if pos == 0 { arg.span } else { - arg.span.with_lo(trait_m_sig.decl.inputs[0].span.lo()) + tcx.mark_span_for_resize(arg.span) + .with_lo(trait_m_sig.decl.inputs[0].span.lo()) } }) }) @@ -1371,7 +1372,7 @@ fn compare_number_of_method_arguments<'tcx>( if pos == 0 { arg.span } else { - arg.span.with_lo(impl_m_sig.decl.inputs[0].span.lo()) + tcx.mark_span_for_resize(arg.span).with_lo(impl_m_sig.decl.inputs[0].span.lo()) } }) .unwrap_or_else(|| tcx.def_span(impl_m.def_id)); @@ -1468,7 +1469,9 @@ fn compare_synthetic_generics<'tcx>( // in case there are no generics, take the spot between the function name // and the opening paren of the argument list - let new_generics_span = tcx.def_ident_span(impl_def_id)?.shrink_to_hi(); + let new_generics_span = tcx + .mark_span_for_resize(tcx.def_ident_span(impl_def_id)?) + .shrink_to_hi(); // in case there are generics, just replace them let generics_span = impl_m.generics.span.substitute_dummy(new_generics_span); diff --git a/compiler/rustc_hir_analysis/src/check/mod.rs b/compiler/rustc_hir_analysis/src/check/mod.rs index 08154cdae4784..81000cbe23992 100644 --- a/compiler/rustc_hir_analysis/src/check/mod.rs +++ b/compiler/rustc_hir_analysis/src/check/mod.rs @@ -200,7 +200,7 @@ fn missing_items_err( let hi = full_impl_span.hi() - BytePos(1); // Point at the place right before the closing brace of the relevant `impl` to suggest // adding the associated item at the end of its body. - let sugg_sp = full_impl_span.with_lo(hi).with_hi(hi); + let sugg_sp = tcx.mark_span_for_resize(full_impl_span).with_lo(hi).with_hi(hi); // Obtain the level of indentation ending in `sugg_sp`. let padding = tcx.sess.source_map().indentation_before(sugg_sp).unwrap_or_else(|| String::new()); diff --git a/compiler/rustc_hir_analysis/src/structured_errors/wrong_number_of_generic_args.rs b/compiler/rustc_hir_analysis/src/structured_errors/wrong_number_of_generic_args.rs index 8f4d81ec3a935..6b96d1aff5156 100644 --- a/compiler/rustc_hir_analysis/src/structured_errors/wrong_number_of_generic_args.rs +++ b/compiler/rustc_hir_analysis/src/structured_errors/wrong_number_of_generic_args.rs @@ -594,7 +594,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { match self.angle_brackets { AngleBrackets::Missing => { - let span = self.path_segment.ident.span; + let span = self.tcx.mark_span_for_resize(self.path_segment.ident.span); // insert a suggestion of the form "Y<'a, 'b>" let sugg = format!("<{}>", suggested_args); @@ -610,11 +610,23 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { AngleBrackets::Available => { let (sugg_span, is_first) = if self.num_provided_lifetime_args() == 0 { - (self.gen_args.span().unwrap().shrink_to_lo(), true) + ( + self.tcx.mark_span_for_resize(self.gen_args.span().unwrap()).shrink_to_lo(), + true, + ) } else { let last_lt = &self.gen_args.args[self.num_provided_lifetime_args() - 1]; - (last_lt.span().shrink_to_hi(), false) + (self.tcx.mark_span_for_resize(last_lt.span()).shrink_to_hi(), false) }; + let path_sp = self.path_segment.ident.span; + if !self.gen_args.args.iter().all(|arg| { + arg.span().can_be_used_for_suggestions() + && arg.span().peel_ctxt() == path_sp.peel_ctxt() + }) || !path_sp.can_be_used_for_suggestions() + { + // Do not suggest syntax when macros are involved. (#90557) + return; + } let has_non_lt_args = self.num_provided_type_or_const_args() != 0; let has_bindings = !self.gen_args.bindings.is_empty(); @@ -644,7 +656,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { match self.angle_brackets { AngleBrackets::Missing | AngleBrackets::Implied => { - let span = self.path_segment.ident.span; + let span = self.tcx.mark_span_for_resize(self.path_segment.ident.span); // insert a suggestion of the form "Y" let sugg = format!("<{}>", suggested_args); @@ -658,14 +670,24 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { ); } AngleBrackets::Available => { - let gen_args_span = self.gen_args.span().unwrap(); + let path_sp = self.path_segment.ident.span; + if !self.gen_args.args.iter().all(|arg| { + arg.span().can_be_used_for_suggestions() + && arg.span().peel_ctxt() == path_sp.peel_ctxt() + }) || !path_sp.can_be_used_for_suggestions() + { + // Do not suggest syntax when macros are involved. (#90557) + return; + } + let gen_args_span = self.tcx.mark_span_for_resize(self.gen_args.span().unwrap()); let sugg_offset = self.get_lifetime_args_offset() + self.num_provided_type_or_const_args(); let (sugg_span, is_first) = if sugg_offset == 0 { - (gen_args_span.shrink_to_lo(), true) + (self.tcx.mark_span_for_resize(gen_args_span).shrink_to_lo(), true) } else { - let arg_span = self.gen_args.args[sugg_offset - 1].span(); + let arg_span = + self.tcx.mark_span_for_resize(self.gen_args.args[sugg_offset - 1].span()); // If we came here then inferred lifetime's spans can only point // to either the opening bracket or to the space right after. // Both of these spans have an `hi` lower than or equal to the span @@ -770,7 +792,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { && let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(span) { let sugg = vec![ (self.path_segment.ident.span, format!("{}::{}", snippet, self.path_segment.ident)), - (span.with_lo(self.path_segment.ident.span.hi()), "".to_owned()) + (self.tcx.mark_span_for_resize(span).with_lo(self.path_segment.ident.span.hi()), "".to_owned()) ]; err.multipart_suggestion( @@ -953,11 +975,8 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { } } else if remove_entire_generics { let span = self - .path_segment - .args - .unwrap() - .span_ext() - .unwrap() + .tcx + .mark_span_for_resize(self.path_segment.args.unwrap().span_ext().unwrap()) .with_lo(self.path_segment.ident.span.hi()); let msg = format!( diff --git a/compiler/rustc_hir_typeck/src/demand.rs b/compiler/rustc_hir_typeck/src/demand.rs index 525acfdaa8124..47511811f30f5 100644 --- a/compiler/rustc_hir_typeck/src/demand.rs +++ b/compiler/rustc_hir_typeck/src/demand.rs @@ -647,7 +647,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ), ), match &args[..] { - [] => (base.span.shrink_to_hi().with_hi(deref.span.hi()), ")".to_string()), + [] => ( + self.tcx + .mark_span_for_resize(base.span) + .shrink_to_hi() + .with_hi(deref.span.hi()), + ")".to_string(), + ), [first, ..] => (base.span.between(first.span), ", ".to_string()), }, ] @@ -771,8 +777,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { "use `?` to coerce and return an appropriate `Err`, and wrap the resulting value \ in `Ok` so the expression remains of type `Result`", vec![ - (expr.span.shrink_to_lo(), "Ok(".to_string()), - (expr.span.shrink_to_hi(), "?)".to_string()), + (self.tcx.mark_span_for_resize(expr.span).shrink_to_lo(), "Ok(".to_string()), + (self.tcx.mark_span_for_resize(expr.span).shrink_to_hi(), "?)".to_string()), ], Applicability::MaybeIncorrect, ); @@ -843,9 +849,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } else { return false; }; - if let Some(indent) = - self.tcx.sess.source_map().indentation_before(span.shrink_to_lo()) - { + if let Some(indent) = self.tcx.sess.source_map().indentation_before( + self.tcx.mark_span_for_resize(span).shrink_to_lo(), + ) { // Add a semicolon, except after `}`. let semicolon = match self.tcx.sess.source_map().span_to_snippet(span) { @@ -853,7 +859,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { _ => ";", }; err.span_suggestions( - span.shrink_to_hi(), + self.tcx.mark_span_for_resize(span).shrink_to_hi(), "try adding an expression at the end of the block", return_suggestions .into_iter() @@ -931,8 +937,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } vec![ - (expr.span.shrink_to_lo(), format!("{prefix}{variant}{open}")), - (expr.span.shrink_to_hi(), close.to_owned()), + ( + self.tcx.mark_span_for_resize(expr.span).shrink_to_lo(), + format!("{prefix}{variant}{open}"), + ), + (self.tcx.mark_span_for_resize(expr.span).shrink_to_hi(), close.to_owned()), ] }; @@ -1016,8 +1025,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { err.multipart_suggestion( format!("consider calling `{s}::new`"), vec![ - (expr.span.shrink_to_lo(), format!("{path}::new(")), - (expr.span.shrink_to_hi(), format!("){unwrap}")), + (self.tcx.mark_span_for_resize(expr.span).shrink_to_lo(), format!("{path}::new(")), + (self.tcx.mark_span_for_resize(expr.span).shrink_to_hi(), format!("){unwrap}")), ], Applicability::MaybeIncorrect, ); @@ -1271,7 +1280,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { && replace_prefix(&src, "\"", "b\"").is_some() { return Some(( - sp.shrink_to_lo(), + self.tcx.mark_span_for_resize(sp).shrink_to_lo(), "consider adding a leading `b`".to_string(), "b".to_string(), Applicability::MachineApplicable, @@ -1468,7 +1477,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { _ if sp == expr.span => { if let Some(mut steps) = self.deref_steps(checked_ty, expected) { let mut expr = expr.peel_blocks(); - let mut prefix_span = expr.span.shrink_to_lo(); + let mut prefix_span = self.tcx.mark_span_for_resize(expr.span).shrink_to_lo(); let mut remove = String::new(); // Try peeling off any existing `&` and `&mut` to reach our target type @@ -1539,7 +1548,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { return None; } else if let Some(expr) = self.maybe_get_block_expr(expr) { // prefix should be empty here.. - (expr.span.shrink_to_lo(), "*".to_string()) + (self.tcx.mark_span_for_resize(expr.span).shrink_to_lo(), "*".to_string()) } else { (prefix_span, format!("{}{}", prefix, "*".repeat(steps))) }; @@ -1596,7 +1605,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // `expr` is a literal field for a struct, only suggest if appropriate if field.is_shorthand { // This is a field literal - sugg.push((field.ident.span.shrink_to_lo(), format!("{}: ", field.ident))); + sugg.push(( + self.tcx.mark_span_for_resize(field.ident.span).shrink_to_lo(), + format!("{}: ", field.ident), + )); } else { // Likely a field was meant, but this field wasn't found. Do not suggest anything. return false; @@ -1652,16 +1664,22 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ); let close_paren = if expr.precedence().order() < PREC_POSTFIX { - sugg.push((expr.span.shrink_to_lo(), "(".to_string())); + sugg.push((self.tcx.mark_span_for_resize(expr.span).shrink_to_lo(), "(".to_string())); ")" } else { "" }; let mut cast_suggestion = sugg.clone(); - cast_suggestion.push((expr.span.shrink_to_hi(), format!("{close_paren} as {expected_ty}"))); + cast_suggestion.push(( + self.tcx.mark_span_for_resize(expr.span).shrink_to_hi(), + format!("{close_paren} as {expected_ty}"), + )); let mut into_suggestion = sugg.clone(); - into_suggestion.push((expr.span.shrink_to_hi(), format!("{close_paren}.into()"))); + into_suggestion.push(( + self.tcx.mark_span_for_resize(expr.span).shrink_to_hi(), + format!("{close_paren}.into()"), + )); let mut suffix_suggestion = sugg.clone(); suffix_suggestion.push(( if matches!( @@ -1715,15 +1733,21 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { "you can convert `{lhs_src}` from `{expected_ty}` to `{checked_ty}`, matching the type of `{src}`", ); let suggestion = vec![ - (lhs_expr.span.shrink_to_lo(), format!("{checked_ty}::from(")), - (lhs_expr.span.shrink_to_hi(), ")".to_string()), + ( + self.tcx.mark_span_for_resize(lhs_expr.span).shrink_to_lo(), + format!("{checked_ty}::from("), + ), + ( + self.tcx.mark_span_for_resize(lhs_expr.span).shrink_to_hi(), + ")".to_string(), + ), ]; (msg, suggestion) } else { let msg = format!("{msg} and panic if the converted value doesn't fit"); let mut suggestion = sugg.clone(); suggestion.push(( - expr.span.shrink_to_hi(), + self.tcx.mark_span_for_resize(expr.span).shrink_to_hi(), format!("{close_paren}.try_into().unwrap()"), )); (msg, suggestion) diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs index 955463c14348c..91128b7998e94 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs @@ -31,7 +31,7 @@ use rustc_middle::ty::visit::TypeVisitableExt; use rustc_middle::ty::{self, IsSuggestable, Ty}; use rustc_session::Session; use rustc_span::symbol::{kw, Ident}; -use rustc_span::{self, sym, BytePos, Span}; +use rustc_span::{self, sym, BytePos, ExpnKind, Span}; use rustc_trait_selection::traits::{self, ObligationCauseCode, SelectionContext}; use std::iter; @@ -496,7 +496,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { hir::ExprKind::MethodCall(path_segment, _, _, span) => { let ident_span = path_segment.ident.span; let ident_span = if let Some(args) = path_segment.args { - ident_span.with_hi(args.span_ext.hi()) + self.tcx.mark_span_for_resize(ident_span).with_hi(args.span_ext.hi()) } else { ident_span }; @@ -706,8 +706,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { err.multipart_suggestion_verbose( "wrap these arguments in parentheses to construct a tuple", vec![ - (lo.shrink_to_lo(), "(".to_string()), - (hi.shrink_to_hi(), ")".to_string()), + (tcx.mark_span_for_resize(*lo).shrink_to_lo(), "(".to_string()), + (tcx.mark_span_for_resize(*hi).shrink_to_hi(), ")".to_string()), ], Applicability::MachineApplicable, ); @@ -1211,6 +1211,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Call out where the function is defined self.label_fn_like(&mut err, fn_def_id, callee_ty, None, is_method); + if !suggestions.iter().all(|(sp, _)| { + sp.macro_backtrace().all(|data| !matches!(data.kind, ExpnKind::Macro(..))) + }) { + // We don't want to provide structured suggestions if macros are involved at all. + err.emit(); + return; + } // And add a suggestion block for all of the parameters let suggestion_text = match suggestion_text { SuggestionText::None => None, @@ -1233,7 +1240,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let source_map = self.sess().source_map(); let (mut suggestion, suggestion_span) = if let Some(call_span) = full_call_span.find_ancestor_inside(error_span) { - ("(".to_string(), call_span.shrink_to_hi().to(error_span.shrink_to_hi())) + ( + "(".to_string(), + tcx.mark_span_for_resize(call_span) + .shrink_to_hi() + .to(tcx.mark_span_for_resize(error_span).shrink_to_hi()), + ) } else { ( format!( diff --git a/compiler/rustc_infer/src/infer/error_reporting/note_and_explain.rs b/compiler/rustc_infer/src/infer/error_reporting/note_and_explain.rs index e410172c8c8d1..5551240e91faf 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/note_and_explain.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/note_and_explain.rs @@ -125,7 +125,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { matched_end_of_args = args_span.is_some(); matching_span = args_span .or_else(|| Some(end_of_trait)) - .map(|span| span.shrink_to_hi()); + .map(|span| self.tcx.mark_span_for_resize(span).shrink_to_hi()); break; } } diff --git a/compiler/rustc_middle/src/lint.rs b/compiler/rustc_middle/src/lint.rs index c61de97d53271..9ab0df67ed924 100644 --- a/compiler/rustc_middle/src/lint.rs +++ b/compiler/rustc_middle/src/lint.rs @@ -466,7 +466,7 @@ pub fn struct_lint_level( /// This is used to test whether a lint should not even begin to figure out whether it should /// be reported on the current node. pub fn in_external_macro(sess: &Session, span: Span) -> bool { - let expn_data = span.ctxt().outer_expn_data(); + let expn_data = span.peel_ctxt().outer_expn_data(); match expn_data.kind { ExpnKind::Inlined | ExpnKind::Root diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index 8e4e708b73c45..4fbc17b8c8b32 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -2395,6 +2395,17 @@ impl<'tcx> TyCtxt<'tcx> { .hygienic_eq(def_name.span.ctxt(), self.expn_that_defined(def_parent_def_id)) } + /// This returns a copy of `span` that has a `DesugaringKind::Resize` mark reason. This mark is + /// used to identify `Span`s that have been modified, while also keeping a link to the original + /// `Span` before it was changed. This is used today only to be able to identify `Span`s coming + /// from a proc-macro even when it was modified, to avoid giving spurious suggestions when the + /// `Span` points at an attribute and not user code. + pub fn mark_span_for_resize(self, span: Span) -> Span { + self.with_stable_hashing_context(|hcx| { + span.mark_with_reason(None, rustc_span::DesugaringKind::Resize, span.edition(), hcx) + }) + } + pub fn adjust_ident(self, mut ident: Ident, scope: DefId) -> Ident { ident.span.normalize_to_macros_2_0_and_adjust(self.expn_that_defined(scope)); ident diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index 4b7048eac0483..aa66b05eac62d 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -1439,6 +1439,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { suggestion: Option, span: Span, ) -> bool { + if !span.can_be_used_for_suggestions() { + return false; + } let suggestion = match suggestion { None => return false, // We shouldn't suggest underscore. @@ -1446,7 +1449,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { Some(suggestion) => suggestion, }; if let Some(def_span) = suggestion.res.opt_def_id().map(|def_id| self.def_span(def_id)) { - if span.overlaps(def_span) { + if span.overlaps(def_span) || !def_span.can_be_used_for_suggestions() { // Don't suggest typo suggestion for itself like in the following: // error[E0423]: expected function, tuple struct or tuple variant, found struct `X` // --> $DIR/issue-64792-bad-unicode-ctor.rs:3:14 diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index e824a6ddc072f..42a1bca50534d 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -28,7 +28,7 @@ use rustc_span::edit_distance::find_best_match_for_name; use rustc_span::edition::Edition; use rustc_span::hygiene::MacroKind; use rustc_span::symbol::{kw, sym, Ident, Symbol}; -use rustc_span::{BytePos, Span}; +use rustc_span::{BytePos, ExpnKind, Span}; use std::iter; use std::ops::Deref; @@ -211,8 +211,32 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { suggestion: None, } } else { - let item_span = path.last().unwrap().ident.span; - let (mod_prefix, mod_str, suggestion) = if path.len() == 1 { + let sp = path.last().unwrap().ident.span; + let ctxt_kind = sp.peel_ctxt().outer_expn_data().kind; + let (mod_prefix, mod_str, name, mod_label, suggestion) = + if let ExpnKind::Macro(MacroKind::Attr | MacroKind::Bang, name) = ctxt_kind + && sp.parent_callsite().map(|p| (p.lo(), p.hi())) == Some((sp.lo(), sp.hi())) + { + // This span comes from a proc macro and it doesn't point at user code. + ( + String::new(), + format!("the expanded code of procedural macro `{name}`"), + format!("`{path_str}` "), + format!("expanded code of this procedural macro"), + None, + ) + } else if let ExpnKind::Macro(MacroKind::Derive, name) = ctxt_kind + && sp.parent_callsite().map(|p| (p.lo(), p.hi())) == Some((sp.lo(), sp.hi())) + { + // This span comes from a `derive` macro and it doesn't point at user code. + ( + String::new(), + format!("the expanded code of `derive` macro `{name}`"), + format!("`{path_str}` "), + format!("expanded code of this `derive` macro"), + None, + ) + } else if path.len() == 1 { debug!(?self.diagnostic_metadata.current_impl_items); debug!(?self.diagnostic_metadata.current_function); let suggestion = if self.current_trait_ref.is_none() @@ -235,7 +259,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { }; Some(( - item_span.shrink_to_lo(), + sp.shrink_to_lo(), match &item.kind { AssocItemKind::Fn(..) => "consider using the associated function", AssocItemKind::Const(..) => "consider using the associated constant", @@ -246,18 +270,22 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { } else { None }; - (String::new(), "this scope".to_string(), suggestion) + let s = "this scope".to_string(); + (String::new(), s.clone(), String::new(), s, suggestion) } else if path.len() == 2 && path[0].ident.name == kw::PathRoot { if self.r.tcx.sess.edition() > Edition::Edition2015 { // In edition 2018 onwards, the `::foo` syntax may only pull from the extern prelude // which overrides all other expectations of item type expected = "crate"; - (String::new(), "the list of imported crates".to_string(), None) + let s = "the list of imported crates".to_string(); + (String::new(), s.clone(), String::new(), s, None) } else { - (String::new(), "the crate root".to_string(), None) + let s = "the crate root".to_string(); + (String::new(), s.clone(), String::new(), s, None) } } else if path.len() == 2 && path[0].ident.name == kw::Crate { - (String::new(), "the crate root".to_string(), None) + let s = "the crate root".to_string(); + (String::new(), s.clone(), String::new(), s, None) } else { let mod_path = &path[..path.len() - 1]; let mod_prefix = match self.resolve_path(mod_path, Some(TypeNS), None) { @@ -265,7 +293,8 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { _ => None, } .map_or_else(String::new, |res| format!("{} ", res.descr())); - (mod_prefix, format!("`{}`", Segment::names_to_string(mod_path)), None) + let s = format!("`{}`", Segment::names_to_string(mod_path)); + (mod_prefix, s.clone(), String::new(), s, None) }; let (fallback_label, suggestion) = if path_str == "async" @@ -274,28 +303,25 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { ("`async` blocks are only allowed in Rust 2018 or later".to_string(), suggestion) } else { // check if we are in situation of typo like `True` instead of `true`. - let override_suggestion = - if ["true", "false"].contains(&item_str.to_string().to_lowercase().as_str()) { - let item_typo = item_str.to_string().to_lowercase(); - Some((item_span, "you may want to use a bool value instead", item_typo)) - // FIXME(vincenzopalazzo): make the check smarter, - // and maybe expand with levenshtein distance checks - } else if item_str.as_str() == "printf" { - Some(( - item_span, - "you may have meant to use the `print` macro", - "print!".to_owned(), - )) - } else { - suggestion - }; - (format!("not found in {mod_str}"), override_suggestion) + let override_suggestion = if ["true", "false"] + .contains(&item_str.to_string().to_lowercase().as_str()) + { + let item_typo = item_str.to_string().to_lowercase(); + Some((sp, "you may want to use a bool value instead", item_typo)) + // FIXME(vincenzopalazzo): make the check smarter, + // and maybe expand with levenshtein distance checks + } else if item_str.as_str() == "printf" { + Some((sp, "you may have meant to use the `print` macro", "print!".to_owned())) + } else { + suggestion + }; + (format!("{name}not found in {mod_label}"), override_suggestion) }; BaseError { msg: format!("cannot find {expected} `{item_str}` in {mod_prefix}{mod_str}"), fallback_label, - span: item_span, + span: sp, span_label: None, could_be_expr: false, suggestion, @@ -454,6 +480,12 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { res: Option, base_error: &BaseError, ) -> (bool, Vec) { + if !span.can_be_used_for_suggestions() { + // If the span comes from a proc-macro, we don't want to provide suggestions for + // importing and using types. We do make it harder on the proc-macro author, but at + // least we don't mislead end-users. + return (false, vec![]); + } // Try to lookup name in more relaxed fashion for better error reporting. let ident = path.last().unwrap().ident; let is_expected = &|res| source.is_expected(res); @@ -2150,7 +2182,9 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { | (Some(Item { kind: kind @ ItemKind::Impl(..), .. }), true, true) | (Some(Item { kind, .. }), false, _) => { if let Some(generics) = kind.generics() { - if span.overlaps(generics.span) { + if span.overlaps(generics.span) + || !generics.span.can_be_used_for_suggestions() + { // Avoid the following: // error[E0405]: cannot find trait `A` in this scope // --> $DIR/typo-suggestion-named-underscore.rs:CC:LL diff --git a/compiler/rustc_span/src/hygiene.rs b/compiler/rustc_span/src/hygiene.rs index c669b64dd2c81..90eb6862a0566 100644 --- a/compiler/rustc_span/src/hygiene.rs +++ b/compiler/rustc_span/src/hygiene.rs @@ -181,7 +181,7 @@ impl LocalExpnId { } pub fn fresh_empty() -> LocalExpnId { - HygieneData::with(|data| { + HygieneData::with_mut(|data| { let expn_id = data.local_expn_data.push(None); let _eid = data.local_expn_hashes.push(ExpnHash(Fingerprint::ZERO)); debug_assert_eq!(expn_id, _eid); @@ -192,7 +192,7 @@ impl LocalExpnId { pub fn fresh(mut expn_data: ExpnData, ctx: impl HashStableContext) -> LocalExpnId { debug_assert_eq!(expn_data.parent.krate, LOCAL_CRATE); let expn_hash = update_disambiguator(&mut expn_data, ctx); - HygieneData::with(|data| { + HygieneData::with_mut(|data| { let expn_id = data.local_expn_data.push(Some(expn_data)); let _eid = data.local_expn_hashes.push(expn_hash); debug_assert_eq!(expn_id, _eid); @@ -221,7 +221,7 @@ impl LocalExpnId { pub fn set_expn_data(self, mut expn_data: ExpnData, ctx: impl HashStableContext) { debug_assert_eq!(expn_data.parent.krate, LOCAL_CRATE); let expn_hash = update_disambiguator(&mut expn_data, ctx); - HygieneData::with(|data| { + HygieneData::with_mut(|data| { let old_expn_data = &mut data.local_expn_data[self]; assert!(old_expn_data.is_none(), "expansion data is reset for an expansion ID"); *old_expn_data = Some(expn_data); @@ -383,10 +383,14 @@ impl HygieneData { } } - pub fn with T>(f: F) -> T { + pub fn with_mut T>(f: F) -> T { with_session_globals(|session_globals| f(&mut session_globals.hygiene_data.borrow_mut())) } + pub fn with T>(f: F) -> T { + with_session_globals(|session_globals| f(&mut session_globals.hygiene_data.borrow())) + } + #[inline] fn local_expn_hash(&self, expn_id: LocalExpnId) -> ExpnHash { self.local_expn_hashes[expn_id] @@ -595,7 +599,7 @@ impl HygieneData { } pub fn clear_syntax_context_map() { - HygieneData::with(|data| data.syntax_context_map = FxHashMap::default()); + HygieneData::with_mut(|data| data.syntax_context_map = FxHashMap::default()); } pub fn walk_chain(span: Span, to: SyntaxContext) -> Span { @@ -619,7 +623,7 @@ pub fn update_dollar_crate_names(mut get_name: impl FnMut(SyntaxContext) -> Symb let range_to_update = len - to_update..len; let names: Vec<_> = range_to_update.clone().map(|idx| get_name(SyntaxContext::from_u32(idx as u32))).collect(); - HygieneData::with(|data| { + HygieneData::with_mut(|data| { range_to_update.zip(names).for_each(|(idx, name)| { data.syntax_context_data[idx].dollar_crate_name = name; }) @@ -683,7 +687,7 @@ impl SyntaxContext { /// Extend a syntax context with a given expansion and transparency. pub(crate) fn apply_mark(self, expn_id: ExpnId, transparency: Transparency) -> SyntaxContext { - HygieneData::with(|data| data.apply_mark(self, expn_id, transparency)) + HygieneData::with_mut(|data| data.apply_mark(self, expn_id, transparency)) } /// Pulls a single mark off of the syntax context. This effectively moves the @@ -802,7 +806,7 @@ impl SyntaxContext { expn_id: ExpnId, glob_span: Span, ) -> Option> { - HygieneData::with(|data| { + HygieneData::with_mut(|data| { if data.adjust(self, expn_id).is_some() { return None; } @@ -878,7 +882,7 @@ impl Span { /// The returned span belongs to the created expansion and has the new properties, /// but its location is inherited from the current span. pub fn fresh_expansion(self, expn_id: LocalExpnId) -> Span { - HygieneData::with(|data| { + HygieneData::with_mut(|data| { self.with_ctxt(data.apply_mark( self.ctxt(), expn_id.to_expn_id(), @@ -1152,6 +1156,10 @@ pub enum DesugaringKind { ForLoop, WhileLoop, Replace, + /// Used to proactively mark `Span`s that have been modified from another `Span`. This allows + /// the diagnostics machinery to be able to detect spans coming from proc-macros that do not + /// point to user code. + Resize, } impl DesugaringKind { @@ -1168,6 +1176,7 @@ impl DesugaringKind { DesugaringKind::ForLoop => "`for` loop", DesugaringKind::WhileLoop => "`while` loop", DesugaringKind::Replace => "drop and replace", + DesugaringKind::Resize => "a resized `Span`", } } } @@ -1253,7 +1262,7 @@ pub struct HygieneDecodeContext { /// Register an expansion which has been decoded from the on-disk-cache for the local crate. pub fn register_local_expn_id(data: ExpnData, hash: ExpnHash) -> ExpnId { - HygieneData::with(|hygiene_data| { + HygieneData::with_mut(|hygiene_data| { let expn_id = hygiene_data.local_expn_data.next_index(); hygiene_data.local_expn_data.push(Some(data)); let _eid = hygiene_data.local_expn_hashes.push(hash); @@ -1276,7 +1285,7 @@ pub fn register_expn_id( ) -> ExpnId { debug_assert!(data.parent == ExpnId::root() || krate == data.parent.krate); let expn_id = ExpnId { krate, local_id }; - HygieneData::with(|hygiene_data| { + HygieneData::with_mut(|hygiene_data| { let _old_data = hygiene_data.foreign_expn_data.insert(expn_id, data); debug_assert!(_old_data.is_none()); let _old_hash = hygiene_data.foreign_expn_hashes.insert(expn_id, hash); @@ -1343,7 +1352,7 @@ pub fn decode_syntax_context SyntaxContext // Allocate and store SyntaxContext id *before* calling the decoder function, // as the SyntaxContextData may reference itself. - let new_ctxt = HygieneData::with(|hygiene_data| { + let new_ctxt = HygieneData::with_mut(|hygiene_data| { let new_ctxt = SyntaxContext(hygiene_data.syntax_context_data.len() as u32); // Push a dummy SyntaxContextData to ensure that nobody else can get the // same ID as us. This will be overwritten after call `decode_Data` @@ -1374,7 +1383,7 @@ pub fn decode_syntax_context SyntaxContext ctxt_data.dollar_crate_name = kw::DollarCrate; // Overwrite the dummy data with our decoded SyntaxContextData - HygieneData::with(|hygiene_data| { + HygieneData::with_mut(|hygiene_data| { let dummy = std::mem::replace( &mut hygiene_data.syntax_context_data[new_ctxt.as_u32() as usize], ctxt_data, @@ -1472,7 +1481,7 @@ fn update_disambiguator(expn_data: &mut ExpnData, mut ctx: impl HashStableContex assert_default_hashing_controls(&ctx, "ExpnData (disambiguator)"); let mut expn_hash = expn_data.hash_expn(&mut ctx); - let disambiguator = HygieneData::with(|data| { + let disambiguator = HygieneData::with_mut(|data| { // If this is the first ExpnData with a given hash, then keep our // disambiguator at 0 (the default u32 value) let disambig = data.expn_data_disambiguators.entry(expn_hash).or_default(); diff --git a/compiler/rustc_span/src/lib.rs b/compiler/rustc_span/src/lib.rs index 8a900ca427ebe..baa39e3e46bfb 100644 --- a/compiler/rustc_span/src/lib.rs +++ b/compiler/rustc_span/src/lib.rs @@ -60,7 +60,7 @@ pub mod fatal_error; pub mod profiling; use rustc_data_structures::stable_hasher::{Hash128, Hash64, HashStable, StableHasher}; -use rustc_data_structures::sync::{Lock, Lrc}; +use rustc_data_structures::sync::{Lock, Lrc, RwLock}; use std::borrow::Cow; use std::cmp::{self, Ordering}; @@ -86,7 +86,7 @@ mod tests; pub struct SessionGlobals { symbol_interner: symbol::Interner, span_interner: Lock, - hygiene_data: Lock, + hygiene_data: RwLock, /// A reference to the source map in the `Session`. It's an `Option` /// because it can't be initialized until `Session` is created, which @@ -103,7 +103,7 @@ impl SessionGlobals { SessionGlobals { symbol_interner: symbol::Interner::fresh(), span_interner: Lock::new(span_encoding::SpanInterner::default()), - hygiene_data: Lock::new(hygiene::HygieneData::new(edition)), + hygiene_data: RwLock::new(hygiene::HygieneData::new(edition)), source_map: Lock::new(None), } } @@ -584,7 +584,7 @@ impl Span { /// Returns `true` if this span comes from any kind of macro, desugaring or inlining. #[inline] pub fn from_expansion(self) -> bool { - self.ctxt() != SyntaxContext::root() + self.peel_ctxt() != SyntaxContext::root() } /// Returns `true` if `span` originates in a macro's expansion where debuginfo should be @@ -607,12 +607,22 @@ impl Span { /// Gate suggestions that would not be appropriate in a context the user didn't write. pub fn can_be_used_for_suggestions(self) -> bool { - !self.from_expansion() - // FIXME: If this span comes from a `derive` macro but it points at code the user wrote, - // the callsite span and the span will be pointing at different places. It also means that - // we can safely provide suggestions on this span. - || (matches!(self.ctxt().outer_expn_data().kind, ExpnKind::Macro(MacroKind::Derive, _)) - && self.parent_callsite().map(|p| (p.lo(), p.hi())) != Some((self.lo(), self.hi()))) + match self.ctxt().outer_expn_data().kind { + ExpnKind::Root | ExpnKind::AstPass(_) | ExpnKind::Inlined => true, + // FIXME: If this span comes from a `derive` macro but it points at code the user wrote, + // the callsite span and the span will be pointing at different places. It also means that + // we can safely provide suggestions on this span. + ExpnKind::Macro(..) + if self.parent_callsite().map(|p| (p.lo(), p.hi())) + != Some((self.lo(), self.hi())) => + { + true + } + ExpnKind::Desugaring(_) => { + self.parent_callsite().unwrap().can_be_used_for_suggestions() + } + ExpnKind::Macro(..) => false, + } } #[inline] @@ -759,7 +769,7 @@ impl Span { /// Checks if this span arises from a compiler desugaring of kind `kind`. pub fn is_desugaring(self, kind: DesugaringKind) -> bool { - match self.ctxt().outer_expn_data().kind { + match self.peel_ctxt().outer_expn_data().kind { ExpnKind::Desugaring(k) => k == kind, _ => false, } @@ -768,7 +778,7 @@ impl Span { /// Returns the compiler desugaring that created this span, or `None` /// if this span is not from a desugaring. pub fn desugaring_kind(self) -> Option { - match self.ctxt().outer_expn_data().kind { + match self.peel_ctxt().outer_expn_data().kind { ExpnKind::Desugaring(k) => Some(k), _ => None, } @@ -831,10 +841,10 @@ impl Span { // FIXME(jseyfried): `self.ctxt` should always equal `end.ctxt` here (cf. issue #23480). // Return the macro span on its own to avoid weird diagnostic output. It is preferable to // have an incomplete span than a completely nonsensical one. - if span_data.ctxt != end_data.ctxt { - if span_data.ctxt == SyntaxContext::root() { + if self.peel_ctxt() != end.peel_ctxt() { + if self.peel_ctxt() == SyntaxContext::root() { return end; - } else if end_data.ctxt == SyntaxContext::root() { + } else if end.peel_ctxt() == SyntaxContext::root() { return self; } // Both spans fall within a macro. @@ -843,7 +853,7 @@ impl Span { Span::new( cmp::min(span_data.lo, end_data.lo), cmp::max(span_data.hi, end_data.hi), - if span_data.ctxt == SyntaxContext::root() { end_data.ctxt } else { span_data.ctxt }, + if self.peel_ctxt() == SyntaxContext::root() { end_data.ctxt } else { span_data.ctxt }, if span_data.parent == end_data.parent { span_data.parent } else { None }, ) } @@ -856,16 +866,29 @@ impl Span { /// ^^^^^^^^^^^^^ /// ``` pub fn between(self, end: Span) -> Span { - let span = self.data(); - let end = end.data(); + let span_data = self.data(); + let end_data = end.data(); Span::new( - span.hi, - end.lo, - if end.ctxt == SyntaxContext::root() { end.ctxt } else { span.ctxt }, - if span.parent == end.parent { span.parent } else { None }, + span_data.hi, + end_data.lo, + if end.peel_ctxt() == SyntaxContext::root() { end_data.ctxt } else { span_data.ctxt }, + if span_data.parent == end_data.parent { span_data.parent } else { None }, ) } + pub fn peel_ctxt(self) -> SyntaxContext { + let mut ctxt = self.ctxt(); + loop { + let data = ctxt.outer_expn_data(); + if let ExpnKind::Desugaring(DesugaringKind::Resize) = data.kind { + ctxt = data.call_site.ctxt(); + } else { + break; + } + } + ctxt + } + /// Returns a `Span` from the beginning of `self` until the beginning of `end`. /// /// ```text @@ -885,9 +908,9 @@ impl Span { // Return the macro span on its own to avoid weird diagnostic output. It is preferable to // have an incomplete span than a completely nonsensical one. if span_data.ctxt != end_data.ctxt { - if span_data.ctxt == SyntaxContext::root() { + if self.peel_ctxt() == SyntaxContext::root() { return end; - } else if end_data.ctxt == SyntaxContext::root() { + } else if end.peel_ctxt() == SyntaxContext::root() { return self; } // Both spans fall within a macro. @@ -896,7 +919,7 @@ impl Span { Span::new( span_data.lo, end_data.lo, - if end_data.ctxt == SyntaxContext::root() { end_data.ctxt } else { span_data.ctxt }, + if end.peel_ctxt() == SyntaxContext::root() { end_data.ctxt } else { span_data.ctxt }, if span_data.parent == end_data.parent { span_data.parent } else { None }, ) } diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index c969e5d4975fc..909dc6153d010 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -956,7 +956,14 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { .join(", "); if matches!(obligation.cause.code(), ObligationCauseCode::FunctionArgumentObligation { .. }) - && obligation.cause.span.can_be_used_for_suggestions() + && match obligation.cause.span.peel_ctxt().outer_expn_data().kind { + ExpnKind::Root + | ExpnKind::AstPass(_) + | ExpnKind::Desugaring(_) + | ExpnKind::Inlined => true, + // When a macro is involved, we don't want to provide a structured suggestion. + ExpnKind::Macro(..) => false, + } { // When the obligation error has been ensured to have been caused by // an argument, the `obligation.cause.span` points at the expression @@ -1241,7 +1248,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { { obligation.cause.code() } else if let ExpnKind::Desugaring(DesugaringKind::ForLoop) = - span.ctxt().outer_expn_data().kind + span.peel_ctxt().outer_expn_data().kind { obligation.cause.code() } else { @@ -1316,7 +1323,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { // } // ``` if !matches!( - span.ctxt().outer_expn_data().kind, + span.peel_ctxt().outer_expn_data().kind, ExpnKind::Root | ExpnKind::Desugaring(DesugaringKind::ForLoop) ) { return false; diff --git a/src/tools/clippy/clippy_lints/src/ranges.rs b/src/tools/clippy/clippy_lints/src/ranges.rs index fc655fe2d0bb3..c67945f471ad6 100644 --- a/src/tools/clippy/clippy_lints/src/ranges.rs +++ b/src/tools/clippy/clippy_lints/src/ranges.rs @@ -3,7 +3,6 @@ use clippy_utils::diagnostics::{span_lint, span_lint_and_sugg, span_lint_and_the use clippy_utils::higher; use clippy_utils::msrvs::{self, Msrv}; use clippy_utils::source::{snippet, snippet_opt, snippet_with_applicability}; -use clippy_utils::sugg::Sugg; use clippy_utils::{get_parent_expr, in_constant, is_integer_const, path_to_local}; use if_chain::if_chain; use rustc_ast::ast::RangeLimits; @@ -356,6 +355,8 @@ fn check_exclusive_range_plus_one(cx: &LateContext<'_>, expr: &Expr<'_>) { end: Some(end), limits: RangeLimits::HalfOpen }) = higher::Range::hir(expr); + if start.map_or(true, |start| start.span.can_be_used_for_suggestions()); + if end.span.can_be_used_for_suggestions(); if let Some(y) = y_plus_one(cx, end); then { let span = expr.span; @@ -365,25 +366,19 @@ fn check_exclusive_range_plus_one(cx: &LateContext<'_>, expr: &Expr<'_>) { span, "an inclusive range would be more readable", |diag| { - let start = start.map_or(String::new(), |x| Sugg::hir(cx, x, "x").maybe_par().to_string()); - let end = Sugg::hir(cx, y, "y").maybe_par(); - if let Some(is_wrapped) = &snippet_opt(cx, span) { - if is_wrapped.starts_with('(') && is_wrapped.ends_with(')') { - diag.span_suggestion( - span, - "use", - format!("({start}..={end})"), - Applicability::MaybeIncorrect, - ); - } else { - diag.span_suggestion( - span, - "use", - format!("{start}..={end}"), - Applicability::MachineApplicable, // snippet - ); - } - } + diag.multipart_suggestion( + "use an inclusive range instead", + vec![ + ( + start.map(|s| s.span.shrink_to_hi()) + .unwrap_or(expr.span) + .until(end.span), + "..=".to_string(), + ), + (y, String::new()), + ], + Applicability::MachineApplicable, + ); }, ); } @@ -392,9 +387,12 @@ fn check_exclusive_range_plus_one(cx: &LateContext<'_>, expr: &Expr<'_>) { // inclusive range minus one: `x..=(y-1)` fn check_inclusive_range_minus_one(cx: &LateContext<'_>, expr: &Expr<'_>) { + if_chain! { if expr.span.can_be_used_for_suggestions(); if let Some(higher::Range { start, end: Some(end), limits: RangeLimits::Closed }) = higher::Range::hir(expr); + if start.map_or(true, |start| start.span.can_be_used_for_suggestions()); + if end.span.can_be_used_for_suggestions(); if let Some(y) = y_minus_one(cx, end); then { span_lint_and_then( @@ -403,13 +401,18 @@ fn check_inclusive_range_minus_one(cx: &LateContext<'_>, expr: &Expr<'_>) { expr.span, "an exclusive range would be more readable", |diag| { - let start = start.map_or(String::new(), |x| Sugg::hir(cx, x, "x").maybe_par().to_string()); - let end = Sugg::hir(cx, y, "y").maybe_par(); - diag.span_suggestion( - expr.span, - "use", - format!("{start}..{end}"), - Applicability::MachineApplicable, // snippet + diag.multipart_suggestion( + "use an exclusive range instead", + vec![ + ( + start.map(|s| s.span.shrink_to_hi()) + .unwrap_or(expr.span) + .until(end.span), + "..".to_string(), + ), + (y, String::new()), + ], + Applicability::MachineApplicable, ); }, ); @@ -497,19 +500,24 @@ fn check_reversed_empty_range(cx: &LateContext<'_>, expr: &Expr<'_>) { } } -fn y_plus_one<'t>(cx: &LateContext<'_>, expr: &'t Expr<'_>) -> Option<&'t Expr<'t>> { +fn y_plus_one<'t>(cx: &LateContext<'_>, expr: &'t Expr<'_>) -> Option { match expr.kind { ExprKind::Binary( Spanned { - node: BinOpKind::Add, .. + node: BinOpKind::Add, + span, }, lhs, rhs, ) => { - if is_integer_const(cx, lhs, 1) { - Some(rhs) - } else if is_integer_const(cx, rhs, 1) { - Some(lhs) + if is_integer_const(cx, lhs, 1) + && lhs.span.peel_ctxt() == span.peel_ctxt() + { + Some(lhs.span.to(span)) + } else if is_integer_const(cx, rhs, 1) + && rhs.span.peel_ctxt() == span.peel_ctxt() + { + Some(span.to(rhs.span)) } else { None } @@ -518,15 +526,18 @@ fn y_plus_one<'t>(cx: &LateContext<'_>, expr: &'t Expr<'_>) -> Option<&'t Expr<' } } -fn y_minus_one<'t>(cx: &LateContext<'_>, expr: &'t Expr<'_>) -> Option<&'t Expr<'t>> { +fn y_minus_one<'t>(cx: &LateContext<'_>, expr: &'t Expr<'_>) -> Option { match expr.kind { ExprKind::Binary( Spanned { - node: BinOpKind::Sub, .. + node: BinOpKind::Sub, + span, }, - lhs, + _, rhs, - ) if is_integer_const(cx, rhs, 1) => Some(lhs), + ) if is_integer_const(cx, rhs, 1) + && rhs.span.peel_ctxt() == span.peel_ctxt() + => Some(span.to(rhs.span)), _ => None, } } diff --git a/src/tools/clippy/tests/ui/range_plus_minus_one.fixed b/src/tools/clippy/tests/ui/range_plus_minus_one.fixed index 79c133cb5e326..2851708d27fff 100644 --- a/src/tools/clippy/tests/ui/range_plus_minus_one.fixed +++ b/src/tools/clippy/tests/ui/range_plus_minus_one.fixed @@ -1,14 +1,14 @@ //@run-rustfix #![allow(unused_parens)] -#![allow(clippy::iter_with_drain)] +#![allow(clippy::iter_with_drain, clippy::needless_parens_on_range_literals)] fn f() -> usize { 42 } macro_rules! macro_plus_one { ($m: literal) => { - for i in 0..$m + 1 { + for i in 0..=$m { println!("{}", i); } }; @@ -16,7 +16,7 @@ macro_rules! macro_plus_one { macro_rules! macro_minus_one { ($m: literal) => { - for i in 0..=$m - 1 { + for i in 0..$m { println!("{}", i); } }; @@ -28,30 +28,30 @@ fn main() { for _ in 0..2 {} for _ in 0..=2 {} - for _ in 0..=3 {} + for _ in 0..=3 {} for _ in 0..=3 + 1 {} - for _ in 0..=5 {} + for _ in 0..= 5 {} for _ in 0..=1 + 5 {} - for _ in 1..=1 {} + for _ in 1..= 1 {} for _ in 1..=1 + 1 {} for _ in 0..13 + 13 {} for _ in 0..=13 - 7 {} - for _ in 0..=f() {} + for _ in 0..=( f()) {} for _ in 0..=(1 + f()) {} let _ = ..11 - 1; - let _ = ..11; - let _ = ..11; - let _ = (1..=11); - let _ = ((f() + 1)..=f()); + let _ = ..11 ; + let _ = ..(11 ); + let _ = (1..=11 ); + let _ = (f() + 1)..=(f() ); const ONE: usize = 1; // integer consts are linted, too - for _ in 1..=ONE {} + for _ in 1..= ONE {} let mut vec: Vec<()> = std::vec::Vec::new(); vec.drain(..); diff --git a/src/tools/clippy/tests/ui/range_plus_minus_one.rs b/src/tools/clippy/tests/ui/range_plus_minus_one.rs index 689a6b7a17ce6..f47c7e8365d52 100644 --- a/src/tools/clippy/tests/ui/range_plus_minus_one.rs +++ b/src/tools/clippy/tests/ui/range_plus_minus_one.rs @@ -1,7 +1,7 @@ //@run-rustfix #![allow(unused_parens)] -#![allow(clippy::iter_with_drain)] +#![allow(clippy::iter_with_drain, clippy::needless_parens_on_range_literals)] fn f() -> usize { 42 } diff --git a/src/tools/clippy/tests/ui/range_plus_minus_one.stderr b/src/tools/clippy/tests/ui/range_plus_minus_one.stderr index 0223696243b20..64cc2169d9050 100644 --- a/src/tools/clippy/tests/ui/range_plus_minus_one.stderr +++ b/src/tools/clippy/tests/ui/range_plus_minus_one.stderr @@ -2,59 +2,143 @@ error: an inclusive range would be more readable --> $DIR/range_plus_minus_one.rs:31:14 | LL | for _ in 0..3 + 1 {} - | ^^^^^^^^ help: use: `0..=3` + | ^^^^^^^^ | = note: `-D clippy::range-plus-one` implied by `-D warnings` +help: use an inclusive range instead + | +LL - for _ in 0..3 + 1 {} +LL + for _ in 0..=3 {} + | error: an inclusive range would be more readable --> $DIR/range_plus_minus_one.rs:34:14 | LL | for _ in 0..1 + 5 {} - | ^^^^^^^^ help: use: `0..=5` + | ^^^^^^^^ + | +help: use an inclusive range instead + | +LL - for _ in 0..1 + 5 {} +LL + for _ in 0..= 5 {} + | error: an inclusive range would be more readable --> $DIR/range_plus_minus_one.rs:37:14 | LL | for _ in 1..1 + 1 {} - | ^^^^^^^^ help: use: `1..=1` + | ^^^^^^^^ + | +help: use an inclusive range instead + | +LL - for _ in 1..1 + 1 {} +LL + for _ in 1..= 1 {} + | error: an inclusive range would be more readable --> $DIR/range_plus_minus_one.rs:43:14 | LL | for _ in 0..(1 + f()) {} - | ^^^^^^^^^^^^ help: use: `0..=f()` + | ^^^^^^^^^^^^ + | +help: use an inclusive range instead + | +LL - for _ in 0..(1 + f()) {} +LL + for _ in 0..=( f()) {} + | error: an exclusive range would be more readable --> $DIR/range_plus_minus_one.rs:47:13 | LL | let _ = ..=11 - 1; - | ^^^^^^^^^ help: use: `..11` + | ^^^^^^^^^ | = note: `-D clippy::range-minus-one` implied by `-D warnings` +help: use an exclusive range instead + | +LL - let _ = ..=11 - 1; +LL + let _ = ..11 ; + | error: an exclusive range would be more readable --> $DIR/range_plus_minus_one.rs:48:13 | LL | let _ = ..=(11 - 1); - | ^^^^^^^^^^^ help: use: `..11` + | ^^^^^^^^^^^ + | +help: use an exclusive range instead + | +LL - let _ = ..=(11 - 1); +LL + let _ = ..(11 ); + | error: an inclusive range would be more readable --> $DIR/range_plus_minus_one.rs:49:13 | LL | let _ = (1..11 + 1); - | ^^^^^^^^^^^ help: use: `(1..=11)` + | ^^^^^^^^^^^ + | +help: use an inclusive range instead + | +LL - let _ = (1..11 + 1); +LL + let _ = (1..=11 ); + | error: an inclusive range would be more readable --> $DIR/range_plus_minus_one.rs:50:13 | LL | let _ = (f() + 1)..(f() + 1); - | ^^^^^^^^^^^^^^^^^^^^ help: use: `((f() + 1)..=f())` + | ^^^^^^^^^^^^^^^^^^^^ + | +help: use an inclusive range instead + | +LL - let _ = (f() + 1)..(f() + 1); +LL + let _ = (f() + 1)..=(f() ); + | error: an inclusive range would be more readable --> $DIR/range_plus_minus_one.rs:54:14 | LL | for _ in 1..ONE + ONE {} - | ^^^^^^^^^^^^ help: use: `1..=ONE` + | ^^^^^^^^^^^^ + | +help: use an inclusive range instead + | +LL - for _ in 1..ONE + ONE {} +LL + for _ in 1..= ONE {} + | + +error: an inclusive range would be more readable + --> $DIR/range_plus_minus_one.rs:11:18 + | +LL | for i in 0..$m + 1 { + | ^^^^^^^^^ +... +LL | macro_plus_one!(5); + | ------------------ in this macro invocation + | + = note: this error originates in the macro `macro_plus_one` (in Nightly builds, run with -Z macro-backtrace for more info) +help: use an inclusive range instead + | +LL - for i in 0..$m + 1 { +LL + for i in 0..=$m { + | + +error: an exclusive range would be more readable + --> $DIR/range_plus_minus_one.rs:19:18 + | +LL | for i in 0..=$m - 1 { + | ^^^^^^^^^^ +... +LL | macro_minus_one!(5); + | ------------------- in this macro invocation + | + = note: this error originates in the macro `macro_minus_one` (in Nightly builds, run with -Z macro-backtrace for more info) +help: use an exclusive range instead + | +LL - for i in 0..=$m - 1 { +LL + for i in 0..$m { + | -error: aborting due to 9 previous errors +error: aborting due to 11 previous errors diff --git a/src/tools/miri/tests/fail/terminate-terminator.stderr b/src/tools/miri/tests/fail/terminate-terminator.stderr index c046678f73f5b..3f5cee7e91952 100644 --- a/src/tools/miri/tests/fail/terminate-terminator.stderr +++ b/src/tools/miri/tests/fail/terminate-terminator.stderr @@ -12,9 +12,6 @@ LL | | let _f = Foo; LL | | panic!(); LL | | } | |_^ panic in a function that cannot unwind -... -LL | has_cleanup(); - | ------------- in this inlined function call | = note: inside `panic_abort` at $DIR/terminate-terminator.rs:LL:CC note: inside `main` diff --git a/src/tools/rustfmt/src/imports.rs b/src/tools/rustfmt/src/imports.rs index 339e5cef5af91..0bb5e66a162ec 100644 --- a/src/tools/rustfmt/src/imports.rs +++ b/src/tools/rustfmt/src/imports.rs @@ -718,7 +718,7 @@ impl UseTree { } if let Some(new_path) = merge_rest(&self.path, &other.path, prefix, merge_by) { self.path = new_path; - self.span = self.span.to(other.span); + self.span = self.span.with_hi(other.span.hi()); } } diff --git a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs index 80ab03ab24c86..3a635a04dbed3 100644 --- a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs +++ b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs @@ -801,7 +801,7 @@ struct SuggestionsInvalidItem { sub: Span, } -#[derive(Diagnostic)] //~ ERROR cannot find value `__code_34` in this scope +#[derive(Diagnostic)] //~ ERROR cannot find value `__code_34` #[diag(no_crate_example)] struct SuggestionsInvalidLiteral { #[suggestion(code = 3)] diff --git a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr index 5e1bea4e38cc3..c8984e16e3078 100644 --- a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr +++ b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr @@ -632,11 +632,11 @@ error[E0425]: cannot find value `nonsense` in module `crate::fluent_generated` LL | #[diag(nonsense, code = "E0123")] | ^^^^^^^^ not found in `crate::fluent_generated` -error[E0425]: cannot find value `__code_34` in this scope +error[E0425]: cannot find value `__code_34` in the expanded code of `derive` macro `Diagnostic` --> $DIR/diagnostic-derive.rs:804:10 | LL | #[derive(Diagnostic)] - | ^^^^^^^^^^ not found in this scope + | ^^^^^^^^^^ `__code_34` not found in expanded code of this `derive` macro | = note: this error originates in the derive macro `Diagnostic` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs b/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs index 1bfbb60015d59..c7db9dbba8163 100644 --- a/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs +++ b/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs @@ -707,9 +707,9 @@ struct BP { } #[derive(Subdiagnostic)] -//~^ ERROR cannot find value `__code_29` in this scope +//~^ ERROR cannot find value `__code_29` //~| NOTE in this expansion -//~| NOTE not found in this scope +//~| NOTE `__code_29` not found in expanded code of this `derive` macro #[multipart_suggestion(no_crate_example)] struct BQ { #[suggestion_part(code = 3)] diff --git a/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr b/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr index fca4f506890bc..dc9617b1a3a45 100644 --- a/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr +++ b/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr @@ -600,11 +600,11 @@ error[E0425]: cannot find value `slug` in module `crate::fluent_generated` LL | #[label(slug)] | ^^^^ not found in `crate::fluent_generated` -error[E0425]: cannot find value `__code_29` in this scope +error[E0425]: cannot find value `__code_29` in the expanded code of `derive` macro `Subdiagnostic` --> $DIR/subdiagnostic-derive.rs:709:10 | LL | #[derive(Subdiagnostic)] - | ^^^^^^^^^^^^^ not found in this scope + | ^^^^^^^^^^^^^ `__code_29` not found in expanded code of this `derive` macro | = note: this error originates in the derive macro `Subdiagnostic` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/alloc-error/alloc-error-handler-bad-signature-1.rs b/tests/ui/alloc-error/alloc-error-handler-bad-signature-1.rs index cd06423e3a557..5d856fb6c1d7a 100644 --- a/tests/ui/alloc-error/alloc-error-handler-bad-signature-1.rs +++ b/tests/ui/alloc-error/alloc-error-handler-bad-signature-1.rs @@ -8,8 +8,8 @@ use core::alloc::Layout; #[alloc_error_handler] fn oom( - info: &Layout, //~^ ERROR mismatched types -) -> () //~^^ ERROR mismatched types + info: &Layout, //~ ERROR mismatched types +) -> () //~ ERROR mismatched types { loop {} } diff --git a/tests/ui/alloc-error/alloc-error-handler-bad-signature-1.stderr b/tests/ui/alloc-error/alloc-error-handler-bad-signature-1.stderr index de92841d7f18e..4b92c577a23cb 100644 --- a/tests/ui/alloc-error/alloc-error-handler-bad-signature-1.stderr +++ b/tests/ui/alloc-error/alloc-error-handler-bad-signature-1.stderr @@ -1,16 +1,16 @@ error[E0308]: mismatched types - --> $DIR/alloc-error-handler-bad-signature-1.rs:10:1 + --> $DIR/alloc-error-handler-bad-signature-1.rs:11:5 | -LL | #[alloc_error_handler] - | ---------------------- in this procedural macro expansion -LL | // fn oom( -LL | || info: &Layout, -LL | || ) -> () - | ||_______- arguments to this function are incorrect -LL | | { -LL | | loop {} -LL | | } - | |__^ expected `&Layout`, found `Layout` +LL | #[alloc_error_handler] + | ---------------------- in this procedural macro expansion +LL | / fn oom( +LL | | info: &Layout, + | | ^^^^^^^^^^^^^ expected `&Layout`, found `Layout` +LL | | ) -> () +LL | | { +LL | | loop {} +LL | | } + | |_- arguments to this function are incorrect | note: function defined here --> $DIR/alloc-error-handler-bad-signature-1.rs:10:4 @@ -22,18 +22,18 @@ LL | info: &Layout, = note: this error originates in the attribute macro `alloc_error_handler` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0308]: mismatched types - --> $DIR/alloc-error-handler-bad-signature-1.rs:10:1 + --> $DIR/alloc-error-handler-bad-signature-1.rs:12:6 | -LL | #[alloc_error_handler] - | ---------------------- in this procedural macro expansion -LL | // fn oom( -LL | || info: &Layout, -LL | || ) -> () - | ||_______^ expected `!`, found `()` -LL | | { -LL | | loop {} -LL | | } - | |__- expected `!` because of return type +LL | #[alloc_error_handler] + | ---------------------- in this procedural macro expansion +LL | / fn oom( +LL | | info: &Layout, +LL | | ) -> () + | | ^^ expected `!`, found `()` +LL | | { +LL | | loop {} +LL | | } + | |_- expected `!` because of return type | = note: expected type `!` found unit type `()` diff --git a/tests/ui/alloc-error/alloc-error-handler-bad-signature-2.rs b/tests/ui/alloc-error/alloc-error-handler-bad-signature-2.rs index 4f76257fc7267..a9114431dadb1 100644 --- a/tests/ui/alloc-error/alloc-error-handler-bad-signature-2.rs +++ b/tests/ui/alloc-error/alloc-error-handler-bad-signature-2.rs @@ -8,8 +8,8 @@ struct Layout; #[alloc_error_handler] fn oom( - info: Layout, //~^ ERROR mismatched types -) { //~^^ ERROR mismatched types + info: Layout, //~ ERROR mismatched types +) { //~ ERROR mismatched types loop {} } diff --git a/tests/ui/alloc-error/alloc-error-handler-bad-signature-2.stderr b/tests/ui/alloc-error/alloc-error-handler-bad-signature-2.stderr index 7a495380f2ba1..9ef1b8dd2c01c 100644 --- a/tests/ui/alloc-error/alloc-error-handler-bad-signature-2.stderr +++ b/tests/ui/alloc-error/alloc-error-handler-bad-signature-2.stderr @@ -1,15 +1,15 @@ error[E0308]: mismatched types - --> $DIR/alloc-error-handler-bad-signature-2.rs:10:1 + --> $DIR/alloc-error-handler-bad-signature-2.rs:11:5 | -LL | #[alloc_error_handler] - | ---------------------- in this procedural macro expansion -LL | // fn oom( -LL | || info: Layout, -LL | || ) { - | ||_- arguments to this function are incorrect -LL | | loop {} -LL | | } - | |__^ expected `Layout`, found `core::alloc::Layout` +LL | #[alloc_error_handler] + | ---------------------- in this procedural macro expansion +LL | / fn oom( +LL | | info: Layout, + | | ^^^^^^^^^^^^ expected `Layout`, found `core::alloc::Layout` +LL | | ) { +LL | | loop {} +LL | | } + | |_- arguments to this function are incorrect | = note: `core::alloc::Layout` and `Layout` have similar names, but are actually distinct types note: `core::alloc::Layout` is defined in crate `core` @@ -29,17 +29,17 @@ LL | info: Layout, = note: this error originates in the attribute macro `alloc_error_handler` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0308]: mismatched types - --> $DIR/alloc-error-handler-bad-signature-2.rs:10:1 + --> $DIR/alloc-error-handler-bad-signature-2.rs:12:3 | -LL | #[alloc_error_handler] - | ---------------------- in this procedural macro expansion -LL | // fn oom( -LL | || info: Layout, -LL | || ) { - | ||_^ expected `!`, found `()` -LL | | loop {} -LL | | } - | |__- expected `!` because of return type +LL | #[alloc_error_handler] + | ---------------------- in this procedural macro expansion +LL | / fn oom( +LL | | info: Layout, +LL | | ) { + | | ^ expected `!`, found `()` +LL | | loop {} +LL | | } + | |_- expected `!` because of return type | = note: expected type `!` found unit type `()` diff --git a/tests/ui/alloc-error/alloc-error-handler-bad-signature-3.stderr b/tests/ui/alloc-error/alloc-error-handler-bad-signature-3.stderr index eb739b149a103..becfcf0690a16 100644 --- a/tests/ui/alloc-error/alloc-error-handler-bad-signature-3.stderr +++ b/tests/ui/alloc-error/alloc-error-handler-bad-signature-3.stderr @@ -3,11 +3,10 @@ error[E0061]: this function takes 0 arguments but 1 argument was supplied | LL | #[alloc_error_handler] | ---------------------- in this procedural macro expansion -LL | fn oom() -> ! { - | _-^^^^^^^^^^^^ +LL | / fn oom() -> ! { LL | | loop {} LL | | } - | |_- unexpected argument of type `core::alloc::Layout` + | |_^ unexpected argument of type `core::alloc::Layout` | note: function defined here --> $DIR/alloc-error-handler-bad-signature-3.rs:10:4 diff --git a/tests/ui/argument-suggestions/extra_arguments.stderr b/tests/ui/argument-suggestions/extra_arguments.stderr index 11c7109974355..b3bb4c302949a 100644 --- a/tests/ui/argument-suggestions/extra_arguments.stderr +++ b/tests/ui/argument-suggestions/extra_arguments.stderr @@ -258,7 +258,6 @@ LL | foo!(1); | ------- | | | | | unexpected argument of type `{integer}` - | | help: remove the extra argument | in this macro invocation | note: function defined here diff --git a/tests/ui/borrowck/borrowck-vec-pattern-nesting.rs b/tests/ui/borrowck/borrowck-vec-pattern-nesting.rs index 127a3f5b2dc97..30ccf3f856c71 100644 --- a/tests/ui/borrowck/borrowck-vec-pattern-nesting.rs +++ b/tests/ui/borrowck/borrowck-vec-pattern-nesting.rs @@ -49,6 +49,7 @@ fn c() { //~| NOTE cannot move out of here //~| NOTE move occurs because //~| HELP consider borrowing here + //~| NOTE in this expansion of desugaring of a resized `Span` } fn d() { @@ -68,6 +69,7 @@ fn d() { //~| NOTE cannot move out of here //~| NOTE move occurs because //~| HELP consider borrowing here + //~| NOTE in this expansion of desugaring of a resized `Span` } fn e() { @@ -88,6 +90,7 @@ fn e() { //~| NOTE cannot move out of here //~| NOTE move occurs because //~| HELP consider borrowing here + //~| NOTE in this expansion of desugaring of a resized `Span` } fn main() {} diff --git a/tests/ui/borrowck/borrowck-vec-pattern-nesting.stderr b/tests/ui/borrowck/borrowck-vec-pattern-nesting.stderr index 5e1251b059093..9a9a719fa4bf8 100644 --- a/tests/ui/borrowck/borrowck-vec-pattern-nesting.stderr +++ b/tests/ui/borrowck/borrowck-vec-pattern-nesting.stderr @@ -55,7 +55,7 @@ LL | let a = &vec[0]; | + error[E0508]: cannot move out of type `[Box]`, a non-copy slice - --> $DIR/borrowck-vec-pattern-nesting.rs:57:11 + --> $DIR/borrowck-vec-pattern-nesting.rs:58:11 | LL | match vec { | ^^^ cannot move out of here @@ -73,7 +73,7 @@ LL + [ | error[E0508]: cannot move out of type `[Box]`, a non-copy slice - --> $DIR/borrowck-vec-pattern-nesting.rs:67:13 + --> $DIR/borrowck-vec-pattern-nesting.rs:68:13 | LL | let a = vec[0]; | ^^^^^^ @@ -87,7 +87,7 @@ LL | let a = &vec[0]; | + error[E0508]: cannot move out of type `[Box]`, a non-copy slice - --> $DIR/borrowck-vec-pattern-nesting.rs:76:11 + --> $DIR/borrowck-vec-pattern-nesting.rs:78:11 | LL | match vec { | ^^^ cannot move out of here @@ -106,7 +106,7 @@ LL + [_a, _b, _c] => {} | error[E0508]: cannot move out of type `[Box]`, a non-copy slice - --> $DIR/borrowck-vec-pattern-nesting.rs:87:13 + --> $DIR/borrowck-vec-pattern-nesting.rs:89:13 | LL | let a = vec[0]; | ^^^^^^ diff --git a/tests/ui/borrowck/issue-87456-point-to-closure.rs b/tests/ui/borrowck/issue-87456-point-to-closure.rs index 9fc12ba749042..39ecf0b901b80 100644 --- a/tests/ui/borrowck/issue-87456-point-to-closure.rs +++ b/tests/ui/borrowck/issue-87456-point-to-closure.rs @@ -10,5 +10,6 @@ fn main() { let _foo: String = val; //~^ ERROR: cannot move out of `val`, a captured variable in an `FnMut` closure [E0507] //~| NOTE: move occurs because + //~| NOTE in this expansion of desugaring of a resized `Span` }) } diff --git a/tests/ui/feature-gates/feature-gate-concat_idents2.rs b/tests/ui/feature-gates/feature-gate-concat_idents2.rs index 9660ffeafa518..9465824f99475 100644 --- a/tests/ui/feature-gates/feature-gate-concat_idents2.rs +++ b/tests/ui/feature-gates/feature-gate-concat_idents2.rs @@ -1,4 +1,4 @@ fn main() { concat_idents!(a, b); //~ ERROR `concat_idents` is not stable enough - //~| ERROR cannot find value `ab` in this scope + //~| ERROR cannot find value `ab` in } diff --git a/tests/ui/feature-gates/feature-gate-concat_idents2.stderr b/tests/ui/feature-gates/feature-gate-concat_idents2.stderr index 8663bc7ca7e77..2f9ff916170f1 100644 --- a/tests/ui/feature-gates/feature-gate-concat_idents2.stderr +++ b/tests/ui/feature-gates/feature-gate-concat_idents2.stderr @@ -7,11 +7,11 @@ LL | concat_idents!(a, b); = note: see issue #29599 for more information = help: add `#![feature(concat_idents)]` to the crate attributes to enable -error[E0425]: cannot find value `ab` in this scope +error[E0425]: cannot find value `ab` in the expanded code of procedural macro `concat_idents` --> $DIR/feature-gate-concat_idents2.rs:2:5 | LL | concat_idents!(a, b); - | ^^^^^^^^^^^^^^^^^^^^ not found in this scope + | ^^^^^^^^^^^^^^^^^^^^ `ab` not found in expanded code of this procedural macro | = note: this error originates in the macro `concat_idents` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/fully-qualified-type/fully-qualified-type-name1.rs b/tests/ui/fully-qualified-type/fully-qualified-type-name1.rs index bbca22ad2e69d..2d1d5b183d9b0 100644 --- a/tests/ui/fully-qualified-type/fully-qualified-type-name1.rs +++ b/tests/ui/fully-qualified-type/fully-qualified-type-name1.rs @@ -7,4 +7,5 @@ fn main() { //~^ ERROR mismatched types //~| NOTE expected enum `Option` //~| NOTE expected `Option`, found integer + //~| NOTE in this expansion of desugaring of a resized `Span` } diff --git a/tests/ui/hygiene/arguments.stderr b/tests/ui/hygiene/arguments.stderr index 714178375f2d1..60d5418b66edf 100644 --- a/tests/ui/hygiene/arguments.stderr +++ b/tests/ui/hygiene/arguments.stderr @@ -3,6 +3,11 @@ error[E0412]: cannot find type `S` in this scope | LL | m!(S, S); | ^ not found in this scope + | +help: you might be missing a type parameter + | +LL | pub(super) fn f(_: $t) {} + | +++ error: aborting due to previous error diff --git a/tests/ui/issues/issue-32950.rs b/tests/ui/issues/issue-32950.rs index 27d68a11c1f16..18b45ca632bc1 100644 --- a/tests/ui/issues/issue-32950.rs +++ b/tests/ui/issues/issue-32950.rs @@ -3,7 +3,7 @@ #[derive(Debug)] struct Baz( concat_idents!(Foo, Bar) //~ ERROR `derive` cannot be used on items with type macros - //~^ ERROR cannot find type `FooBar` in this scope + //~^ ERROR cannot find type `FooBar` ); fn main() {} diff --git a/tests/ui/issues/issue-32950.stderr b/tests/ui/issues/issue-32950.stderr index f6635d982e4ec..c0ad29450161b 100644 --- a/tests/ui/issues/issue-32950.stderr +++ b/tests/ui/issues/issue-32950.stderr @@ -4,11 +4,11 @@ error: `derive` cannot be used on items with type macros LL | concat_idents!(Foo, Bar) | ^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0412]: cannot find type `FooBar` in this scope +error[E0412]: cannot find type `FooBar` in the expanded code of procedural macro `concat_idents` --> $DIR/issue-32950.rs:5:5 | LL | concat_idents!(Foo, Bar) - | ^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope + | ^^^^^^^^^^^^^^^^^^^^^^^^ `FooBar` not found in expanded code of this procedural macro | = note: this error originates in the macro `concat_idents` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/issues/issue-70724-add_type_neq_err_label-unwrap.stderr b/tests/ui/issues/issue-70724-add_type_neq_err_label-unwrap.stderr index b30bcfb776c8c..8dd2aec95223b 100644 --- a/tests/ui/issues/issue-70724-add_type_neq_err_label-unwrap.stderr +++ b/tests/ui/issues/issue-70724-add_type_neq_err_label-unwrap.stderr @@ -13,10 +13,10 @@ error[E0308]: mismatched types --> $DIR/issue-70724-add_type_neq_err_label-unwrap.rs:6:5 | LL | assert_eq!(a, 0); - | ^^^^^^^^^^^^^^^^ expected fn item, found integer + | ^^^^^^^^^^^^^^^^ expected fn item, found `i32` | = note: expected fn item `fn() -> i32 {a}` - found type `{integer}` + found type `i32` = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: `fn() -> i32 {a}` doesn't implement `Debug` diff --git a/tests/ui/lifetimes/missing-lifetime-in-alias.rs b/tests/ui/lifetimes/missing-lifetime-in-alias.rs index 51c564c011a86..44be06e1fef7c 100644 --- a/tests/ui/lifetimes/missing-lifetime-in-alias.rs +++ b/tests/ui/lifetimes/missing-lifetime-in-alias.rs @@ -27,5 +27,6 @@ type C<'a, 'b> = as Trait>::Bar; //~| NOTE expected named lifetime parameter //~| NOTE these named lifetimes are available to use //~| NOTE expected 1 lifetime argument +//~| NOTE in this expansion of desugaring of a resized `Span` fn main() {} diff --git a/tests/ui/macros/issue-100199.rs b/tests/ui/macros/issue-100199.rs index 6e50afa075984..0ee657c549a4e 100644 --- a/tests/ui/macros/issue-100199.rs +++ b/tests/ui/macros/issue-100199.rs @@ -1,4 +1,4 @@ -#[issue_100199::struct_with_bound] //~ ERROR cannot find trait `MyTrait` in the crate root +#[issue_100199::struct_with_bound] //~ ERROR cannot find trait `MyTrait` in struct Foo {} // The above must be on the first line so that it's span points to pos 0. // This used to trigger an ICE because the diagnostic emitter would get diff --git a/tests/ui/macros/issue-100199.stderr b/tests/ui/macros/issue-100199.stderr index 89a6f585ce415..e79b63302000d 100644 --- a/tests/ui/macros/issue-100199.stderr +++ b/tests/ui/macros/issue-100199.stderr @@ -1,14 +1,10 @@ -error[E0405]: cannot find trait `MyTrait` in the crate root +error[E0405]: cannot find trait `MyTrait` in the expanded code of procedural macro `issue_100199::struct_with_bound` --> $DIR/issue-100199.rs:1:1 | LL | #[issue_100199::struct_with_bound] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in the crate root + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `crate::MyTrait` not found in expanded code of this procedural macro | = note: this error originates in the attribute macro `issue_100199::struct_with_bound` (in Nightly builds, run with -Z macro-backtrace for more info) -help: consider importing this trait - | -LL + use traits::MyTrait; - | error: aborting due to previous error diff --git a/tests/ui/macros/issue-90557.rs b/tests/ui/macros/issue-90557.rs new file mode 100644 index 0000000000000..5a9aa5dabb70c --- /dev/null +++ b/tests/ui/macros/issue-90557.rs @@ -0,0 +1,18 @@ +struct Example { + foo: T, + bar: U, +} + +macro_rules! impl_example { + ($($t:ty)+) => {$( + impl Example<$t> { //~ ERROR struct takes 2 generic arguments but 1 generic argument was supplied + fn baz() { + println!(":)"); + } + } + )+} +} + +impl_example! { u8 } + +fn main() {} diff --git a/tests/ui/macros/issue-90557.stderr b/tests/ui/macros/issue-90557.stderr new file mode 100644 index 0000000000000..f28521efe75c1 --- /dev/null +++ b/tests/ui/macros/issue-90557.stderr @@ -0,0 +1,22 @@ +error[E0107]: struct takes 2 generic arguments but 1 generic argument was supplied + --> $DIR/issue-90557.rs:8:14 + | +LL | impl Example<$t> { + | ^^^^^^^ expected 2 generic arguments +... +LL | impl_example! { u8 } + | -------------------- + | | | + | | supplied 1 generic argument + | in this macro invocation + | +note: struct defined here, with 2 generic parameters: `T`, `U` + --> $DIR/issue-90557.rs:1:8 + | +LL | struct Example { + | ^^^^^^^ - - + = note: this error originates in the macro `impl_example` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0107`. diff --git a/tests/ui/match/match-type-err-first-arm.rs b/tests/ui/match/match-type-err-first-arm.rs index e9027eb24897f..63e723ee3ddbc 100644 --- a/tests/ui/match/match-type-err-first-arm.rs +++ b/tests/ui/match/match-type-err-first-arm.rs @@ -8,6 +8,7 @@ fn test_func1(n: i32) -> i32 { //~ NOTE expected `i32` because of return type 12 => 'b', //~^ ERROR mismatched types //~| NOTE expected `i32`, found `char` + //~| NOTE in this expansion of desugaring of a resized `Span` _ => 42, } } diff --git a/tests/ui/match/match-type-err-first-arm.stderr b/tests/ui/match/match-type-err-first-arm.stderr index 1cfe7ce1ed726..6ede2fb470334 100644 --- a/tests/ui/match/match-type-err-first-arm.stderr +++ b/tests/ui/match/match-type-err-first-arm.stderr @@ -13,7 +13,7 @@ LL | 12 => 'b' as i32, | ++++++ error[E0308]: `match` arms have incompatible types - --> $DIR/match-type-err-first-arm.rs:18:14 + --> $DIR/match-type-err-first-arm.rs:19:14 | LL | let x = match n { | _____________- @@ -27,7 +27,7 @@ LL | | }; | |_____- `match` arms have incompatible types error[E0308]: `match` arms have incompatible types - --> $DIR/match-type-err-first-arm.rs:34:14 + --> $DIR/match-type-err-first-arm.rs:35:14 | LL | let x = match n { | _____________- @@ -46,7 +46,7 @@ LL | | }; | |_____- `match` arms have incompatible types error[E0308]: `match` arms have incompatible types - --> $DIR/match-type-err-first-arm.rs:46:17 + --> $DIR/match-type-err-first-arm.rs:47:17 | LL | / match Some(0u32) { LL | | Some(x) => { diff --git a/tests/ui/numeric/numeric-cast-3.fixed b/tests/ui/numeric/numeric-cast-3.fixed new file mode 100644 index 0000000000000..d8edf562a0a61 --- /dev/null +++ b/tests/ui/numeric/numeric-cast-3.fixed @@ -0,0 +1,151 @@ +// run-rustfix + +// The `try_into` suggestion doesn't include this, but we do suggest it after applying it +use std::convert::TryInto; + +fn foo(_x: N) {} + +fn main() { + let x_usize: usize = 1; + let x_u64: u64 = 2; + let x_u32: u32 = 3; + let x_u16: u16 = 4; + let x_u8: u8 = 5; + let x_isize: isize = 6; + let x_i64: i64 = 7; + let x_i32: i32 = 8; + let x_i16: i16 = 9; + let x_i8: i8 = 10; + + 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::(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); + 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::(x_f64); + // foo::(x_f32); + + foo::(x_usize.try_into().unwrap()); + //~^ ERROR mismatched types + 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::(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::(x_i64); + foo::(x_i32.into()); + //~^ ERROR mismatched types + foo::(x_i16.into()); + //~^ ERROR mismatched types + foo::(x_i8.into()); + //~^ ERROR mismatched types + // 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); + 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::(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::(x_i32); + foo::(x_i16.into()); + //~^ ERROR mismatched types + foo::(x_i8.into()); + //~^ ERROR mismatched types + // foo::(x_f64); + // foo::(x_f32); +} diff --git a/tests/ui/numeric/numeric-cast-3.rs b/tests/ui/numeric/numeric-cast-3.rs new file mode 100644 index 0000000000000..990320cf2aa99 --- /dev/null +++ b/tests/ui/numeric/numeric-cast-3.rs @@ -0,0 +1,151 @@ +// run-rustfix + +// The `try_into` suggestion doesn't include this, but we do suggest it after applying it +use std::convert::TryInto; + +fn foo(_x: N) {} + +fn main() { + let x_usize: usize = 1; + let x_u64: u64 = 2; + let x_u32: u32 = 3; + let x_u16: u16 = 4; + let x_u8: u8 = 5; + let x_isize: isize = 6; + let x_i64: i64 = 7; + let x_i32: i32 = 8; + let x_i16: i16 = 9; + let x_i8: i8 = 10; + + foo::(x_usize); + foo::(x_u64); + //~^ ERROR mismatched types + foo::(x_u32); + //~^ ERROR mismatched types + foo::(x_u16); + //~^ ERROR mismatched types + foo::(x_u8); + //~^ ERROR mismatched types + foo::(x_isize); + //~^ ERROR mismatched types + foo::(x_i64); + //~^ ERROR mismatched types + foo::(x_i32); + //~^ ERROR mismatched types + foo::(x_i16); + //~^ ERROR mismatched types + foo::(x_i8); + //~^ ERROR mismatched types + // foo::(x_f64); + // foo::(x_f32); + + foo::(x_usize); + //~^ ERROR mismatched types + foo::(x_u64); + //~^ ERROR mismatched types + foo::(x_u32); + //~^ ERROR mismatched types + foo::(x_u16); + //~^ ERROR mismatched types + foo::(x_u8); + //~^ ERROR mismatched types + foo::(x_isize); + foo::(x_i64); + //~^ ERROR mismatched types + foo::(x_i32); + //~^ ERROR mismatched types + foo::(x_i16); + //~^ ERROR mismatched types + foo::(x_i8); + //~^ ERROR mismatched types + // foo::(x_f64); + // foo::(x_f32); + + foo::(x_usize); + //~^ ERROR mismatched types + foo::(x_u64); + foo::(x_u32); + //~^ ERROR mismatched types + foo::(x_u16); + //~^ ERROR mismatched types + foo::(x_u8); + //~^ ERROR mismatched types + foo::(x_isize); + //~^ ERROR mismatched types + foo::(x_i64); + //~^ ERROR mismatched types + foo::(x_i32); + //~^ ERROR mismatched types + foo::(x_i16); + //~^ ERROR mismatched types + foo::(x_i8); + //~^ ERROR mismatched types + // foo::(x_f64); + // foo::(x_f32); + + foo::(x_usize); + //~^ ERROR mismatched types + foo::(x_u64); + //~^ ERROR mismatched types + foo::(x_u32); + //~^ ERROR mismatched types + foo::(x_u16); + //~^ ERROR mismatched types + foo::(x_u8); + //~^ ERROR mismatched types + foo::(x_isize); + //~^ ERROR mismatched types + foo::(x_i64); + foo::(x_i32); + //~^ ERROR mismatched types + foo::(x_i16); + //~^ ERROR mismatched types + foo::(x_i8); + //~^ ERROR mismatched types + // foo::(x_f64); + // foo::(x_f32); + + foo::(x_usize); + //~^ ERROR mismatched types + foo::(x_u64); + //~^ ERROR mismatched types + foo::(x_u32); + foo::(x_u16); + //~^ ERROR mismatched types + foo::(x_u8); + //~^ ERROR mismatched types + foo::(x_isize); + //~^ ERROR mismatched types + foo::(x_i64); + //~^ ERROR mismatched types + foo::(x_i32); + //~^ ERROR mismatched types + foo::(x_i16); + //~^ ERROR mismatched types + foo::(x_i8); + //~^ ERROR mismatched types + // foo::(x_f64); + // foo::(x_f32); + + foo::(x_usize); + //~^ ERROR mismatched types + foo::(x_u64); + //~^ ERROR mismatched types + foo::(x_u32); + //~^ ERROR mismatched types + foo::(x_u16); + //~^ ERROR mismatched types + foo::(x_u8); + //~^ ERROR mismatched types + foo::(x_isize); + //~^ ERROR mismatched types + foo::(x_i64); + //~^ ERROR mismatched types + foo::(x_i32); + foo::(x_i16); + //~^ ERROR mismatched types + foo::(x_i8); + //~^ ERROR mismatched types + // foo::(x_f64); + // foo::(x_f32); +} diff --git a/tests/ui/numeric/numeric-cast-3.stderr b/tests/ui/numeric/numeric-cast-3.stderr new file mode 100644 index 0000000000000..d086fea4788f6 --- /dev/null +++ b/tests/ui/numeric/numeric-cast-3.stderr @@ -0,0 +1,975 @@ +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:21:18 + | +LL | foo::(x_u64); + | ------------ ^^^^^ expected `usize`, found `u64` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `u64` to a `usize` and panic if the converted value doesn't fit + | +LL | foo::(x_u64.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:23:18 + | +LL | foo::(x_u32); + | ------------ ^^^^^ expected `usize`, found `u32` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `u32` to a `usize` and panic if the converted value doesn't fit + | +LL | foo::(x_u32.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:25:18 + | +LL | foo::(x_u16); + | ------------ ^^^^^ expected `usize`, found `u16` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `u16` to a `usize` + | +LL | foo::(x_u16.into()); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:27:18 + | +LL | foo::(x_u8); + | ------------ ^^^^ expected `usize`, found `u8` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `u8` to a `usize` + | +LL | foo::(x_u8.into()); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:29:18 + | +LL | foo::(x_isize); + | ------------ ^^^^^^^ expected `usize`, found `isize` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `isize` to a `usize` and panic if the converted value doesn't fit + | +LL | foo::(x_isize.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:31:18 + | +LL | foo::(x_i64); + | ------------ ^^^^^ expected `usize`, found `i64` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `i64` to a `usize` and panic if the converted value doesn't fit + | +LL | foo::(x_i64.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:33:18 + | +LL | foo::(x_i32); + | ------------ ^^^^^ expected `usize`, found `i32` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `i32` to a `usize` and panic if the converted value doesn't fit + | +LL | foo::(x_i32.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:35:18 + | +LL | foo::(x_i16); + | ------------ ^^^^^ expected `usize`, found `i16` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `i16` to a `usize` and panic if the converted value doesn't fit + | +LL | foo::(x_i16.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:37:18 + | +LL | foo::(x_i8); + | ------------ ^^^^ expected `usize`, found `i8` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `i8` to a `usize` and panic if the converted value doesn't fit + | +LL | foo::(x_i8.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:42:18 + | +LL | foo::(x_usize); + | ------------ ^^^^^^^ expected `isize`, found `usize` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `usize` to an `isize` and panic if the converted value doesn't fit + | +LL | foo::(x_usize.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:44:18 + | +LL | foo::(x_u64); + | ------------ ^^^^^ expected `isize`, found `u64` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `u64` to an `isize` and panic if the converted value doesn't fit + | +LL | foo::(x_u64.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:46:18 + | +LL | foo::(x_u32); + | ------------ ^^^^^ expected `isize`, found `u32` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `u32` to an `isize` and panic if the converted value doesn't fit + | +LL | foo::(x_u32.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:48:18 + | +LL | foo::(x_u16); + | ------------ ^^^^^ expected `isize`, found `u16` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `u16` to an `isize` and panic if the converted value doesn't fit + | +LL | foo::(x_u16.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:50:18 + | +LL | foo::(x_u8); + | ------------ ^^^^ expected `isize`, found `u8` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `u8` to an `isize` + | +LL | foo::(x_u8.into()); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:53:18 + | +LL | foo::(x_i64); + | ------------ ^^^^^ expected `isize`, found `i64` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `i64` to an `isize` and panic if the converted value doesn't fit + | +LL | foo::(x_i64.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:55:18 + | +LL | foo::(x_i32); + | ------------ ^^^^^ expected `isize`, found `i32` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `i32` to an `isize` and panic if the converted value doesn't fit + | +LL | foo::(x_i32.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:57:18 + | +LL | foo::(x_i16); + | ------------ ^^^^^ expected `isize`, found `i16` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `i16` to an `isize` + | +LL | foo::(x_i16.into()); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:59:18 + | +LL | foo::(x_i8); + | ------------ ^^^^ expected `isize`, found `i8` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `i8` to an `isize` + | +LL | foo::(x_i8.into()); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:64:16 + | +LL | foo::(x_usize); + | ---------- ^^^^^^^ expected `u64`, found `usize` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `usize` to a `u64` and panic if the converted value doesn't fit + | +LL | foo::(x_usize.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:67:16 + | +LL | foo::(x_u32); + | ---------- ^^^^^ expected `u64`, found `u32` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `u32` to a `u64` + | +LL | foo::(x_u32.into()); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:69:16 + | +LL | foo::(x_u16); + | ---------- ^^^^^ expected `u64`, found `u16` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `u16` to a `u64` + | +LL | foo::(x_u16.into()); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:71:16 + | +LL | foo::(x_u8); + | ---------- ^^^^ expected `u64`, found `u8` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `u8` to a `u64` + | +LL | foo::(x_u8.into()); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:73:16 + | +LL | foo::(x_isize); + | ---------- ^^^^^^^ expected `u64`, found `isize` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `isize` to a `u64` and panic if the converted value doesn't fit + | +LL | foo::(x_isize.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:75:16 + | +LL | foo::(x_i64); + | ---------- ^^^^^ expected `u64`, found `i64` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `i64` to a `u64` and panic if the converted value doesn't fit + | +LL | foo::(x_i64.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:77:16 + | +LL | foo::(x_i32); + | ---------- ^^^^^ expected `u64`, found `i32` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `i32` to a `u64` and panic if the converted value doesn't fit + | +LL | foo::(x_i32.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:79:16 + | +LL | foo::(x_i16); + | ---------- ^^^^^ expected `u64`, found `i16` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `i16` to a `u64` and panic if the converted value doesn't fit + | +LL | foo::(x_i16.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:81:16 + | +LL | foo::(x_i8); + | ---------- ^^^^ expected `u64`, found `i8` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `i8` to a `u64` and panic if the converted value doesn't fit + | +LL | foo::(x_i8.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:86:16 + | +LL | foo::(x_usize); + | ---------- ^^^^^^^ expected `i64`, found `usize` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `usize` to an `i64` and panic if the converted value doesn't fit + | +LL | foo::(x_usize.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:88:16 + | +LL | foo::(x_u64); + | ---------- ^^^^^ expected `i64`, found `u64` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `u64` to an `i64` and panic if the converted value doesn't fit + | +LL | foo::(x_u64.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:90:16 + | +LL | foo::(x_u32); + | ---------- ^^^^^ expected `i64`, found `u32` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `u32` to an `i64` + | +LL | foo::(x_u32.into()); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:92:16 + | +LL | foo::(x_u16); + | ---------- ^^^^^ expected `i64`, found `u16` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `u16` to an `i64` + | +LL | foo::(x_u16.into()); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:94:16 + | +LL | foo::(x_u8); + | ---------- ^^^^ expected `i64`, found `u8` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `u8` to an `i64` + | +LL | foo::(x_u8.into()); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:96:16 + | +LL | foo::(x_isize); + | ---------- ^^^^^^^ expected `i64`, found `isize` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `isize` to an `i64` and panic if the converted value doesn't fit + | +LL | foo::(x_isize.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:99:16 + | +LL | foo::(x_i32); + | ---------- ^^^^^ expected `i64`, found `i32` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `i32` to an `i64` + | +LL | foo::(x_i32.into()); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:101:16 + | +LL | foo::(x_i16); + | ---------- ^^^^^ expected `i64`, found `i16` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `i16` to an `i64` + | +LL | foo::(x_i16.into()); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:103:16 + | +LL | foo::(x_i8); + | ---------- ^^^^ expected `i64`, found `i8` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `i8` to an `i64` + | +LL | foo::(x_i8.into()); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:108:16 + | +LL | foo::(x_usize); + | ---------- ^^^^^^^ expected `u32`, found `usize` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit + | +LL | foo::(x_usize.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:110:16 + | +LL | foo::(x_u64); + | ---------- ^^^^^ expected `u32`, found `u64` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `u64` to a `u32` and panic if the converted value doesn't fit + | +LL | foo::(x_u64.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:113:16 + | +LL | foo::(x_u16); + | ---------- ^^^^^ expected `u32`, found `u16` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `u16` to a `u32` + | +LL | foo::(x_u16.into()); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:115:16 + | +LL | foo::(x_u8); + | ---------- ^^^^ expected `u32`, found `u8` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `u8` to a `u32` + | +LL | foo::(x_u8.into()); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:117:16 + | +LL | foo::(x_isize); + | ---------- ^^^^^^^ expected `u32`, found `isize` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `isize` to a `u32` and panic if the converted value doesn't fit + | +LL | foo::(x_isize.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:119:16 + | +LL | foo::(x_i64); + | ---------- ^^^^^ expected `u32`, found `i64` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `i64` to a `u32` and panic if the converted value doesn't fit + | +LL | foo::(x_i64.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:121:16 + | +LL | foo::(x_i32); + | ---------- ^^^^^ expected `u32`, found `i32` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `i32` to a `u32` and panic if the converted value doesn't fit + | +LL | foo::(x_i32.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:123:16 + | +LL | foo::(x_i16); + | ---------- ^^^^^ expected `u32`, found `i16` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `i16` to a `u32` and panic if the converted value doesn't fit + | +LL | foo::(x_i16.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:125:16 + | +LL | foo::(x_i8); + | ---------- ^^^^ expected `u32`, found `i8` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `i8` to a `u32` and panic if the converted value doesn't fit + | +LL | foo::(x_i8.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:130:16 + | +LL | foo::(x_usize); + | ---------- ^^^^^^^ expected `i32`, found `usize` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `usize` to an `i32` and panic if the converted value doesn't fit + | +LL | foo::(x_usize.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:132:16 + | +LL | foo::(x_u64); + | ---------- ^^^^^ expected `i32`, found `u64` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `u64` to an `i32` and panic if the converted value doesn't fit + | +LL | foo::(x_u64.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:134:16 + | +LL | foo::(x_u32); + | ---------- ^^^^^ expected `i32`, found `u32` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `u32` to an `i32` and panic if the converted value doesn't fit + | +LL | foo::(x_u32.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:136:16 + | +LL | foo::(x_u16); + | ---------- ^^^^^ expected `i32`, found `u16` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `u16` to an `i32` + | +LL | foo::(x_u16.into()); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:138:16 + | +LL | foo::(x_u8); + | ---------- ^^^^ expected `i32`, found `u8` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `u8` to an `i32` + | +LL | foo::(x_u8.into()); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:140:16 + | +LL | foo::(x_isize); + | ---------- ^^^^^^^ expected `i32`, found `isize` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `isize` to an `i32` and panic if the converted value doesn't fit + | +LL | foo::(x_isize.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:142:16 + | +LL | foo::(x_i64); + | ---------- ^^^^^ expected `i32`, found `i64` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `i64` to an `i32` and panic if the converted value doesn't fit + | +LL | foo::(x_i64.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:145:16 + | +LL | foo::(x_i16); + | ---------- ^^^^^ expected `i32`, found `i16` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `i16` to an `i32` + | +LL | foo::(x_i16.into()); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:147:16 + | +LL | foo::(x_i8); + | ---------- ^^^^ expected `i32`, found `i8` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `i8` to an `i32` + | +LL | foo::(x_i8.into()); + | +++++++ + +error: aborting due to 54 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/numeric/numeric-cast-binop-2.fixed b/tests/ui/numeric/numeric-cast-binop-2.fixed new file mode 100644 index 0000000000000..61cf2795537a6 --- /dev/null +++ b/tests/ui/numeric/numeric-cast-binop-2.fixed @@ -0,0 +1,158 @@ +// run-rustfix + +// The `try_into` suggestion doesn't include this, but we do suggest it after applying it +use std::convert::TryInto; + +#[allow(unused_must_use)] +fn main() { + let x_usize: usize = 1; + let x_u128: u128 = 2; + let x_u64: u64 = 3; + let x_u32: u32 = 4; + let x_u16: u16 = 5; + let x_u8: u8 = 6; + let x_isize: isize = 7; + let x_i64: i64 = 8; + let x_i32: i32 = 9; + let x_i16: i16 = 10; + let x_i8: i8 = 11; + let x_i128: i128 = 12; + + /* u<->u */ + { + u16::from(x_u8) > x_u16; + //~^ ERROR mismatched types + u32::from(x_u8) > x_u32; + //~^ ERROR mismatched types + u64::from(x_u8) > x_u64; + //~^ ERROR mismatched types + u128::from(x_u8) > x_u128; + //~^ ERROR mismatched types + usize::from(x_u8) > x_usize; + //~^ ERROR mismatched types + + x_u16 > x_u8.into(); + //~^ ERROR mismatched types + u32::from(x_u16) > x_u32; + //~^ ERROR mismatched types + u64::from(x_u16) > x_u64; + //~^ ERROR mismatched types + u128::from(x_u16) > x_u128; + //~^ ERROR mismatched types + usize::from(x_u16) > x_usize; + //~^ ERROR mismatched types + + x_u32 > x_u8.into(); + //~^ ERROR mismatched types + x_u32 > x_u16.into(); + //~^ ERROR mismatched types + u64::from(x_u32) > x_u64; + //~^ ERROR mismatched types + u128::from(x_u32) > x_u128; + //~^ ERROR mismatched types + x_u32 > x_usize.try_into().unwrap(); + //~^ ERROR mismatched types + + x_u64 > x_u8.into(); + //~^ ERROR mismatched types + x_u64 > x_u16.into(); + //~^ ERROR mismatched types + x_u64 > x_u32.into(); + //~^ ERROR mismatched types + u128::from(x_u64) > x_u128; + //~^ ERROR mismatched types + x_u64 > x_usize.try_into().unwrap(); + //~^ ERROR mismatched types + + x_u128 > x_u8.into(); + //~^ ERROR mismatched types + x_u128 > x_u16.into(); + //~^ ERROR mismatched types + x_u128 > x_u32.into(); + //~^ ERROR mismatched types + x_u128 > x_u64.into(); + //~^ ERROR mismatched types + x_u128 > x_usize.try_into().unwrap(); + //~^ ERROR mismatched types + + x_usize > x_u8.into(); + //~^ ERROR mismatched types + x_usize > x_u16.into(); + //~^ ERROR mismatched types + x_usize > x_u32.try_into().unwrap(); + //~^ ERROR mismatched types + x_usize > x_u64.try_into().unwrap(); + //~^ ERROR mismatched types + x_usize > x_u128.try_into().unwrap(); + //~^ ERROR mismatched types + } + + /* i<->i */ + { + i16::from(x_i8) > x_i16; + //~^ ERROR mismatched types + i32::from(x_i8) > x_i32; + //~^ ERROR mismatched types + i64::from(x_i8) > x_i64; + //~^ ERROR mismatched types + i128::from(x_i8) > x_i128; + //~^ ERROR mismatched types + isize::from(x_i8) > x_isize; + //~^ ERROR mismatched types + + x_i16 > x_i8.into(); + //~^ ERROR mismatched types + i32::from(x_i16) > x_i32; + //~^ ERROR mismatched types + i64::from(x_i16) > x_i64; + //~^ ERROR mismatched types + i128::from(x_i16) > x_i128; + //~^ ERROR mismatched types + isize::from(x_i16) > x_isize; + //~^ ERROR mismatched types + + x_i32 > x_i8.into(); + //~^ ERROR mismatched types + x_i32 > x_i16.into(); + //~^ ERROR mismatched types + i64::from(x_i32) > x_i64; + //~^ ERROR mismatched types + i128::from(x_i32) > x_i128; + //~^ ERROR mismatched types + x_i32 > x_isize.try_into().unwrap(); + //~^ ERROR mismatched types + + x_i64 > x_i8.into(); + //~^ ERROR mismatched types + x_i64 > x_i16.into(); + //~^ ERROR mismatched types + x_i64 > x_i32.into(); + //~^ ERROR mismatched types + i128::from(x_i64) > x_i128; + //~^ ERROR mismatched types + x_i64 > x_isize.try_into().unwrap(); + //~^ ERROR mismatched types + + x_i128 > x_i8.into(); + //~^ ERROR mismatched types + x_i128 > x_i16.into(); + //~^ ERROR mismatched types + x_i128 > x_i32.into(); + //~^ ERROR mismatched types + x_i128 > x_i64.into(); + //~^ ERROR mismatched types + x_i128 > x_isize.try_into().unwrap(); + //~^ ERROR mismatched types + + x_isize > x_i8.into(); + //~^ ERROR mismatched types + x_isize > x_i16.into(); + //~^ ERROR mismatched types + x_isize > x_i32.try_into().unwrap(); + //~^ ERROR mismatched types + x_isize > x_i64.try_into().unwrap(); + //~^ ERROR mismatched types + x_isize > x_i128.try_into().unwrap(); + //~^ ERROR mismatched types + } +} diff --git a/tests/ui/numeric/numeric-cast-binop-2.rs b/tests/ui/numeric/numeric-cast-binop-2.rs new file mode 100644 index 0000000000000..37329bbb4cb1d --- /dev/null +++ b/tests/ui/numeric/numeric-cast-binop-2.rs @@ -0,0 +1,158 @@ +// run-rustfix + +// The `try_into` suggestion doesn't include this, but we do suggest it after applying it +use std::convert::TryInto; + +#[allow(unused_must_use)] +fn main() { + let x_usize: usize = 1; + let x_u128: u128 = 2; + let x_u64: u64 = 3; + let x_u32: u32 = 4; + let x_u16: u16 = 5; + let x_u8: u8 = 6; + let x_isize: isize = 7; + let x_i64: i64 = 8; + let x_i32: i32 = 9; + let x_i16: i16 = 10; + let x_i8: i8 = 11; + let x_i128: i128 = 12; + + /* u<->u */ + { + x_u8 > x_u16; + //~^ ERROR mismatched types + x_u8 > x_u32; + //~^ ERROR mismatched types + x_u8 > x_u64; + //~^ ERROR mismatched types + x_u8 > x_u128; + //~^ ERROR mismatched types + x_u8 > x_usize; + //~^ ERROR mismatched types + + x_u16 > x_u8; + //~^ ERROR mismatched types + x_u16 > x_u32; + //~^ ERROR mismatched types + x_u16 > x_u64; + //~^ ERROR mismatched types + x_u16 > x_u128; + //~^ ERROR mismatched types + x_u16 > x_usize; + //~^ ERROR mismatched types + + x_u32 > x_u8; + //~^ ERROR mismatched types + x_u32 > x_u16; + //~^ ERROR mismatched types + x_u32 > x_u64; + //~^ ERROR mismatched types + x_u32 > x_u128; + //~^ ERROR mismatched types + x_u32 > x_usize; + //~^ ERROR mismatched types + + x_u64 > x_u8; + //~^ ERROR mismatched types + x_u64 > x_u16; + //~^ ERROR mismatched types + x_u64 > x_u32; + //~^ ERROR mismatched types + x_u64 > x_u128; + //~^ ERROR mismatched types + x_u64 > x_usize; + //~^ ERROR mismatched types + + x_u128 > x_u8; + //~^ ERROR mismatched types + x_u128 > x_u16; + //~^ ERROR mismatched types + x_u128 > x_u32; + //~^ ERROR mismatched types + x_u128 > x_u64; + //~^ ERROR mismatched types + x_u128 > x_usize; + //~^ ERROR mismatched types + + x_usize > x_u8; + //~^ ERROR mismatched types + x_usize > x_u16; + //~^ ERROR mismatched types + x_usize > x_u32; + //~^ ERROR mismatched types + x_usize > x_u64; + //~^ ERROR mismatched types + x_usize > x_u128; + //~^ ERROR mismatched types + } + + /* i<->i */ + { + x_i8 > x_i16; + //~^ ERROR mismatched types + x_i8 > x_i32; + //~^ ERROR mismatched types + x_i8 > x_i64; + //~^ ERROR mismatched types + x_i8 > x_i128; + //~^ ERROR mismatched types + x_i8 > x_isize; + //~^ ERROR mismatched types + + x_i16 > x_i8; + //~^ ERROR mismatched types + x_i16 > x_i32; + //~^ ERROR mismatched types + x_i16 > x_i64; + //~^ ERROR mismatched types + x_i16 > x_i128; + //~^ ERROR mismatched types + x_i16 > x_isize; + //~^ ERROR mismatched types + + x_i32 > x_i8; + //~^ ERROR mismatched types + x_i32 > x_i16; + //~^ ERROR mismatched types + x_i32 > x_i64; + //~^ ERROR mismatched types + x_i32 > x_i128; + //~^ ERROR mismatched types + x_i32 > x_isize; + //~^ ERROR mismatched types + + x_i64 > x_i8; + //~^ ERROR mismatched types + x_i64 > x_i16; + //~^ ERROR mismatched types + x_i64 > x_i32; + //~^ ERROR mismatched types + x_i64 > x_i128; + //~^ ERROR mismatched types + x_i64 > x_isize; + //~^ ERROR mismatched types + + x_i128 > x_i8; + //~^ ERROR mismatched types + x_i128 > x_i16; + //~^ ERROR mismatched types + x_i128 > x_i32; + //~^ ERROR mismatched types + x_i128 > x_i64; + //~^ ERROR mismatched types + x_i128 > x_isize; + //~^ ERROR mismatched types + + x_isize > x_i8; + //~^ ERROR mismatched types + x_isize > x_i16; + //~^ ERROR mismatched types + x_isize > x_i32; + //~^ ERROR mismatched types + x_isize > x_i64; + //~^ ERROR mismatched types + x_isize > x_i128; + //~^ ERROR mismatched types + } +} diff --git a/tests/ui/numeric/numeric-cast-binop-2.stderr b/tests/ui/numeric/numeric-cast-binop-2.stderr new file mode 100644 index 0000000000000..7050969d55165 --- /dev/null +++ b/tests/ui/numeric/numeric-cast-binop-2.stderr @@ -0,0 +1,783 @@ +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:23:16 + | +LL | x_u8 > x_u16; + | ---- ^^^^^ expected `u8`, found `u16` + | | + | expected because this is `u8` + | +help: you can convert `x_u8` from `u8` to `u16`, matching the type of `x_u16` + | +LL | u16::from(x_u8) > x_u16; + | ++++++++++ + + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:25:16 + | +LL | x_u8 > x_u32; + | ---- ^^^^^ expected `u8`, found `u32` + | | + | expected because this is `u8` + | +help: you can convert `x_u8` from `u8` to `u32`, matching the type of `x_u32` + | +LL | u32::from(x_u8) > x_u32; + | ++++++++++ + + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:27:16 + | +LL | x_u8 > x_u64; + | ---- ^^^^^ expected `u8`, found `u64` + | | + | expected because this is `u8` + | +help: you can convert `x_u8` from `u8` to `u64`, matching the type of `x_u64` + | +LL | u64::from(x_u8) > x_u64; + | ++++++++++ + + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:29:16 + | +LL | x_u8 > x_u128; + | ---- ^^^^^^ expected `u8`, found `u128` + | | + | expected because this is `u8` + | +help: you can convert `x_u8` from `u8` to `u128`, matching the type of `x_u128` + | +LL | u128::from(x_u8) > x_u128; + | +++++++++++ + + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:31:16 + | +LL | x_u8 > x_usize; + | ---- ^^^^^^^ expected `u8`, found `usize` + | | + | expected because this is `u8` + | +help: you can convert `x_u8` from `u8` to `usize`, matching the type of `x_usize` + | +LL | usize::from(x_u8) > x_usize; + | ++++++++++++ + + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:34:17 + | +LL | x_u16 > x_u8; + | ----- ^^^^ expected `u16`, found `u8` + | | + | expected because this is `u16` + | +help: you can convert a `u8` to a `u16` + | +LL | x_u16 > x_u8.into(); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:36:17 + | +LL | x_u16 > x_u32; + | ----- ^^^^^ expected `u16`, found `u32` + | | + | expected because this is `u16` + | +help: you can convert `x_u16` from `u16` to `u32`, matching the type of `x_u32` + | +LL | u32::from(x_u16) > x_u32; + | ++++++++++ + + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:38:17 + | +LL | x_u16 > x_u64; + | ----- ^^^^^ expected `u16`, found `u64` + | | + | expected because this is `u16` + | +help: you can convert `x_u16` from `u16` to `u64`, matching the type of `x_u64` + | +LL | u64::from(x_u16) > x_u64; + | ++++++++++ + + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:40:17 + | +LL | x_u16 > x_u128; + | ----- ^^^^^^ expected `u16`, found `u128` + | | + | expected because this is `u16` + | +help: you can convert `x_u16` from `u16` to `u128`, matching the type of `x_u128` + | +LL | u128::from(x_u16) > x_u128; + | +++++++++++ + + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:42:17 + | +LL | x_u16 > x_usize; + | ----- ^^^^^^^ expected `u16`, found `usize` + | | + | expected because this is `u16` + | +help: you can convert `x_u16` from `u16` to `usize`, matching the type of `x_usize` + | +LL | usize::from(x_u16) > x_usize; + | ++++++++++++ + + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:45:17 + | +LL | x_u32 > x_u8; + | ----- ^^^^ expected `u32`, found `u8` + | | + | expected because this is `u32` + | +help: you can convert a `u8` to a `u32` + | +LL | x_u32 > x_u8.into(); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:47:17 + | +LL | x_u32 > x_u16; + | ----- ^^^^^ expected `u32`, found `u16` + | | + | expected because this is `u32` + | +help: you can convert a `u16` to a `u32` + | +LL | x_u32 > x_u16.into(); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:49:17 + | +LL | x_u32 > x_u64; + | ----- ^^^^^ expected `u32`, found `u64` + | | + | expected because this is `u32` + | +help: you can convert `x_u32` from `u32` to `u64`, matching the type of `x_u64` + | +LL | u64::from(x_u32) > x_u64; + | ++++++++++ + + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:51:17 + | +LL | x_u32 > x_u128; + | ----- ^^^^^^ expected `u32`, found `u128` + | | + | expected because this is `u32` + | +help: you can convert `x_u32` from `u32` to `u128`, matching the type of `x_u128` + | +LL | u128::from(x_u32) > x_u128; + | +++++++++++ + + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:53:17 + | +LL | x_u32 > x_usize; + | ----- ^^^^^^^ expected `u32`, found `usize` + | | + | expected because this is `u32` + | +help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit + | +LL | x_u32 > x_usize.try_into().unwrap(); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:56:17 + | +LL | x_u64 > x_u8; + | ----- ^^^^ expected `u64`, found `u8` + | | + | expected because this is `u64` + | +help: you can convert a `u8` to a `u64` + | +LL | x_u64 > x_u8.into(); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:58:17 + | +LL | x_u64 > x_u16; + | ----- ^^^^^ expected `u64`, found `u16` + | | + | expected because this is `u64` + | +help: you can convert a `u16` to a `u64` + | +LL | x_u64 > x_u16.into(); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:60:17 + | +LL | x_u64 > x_u32; + | ----- ^^^^^ expected `u64`, found `u32` + | | + | expected because this is `u64` + | +help: you can convert a `u32` to a `u64` + | +LL | x_u64 > x_u32.into(); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:62:17 + | +LL | x_u64 > x_u128; + | ----- ^^^^^^ expected `u64`, found `u128` + | | + | expected because this is `u64` + | +help: you can convert `x_u64` from `u64` to `u128`, matching the type of `x_u128` + | +LL | u128::from(x_u64) > x_u128; + | +++++++++++ + + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:64:17 + | +LL | x_u64 > x_usize; + | ----- ^^^^^^^ expected `u64`, found `usize` + | | + | expected because this is `u64` + | +help: you can convert a `usize` to a `u64` and panic if the converted value doesn't fit + | +LL | x_u64 > x_usize.try_into().unwrap(); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:67:18 + | +LL | x_u128 > x_u8; + | ------ ^^^^ expected `u128`, found `u8` + | | + | expected because this is `u128` + | +help: you can convert a `u8` to a `u128` + | +LL | x_u128 > x_u8.into(); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:69:18 + | +LL | x_u128 > x_u16; + | ------ ^^^^^ expected `u128`, found `u16` + | | + | expected because this is `u128` + | +help: you can convert a `u16` to a `u128` + | +LL | x_u128 > x_u16.into(); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:71:18 + | +LL | x_u128 > x_u32; + | ------ ^^^^^ expected `u128`, found `u32` + | | + | expected because this is `u128` + | +help: you can convert a `u32` to a `u128` + | +LL | x_u128 > x_u32.into(); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:73:18 + | +LL | x_u128 > x_u64; + | ------ ^^^^^ expected `u128`, found `u64` + | | + | expected because this is `u128` + | +help: you can convert a `u64` to a `u128` + | +LL | x_u128 > x_u64.into(); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:75:18 + | +LL | x_u128 > x_usize; + | ------ ^^^^^^^ expected `u128`, found `usize` + | | + | expected because this is `u128` + | +help: you can convert a `usize` to a `u128` and panic if the converted value doesn't fit + | +LL | x_u128 > x_usize.try_into().unwrap(); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:78:19 + | +LL | x_usize > x_u8; + | ------- ^^^^ expected `usize`, found `u8` + | | + | expected because this is `usize` + | +help: you can convert a `u8` to a `usize` + | +LL | x_usize > x_u8.into(); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:80:19 + | +LL | x_usize > x_u16; + | ------- ^^^^^ expected `usize`, found `u16` + | | + | expected because this is `usize` + | +help: you can convert a `u16` to a `usize` + | +LL | x_usize > x_u16.into(); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:82:19 + | +LL | x_usize > x_u32; + | ------- ^^^^^ expected `usize`, found `u32` + | | + | expected because this is `usize` + | +help: you can convert a `u32` to a `usize` and panic if the converted value doesn't fit + | +LL | x_usize > x_u32.try_into().unwrap(); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:84:19 + | +LL | x_usize > x_u64; + | ------- ^^^^^ expected `usize`, found `u64` + | | + | expected because this is `usize` + | +help: you can convert a `u64` to a `usize` and panic if the converted value doesn't fit + | +LL | x_usize > x_u64.try_into().unwrap(); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:86:19 + | +LL | x_usize > x_u128; + | ------- ^^^^^^ expected `usize`, found `u128` + | | + | expected because this is `usize` + | +help: you can convert a `u128` to a `usize` and panic if the converted value doesn't fit + | +LL | x_usize > x_u128.try_into().unwrap(); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:92:16 + | +LL | x_i8 > x_i16; + | ---- ^^^^^ expected `i8`, found `i16` + | | + | expected because this is `i8` + | +help: you can convert `x_i8` from `i8` to `i16`, matching the type of `x_i16` + | +LL | i16::from(x_i8) > x_i16; + | ++++++++++ + + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:94:16 + | +LL | x_i8 > x_i32; + | ---- ^^^^^ expected `i8`, found `i32` + | | + | expected because this is `i8` + | +help: you can convert `x_i8` from `i8` to `i32`, matching the type of `x_i32` + | +LL | i32::from(x_i8) > x_i32; + | ++++++++++ + + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:96:16 + | +LL | x_i8 > x_i64; + | ---- ^^^^^ expected `i8`, found `i64` + | | + | expected because this is `i8` + | +help: you can convert `x_i8` from `i8` to `i64`, matching the type of `x_i64` + | +LL | i64::from(x_i8) > x_i64; + | ++++++++++ + + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:98:16 + | +LL | x_i8 > x_i128; + | ---- ^^^^^^ expected `i8`, found `i128` + | | + | expected because this is `i8` + | +help: you can convert `x_i8` from `i8` to `i128`, matching the type of `x_i128` + | +LL | i128::from(x_i8) > x_i128; + | +++++++++++ + + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:100:16 + | +LL | x_i8 > x_isize; + | ---- ^^^^^^^ expected `i8`, found `isize` + | | + | expected because this is `i8` + | +help: you can convert `x_i8` from `i8` to `isize`, matching the type of `x_isize` + | +LL | isize::from(x_i8) > x_isize; + | ++++++++++++ + + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:103:17 + | +LL | x_i16 > x_i8; + | ----- ^^^^ expected `i16`, found `i8` + | | + | expected because this is `i16` + | +help: you can convert an `i8` to an `i16` + | +LL | x_i16 > x_i8.into(); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:105:17 + | +LL | x_i16 > x_i32; + | ----- ^^^^^ expected `i16`, found `i32` + | | + | expected because this is `i16` + | +help: you can convert `x_i16` from `i16` to `i32`, matching the type of `x_i32` + | +LL | i32::from(x_i16) > x_i32; + | ++++++++++ + + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:107:17 + | +LL | x_i16 > x_i64; + | ----- ^^^^^ expected `i16`, found `i64` + | | + | expected because this is `i16` + | +help: you can convert `x_i16` from `i16` to `i64`, matching the type of `x_i64` + | +LL | i64::from(x_i16) > x_i64; + | ++++++++++ + + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:109:17 + | +LL | x_i16 > x_i128; + | ----- ^^^^^^ expected `i16`, found `i128` + | | + | expected because this is `i16` + | +help: you can convert `x_i16` from `i16` to `i128`, matching the type of `x_i128` + | +LL | i128::from(x_i16) > x_i128; + | +++++++++++ + + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:111:17 + | +LL | x_i16 > x_isize; + | ----- ^^^^^^^ expected `i16`, found `isize` + | | + | expected because this is `i16` + | +help: you can convert `x_i16` from `i16` to `isize`, matching the type of `x_isize` + | +LL | isize::from(x_i16) > x_isize; + | ++++++++++++ + + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:114:17 + | +LL | x_i32 > x_i8; + | ----- ^^^^ expected `i32`, found `i8` + | | + | expected because this is `i32` + | +help: you can convert an `i8` to an `i32` + | +LL | x_i32 > x_i8.into(); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:116:17 + | +LL | x_i32 > x_i16; + | ----- ^^^^^ expected `i32`, found `i16` + | | + | expected because this is `i32` + | +help: you can convert an `i16` to an `i32` + | +LL | x_i32 > x_i16.into(); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:118:17 + | +LL | x_i32 > x_i64; + | ----- ^^^^^ expected `i32`, found `i64` + | | + | expected because this is `i32` + | +help: you can convert `x_i32` from `i32` to `i64`, matching the type of `x_i64` + | +LL | i64::from(x_i32) > x_i64; + | ++++++++++ + + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:120:17 + | +LL | x_i32 > x_i128; + | ----- ^^^^^^ expected `i32`, found `i128` + | | + | expected because this is `i32` + | +help: you can convert `x_i32` from `i32` to `i128`, matching the type of `x_i128` + | +LL | i128::from(x_i32) > x_i128; + | +++++++++++ + + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:122:17 + | +LL | x_i32 > x_isize; + | ----- ^^^^^^^ expected `i32`, found `isize` + | | + | expected because this is `i32` + | +help: you can convert an `isize` to an `i32` and panic if the converted value doesn't fit + | +LL | x_i32 > x_isize.try_into().unwrap(); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:125:17 + | +LL | x_i64 > x_i8; + | ----- ^^^^ expected `i64`, found `i8` + | | + | expected because this is `i64` + | +help: you can convert an `i8` to an `i64` + | +LL | x_i64 > x_i8.into(); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:127:17 + | +LL | x_i64 > x_i16; + | ----- ^^^^^ expected `i64`, found `i16` + | | + | expected because this is `i64` + | +help: you can convert an `i16` to an `i64` + | +LL | x_i64 > x_i16.into(); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:129:17 + | +LL | x_i64 > x_i32; + | ----- ^^^^^ expected `i64`, found `i32` + | | + | expected because this is `i64` + | +help: you can convert an `i32` to an `i64` + | +LL | x_i64 > x_i32.into(); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:131:17 + | +LL | x_i64 > x_i128; + | ----- ^^^^^^ expected `i64`, found `i128` + | | + | expected because this is `i64` + | +help: you can convert `x_i64` from `i64` to `i128`, matching the type of `x_i128` + | +LL | i128::from(x_i64) > x_i128; + | +++++++++++ + + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:133:17 + | +LL | x_i64 > x_isize; + | ----- ^^^^^^^ expected `i64`, found `isize` + | | + | expected because this is `i64` + | +help: you can convert an `isize` to an `i64` and panic if the converted value doesn't fit + | +LL | x_i64 > x_isize.try_into().unwrap(); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:136:18 + | +LL | x_i128 > x_i8; + | ------ ^^^^ expected `i128`, found `i8` + | | + | expected because this is `i128` + | +help: you can convert an `i8` to an `i128` + | +LL | x_i128 > x_i8.into(); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:138:18 + | +LL | x_i128 > x_i16; + | ------ ^^^^^ expected `i128`, found `i16` + | | + | expected because this is `i128` + | +help: you can convert an `i16` to an `i128` + | +LL | x_i128 > x_i16.into(); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:140:18 + | +LL | x_i128 > x_i32; + | ------ ^^^^^ expected `i128`, found `i32` + | | + | expected because this is `i128` + | +help: you can convert an `i32` to an `i128` + | +LL | x_i128 > x_i32.into(); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:142:18 + | +LL | x_i128 > x_i64; + | ------ ^^^^^ expected `i128`, found `i64` + | | + | expected because this is `i128` + | +help: you can convert an `i64` to an `i128` + | +LL | x_i128 > x_i64.into(); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:144:18 + | +LL | x_i128 > x_isize; + | ------ ^^^^^^^ expected `i128`, found `isize` + | | + | expected because this is `i128` + | +help: you can convert an `isize` to an `i128` and panic if the converted value doesn't fit + | +LL | x_i128 > x_isize.try_into().unwrap(); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:147:19 + | +LL | x_isize > x_i8; + | ------- ^^^^ expected `isize`, found `i8` + | | + | expected because this is `isize` + | +help: you can convert an `i8` to an `isize` + | +LL | x_isize > x_i8.into(); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:149:19 + | +LL | x_isize > x_i16; + | ------- ^^^^^ expected `isize`, found `i16` + | | + | expected because this is `isize` + | +help: you can convert an `i16` to an `isize` + | +LL | x_isize > x_i16.into(); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:151:19 + | +LL | x_isize > x_i32; + | ------- ^^^^^ expected `isize`, found `i32` + | | + | expected because this is `isize` + | +help: you can convert an `i32` to an `isize` and panic if the converted value doesn't fit + | +LL | x_isize > x_i32.try_into().unwrap(); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:153:19 + | +LL | x_isize > x_i64; + | ------- ^^^^^ expected `isize`, found `i64` + | | + | expected because this is `isize` + | +help: you can convert an `i64` to an `isize` and panic if the converted value doesn't fit + | +LL | x_isize > x_i64.try_into().unwrap(); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:155:19 + | +LL | x_isize > x_i128; + | ------- ^^^^^^ expected `isize`, found `i128` + | | + | expected because this is `isize` + | +help: you can convert an `i128` to an `isize` and panic if the converted value doesn't fit + | +LL | x_isize > x_i128.try_into().unwrap(); + | ++++++++++++++++++++ + +error: aborting due to 60 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/numeric/numeric-cast-binop.fixed b/tests/ui/numeric/numeric-cast-binop.fixed index edb085e71d324..252c7ab0de3e4 100644 --- a/tests/ui/numeric/numeric-cast-binop.fixed +++ b/tests/ui/numeric/numeric-cast-binop.fixed @@ -18,144 +18,6 @@ fn main() { let x_i8: i8 = 11; let x_i128: i128 = 12; - /* u<->u */ - { - u16::from(x_u8) > x_u16; - //~^ ERROR mismatched types - u32::from(x_u8) > x_u32; - //~^ ERROR mismatched types - u64::from(x_u8) > x_u64; - //~^ ERROR mismatched types - u128::from(x_u8) > x_u128; - //~^ ERROR mismatched types - usize::from(x_u8) > x_usize; - //~^ ERROR mismatched types - - x_u16 > x_u8.into(); - //~^ ERROR mismatched types - u32::from(x_u16) > x_u32; - //~^ ERROR mismatched types - u64::from(x_u16) > x_u64; - //~^ ERROR mismatched types - u128::from(x_u16) > x_u128; - //~^ ERROR mismatched types - usize::from(x_u16) > x_usize; - //~^ ERROR mismatched types - - x_u32 > x_u8.into(); - //~^ ERROR mismatched types - x_u32 > x_u16.into(); - //~^ ERROR mismatched types - u64::from(x_u32) > x_u64; - //~^ ERROR mismatched types - u128::from(x_u32) > x_u128; - //~^ ERROR mismatched types - x_u32 > x_usize.try_into().unwrap(); - //~^ ERROR mismatched types - - x_u64 > x_u8.into(); - //~^ ERROR mismatched types - x_u64 > x_u16.into(); - //~^ ERROR mismatched types - x_u64 > x_u32.into(); - //~^ ERROR mismatched types - u128::from(x_u64) > x_u128; - //~^ ERROR mismatched types - x_u64 > x_usize.try_into().unwrap(); - //~^ ERROR mismatched types - - x_u128 > x_u8.into(); - //~^ ERROR mismatched types - x_u128 > x_u16.into(); - //~^ ERROR mismatched types - x_u128 > x_u32.into(); - //~^ ERROR mismatched types - x_u128 > x_u64.into(); - //~^ ERROR mismatched types - x_u128 > x_usize.try_into().unwrap(); - //~^ ERROR mismatched types - - x_usize > x_u8.into(); - //~^ ERROR mismatched types - x_usize > x_u16.into(); - //~^ ERROR mismatched types - x_usize > x_u32.try_into().unwrap(); - //~^ ERROR mismatched types - x_usize > x_u64.try_into().unwrap(); - //~^ ERROR mismatched types - x_usize > x_u128.try_into().unwrap(); - //~^ ERROR mismatched types - } - - /* i<->i */ - { - i16::from(x_i8) > x_i16; - //~^ ERROR mismatched types - i32::from(x_i8) > x_i32; - //~^ ERROR mismatched types - i64::from(x_i8) > x_i64; - //~^ ERROR mismatched types - i128::from(x_i8) > x_i128; - //~^ ERROR mismatched types - isize::from(x_i8) > x_isize; - //~^ ERROR mismatched types - - x_i16 > x_i8.into(); - //~^ ERROR mismatched types - i32::from(x_i16) > x_i32; - //~^ ERROR mismatched types - i64::from(x_i16) > x_i64; - //~^ ERROR mismatched types - i128::from(x_i16) > x_i128; - //~^ ERROR mismatched types - isize::from(x_i16) > x_isize; - //~^ ERROR mismatched types - - x_i32 > x_i8.into(); - //~^ ERROR mismatched types - x_i32 > x_i16.into(); - //~^ ERROR mismatched types - i64::from(x_i32) > x_i64; - //~^ ERROR mismatched types - i128::from(x_i32) > x_i128; - //~^ ERROR mismatched types - x_i32 > x_isize.try_into().unwrap(); - //~^ ERROR mismatched types - - x_i64 > x_i8.into(); - //~^ ERROR mismatched types - x_i64 > x_i16.into(); - //~^ ERROR mismatched types - x_i64 > x_i32.into(); - //~^ ERROR mismatched types - i128::from(x_i64) > x_i128; - //~^ ERROR mismatched types - x_i64 > x_isize.try_into().unwrap(); - //~^ ERROR mismatched types - - x_i128 > x_i8.into(); - //~^ ERROR mismatched types - x_i128 > x_i16.into(); - //~^ ERROR mismatched types - x_i128 > x_i32.into(); - //~^ ERROR mismatched types - x_i128 > x_i64.into(); - //~^ ERROR mismatched types - x_i128 > x_isize.try_into().unwrap(); - //~^ ERROR mismatched types - - x_isize > x_i8.into(); - //~^ ERROR mismatched types - x_isize > x_i16.into(); - //~^ ERROR mismatched types - x_isize > x_i32.try_into().unwrap(); - //~^ ERROR mismatched types - x_isize > x_i64.try_into().unwrap(); - //~^ ERROR mismatched types - x_isize > x_i128.try_into().unwrap(); - //~^ ERROR mismatched types - } - /* u<->i */ { x_u8 > x_i8.try_into().unwrap(); diff --git a/tests/ui/numeric/numeric-cast-binop.rs b/tests/ui/numeric/numeric-cast-binop.rs index c1ed8de8ad8c3..e77b696fce359 100644 --- a/tests/ui/numeric/numeric-cast-binop.rs +++ b/tests/ui/numeric/numeric-cast-binop.rs @@ -18,144 +18,6 @@ fn main() { let x_i8: i8 = 11; let x_i128: i128 = 12; - /* u<->u */ - { - x_u8 > x_u16; - //~^ ERROR mismatched types - x_u8 > x_u32; - //~^ ERROR mismatched types - x_u8 > x_u64; - //~^ ERROR mismatched types - x_u8 > x_u128; - //~^ ERROR mismatched types - x_u8 > x_usize; - //~^ ERROR mismatched types - - x_u16 > x_u8; - //~^ ERROR mismatched types - x_u16 > x_u32; - //~^ ERROR mismatched types - x_u16 > x_u64; - //~^ ERROR mismatched types - x_u16 > x_u128; - //~^ ERROR mismatched types - x_u16 > x_usize; - //~^ ERROR mismatched types - - x_u32 > x_u8; - //~^ ERROR mismatched types - x_u32 > x_u16; - //~^ ERROR mismatched types - x_u32 > x_u64; - //~^ ERROR mismatched types - x_u32 > x_u128; - //~^ ERROR mismatched types - x_u32 > x_usize; - //~^ ERROR mismatched types - - x_u64 > x_u8; - //~^ ERROR mismatched types - x_u64 > x_u16; - //~^ ERROR mismatched types - x_u64 > x_u32; - //~^ ERROR mismatched types - x_u64 > x_u128; - //~^ ERROR mismatched types - x_u64 > x_usize; - //~^ ERROR mismatched types - - x_u128 > x_u8; - //~^ ERROR mismatched types - x_u128 > x_u16; - //~^ ERROR mismatched types - x_u128 > x_u32; - //~^ ERROR mismatched types - x_u128 > x_u64; - //~^ ERROR mismatched types - x_u128 > x_usize; - //~^ ERROR mismatched types - - x_usize > x_u8; - //~^ ERROR mismatched types - x_usize > x_u16; - //~^ ERROR mismatched types - x_usize > x_u32; - //~^ ERROR mismatched types - x_usize > x_u64; - //~^ ERROR mismatched types - x_usize > x_u128; - //~^ ERROR mismatched types - } - - /* i<->i */ - { - x_i8 > x_i16; - //~^ ERROR mismatched types - x_i8 > x_i32; - //~^ ERROR mismatched types - x_i8 > x_i64; - //~^ ERROR mismatched types - x_i8 > x_i128; - //~^ ERROR mismatched types - x_i8 > x_isize; - //~^ ERROR mismatched types - - x_i16 > x_i8; - //~^ ERROR mismatched types - x_i16 > x_i32; - //~^ ERROR mismatched types - x_i16 > x_i64; - //~^ ERROR mismatched types - x_i16 > x_i128; - //~^ ERROR mismatched types - x_i16 > x_isize; - //~^ ERROR mismatched types - - x_i32 > x_i8; - //~^ ERROR mismatched types - x_i32 > x_i16; - //~^ ERROR mismatched types - x_i32 > x_i64; - //~^ ERROR mismatched types - x_i32 > x_i128; - //~^ ERROR mismatched types - x_i32 > x_isize; - //~^ ERROR mismatched types - - x_i64 > x_i8; - //~^ ERROR mismatched types - x_i64 > x_i16; - //~^ ERROR mismatched types - x_i64 > x_i32; - //~^ ERROR mismatched types - x_i64 > x_i128; - //~^ ERROR mismatched types - x_i64 > x_isize; - //~^ ERROR mismatched types - - x_i128 > x_i8; - //~^ ERROR mismatched types - x_i128 > x_i16; - //~^ ERROR mismatched types - x_i128 > x_i32; - //~^ ERROR mismatched types - x_i128 > x_i64; - //~^ ERROR mismatched types - x_i128 > x_isize; - //~^ ERROR mismatched types - - x_isize > x_i8; - //~^ ERROR mismatched types - x_isize > x_i16; - //~^ ERROR mismatched types - x_isize > x_i32; - //~^ ERROR mismatched types - x_isize > x_i64; - //~^ ERROR mismatched types - x_isize > x_i128; - //~^ ERROR mismatched types - } - /* u<->i */ { x_u8 > x_i8; diff --git a/tests/ui/numeric/numeric-cast-binop.stderr b/tests/ui/numeric/numeric-cast-binop.stderr index d5213e3f5b690..2f7bdc37a337b 100644 --- a/tests/ui/numeric/numeric-cast-binop.stderr +++ b/tests/ui/numeric/numeric-cast-binop.stderr @@ -1,786 +1,6 @@ error[E0308]: mismatched types --> $DIR/numeric-cast-binop.rs:23:16 | -LL | x_u8 > x_u16; - | ---- ^^^^^ expected `u8`, found `u16` - | | - | expected because this is `u8` - | -help: you can convert `x_u8` from `u8` to `u16`, matching the type of `x_u16` - | -LL | u16::from(x_u8) > x_u16; - | ++++++++++ + - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:25:16 - | -LL | x_u8 > x_u32; - | ---- ^^^^^ expected `u8`, found `u32` - | | - | expected because this is `u8` - | -help: you can convert `x_u8` from `u8` to `u32`, matching the type of `x_u32` - | -LL | u32::from(x_u8) > x_u32; - | ++++++++++ + - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:27:16 - | -LL | x_u8 > x_u64; - | ---- ^^^^^ expected `u8`, found `u64` - | | - | expected because this is `u8` - | -help: you can convert `x_u8` from `u8` to `u64`, matching the type of `x_u64` - | -LL | u64::from(x_u8) > x_u64; - | ++++++++++ + - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:29:16 - | -LL | x_u8 > x_u128; - | ---- ^^^^^^ expected `u8`, found `u128` - | | - | expected because this is `u8` - | -help: you can convert `x_u8` from `u8` to `u128`, matching the type of `x_u128` - | -LL | u128::from(x_u8) > x_u128; - | +++++++++++ + - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:31:16 - | -LL | x_u8 > x_usize; - | ---- ^^^^^^^ expected `u8`, found `usize` - | | - | expected because this is `u8` - | -help: you can convert `x_u8` from `u8` to `usize`, matching the type of `x_usize` - | -LL | usize::from(x_u8) > x_usize; - | ++++++++++++ + - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:34:17 - | -LL | x_u16 > x_u8; - | ----- ^^^^ expected `u16`, found `u8` - | | - | expected because this is `u16` - | -help: you can convert a `u8` to a `u16` - | -LL | x_u16 > x_u8.into(); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:36:17 - | -LL | x_u16 > x_u32; - | ----- ^^^^^ expected `u16`, found `u32` - | | - | expected because this is `u16` - | -help: you can convert `x_u16` from `u16` to `u32`, matching the type of `x_u32` - | -LL | u32::from(x_u16) > x_u32; - | ++++++++++ + - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:38:17 - | -LL | x_u16 > x_u64; - | ----- ^^^^^ expected `u16`, found `u64` - | | - | expected because this is `u16` - | -help: you can convert `x_u16` from `u16` to `u64`, matching the type of `x_u64` - | -LL | u64::from(x_u16) > x_u64; - | ++++++++++ + - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:40:17 - | -LL | x_u16 > x_u128; - | ----- ^^^^^^ expected `u16`, found `u128` - | | - | expected because this is `u16` - | -help: you can convert `x_u16` from `u16` to `u128`, matching the type of `x_u128` - | -LL | u128::from(x_u16) > x_u128; - | +++++++++++ + - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:42:17 - | -LL | x_u16 > x_usize; - | ----- ^^^^^^^ expected `u16`, found `usize` - | | - | expected because this is `u16` - | -help: you can convert `x_u16` from `u16` to `usize`, matching the type of `x_usize` - | -LL | usize::from(x_u16) > x_usize; - | ++++++++++++ + - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:45:17 - | -LL | x_u32 > x_u8; - | ----- ^^^^ expected `u32`, found `u8` - | | - | expected because this is `u32` - | -help: you can convert a `u8` to a `u32` - | -LL | x_u32 > x_u8.into(); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:47:17 - | -LL | x_u32 > x_u16; - | ----- ^^^^^ expected `u32`, found `u16` - | | - | expected because this is `u32` - | -help: you can convert a `u16` to a `u32` - | -LL | x_u32 > x_u16.into(); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:49:17 - | -LL | x_u32 > x_u64; - | ----- ^^^^^ expected `u32`, found `u64` - | | - | expected because this is `u32` - | -help: you can convert `x_u32` from `u32` to `u64`, matching the type of `x_u64` - | -LL | u64::from(x_u32) > x_u64; - | ++++++++++ + - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:51:17 - | -LL | x_u32 > x_u128; - | ----- ^^^^^^ expected `u32`, found `u128` - | | - | expected because this is `u32` - | -help: you can convert `x_u32` from `u32` to `u128`, matching the type of `x_u128` - | -LL | u128::from(x_u32) > x_u128; - | +++++++++++ + - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:53:17 - | -LL | x_u32 > x_usize; - | ----- ^^^^^^^ expected `u32`, found `usize` - | | - | expected because this is `u32` - | -help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit - | -LL | x_u32 > x_usize.try_into().unwrap(); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:56:17 - | -LL | x_u64 > x_u8; - | ----- ^^^^ expected `u64`, found `u8` - | | - | expected because this is `u64` - | -help: you can convert a `u8` to a `u64` - | -LL | x_u64 > x_u8.into(); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:58:17 - | -LL | x_u64 > x_u16; - | ----- ^^^^^ expected `u64`, found `u16` - | | - | expected because this is `u64` - | -help: you can convert a `u16` to a `u64` - | -LL | x_u64 > x_u16.into(); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:60:17 - | -LL | x_u64 > x_u32; - | ----- ^^^^^ expected `u64`, found `u32` - | | - | expected because this is `u64` - | -help: you can convert a `u32` to a `u64` - | -LL | x_u64 > x_u32.into(); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:62:17 - | -LL | x_u64 > x_u128; - | ----- ^^^^^^ expected `u64`, found `u128` - | | - | expected because this is `u64` - | -help: you can convert `x_u64` from `u64` to `u128`, matching the type of `x_u128` - | -LL | u128::from(x_u64) > x_u128; - | +++++++++++ + - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:64:17 - | -LL | x_u64 > x_usize; - | ----- ^^^^^^^ expected `u64`, found `usize` - | | - | expected because this is `u64` - | -help: you can convert a `usize` to a `u64` and panic if the converted value doesn't fit - | -LL | x_u64 > x_usize.try_into().unwrap(); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:67:18 - | -LL | x_u128 > x_u8; - | ------ ^^^^ expected `u128`, found `u8` - | | - | expected because this is `u128` - | -help: you can convert a `u8` to a `u128` - | -LL | x_u128 > x_u8.into(); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:69:18 - | -LL | x_u128 > x_u16; - | ------ ^^^^^ expected `u128`, found `u16` - | | - | expected because this is `u128` - | -help: you can convert a `u16` to a `u128` - | -LL | x_u128 > x_u16.into(); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:71:18 - | -LL | x_u128 > x_u32; - | ------ ^^^^^ expected `u128`, found `u32` - | | - | expected because this is `u128` - | -help: you can convert a `u32` to a `u128` - | -LL | x_u128 > x_u32.into(); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:73:18 - | -LL | x_u128 > x_u64; - | ------ ^^^^^ expected `u128`, found `u64` - | | - | expected because this is `u128` - | -help: you can convert a `u64` to a `u128` - | -LL | x_u128 > x_u64.into(); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:75:18 - | -LL | x_u128 > x_usize; - | ------ ^^^^^^^ expected `u128`, found `usize` - | | - | expected because this is `u128` - | -help: you can convert a `usize` to a `u128` and panic if the converted value doesn't fit - | -LL | x_u128 > x_usize.try_into().unwrap(); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:78:19 - | -LL | x_usize > x_u8; - | ------- ^^^^ expected `usize`, found `u8` - | | - | expected because this is `usize` - | -help: you can convert a `u8` to a `usize` - | -LL | x_usize > x_u8.into(); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:80:19 - | -LL | x_usize > x_u16; - | ------- ^^^^^ expected `usize`, found `u16` - | | - | expected because this is `usize` - | -help: you can convert a `u16` to a `usize` - | -LL | x_usize > x_u16.into(); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:82:19 - | -LL | x_usize > x_u32; - | ------- ^^^^^ expected `usize`, found `u32` - | | - | expected because this is `usize` - | -help: you can convert a `u32` to a `usize` and panic if the converted value doesn't fit - | -LL | x_usize > x_u32.try_into().unwrap(); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:84:19 - | -LL | x_usize > x_u64; - | ------- ^^^^^ expected `usize`, found `u64` - | | - | expected because this is `usize` - | -help: you can convert a `u64` to a `usize` and panic if the converted value doesn't fit - | -LL | x_usize > x_u64.try_into().unwrap(); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:86:19 - | -LL | x_usize > x_u128; - | ------- ^^^^^^ expected `usize`, found `u128` - | | - | expected because this is `usize` - | -help: you can convert a `u128` to a `usize` and panic if the converted value doesn't fit - | -LL | x_usize > x_u128.try_into().unwrap(); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:92:16 - | -LL | x_i8 > x_i16; - | ---- ^^^^^ expected `i8`, found `i16` - | | - | expected because this is `i8` - | -help: you can convert `x_i8` from `i8` to `i16`, matching the type of `x_i16` - | -LL | i16::from(x_i8) > x_i16; - | ++++++++++ + - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:94:16 - | -LL | x_i8 > x_i32; - | ---- ^^^^^ expected `i8`, found `i32` - | | - | expected because this is `i8` - | -help: you can convert `x_i8` from `i8` to `i32`, matching the type of `x_i32` - | -LL | i32::from(x_i8) > x_i32; - | ++++++++++ + - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:96:16 - | -LL | x_i8 > x_i64; - | ---- ^^^^^ expected `i8`, found `i64` - | | - | expected because this is `i8` - | -help: you can convert `x_i8` from `i8` to `i64`, matching the type of `x_i64` - | -LL | i64::from(x_i8) > x_i64; - | ++++++++++ + - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:98:16 - | -LL | x_i8 > x_i128; - | ---- ^^^^^^ expected `i8`, found `i128` - | | - | expected because this is `i8` - | -help: you can convert `x_i8` from `i8` to `i128`, matching the type of `x_i128` - | -LL | i128::from(x_i8) > x_i128; - | +++++++++++ + - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:100:16 - | -LL | x_i8 > x_isize; - | ---- ^^^^^^^ expected `i8`, found `isize` - | | - | expected because this is `i8` - | -help: you can convert `x_i8` from `i8` to `isize`, matching the type of `x_isize` - | -LL | isize::from(x_i8) > x_isize; - | ++++++++++++ + - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:103:17 - | -LL | x_i16 > x_i8; - | ----- ^^^^ expected `i16`, found `i8` - | | - | expected because this is `i16` - | -help: you can convert an `i8` to an `i16` - | -LL | x_i16 > x_i8.into(); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:105:17 - | -LL | x_i16 > x_i32; - | ----- ^^^^^ expected `i16`, found `i32` - | | - | expected because this is `i16` - | -help: you can convert `x_i16` from `i16` to `i32`, matching the type of `x_i32` - | -LL | i32::from(x_i16) > x_i32; - | ++++++++++ + - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:107:17 - | -LL | x_i16 > x_i64; - | ----- ^^^^^ expected `i16`, found `i64` - | | - | expected because this is `i16` - | -help: you can convert `x_i16` from `i16` to `i64`, matching the type of `x_i64` - | -LL | i64::from(x_i16) > x_i64; - | ++++++++++ + - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:109:17 - | -LL | x_i16 > x_i128; - | ----- ^^^^^^ expected `i16`, found `i128` - | | - | expected because this is `i16` - | -help: you can convert `x_i16` from `i16` to `i128`, matching the type of `x_i128` - | -LL | i128::from(x_i16) > x_i128; - | +++++++++++ + - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:111:17 - | -LL | x_i16 > x_isize; - | ----- ^^^^^^^ expected `i16`, found `isize` - | | - | expected because this is `i16` - | -help: you can convert `x_i16` from `i16` to `isize`, matching the type of `x_isize` - | -LL | isize::from(x_i16) > x_isize; - | ++++++++++++ + - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:114:17 - | -LL | x_i32 > x_i8; - | ----- ^^^^ expected `i32`, found `i8` - | | - | expected because this is `i32` - | -help: you can convert an `i8` to an `i32` - | -LL | x_i32 > x_i8.into(); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:116:17 - | -LL | x_i32 > x_i16; - | ----- ^^^^^ expected `i32`, found `i16` - | | - | expected because this is `i32` - | -help: you can convert an `i16` to an `i32` - | -LL | x_i32 > x_i16.into(); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:118:17 - | -LL | x_i32 > x_i64; - | ----- ^^^^^ expected `i32`, found `i64` - | | - | expected because this is `i32` - | -help: you can convert `x_i32` from `i32` to `i64`, matching the type of `x_i64` - | -LL | i64::from(x_i32) > x_i64; - | ++++++++++ + - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:120:17 - | -LL | x_i32 > x_i128; - | ----- ^^^^^^ expected `i32`, found `i128` - | | - | expected because this is `i32` - | -help: you can convert `x_i32` from `i32` to `i128`, matching the type of `x_i128` - | -LL | i128::from(x_i32) > x_i128; - | +++++++++++ + - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:122:17 - | -LL | x_i32 > x_isize; - | ----- ^^^^^^^ expected `i32`, found `isize` - | | - | expected because this is `i32` - | -help: you can convert an `isize` to an `i32` and panic if the converted value doesn't fit - | -LL | x_i32 > x_isize.try_into().unwrap(); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:125:17 - | -LL | x_i64 > x_i8; - | ----- ^^^^ expected `i64`, found `i8` - | | - | expected because this is `i64` - | -help: you can convert an `i8` to an `i64` - | -LL | x_i64 > x_i8.into(); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:127:17 - | -LL | x_i64 > x_i16; - | ----- ^^^^^ expected `i64`, found `i16` - | | - | expected because this is `i64` - | -help: you can convert an `i16` to an `i64` - | -LL | x_i64 > x_i16.into(); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:129:17 - | -LL | x_i64 > x_i32; - | ----- ^^^^^ expected `i64`, found `i32` - | | - | expected because this is `i64` - | -help: you can convert an `i32` to an `i64` - | -LL | x_i64 > x_i32.into(); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:131:17 - | -LL | x_i64 > x_i128; - | ----- ^^^^^^ expected `i64`, found `i128` - | | - | expected because this is `i64` - | -help: you can convert `x_i64` from `i64` to `i128`, matching the type of `x_i128` - | -LL | i128::from(x_i64) > x_i128; - | +++++++++++ + - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:133:17 - | -LL | x_i64 > x_isize; - | ----- ^^^^^^^ expected `i64`, found `isize` - | | - | expected because this is `i64` - | -help: you can convert an `isize` to an `i64` and panic if the converted value doesn't fit - | -LL | x_i64 > x_isize.try_into().unwrap(); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:136:18 - | -LL | x_i128 > x_i8; - | ------ ^^^^ expected `i128`, found `i8` - | | - | expected because this is `i128` - | -help: you can convert an `i8` to an `i128` - | -LL | x_i128 > x_i8.into(); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:138:18 - | -LL | x_i128 > x_i16; - | ------ ^^^^^ expected `i128`, found `i16` - | | - | expected because this is `i128` - | -help: you can convert an `i16` to an `i128` - | -LL | x_i128 > x_i16.into(); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:140:18 - | -LL | x_i128 > x_i32; - | ------ ^^^^^ expected `i128`, found `i32` - | | - | expected because this is `i128` - | -help: you can convert an `i32` to an `i128` - | -LL | x_i128 > x_i32.into(); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:142:18 - | -LL | x_i128 > x_i64; - | ------ ^^^^^ expected `i128`, found `i64` - | | - | expected because this is `i128` - | -help: you can convert an `i64` to an `i128` - | -LL | x_i128 > x_i64.into(); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:144:18 - | -LL | x_i128 > x_isize; - | ------ ^^^^^^^ expected `i128`, found `isize` - | | - | expected because this is `i128` - | -help: you can convert an `isize` to an `i128` and panic if the converted value doesn't fit - | -LL | x_i128 > x_isize.try_into().unwrap(); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:147:19 - | -LL | x_isize > x_i8; - | ------- ^^^^ expected `isize`, found `i8` - | | - | expected because this is `isize` - | -help: you can convert an `i8` to an `isize` - | -LL | x_isize > x_i8.into(); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:149:19 - | -LL | x_isize > x_i16; - | ------- ^^^^^ expected `isize`, found `i16` - | | - | expected because this is `isize` - | -help: you can convert an `i16` to an `isize` - | -LL | x_isize > x_i16.into(); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:151:19 - | -LL | x_isize > x_i32; - | ------- ^^^^^ expected `isize`, found `i32` - | | - | expected because this is `isize` - | -help: you can convert an `i32` to an `isize` and panic if the converted value doesn't fit - | -LL | x_isize > x_i32.try_into().unwrap(); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:153:19 - | -LL | x_isize > x_i64; - | ------- ^^^^^ expected `isize`, found `i64` - | | - | expected because this is `isize` - | -help: you can convert an `i64` to an `isize` and panic if the converted value doesn't fit - | -LL | x_isize > x_i64.try_into().unwrap(); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:155:19 - | -LL | x_isize > x_i128; - | ------- ^^^^^^ expected `isize`, found `i128` - | | - | expected because this is `isize` - | -help: you can convert an `i128` to an `isize` and panic if the converted value doesn't fit - | -LL | x_isize > x_i128.try_into().unwrap(); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:161:16 - | LL | x_u8 > x_i8; | ---- ^^^^ expected `u8`, found `i8` | | @@ -792,7 +12,7 @@ LL | x_u8 > x_i8.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:163:16 + --> $DIR/numeric-cast-binop.rs:25:16 | LL | x_u8 > x_i16; | ---- ^^^^^ expected `u8`, found `i16` @@ -805,7 +25,7 @@ LL | i16::from(x_u8) > x_i16; | ++++++++++ + error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:165:16 + --> $DIR/numeric-cast-binop.rs:27:16 | LL | x_u8 > x_i32; | ---- ^^^^^ expected `u8`, found `i32` @@ -818,7 +38,7 @@ LL | i32::from(x_u8) > x_i32; | ++++++++++ + error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:167:16 + --> $DIR/numeric-cast-binop.rs:29:16 | LL | x_u8 > x_i64; | ---- ^^^^^ expected `u8`, found `i64` @@ -831,7 +51,7 @@ LL | i64::from(x_u8) > x_i64; | ++++++++++ + error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:169:16 + --> $DIR/numeric-cast-binop.rs:31:16 | LL | x_u8 > x_i128; | ---- ^^^^^^ expected `u8`, found `i128` @@ -844,7 +64,7 @@ LL | i128::from(x_u8) > x_i128; | +++++++++++ + error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:171:16 + --> $DIR/numeric-cast-binop.rs:33:16 | LL | x_u8 > x_isize; | ---- ^^^^^^^ expected `u8`, found `isize` @@ -857,7 +77,7 @@ LL | isize::from(x_u8) > x_isize; | ++++++++++++ + error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:174:17 + --> $DIR/numeric-cast-binop.rs:36:17 | LL | x_u16 > x_i8; | ----- ^^^^ expected `u16`, found `i8` @@ -870,7 +90,7 @@ LL | x_u16 > x_i8.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:176:17 + --> $DIR/numeric-cast-binop.rs:38:17 | LL | x_u16 > x_i16; | ----- ^^^^^ expected `u16`, found `i16` @@ -883,7 +103,7 @@ LL | x_u16 > x_i16.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:178:17 + --> $DIR/numeric-cast-binop.rs:40:17 | LL | x_u16 > x_i32; | ----- ^^^^^ expected `u16`, found `i32` @@ -896,7 +116,7 @@ LL | i32::from(x_u16) > x_i32; | ++++++++++ + error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:180:17 + --> $DIR/numeric-cast-binop.rs:42:17 | LL | x_u16 > x_i64; | ----- ^^^^^ expected `u16`, found `i64` @@ -909,7 +129,7 @@ LL | i64::from(x_u16) > x_i64; | ++++++++++ + error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:182:17 + --> $DIR/numeric-cast-binop.rs:44:17 | LL | x_u16 > x_i128; | ----- ^^^^^^ expected `u16`, found `i128` @@ -922,7 +142,7 @@ LL | i128::from(x_u16) > x_i128; | +++++++++++ + error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:184:17 + --> $DIR/numeric-cast-binop.rs:46:17 | LL | x_u16 > x_isize; | ----- ^^^^^^^ expected `u16`, found `isize` @@ -935,7 +155,7 @@ LL | x_u16 > x_isize.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:187:17 + --> $DIR/numeric-cast-binop.rs:49:17 | LL | x_u32 > x_i8; | ----- ^^^^ expected `u32`, found `i8` @@ -948,7 +168,7 @@ LL | x_u32 > x_i8.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:189:17 + --> $DIR/numeric-cast-binop.rs:51:17 | LL | x_u32 > x_i16; | ----- ^^^^^ expected `u32`, found `i16` @@ -961,7 +181,7 @@ LL | x_u32 > x_i16.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:191:17 + --> $DIR/numeric-cast-binop.rs:53:17 | LL | x_u32 > x_i32; | ----- ^^^^^ expected `u32`, found `i32` @@ -974,7 +194,7 @@ LL | x_u32 > x_i32.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:193:17 + --> $DIR/numeric-cast-binop.rs:55:17 | LL | x_u32 > x_i64; | ----- ^^^^^ expected `u32`, found `i64` @@ -987,7 +207,7 @@ LL | i64::from(x_u32) > x_i64; | ++++++++++ + error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:195:17 + --> $DIR/numeric-cast-binop.rs:57:17 | LL | x_u32 > x_i128; | ----- ^^^^^^ expected `u32`, found `i128` @@ -1000,7 +220,7 @@ LL | i128::from(x_u32) > x_i128; | +++++++++++ + error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:197:17 + --> $DIR/numeric-cast-binop.rs:59:17 | LL | x_u32 > x_isize; | ----- ^^^^^^^ expected `u32`, found `isize` @@ -1013,7 +233,7 @@ LL | x_u32 > x_isize.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:200:17 + --> $DIR/numeric-cast-binop.rs:62:17 | LL | x_u64 > x_i8; | ----- ^^^^ expected `u64`, found `i8` @@ -1026,7 +246,7 @@ LL | x_u64 > x_i8.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:202:17 + --> $DIR/numeric-cast-binop.rs:64:17 | LL | x_u64 > x_i16; | ----- ^^^^^ expected `u64`, found `i16` @@ -1039,7 +259,7 @@ LL | x_u64 > x_i16.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:204:17 + --> $DIR/numeric-cast-binop.rs:66:17 | LL | x_u64 > x_i32; | ----- ^^^^^ expected `u64`, found `i32` @@ -1052,7 +272,7 @@ LL | x_u64 > x_i32.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:206:17 + --> $DIR/numeric-cast-binop.rs:68:17 | LL | x_u64 > x_i64; | ----- ^^^^^ expected `u64`, found `i64` @@ -1065,7 +285,7 @@ LL | x_u64 > x_i64.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:208:17 + --> $DIR/numeric-cast-binop.rs:70:17 | LL | x_u64 > x_i128; | ----- ^^^^^^ expected `u64`, found `i128` @@ -1078,7 +298,7 @@ LL | i128::from(x_u64) > x_i128; | +++++++++++ + error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:210:17 + --> $DIR/numeric-cast-binop.rs:72:17 | LL | x_u64 > x_isize; | ----- ^^^^^^^ expected `u64`, found `isize` @@ -1091,7 +311,7 @@ LL | x_u64 > x_isize.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:213:18 + --> $DIR/numeric-cast-binop.rs:75:18 | LL | x_u128 > x_i8; | ------ ^^^^ expected `u128`, found `i8` @@ -1104,7 +324,7 @@ LL | x_u128 > x_i8.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:215:18 + --> $DIR/numeric-cast-binop.rs:77:18 | LL | x_u128 > x_i16; | ------ ^^^^^ expected `u128`, found `i16` @@ -1117,7 +337,7 @@ LL | x_u128 > x_i16.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:217:18 + --> $DIR/numeric-cast-binop.rs:79:18 | LL | x_u128 > x_i32; | ------ ^^^^^ expected `u128`, found `i32` @@ -1130,7 +350,7 @@ LL | x_u128 > x_i32.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:219:18 + --> $DIR/numeric-cast-binop.rs:81:18 | LL | x_u128 > x_i64; | ------ ^^^^^ expected `u128`, found `i64` @@ -1143,7 +363,7 @@ LL | x_u128 > x_i64.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:221:18 + --> $DIR/numeric-cast-binop.rs:83:18 | LL | x_u128 > x_i128; | ------ ^^^^^^ expected `u128`, found `i128` @@ -1156,7 +376,7 @@ LL | x_u128 > x_i128.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:223:18 + --> $DIR/numeric-cast-binop.rs:85:18 | LL | x_u128 > x_isize; | ------ ^^^^^^^ expected `u128`, found `isize` @@ -1169,7 +389,7 @@ LL | x_u128 > x_isize.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:226:19 + --> $DIR/numeric-cast-binop.rs:88:19 | LL | x_usize > x_i8; | ------- ^^^^ expected `usize`, found `i8` @@ -1182,7 +402,7 @@ LL | x_usize > x_i8.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:228:19 + --> $DIR/numeric-cast-binop.rs:90:19 | LL | x_usize > x_i16; | ------- ^^^^^ expected `usize`, found `i16` @@ -1195,7 +415,7 @@ LL | x_usize > x_i16.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:230:19 + --> $DIR/numeric-cast-binop.rs:92:19 | LL | x_usize > x_i32; | ------- ^^^^^ expected `usize`, found `i32` @@ -1208,7 +428,7 @@ LL | x_usize > x_i32.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:232:19 + --> $DIR/numeric-cast-binop.rs:94:19 | LL | x_usize > x_i64; | ------- ^^^^^ expected `usize`, found `i64` @@ -1221,7 +441,7 @@ LL | x_usize > x_i64.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:234:19 + --> $DIR/numeric-cast-binop.rs:96:19 | LL | x_usize > x_i128; | ------- ^^^^^^ expected `usize`, found `i128` @@ -1234,7 +454,7 @@ LL | x_usize > x_i128.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:236:19 + --> $DIR/numeric-cast-binop.rs:98:19 | LL | x_usize > x_isize; | ------- ^^^^^^^ expected `usize`, found `isize` @@ -1247,7 +467,7 @@ LL | x_usize > x_isize.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:242:16 + --> $DIR/numeric-cast-binop.rs:104:16 | LL | x_i8 > x_u8; | ---- ^^^^ expected `i8`, found `u8` @@ -1260,7 +480,7 @@ LL | x_i8 > x_u8.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:244:16 + --> $DIR/numeric-cast-binop.rs:106:16 | LL | x_i8 > x_u16; | ---- ^^^^^ expected `i8`, found `u16` @@ -1273,7 +493,7 @@ LL | x_i8 > x_u16.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:246:16 + --> $DIR/numeric-cast-binop.rs:108:16 | LL | x_i8 > x_u32; | ---- ^^^^^ expected `i8`, found `u32` @@ -1286,7 +506,7 @@ LL | x_i8 > x_u32.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:248:16 + --> $DIR/numeric-cast-binop.rs:110:16 | LL | x_i8 > x_u64; | ---- ^^^^^ expected `i8`, found `u64` @@ -1299,7 +519,7 @@ LL | x_i8 > x_u64.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:250:16 + --> $DIR/numeric-cast-binop.rs:112:16 | LL | x_i8 > x_u128; | ---- ^^^^^^ expected `i8`, found `u128` @@ -1312,7 +532,7 @@ LL | x_i8 > x_u128.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:252:16 + --> $DIR/numeric-cast-binop.rs:114:16 | LL | x_i8 > x_usize; | ---- ^^^^^^^ expected `i8`, found `usize` @@ -1325,7 +545,7 @@ LL | x_i8 > x_usize.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:255:17 + --> $DIR/numeric-cast-binop.rs:117:17 | LL | x_i16 > x_u8; | ----- ^^^^ expected `i16`, found `u8` @@ -1338,7 +558,7 @@ LL | x_i16 > x_u8.into(); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:257:17 + --> $DIR/numeric-cast-binop.rs:119:17 | LL | x_i16 > x_u16; | ----- ^^^^^ expected `i16`, found `u16` @@ -1351,7 +571,7 @@ LL | x_i16 > x_u16.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:259:17 + --> $DIR/numeric-cast-binop.rs:121:17 | LL | x_i16 > x_u32; | ----- ^^^^^ expected `i16`, found `u32` @@ -1364,7 +584,7 @@ LL | x_i16 > x_u32.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:261:17 + --> $DIR/numeric-cast-binop.rs:123:17 | LL | x_i16 > x_u64; | ----- ^^^^^ expected `i16`, found `u64` @@ -1377,7 +597,7 @@ LL | x_i16 > x_u64.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:263:17 + --> $DIR/numeric-cast-binop.rs:125:17 | LL | x_i16 > x_u128; | ----- ^^^^^^ expected `i16`, found `u128` @@ -1390,7 +610,7 @@ LL | x_i16 > x_u128.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:265:17 + --> $DIR/numeric-cast-binop.rs:127:17 | LL | x_i16 > x_usize; | ----- ^^^^^^^ expected `i16`, found `usize` @@ -1403,7 +623,7 @@ LL | x_i16 > x_usize.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:268:17 + --> $DIR/numeric-cast-binop.rs:130:17 | LL | x_i32 > x_u8; | ----- ^^^^ expected `i32`, found `u8` @@ -1416,7 +636,7 @@ LL | x_i32 > x_u8.into(); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:270:17 + --> $DIR/numeric-cast-binop.rs:132:17 | LL | x_i32 > x_u16; | ----- ^^^^^ expected `i32`, found `u16` @@ -1429,7 +649,7 @@ LL | x_i32 > x_u16.into(); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:272:17 + --> $DIR/numeric-cast-binop.rs:134:17 | LL | x_i32 > x_u32; | ----- ^^^^^ expected `i32`, found `u32` @@ -1442,7 +662,7 @@ LL | x_i32 > x_u32.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:274:17 + --> $DIR/numeric-cast-binop.rs:136:17 | LL | x_i32 > x_u64; | ----- ^^^^^ expected `i32`, found `u64` @@ -1455,7 +675,7 @@ LL | x_i32 > x_u64.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:276:17 + --> $DIR/numeric-cast-binop.rs:138:17 | LL | x_i32 > x_u128; | ----- ^^^^^^ expected `i32`, found `u128` @@ -1468,7 +688,7 @@ LL | x_i32 > x_u128.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:278:17 + --> $DIR/numeric-cast-binop.rs:140:17 | LL | x_i32 > x_usize; | ----- ^^^^^^^ expected `i32`, found `usize` @@ -1481,7 +701,7 @@ LL | x_i32 > x_usize.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:281:17 + --> $DIR/numeric-cast-binop.rs:143:17 | LL | x_i64 > x_u8; | ----- ^^^^ expected `i64`, found `u8` @@ -1494,7 +714,7 @@ LL | x_i64 > x_u8.into(); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:283:17 + --> $DIR/numeric-cast-binop.rs:145:17 | LL | x_i64 > x_u16; | ----- ^^^^^ expected `i64`, found `u16` @@ -1507,7 +727,7 @@ LL | x_i64 > x_u16.into(); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:285:17 + --> $DIR/numeric-cast-binop.rs:147:17 | LL | x_i64 > x_u32; | ----- ^^^^^ expected `i64`, found `u32` @@ -1520,7 +740,7 @@ LL | x_i64 > x_u32.into(); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:287:17 + --> $DIR/numeric-cast-binop.rs:149:17 | LL | x_i64 > x_u64; | ----- ^^^^^ expected `i64`, found `u64` @@ -1533,7 +753,7 @@ LL | x_i64 > x_u64.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:289:17 + --> $DIR/numeric-cast-binop.rs:151:17 | LL | x_i64 > x_u128; | ----- ^^^^^^ expected `i64`, found `u128` @@ -1546,7 +766,7 @@ LL | x_i64 > x_u128.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:291:17 + --> $DIR/numeric-cast-binop.rs:153:17 | LL | x_i64 > x_usize; | ----- ^^^^^^^ expected `i64`, found `usize` @@ -1559,7 +779,7 @@ LL | x_i64 > x_usize.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:294:18 + --> $DIR/numeric-cast-binop.rs:156:18 | LL | x_i128 > x_u8; | ------ ^^^^ expected `i128`, found `u8` @@ -1572,7 +792,7 @@ LL | x_i128 > x_u8.into(); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:296:18 + --> $DIR/numeric-cast-binop.rs:158:18 | LL | x_i128 > x_u16; | ------ ^^^^^ expected `i128`, found `u16` @@ -1585,7 +805,7 @@ LL | x_i128 > x_u16.into(); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:298:18 + --> $DIR/numeric-cast-binop.rs:160:18 | LL | x_i128 > x_u32; | ------ ^^^^^ expected `i128`, found `u32` @@ -1598,7 +818,7 @@ LL | x_i128 > x_u32.into(); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:300:18 + --> $DIR/numeric-cast-binop.rs:162:18 | LL | x_i128 > x_u64; | ------ ^^^^^ expected `i128`, found `u64` @@ -1611,7 +831,7 @@ LL | x_i128 > x_u64.into(); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:302:18 + --> $DIR/numeric-cast-binop.rs:164:18 | LL | x_i128 > x_u128; | ------ ^^^^^^ expected `i128`, found `u128` @@ -1624,7 +844,7 @@ LL | x_i128 > x_u128.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:304:18 + --> $DIR/numeric-cast-binop.rs:166:18 | LL | x_i128 > x_usize; | ------ ^^^^^^^ expected `i128`, found `usize` @@ -1637,7 +857,7 @@ LL | x_i128 > x_usize.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:307:19 + --> $DIR/numeric-cast-binop.rs:169:19 | LL | x_isize > x_u8; | ------- ^^^^ expected `isize`, found `u8` @@ -1650,7 +870,7 @@ LL | x_isize > x_u8.into(); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:309:19 + --> $DIR/numeric-cast-binop.rs:171:19 | LL | x_isize > x_u16; | ------- ^^^^^ expected `isize`, found `u16` @@ -1663,7 +883,7 @@ LL | x_isize > x_u16.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:311:19 + --> $DIR/numeric-cast-binop.rs:173:19 | LL | x_isize > x_u32; | ------- ^^^^^ expected `isize`, found `u32` @@ -1676,7 +896,7 @@ LL | x_isize > x_u32.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:313:19 + --> $DIR/numeric-cast-binop.rs:175:19 | LL | x_isize > x_u64; | ------- ^^^^^ expected `isize`, found `u64` @@ -1689,7 +909,7 @@ LL | x_isize > x_u64.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:315:19 + --> $DIR/numeric-cast-binop.rs:177:19 | LL | x_isize > x_u128; | ------- ^^^^^^ expected `isize`, found `u128` @@ -1702,7 +922,7 @@ LL | x_isize > x_u128.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:317:19 + --> $DIR/numeric-cast-binop.rs:179:19 | LL | x_isize > x_usize; | ------- ^^^^^^^ expected `isize`, found `usize` @@ -1714,6 +934,6 @@ help: you can convert a `usize` to an `isize` and panic if the converted value d LL | x_isize > x_usize.try_into().unwrap(); | ++++++++++++++++++++ -error: aborting due to 132 previous errors +error: aborting due to 72 previous errors For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/numeric/numeric-cast.fixed b/tests/ui/numeric/numeric-cast.fixed index cf0560a107772..537116400ce2e 100644 --- a/tests/ui/numeric/numeric-cast.fixed +++ b/tests/ui/numeric/numeric-cast.fixed @@ -19,138 +19,6 @@ fn main() { let x_f64: f64 = 11.0; 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::(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); - 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::(x_f64); - // foo::(x_f32); - - foo::(x_usize.try_into().unwrap()); - //~^ ERROR mismatched types - 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::(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::(x_i64); - foo::(x_i32.into()); - //~^ ERROR mismatched types - foo::(x_i16.into()); - //~^ ERROR mismatched types - foo::(x_i8.into()); - //~^ ERROR mismatched types - // 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); - 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::(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::(x_i32); - foo::(x_i16.into()); - //~^ ERROR mismatched types - foo::(x_i8.into()); - //~^ ERROR mismatched types - // foo::(x_f64); - // foo::(x_f32); - foo::(x_usize.try_into().unwrap()); //~^ ERROR mismatched types foo::(x_u64.try_into().unwrap()); diff --git a/tests/ui/numeric/numeric-cast.rs b/tests/ui/numeric/numeric-cast.rs index 7bddfc5090535..9ba283668c2d0 100644 --- a/tests/ui/numeric/numeric-cast.rs +++ b/tests/ui/numeric/numeric-cast.rs @@ -19,138 +19,6 @@ fn main() { let x_f64: f64 = 11.0; let x_f32: f32 = 12.0; - foo::(x_usize); - foo::(x_u64); - //~^ ERROR mismatched types - foo::(x_u32); - //~^ ERROR mismatched types - foo::(x_u16); - //~^ ERROR mismatched types - foo::(x_u8); - //~^ ERROR mismatched types - foo::(x_isize); - //~^ ERROR mismatched types - foo::(x_i64); - //~^ ERROR mismatched types - foo::(x_i32); - //~^ ERROR mismatched types - foo::(x_i16); - //~^ ERROR mismatched types - foo::(x_i8); - //~^ ERROR mismatched types - // foo::(x_f64); - // foo::(x_f32); - - foo::(x_usize); - //~^ ERROR mismatched types - foo::(x_u64); - //~^ ERROR mismatched types - foo::(x_u32); - //~^ ERROR mismatched types - foo::(x_u16); - //~^ ERROR mismatched types - foo::(x_u8); - //~^ ERROR mismatched types - foo::(x_isize); - foo::(x_i64); - //~^ ERROR mismatched types - foo::(x_i32); - //~^ ERROR mismatched types - foo::(x_i16); - //~^ ERROR mismatched types - foo::(x_i8); - //~^ ERROR mismatched types - // foo::(x_f64); - // foo::(x_f32); - - foo::(x_usize); - //~^ ERROR mismatched types - foo::(x_u64); - foo::(x_u32); - //~^ ERROR mismatched types - foo::(x_u16); - //~^ ERROR mismatched types - foo::(x_u8); - //~^ ERROR mismatched types - foo::(x_isize); - //~^ ERROR mismatched types - foo::(x_i64); - //~^ ERROR mismatched types - foo::(x_i32); - //~^ ERROR mismatched types - foo::(x_i16); - //~^ ERROR mismatched types - foo::(x_i8); - //~^ ERROR mismatched types - // foo::(x_f64); - // foo::(x_f32); - - foo::(x_usize); - //~^ ERROR mismatched types - foo::(x_u64); - //~^ ERROR mismatched types - foo::(x_u32); - //~^ ERROR mismatched types - foo::(x_u16); - //~^ ERROR mismatched types - foo::(x_u8); - //~^ ERROR mismatched types - foo::(x_isize); - //~^ ERROR mismatched types - foo::(x_i64); - foo::(x_i32); - //~^ ERROR mismatched types - foo::(x_i16); - //~^ ERROR mismatched types - foo::(x_i8); - //~^ ERROR mismatched types - // foo::(x_f64); - // foo::(x_f32); - - foo::(x_usize); - //~^ ERROR mismatched types - foo::(x_u64); - //~^ ERROR mismatched types - foo::(x_u32); - foo::(x_u16); - //~^ ERROR mismatched types - foo::(x_u8); - //~^ ERROR mismatched types - foo::(x_isize); - //~^ ERROR mismatched types - foo::(x_i64); - //~^ ERROR mismatched types - foo::(x_i32); - //~^ ERROR mismatched types - foo::(x_i16); - //~^ ERROR mismatched types - foo::(x_i8); - //~^ ERROR mismatched types - // foo::(x_f64); - // foo::(x_f32); - - foo::(x_usize); - //~^ ERROR mismatched types - foo::(x_u64); - //~^ ERROR mismatched types - foo::(x_u32); - //~^ ERROR mismatched types - foo::(x_u16); - //~^ ERROR mismatched types - foo::(x_u8); - //~^ ERROR mismatched types - foo::(x_isize); - //~^ ERROR mismatched types - foo::(x_i64); - //~^ ERROR mismatched types - foo::(x_i32); - foo::(x_i16); - //~^ ERROR mismatched types - foo::(x_i8); - //~^ ERROR mismatched types - // foo::(x_f64); - // foo::(x_f32); - foo::(x_usize); //~^ ERROR mismatched types foo::(x_u64); diff --git a/tests/ui/numeric/numeric-cast.stderr b/tests/ui/numeric/numeric-cast.stderr index d347875d5a947..5d4e06c94e8db 100644 --- a/tests/ui/numeric/numeric-cast.stderr +++ b/tests/ui/numeric/numeric-cast.stderr @@ -1,977 +1,5 @@ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:23:18 - | -LL | foo::(x_u64); - | ------------ ^^^^^ expected `usize`, found `u64` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `u64` to a `usize` and panic if the converted value doesn't fit - | -LL | foo::(x_u64.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:25:18 - | -LL | foo::(x_u32); - | ------------ ^^^^^ expected `usize`, found `u32` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `u32` to a `usize` and panic if the converted value doesn't fit - | -LL | foo::(x_u32.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:27:18 - | -LL | foo::(x_u16); - | ------------ ^^^^^ expected `usize`, found `u16` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `u16` to a `usize` - | -LL | foo::(x_u16.into()); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:29:18 - | -LL | foo::(x_u8); - | ------------ ^^^^ expected `usize`, found `u8` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `u8` to a `usize` - | -LL | foo::(x_u8.into()); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:31:18 - | -LL | foo::(x_isize); - | ------------ ^^^^^^^ expected `usize`, found `isize` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `isize` to a `usize` and panic if the converted value doesn't fit - | -LL | foo::(x_isize.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:33:18 - | -LL | foo::(x_i64); - | ------------ ^^^^^ expected `usize`, found `i64` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `i64` to a `usize` and panic if the converted value doesn't fit - | -LL | foo::(x_i64.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:35:18 - | -LL | foo::(x_i32); - | ------------ ^^^^^ expected `usize`, found `i32` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `i32` to a `usize` and panic if the converted value doesn't fit - | -LL | foo::(x_i32.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:37:18 - | -LL | foo::(x_i16); - | ------------ ^^^^^ expected `usize`, found `i16` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `i16` to a `usize` and panic if the converted value doesn't fit - | -LL | foo::(x_i16.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:39:18 - | -LL | foo::(x_i8); - | ------------ ^^^^ expected `usize`, found `i8` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `i8` to a `usize` and panic if the converted value doesn't fit - | -LL | foo::(x_i8.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:44:18 - | -LL | foo::(x_usize); - | ------------ ^^^^^^^ expected `isize`, found `usize` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `usize` to an `isize` and panic if the converted value doesn't fit - | -LL | foo::(x_usize.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:46:18 - | -LL | foo::(x_u64); - | ------------ ^^^^^ expected `isize`, found `u64` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `u64` to an `isize` and panic if the converted value doesn't fit - | -LL | foo::(x_u64.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:48:18 - | -LL | foo::(x_u32); - | ------------ ^^^^^ expected `isize`, found `u32` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `u32` to an `isize` and panic if the converted value doesn't fit - | -LL | foo::(x_u32.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:50:18 - | -LL | foo::(x_u16); - | ------------ ^^^^^ expected `isize`, found `u16` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `u16` to an `isize` and panic if the converted value doesn't fit - | -LL | foo::(x_u16.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:52:18 - | -LL | foo::(x_u8); - | ------------ ^^^^ expected `isize`, found `u8` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `u8` to an `isize` - | -LL | foo::(x_u8.into()); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:55:18 - | -LL | foo::(x_i64); - | ------------ ^^^^^ expected `isize`, found `i64` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `i64` to an `isize` and panic if the converted value doesn't fit - | -LL | foo::(x_i64.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:57:18 - | -LL | foo::(x_i32); - | ------------ ^^^^^ expected `isize`, found `i32` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `i32` to an `isize` and panic if the converted value doesn't fit - | -LL | foo::(x_i32.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:59:18 - | -LL | foo::(x_i16); - | ------------ ^^^^^ expected `isize`, found `i16` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `i16` to an `isize` - | -LL | foo::(x_i16.into()); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:61:18 - | -LL | foo::(x_i8); - | ------------ ^^^^ expected `isize`, found `i8` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `i8` to an `isize` - | -LL | foo::(x_i8.into()); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:66:16 - | -LL | foo::(x_usize); - | ---------- ^^^^^^^ expected `u64`, found `usize` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `usize` to a `u64` and panic if the converted value doesn't fit - | -LL | foo::(x_usize.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:69:16 - | -LL | foo::(x_u32); - | ---------- ^^^^^ expected `u64`, found `u32` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `u32` to a `u64` - | -LL | foo::(x_u32.into()); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:71:16 - | -LL | foo::(x_u16); - | ---------- ^^^^^ expected `u64`, found `u16` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `u16` to a `u64` - | -LL | foo::(x_u16.into()); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:73:16 - | -LL | foo::(x_u8); - | ---------- ^^^^ expected `u64`, found `u8` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `u8` to a `u64` - | -LL | foo::(x_u8.into()); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:75:16 - | -LL | foo::(x_isize); - | ---------- ^^^^^^^ expected `u64`, found `isize` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `isize` to a `u64` and panic if the converted value doesn't fit - | -LL | foo::(x_isize.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:77:16 - | -LL | foo::(x_i64); - | ---------- ^^^^^ expected `u64`, found `i64` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `i64` to a `u64` and panic if the converted value doesn't fit - | -LL | foo::(x_i64.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:79:16 - | -LL | foo::(x_i32); - | ---------- ^^^^^ expected `u64`, found `i32` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `i32` to a `u64` and panic if the converted value doesn't fit - | -LL | foo::(x_i32.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:81:16 - | -LL | foo::(x_i16); - | ---------- ^^^^^ expected `u64`, found `i16` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `i16` to a `u64` and panic if the converted value doesn't fit - | -LL | foo::(x_i16.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:83:16 - | -LL | foo::(x_i8); - | ---------- ^^^^ expected `u64`, found `i8` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `i8` to a `u64` and panic if the converted value doesn't fit - | -LL | foo::(x_i8.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:88:16 - | -LL | foo::(x_usize); - | ---------- ^^^^^^^ expected `i64`, found `usize` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `usize` to an `i64` and panic if the converted value doesn't fit - | -LL | foo::(x_usize.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:90:16 - | -LL | foo::(x_u64); - | ---------- ^^^^^ expected `i64`, found `u64` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `u64` to an `i64` and panic if the converted value doesn't fit - | -LL | foo::(x_u64.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:92:16 - | -LL | foo::(x_u32); - | ---------- ^^^^^ expected `i64`, found `u32` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `u32` to an `i64` - | -LL | foo::(x_u32.into()); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:94:16 - | -LL | foo::(x_u16); - | ---------- ^^^^^ expected `i64`, found `u16` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `u16` to an `i64` - | -LL | foo::(x_u16.into()); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:96:16 - | -LL | foo::(x_u8); - | ---------- ^^^^ expected `i64`, found `u8` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `u8` to an `i64` - | -LL | foo::(x_u8.into()); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:98:16 - | -LL | foo::(x_isize); - | ---------- ^^^^^^^ expected `i64`, found `isize` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `isize` to an `i64` and panic if the converted value doesn't fit - | -LL | foo::(x_isize.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:101:16 - | -LL | foo::(x_i32); - | ---------- ^^^^^ expected `i64`, found `i32` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `i32` to an `i64` - | -LL | foo::(x_i32.into()); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:103:16 - | -LL | foo::(x_i16); - | ---------- ^^^^^ expected `i64`, found `i16` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `i16` to an `i64` - | -LL | foo::(x_i16.into()); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:105:16 - | -LL | foo::(x_i8); - | ---------- ^^^^ expected `i64`, found `i8` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `i8` to an `i64` - | -LL | foo::(x_i8.into()); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:110:16 - | -LL | foo::(x_usize); - | ---------- ^^^^^^^ expected `u32`, found `usize` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit - | -LL | foo::(x_usize.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:112:16 - | -LL | foo::(x_u64); - | ---------- ^^^^^ expected `u32`, found `u64` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `u64` to a `u32` and panic if the converted value doesn't fit - | -LL | foo::(x_u64.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:115:16 - | -LL | foo::(x_u16); - | ---------- ^^^^^ expected `u32`, found `u16` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `u16` to a `u32` - | -LL | foo::(x_u16.into()); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:117:16 - | -LL | foo::(x_u8); - | ---------- ^^^^ expected `u32`, found `u8` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `u8` to a `u32` - | -LL | foo::(x_u8.into()); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:119:16 - | -LL | foo::(x_isize); - | ---------- ^^^^^^^ expected `u32`, found `isize` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `isize` to a `u32` and panic if the converted value doesn't fit - | -LL | foo::(x_isize.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:121:16 - | -LL | foo::(x_i64); - | ---------- ^^^^^ expected `u32`, found `i64` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `i64` to a `u32` and panic if the converted value doesn't fit - | -LL | foo::(x_i64.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:123:16 - | -LL | foo::(x_i32); - | ---------- ^^^^^ expected `u32`, found `i32` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `i32` to a `u32` and panic if the converted value doesn't fit - | -LL | foo::(x_i32.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:125:16 - | -LL | foo::(x_i16); - | ---------- ^^^^^ expected `u32`, found `i16` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `i16` to a `u32` and panic if the converted value doesn't fit - | -LL | foo::(x_i16.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:127:16 - | -LL | foo::(x_i8); - | ---------- ^^^^ expected `u32`, found `i8` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `i8` to a `u32` and panic if the converted value doesn't fit - | -LL | foo::(x_i8.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:132:16 - | -LL | foo::(x_usize); - | ---------- ^^^^^^^ expected `i32`, found `usize` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `usize` to an `i32` and panic if the converted value doesn't fit - | -LL | foo::(x_usize.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:134:16 - | -LL | foo::(x_u64); - | ---------- ^^^^^ expected `i32`, found `u64` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `u64` to an `i32` and panic if the converted value doesn't fit - | -LL | foo::(x_u64.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:136:16 - | -LL | foo::(x_u32); - | ---------- ^^^^^ expected `i32`, found `u32` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `u32` to an `i32` and panic if the converted value doesn't fit - | -LL | foo::(x_u32.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:138:16 - | -LL | foo::(x_u16); - | ---------- ^^^^^ expected `i32`, found `u16` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `u16` to an `i32` - | -LL | foo::(x_u16.into()); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:140:16 - | -LL | foo::(x_u8); - | ---------- ^^^^ expected `i32`, found `u8` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `u8` to an `i32` - | -LL | foo::(x_u8.into()); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:142:16 - | -LL | foo::(x_isize); - | ---------- ^^^^^^^ expected `i32`, found `isize` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `isize` to an `i32` and panic if the converted value doesn't fit - | -LL | foo::(x_isize.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:144:16 - | -LL | foo::(x_i64); - | ---------- ^^^^^ expected `i32`, found `i64` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `i64` to an `i32` and panic if the converted value doesn't fit - | -LL | foo::(x_i64.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:147:16 - | -LL | foo::(x_i16); - | ---------- ^^^^^ expected `i32`, found `i16` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `i16` to an `i32` - | -LL | foo::(x_i16.into()); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:149:16 - | -LL | foo::(x_i8); - | ---------- ^^^^ expected `i32`, found `i8` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `i8` to an `i32` - | -LL | foo::(x_i8.into()); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:154:16 + --> $DIR/numeric-cast.rs:22:16 | LL | foo::(x_usize); | ---------- ^^^^^^^ expected `u16`, found `usize` @@ -989,7 +17,7 @@ LL | foo::(x_usize.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:156:16 + --> $DIR/numeric-cast.rs:24:16 | LL | foo::(x_u64); | ---------- ^^^^^ expected `u16`, found `u64` @@ -1007,7 +35,7 @@ LL | foo::(x_u64.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:158:16 + --> $DIR/numeric-cast.rs:26:16 | LL | foo::(x_u32); | ---------- ^^^^^ expected `u16`, found `u32` @@ -1025,7 +53,7 @@ LL | foo::(x_u32.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:161:16 + --> $DIR/numeric-cast.rs:29:16 | LL | foo::(x_u8); | ---------- ^^^^ expected `u16`, found `u8` @@ -1043,7 +71,7 @@ LL | foo::(x_u8.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:163:16 + --> $DIR/numeric-cast.rs:31:16 | LL | foo::(x_isize); | ---------- ^^^^^^^ expected `u16`, found `isize` @@ -1061,7 +89,7 @@ LL | foo::(x_isize.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:165:16 + --> $DIR/numeric-cast.rs:33:16 | LL | foo::(x_i64); | ---------- ^^^^^ expected `u16`, found `i64` @@ -1079,7 +107,7 @@ LL | foo::(x_i64.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:167:16 + --> $DIR/numeric-cast.rs:35:16 | LL | foo::(x_i32); | ---------- ^^^^^ expected `u16`, found `i32` @@ -1097,7 +125,7 @@ LL | foo::(x_i32.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:169:16 + --> $DIR/numeric-cast.rs:37:16 | LL | foo::(x_i16); | ---------- ^^^^^ expected `u16`, found `i16` @@ -1115,7 +143,7 @@ LL | foo::(x_i16.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:171:16 + --> $DIR/numeric-cast.rs:39:16 | LL | foo::(x_i8); | ---------- ^^^^ expected `u16`, found `i8` @@ -1133,7 +161,7 @@ LL | foo::(x_i8.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:176:16 + --> $DIR/numeric-cast.rs:44:16 | LL | foo::(x_usize); | ---------- ^^^^^^^ expected `i16`, found `usize` @@ -1151,7 +179,7 @@ LL | foo::(x_usize.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:178:16 + --> $DIR/numeric-cast.rs:46:16 | LL | foo::(x_u64); | ---------- ^^^^^ expected `i16`, found `u64` @@ -1169,7 +197,7 @@ LL | foo::(x_u64.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:180:16 + --> $DIR/numeric-cast.rs:48:16 | LL | foo::(x_u32); | ---------- ^^^^^ expected `i16`, found `u32` @@ -1187,7 +215,7 @@ LL | foo::(x_u32.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:182:16 + --> $DIR/numeric-cast.rs:50:16 | LL | foo::(x_u16); | ---------- ^^^^^ expected `i16`, found `u16` @@ -1205,7 +233,7 @@ LL | foo::(x_u16.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:184:16 + --> $DIR/numeric-cast.rs:52:16 | LL | foo::(x_u8); | ---------- ^^^^ expected `i16`, found `u8` @@ -1223,7 +251,7 @@ LL | foo::(x_u8.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:186:16 + --> $DIR/numeric-cast.rs:54:16 | LL | foo::(x_isize); | ---------- ^^^^^^^ expected `i16`, found `isize` @@ -1241,7 +269,7 @@ LL | foo::(x_isize.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:188:16 + --> $DIR/numeric-cast.rs:56:16 | LL | foo::(x_i64); | ---------- ^^^^^ expected `i16`, found `i64` @@ -1259,7 +287,7 @@ LL | foo::(x_i64.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:190:16 + --> $DIR/numeric-cast.rs:58:16 | LL | foo::(x_i32); | ---------- ^^^^^ expected `i16`, found `i32` @@ -1277,7 +305,7 @@ LL | foo::(x_i32.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:193:16 + --> $DIR/numeric-cast.rs:61:16 | LL | foo::(x_i8); | ---------- ^^^^ expected `i16`, found `i8` @@ -1295,7 +323,7 @@ LL | foo::(x_i8.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:198:15 + --> $DIR/numeric-cast.rs:66:15 | LL | foo::(x_usize); | --------- ^^^^^^^ expected `u8`, found `usize` @@ -1313,7 +341,7 @@ LL | foo::(x_usize.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:200:15 + --> $DIR/numeric-cast.rs:68:15 | LL | foo::(x_u64); | --------- ^^^^^ expected `u8`, found `u64` @@ -1331,7 +359,7 @@ LL | foo::(x_u64.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:202:15 + --> $DIR/numeric-cast.rs:70:15 | LL | foo::(x_u32); | --------- ^^^^^ expected `u8`, found `u32` @@ -1349,7 +377,7 @@ LL | foo::(x_u32.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:204:15 + --> $DIR/numeric-cast.rs:72:15 | LL | foo::(x_u16); | --------- ^^^^^ expected `u8`, found `u16` @@ -1367,7 +395,7 @@ LL | foo::(x_u16.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:207:15 + --> $DIR/numeric-cast.rs:75:15 | LL | foo::(x_isize); | --------- ^^^^^^^ expected `u8`, found `isize` @@ -1385,7 +413,7 @@ LL | foo::(x_isize.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:209:15 + --> $DIR/numeric-cast.rs:77:15 | LL | foo::(x_i64); | --------- ^^^^^ expected `u8`, found `i64` @@ -1403,7 +431,7 @@ LL | foo::(x_i64.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:211:15 + --> $DIR/numeric-cast.rs:79:15 | LL | foo::(x_i32); | --------- ^^^^^ expected `u8`, found `i32` @@ -1421,7 +449,7 @@ LL | foo::(x_i32.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:213:15 + --> $DIR/numeric-cast.rs:81:15 | LL | foo::(x_i16); | --------- ^^^^^ expected `u8`, found `i16` @@ -1439,7 +467,7 @@ LL | foo::(x_i16.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:215:15 + --> $DIR/numeric-cast.rs:83:15 | LL | foo::(x_i8); | --------- ^^^^ expected `u8`, found `i8` @@ -1457,7 +485,7 @@ LL | foo::(x_i8.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:220:15 + --> $DIR/numeric-cast.rs:88:15 | LL | foo::(x_usize); | --------- ^^^^^^^ expected `i8`, found `usize` @@ -1475,7 +503,7 @@ LL | foo::(x_usize.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:222:15 + --> $DIR/numeric-cast.rs:90:15 | LL | foo::(x_u64); | --------- ^^^^^ expected `i8`, found `u64` @@ -1493,7 +521,7 @@ LL | foo::(x_u64.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:224:15 + --> $DIR/numeric-cast.rs:92:15 | LL | foo::(x_u32); | --------- ^^^^^ expected `i8`, found `u32` @@ -1511,7 +539,7 @@ LL | foo::(x_u32.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:226:15 + --> $DIR/numeric-cast.rs:94:15 | LL | foo::(x_u16); | --------- ^^^^^ expected `i8`, found `u16` @@ -1529,7 +557,7 @@ LL | foo::(x_u16.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:228:15 + --> $DIR/numeric-cast.rs:96:15 | LL | foo::(x_u8); | --------- ^^^^ expected `i8`, found `u8` @@ -1547,7 +575,7 @@ LL | foo::(x_u8.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:230:15 + --> $DIR/numeric-cast.rs:98:15 | LL | foo::(x_isize); | --------- ^^^^^^^ expected `i8`, found `isize` @@ -1565,7 +593,7 @@ LL | foo::(x_isize.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:232:15 + --> $DIR/numeric-cast.rs:100:15 | LL | foo::(x_i64); | --------- ^^^^^ expected `i8`, found `i64` @@ -1583,7 +611,7 @@ LL | foo::(x_i64.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:234:15 + --> $DIR/numeric-cast.rs:102:15 | LL | foo::(x_i32); | --------- ^^^^^ expected `i8`, found `i32` @@ -1601,7 +629,7 @@ LL | foo::(x_i32.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:236:15 + --> $DIR/numeric-cast.rs:104:15 | LL | foo::(x_i16); | --------- ^^^^^ expected `i8`, found `i16` @@ -1619,7 +647,7 @@ LL | foo::(x_i16.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:242:16 + --> $DIR/numeric-cast.rs:110:16 | LL | foo::(x_usize); | ---------- ^^^^^^^ expected `f64`, found `usize` @@ -1637,7 +665,7 @@ LL | foo::(x_usize as f64); | ++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:244:16 + --> $DIR/numeric-cast.rs:112:16 | LL | foo::(x_u64); | ---------- ^^^^^ expected `f64`, found `u64` @@ -1655,7 +683,7 @@ LL | foo::(x_u64 as f64); | ++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:246:16 + --> $DIR/numeric-cast.rs:114:16 | LL | foo::(x_u32); | ---------- ^^^^^ expected `f64`, found `u32` @@ -1673,7 +701,7 @@ LL | foo::(x_u32.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:248:16 + --> $DIR/numeric-cast.rs:116:16 | LL | foo::(x_u16); | ---------- ^^^^^ expected `f64`, found `u16` @@ -1691,7 +719,7 @@ LL | foo::(x_u16.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:250:16 + --> $DIR/numeric-cast.rs:118:16 | LL | foo::(x_u8); | ---------- ^^^^ expected `f64`, found `u8` @@ -1709,7 +737,7 @@ LL | foo::(x_u8.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:252:16 + --> $DIR/numeric-cast.rs:120:16 | LL | foo::(x_isize); | ---------- ^^^^^^^ expected `f64`, found `isize` @@ -1727,7 +755,7 @@ LL | foo::(x_isize as f64); | ++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:254:16 + --> $DIR/numeric-cast.rs:122:16 | LL | foo::(x_i64); | ---------- ^^^^^ expected `f64`, found `i64` @@ -1745,7 +773,7 @@ LL | foo::(x_i64 as f64); | ++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:256:16 + --> $DIR/numeric-cast.rs:124:16 | LL | foo::(x_i32); | ---------- ^^^^^ expected `f64`, found `i32` @@ -1763,7 +791,7 @@ LL | foo::(x_i32.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:258:16 + --> $DIR/numeric-cast.rs:126:16 | LL | foo::(x_i16); | ---------- ^^^^^ expected `f64`, found `i16` @@ -1781,7 +809,7 @@ LL | foo::(x_i16.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:260:16 + --> $DIR/numeric-cast.rs:128:16 | LL | foo::(x_i8); | ---------- ^^^^ expected `f64`, found `i8` @@ -1799,7 +827,7 @@ LL | foo::(x_i8.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:263:16 + --> $DIR/numeric-cast.rs:131:16 | LL | foo::(x_f32); | ---------- ^^^^^ expected `f64`, found `f32` @@ -1817,7 +845,7 @@ LL | foo::(x_f32.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:266:16 + --> $DIR/numeric-cast.rs:134:16 | LL | foo::(x_usize); | ---------- ^^^^^^^ expected `f32`, found `usize` @@ -1835,7 +863,7 @@ LL | foo::(x_usize as f32); | ++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:268:16 + --> $DIR/numeric-cast.rs:136:16 | LL | foo::(x_u64); | ---------- ^^^^^ expected `f32`, found `u64` @@ -1853,7 +881,7 @@ LL | foo::(x_u64 as f32); | ++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:270:16 + --> $DIR/numeric-cast.rs:138:16 | LL | foo::(x_u32); | ---------- ^^^^^ expected `f32`, found `u32` @@ -1871,7 +899,7 @@ LL | foo::(x_u32 as f32); | ++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:272:16 + --> $DIR/numeric-cast.rs:140:16 | LL | foo::(x_u16); | ---------- ^^^^^ expected `f32`, found `u16` @@ -1889,7 +917,7 @@ LL | foo::(x_u16.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:274:16 + --> $DIR/numeric-cast.rs:142:16 | LL | foo::(x_u8); | ---------- ^^^^ expected `f32`, found `u8` @@ -1907,7 +935,7 @@ LL | foo::(x_u8.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:276:16 + --> $DIR/numeric-cast.rs:144:16 | LL | foo::(x_isize); | ---------- ^^^^^^^ expected `f32`, found `isize` @@ -1925,7 +953,7 @@ LL | foo::(x_isize as f32); | ++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:278:16 + --> $DIR/numeric-cast.rs:146:16 | LL | foo::(x_i64); | ---------- ^^^^^ expected `f32`, found `i64` @@ -1943,7 +971,7 @@ LL | foo::(x_i64 as f32); | ++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:280:16 + --> $DIR/numeric-cast.rs:148:16 | LL | foo::(x_i32); | ---------- ^^^^^ expected `f32`, found `i32` @@ -1961,7 +989,7 @@ LL | foo::(x_i32 as f32); | ++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:282:16 + --> $DIR/numeric-cast.rs:150:16 | LL | foo::(x_i16); | ---------- ^^^^^ expected `f32`, found `i16` @@ -1979,7 +1007,7 @@ LL | foo::(x_i16.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:284:16 + --> $DIR/numeric-cast.rs:152:16 | LL | foo::(x_i8); | ---------- ^^^^ expected `f32`, found `i8` @@ -1997,7 +1025,7 @@ LL | foo::(x_i8.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:289:16 + --> $DIR/numeric-cast.rs:157:16 | LL | foo::(x_u8 as u16); | ---------- ^^^^^^^^^^^ expected `u32`, found `u16` @@ -2015,7 +1043,7 @@ LL | foo::((x_u8 as u16).into()); | + ++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:291:16 + --> $DIR/numeric-cast.rs:159:16 | LL | foo::(-x_i8); | ---------- ^^^^^ expected `i32`, found `i8` @@ -2032,6 +1060,6 @@ help: you can convert an `i8` to an `i32` LL | foo::((-x_i8).into()); | + ++++++++ -error: aborting due to 113 previous errors +error: aborting due to 59 previous errors For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/numeric/numeric-suffix/numeric-suffix.fixed b/tests/ui/numeric/numeric-suffix/numeric-suffix.fixed index 69934db217b62..24596a847a18f 100644 --- a/tests/ui/numeric/numeric-suffix/numeric-suffix.fixed +++ b/tests/ui/numeric/numeric-suffix/numeric-suffix.fixed @@ -336,14 +336,17 @@ fn main() { //~^ ERROR mismatched types //~| NOTE expected //~| NOTE arguments + //~| NOTE in this expansion of desugaring of a resized `Span` foo::(42_u16.into()); //~^ ERROR mismatched types //~| NOTE expected //~| NOTE arguments + //~| NOTE in this expansion of desugaring of a resized `Span` foo::(42_u8.into()); //~^ ERROR mismatched types //~| NOTE expected //~| NOTE arguments + //~| NOTE in this expansion of desugaring of a resized `Span` foo::(42_f64); //~^ ERROR mismatched types //~| NOTE expected @@ -356,14 +359,17 @@ fn main() { //~^ ERROR mismatched types //~| NOTE expected //~| NOTE arguments + //~| NOTE in this expansion of desugaring of a resized `Span` foo::(42_i16.into()); //~^ ERROR mismatched types //~| NOTE expected //~| NOTE arguments + //~| NOTE in this expansion of desugaring of a resized `Span` foo::(42_i8.into()); //~^ ERROR mismatched types //~| NOTE expected //~| NOTE arguments + //~| NOTE in this expansion of desugaring of a resized `Span` foo::(42.0_f64); foo::(42.0_f64); //~^ ERROR mismatched types @@ -386,10 +392,12 @@ fn main() { //~^ ERROR mismatched types //~| NOTE expected //~| NOTE arguments + //~| NOTE in this expansion of desugaring of a resized `Span` foo::(42_u8.into()); //~^ ERROR mismatched types //~| NOTE expected //~| NOTE arguments + //~| NOTE in this expansion of desugaring of a resized `Span` foo::(42_f32); //~^ ERROR mismatched types //~| NOTE expected @@ -406,10 +414,12 @@ fn main() { //~^ ERROR mismatched types //~| NOTE expected //~| NOTE arguments + //~| NOTE in this expansion of desugaring of a resized `Span` foo::(42_i8.into()); //~^ ERROR mismatched types //~| NOTE expected //~| NOTE arguments + //~| NOTE in this expansion of desugaring of a resized `Span` foo::(42.0_f32); //~^ ERROR mismatched types //~| NOTE expected @@ -420,8 +430,10 @@ fn main() { //~^ ERROR mismatched types //~| NOTE expected //~| NOTE arguments + //~| NOTE in this expansion of desugaring of a resized `Span` foo::((-42_i8).into()); //~^ ERROR mismatched types //~| NOTE expected //~| NOTE arguments + //~| NOTE in this expansion of desugaring of a resized `Span` } diff --git a/tests/ui/numeric/numeric-suffix/numeric-suffix.rs b/tests/ui/numeric/numeric-suffix/numeric-suffix.rs index dabf43f82046f..d201c1d8d46ff 100644 --- a/tests/ui/numeric/numeric-suffix/numeric-suffix.rs +++ b/tests/ui/numeric/numeric-suffix/numeric-suffix.rs @@ -336,14 +336,17 @@ fn main() { //~^ ERROR mismatched types //~| NOTE expected //~| NOTE arguments + //~| NOTE in this expansion of desugaring of a resized `Span` foo::(42_u16); //~^ ERROR mismatched types //~| NOTE expected //~| NOTE arguments + //~| NOTE in this expansion of desugaring of a resized `Span` foo::(42_u8); //~^ ERROR mismatched types //~| NOTE expected //~| NOTE arguments + //~| NOTE in this expansion of desugaring of a resized `Span` foo::(42_isize); //~^ ERROR mismatched types //~| NOTE expected @@ -356,14 +359,17 @@ fn main() { //~^ ERROR mismatched types //~| NOTE expected //~| NOTE arguments + //~| NOTE in this expansion of desugaring of a resized `Span` foo::(42_i16); //~^ ERROR mismatched types //~| NOTE expected //~| NOTE arguments + //~| NOTE in this expansion of desugaring of a resized `Span` foo::(42_i8); //~^ ERROR mismatched types //~| NOTE expected //~| NOTE arguments + //~| NOTE in this expansion of desugaring of a resized `Span` foo::(42.0_f64); foo::(42.0_f32); //~^ ERROR mismatched types @@ -386,10 +392,12 @@ fn main() { //~^ ERROR mismatched types //~| NOTE expected //~| NOTE arguments + //~| NOTE in this expansion of desugaring of a resized `Span` foo::(42_u8); //~^ ERROR mismatched types //~| NOTE expected //~| NOTE arguments + //~| NOTE in this expansion of desugaring of a resized `Span` foo::(42_isize); //~^ ERROR mismatched types //~| NOTE expected @@ -406,10 +414,12 @@ fn main() { //~^ ERROR mismatched types //~| NOTE expected //~| NOTE arguments + //~| NOTE in this expansion of desugaring of a resized `Span` foo::(42_i8); //~^ ERROR mismatched types //~| NOTE expected //~| NOTE arguments + //~| NOTE in this expansion of desugaring of a resized `Span` foo::(42.0_f64); //~^ ERROR mismatched types //~| NOTE expected @@ -420,8 +430,10 @@ fn main() { //~^ ERROR mismatched types //~| NOTE expected //~| NOTE arguments + //~| NOTE in this expansion of desugaring of a resized `Span` foo::(-42_i8); //~^ ERROR mismatched types //~| NOTE expected //~| NOTE arguments + //~| NOTE in this expansion of desugaring of a resized `Span` } diff --git a/tests/ui/numeric/numeric-suffix/numeric-suffix.stderr b/tests/ui/numeric/numeric-suffix/numeric-suffix.stderr index e05913b9c621c..eb6c749c9e01c 100644 --- a/tests/ui/numeric/numeric-suffix/numeric-suffix.stderr +++ b/tests/ui/numeric/numeric-suffix/numeric-suffix.stderr @@ -845,7 +845,7 @@ LL | foo::(42_u32.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-suffix.rs:339:16 + --> $DIR/numeric-suffix.rs:340:16 | LL | foo::(42_u16); | ---------- ^^^^^^ expected `f64`, found `u16` @@ -863,7 +863,7 @@ LL | foo::(42_u16.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-suffix.rs:343:16 + --> $DIR/numeric-suffix.rs:345:16 | LL | foo::(42_u8); | ---------- ^^^^^ expected `f64`, found `u8` @@ -881,7 +881,7 @@ LL | foo::(42_u8.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-suffix.rs:347:16 + --> $DIR/numeric-suffix.rs:350:16 | LL | foo::(42_isize); | ---------- ^^^^^^^^ expected `f64`, found `isize` @@ -899,7 +899,7 @@ LL | foo::(42_f64); | ~~~ error[E0308]: mismatched types - --> $DIR/numeric-suffix.rs:351:16 + --> $DIR/numeric-suffix.rs:354:16 | LL | foo::(42_i64); | ---------- ^^^^^^ expected `f64`, found `i64` @@ -917,7 +917,7 @@ LL | foo::(42_f64); | ~~~ error[E0308]: mismatched types - --> $DIR/numeric-suffix.rs:355:16 + --> $DIR/numeric-suffix.rs:358:16 | LL | foo::(42_i32); | ---------- ^^^^^^ expected `f64`, found `i32` @@ -935,7 +935,7 @@ LL | foo::(42_i32.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-suffix.rs:359:16 + --> $DIR/numeric-suffix.rs:363:16 | LL | foo::(42_i16); | ---------- ^^^^^^ expected `f64`, found `i16` @@ -953,7 +953,7 @@ LL | foo::(42_i16.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-suffix.rs:363:16 + --> $DIR/numeric-suffix.rs:368:16 | LL | foo::(42_i8); | ---------- ^^^^^ expected `f64`, found `i8` @@ -971,7 +971,7 @@ LL | foo::(42_i8.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-suffix.rs:368:16 + --> $DIR/numeric-suffix.rs:374:16 | LL | foo::(42.0_f32); | ---------- ^^^^^^^^ expected `f64`, found `f32` @@ -989,7 +989,7 @@ LL | foo::(42.0_f64); | ~~~ error[E0308]: mismatched types - --> $DIR/numeric-suffix.rs:373:16 + --> $DIR/numeric-suffix.rs:379:16 | LL | foo::(42_usize); | ---------- ^^^^^^^^ expected `f32`, found `usize` @@ -1007,7 +1007,7 @@ LL | foo::(42_f32); | ~~~ error[E0308]: mismatched types - --> $DIR/numeric-suffix.rs:377:16 + --> $DIR/numeric-suffix.rs:383:16 | LL | foo::(42_u64); | ---------- ^^^^^^ expected `f32`, found `u64` @@ -1025,7 +1025,7 @@ LL | foo::(42_f32); | ~~~ error[E0308]: mismatched types - --> $DIR/numeric-suffix.rs:381:16 + --> $DIR/numeric-suffix.rs:387:16 | LL | foo::(42_u32); | ---------- ^^^^^^ expected `f32`, found `u32` @@ -1043,7 +1043,7 @@ LL | foo::(42_f32); | ~~~ error[E0308]: mismatched types - --> $DIR/numeric-suffix.rs:385:16 + --> $DIR/numeric-suffix.rs:391:16 | LL | foo::(42_u16); | ---------- ^^^^^^ expected `f32`, found `u16` @@ -1061,7 +1061,7 @@ LL | foo::(42_u16.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-suffix.rs:389:16 + --> $DIR/numeric-suffix.rs:396:16 | LL | foo::(42_u8); | ---------- ^^^^^ expected `f32`, found `u8` @@ -1079,7 +1079,7 @@ LL | foo::(42_u8.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-suffix.rs:393:16 + --> $DIR/numeric-suffix.rs:401:16 | LL | foo::(42_isize); | ---------- ^^^^^^^^ expected `f32`, found `isize` @@ -1097,7 +1097,7 @@ LL | foo::(42_f32); | ~~~ error[E0308]: mismatched types - --> $DIR/numeric-suffix.rs:397:16 + --> $DIR/numeric-suffix.rs:405:16 | LL | foo::(42_i64); | ---------- ^^^^^^ expected `f32`, found `i64` @@ -1115,7 +1115,7 @@ LL | foo::(42_f32); | ~~~ error[E0308]: mismatched types - --> $DIR/numeric-suffix.rs:401:16 + --> $DIR/numeric-suffix.rs:409:16 | LL | foo::(42_i32); | ---------- ^^^^^^ expected `f32`, found `i32` @@ -1133,7 +1133,7 @@ LL | foo::(42_f32); | ~~~ error[E0308]: mismatched types - --> $DIR/numeric-suffix.rs:405:16 + --> $DIR/numeric-suffix.rs:413:16 | LL | foo::(42_i16); | ---------- ^^^^^^ expected `f32`, found `i16` @@ -1151,7 +1151,7 @@ LL | foo::(42_i16.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-suffix.rs:409:16 + --> $DIR/numeric-suffix.rs:418:16 | LL | foo::(42_i8); | ---------- ^^^^^ expected `f32`, found `i8` @@ -1169,7 +1169,7 @@ LL | foo::(42_i8.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-suffix.rs:413:16 + --> $DIR/numeric-suffix.rs:423:16 | LL | foo::(42.0_f64); | ---------- ^^^^^^^^ expected `f32`, found `f64` @@ -1187,7 +1187,7 @@ LL | foo::(42.0_f32); | ~~~ error[E0308]: mismatched types - --> $DIR/numeric-suffix.rs:419:16 + --> $DIR/numeric-suffix.rs:429:16 | LL | foo::(42_u8 as u16); | ---------- ^^^^^^^^^^^^ expected `u32`, found `u16` @@ -1205,7 +1205,7 @@ LL | foo::((42_u8 as u16).into()); | + ++++++++ error[E0308]: mismatched types - --> $DIR/numeric-suffix.rs:423:16 + --> $DIR/numeric-suffix.rs:434:16 | LL | foo::(-42_i8); | ---------- ^^^^^^ expected `i32`, found `i8` diff --git a/tests/ui/proc-macro/generate-mod.rs b/tests/ui/proc-macro/generate-mod.rs index 471f317edf964..85b2b530fb318 100644 --- a/tests/ui/proc-macro/generate-mod.rs +++ b/tests/ui/proc-macro/generate-mod.rs @@ -6,22 +6,22 @@ extern crate generate_mod; struct FromOutside; -generate_mod::check!(); //~ ERROR cannot find type `FromOutside` in this scope - //~| ERROR cannot find type `Outer` in this scope +generate_mod::check!(); //~ ERROR cannot find type `FromOutside` in + //~| ERROR cannot find type `Outer` in -#[generate_mod::check_attr] //~ ERROR cannot find type `FromOutside` in this scope - //~| ERROR cannot find type `OuterAttr` in this scope +#[generate_mod::check_attr] //~ ERROR cannot find type `FromOutside` in + //~| ERROR cannot find type `OuterAttr` in struct S; -#[derive(generate_mod::CheckDerive)] //~ ERROR cannot find type `FromOutside` in this scope - //~| ERROR cannot find type `OuterDerive` in this scope +#[derive(generate_mod::CheckDerive)] //~ ERROR cannot find type `FromOutside` in + //~| ERROR cannot find type `OuterDerive` in //~| WARN this was previously accepted //~| WARN this was previously accepted struct Z; fn inner_block() { - #[derive(generate_mod::CheckDerive)] //~ ERROR cannot find type `FromOutside` in this scope - //~| ERROR cannot find type `OuterDerive` in this scope + #[derive(generate_mod::CheckDerive)] //~ ERROR cannot find type `FromOutside` in + //~| ERROR cannot find type `OuterDerive` in //~| WARN this was previously accepted //~| WARN this was previously accepted struct InnerZ; diff --git a/tests/ui/proc-macro/generate-mod.stderr b/tests/ui/proc-macro/generate-mod.stderr index db629b5b5e239..0059e64f4664c 100644 --- a/tests/ui/proc-macro/generate-mod.stderr +++ b/tests/ui/proc-macro/generate-mod.stderr @@ -1,41 +1,33 @@ -error[E0412]: cannot find type `FromOutside` in this scope +error[E0412]: cannot find type `FromOutside` in the expanded code of procedural macro `generate_mod::check` --> $DIR/generate-mod.rs:9:1 | LL | generate_mod::check!(); - | ^^^^^^^^^^^^^^^^^^^^^^ not found in this scope + | ^^^^^^^^^^^^^^^^^^^^^^ `FromOutside` not found in expanded code of this procedural macro | - = help: consider importing this struct: - FromOutside = note: this error originates in the macro `generate_mod::check` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0412]: cannot find type `Outer` in this scope +error[E0412]: cannot find type `Outer` in the expanded code of procedural macro `generate_mod::check` --> $DIR/generate-mod.rs:9:1 | LL | generate_mod::check!(); - | ^^^^^^^^^^^^^^^^^^^^^^ not found in this scope + | ^^^^^^^^^^^^^^^^^^^^^^ `Outer` not found in expanded code of this procedural macro | - = help: consider importing this struct: - Outer = note: this error originates in the macro `generate_mod::check` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0412]: cannot find type `FromOutside` in this scope +error[E0412]: cannot find type `FromOutside` in the expanded code of procedural macro `generate_mod::check_attr` --> $DIR/generate-mod.rs:12:1 | LL | #[generate_mod::check_attr] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `FromOutside` not found in expanded code of this procedural macro | - = help: consider importing this struct: - FromOutside = note: this error originates in the attribute macro `generate_mod::check_attr` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0412]: cannot find type `OuterAttr` in this scope +error[E0412]: cannot find type `OuterAttr` in the expanded code of procedural macro `generate_mod::check_attr` --> $DIR/generate-mod.rs:12:1 | LL | #[generate_mod::check_attr] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `OuterAttr` not found in expanded code of this procedural macro | - = help: consider importing this struct: - OuterAttr = note: this error originates in the attribute macro `generate_mod::check_attr` (in Nightly builds, run with -Z macro-backtrace for more info) error: cannot find type `FromOutside` in this scope diff --git a/tests/ui/proc-macro/issue-38586.stderr b/tests/ui/proc-macro/issue-38586.stderr index ddd0a0874dd3e..d3fce750343f4 100644 --- a/tests/ui/proc-macro/issue-38586.stderr +++ b/tests/ui/proc-macro/issue-38586.stderr @@ -1,8 +1,8 @@ -error[E0425]: cannot find value `foo` in this scope +error[E0425]: cannot find value `foo` in the expanded code of `derive` macro `A` --> $DIR/issue-38586.rs:6:10 | LL | #[derive(A)] - | ^ not found in this scope + | ^ `foo` not found in expanded code of this `derive` macro | = note: this error originates in the derive macro `A` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/proc-macro/issue-83510.rs b/tests/ui/proc-macro/issue-83510.rs index 2b1aec4df0be3..4c89dc98bcb41 100644 --- a/tests/ui/proc-macro/issue-83510.rs +++ b/tests/ui/proc-macro/issue-83510.rs @@ -3,9 +3,9 @@ extern crate issue_83510; issue_83510::dance_like_you_want_to_ice!(); -//~^ ERROR: cannot find type `Foo` in this scope +//~^ ERROR: cannot find type `Foo` //~| ERROR: expected trait, found struct `Box` -//~| ERROR: cannot find trait `Baz` in this scope +//~| ERROR: cannot find trait `Baz` //~| ERROR: inherent associated types are unstable fn main() {} diff --git a/tests/ui/proc-macro/issue-83510.stderr b/tests/ui/proc-macro/issue-83510.stderr index e0628a317918b..ed4c1c9b8d44a 100644 --- a/tests/ui/proc-macro/issue-83510.stderr +++ b/tests/ui/proc-macro/issue-83510.stderr @@ -1,8 +1,8 @@ -error[E0412]: cannot find type `Foo` in this scope +error[E0412]: cannot find type `Foo` in the expanded code of procedural macro `issue_83510::dance_like_you_want_to_ice` --> $DIR/issue-83510.rs:5:1 | LL | issue_83510::dance_like_you_want_to_ice!(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Foo` not found in expanded code of this procedural macro | = note: this error originates in the macro `issue_83510::dance_like_you_want_to_ice` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -14,11 +14,11 @@ LL | issue_83510::dance_like_you_want_to_ice!(); | = note: this error originates in the macro `issue_83510::dance_like_you_want_to_ice` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0405]: cannot find trait `Baz` in this scope +error[E0405]: cannot find trait `Baz` in the expanded code of procedural macro `issue_83510::dance_like_you_want_to_ice` --> $DIR/issue-83510.rs:5:1 | LL | issue_83510::dance_like_you_want_to_ice!(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Baz` not found in expanded code of this procedural macro | = note: this error originates in the macro `issue_83510::dance_like_you_want_to_ice` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/proc-macro/lints_in_proc_macros.rs b/tests/ui/proc-macro/lints_in_proc_macros.rs index 377a1f25b635c..5f163f17a19db 100644 --- a/tests/ui/proc-macro/lints_in_proc_macros.rs +++ b/tests/ui/proc-macro/lints_in_proc_macros.rs @@ -7,8 +7,6 @@ use bang_proc_macro2::bang_proc_macro2; fn main() { let foobar = 42; bang_proc_macro2!(); - //~^ ERROR cannot find value `foobar2` in this scope - //~| HELP a local variable with a similar name exists - //~| SUGGESTION foobar + //~^ ERROR cannot find value `foobar2` println!("{}", x); } diff --git a/tests/ui/proc-macro/lints_in_proc_macros.stderr b/tests/ui/proc-macro/lints_in_proc_macros.stderr index 4dd8be7d9b6ef..9381bee36ca2b 100644 --- a/tests/ui/proc-macro/lints_in_proc_macros.stderr +++ b/tests/ui/proc-macro/lints_in_proc_macros.stderr @@ -1,8 +1,8 @@ -error[E0425]: cannot find value `foobar2` in this scope +error[E0425]: cannot find value `foobar2` in the expanded code of procedural macro `bang_proc_macro2` --> $DIR/lints_in_proc_macros.rs:9:5 | LL | bang_proc_macro2!(); - | ^^^^^^^^^^^^^^^^^^^ help: a local variable with a similar name exists: `foobar` + | ^^^^^^^^^^^^^^^^^^^ `foobar2` not found in expanded code of this procedural macro | = note: this error originates in the macro `bang_proc_macro2` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/proc-macro/mixed-site-span.rs b/tests/ui/proc-macro/mixed-site-span.rs index 0083846568e29..2f0a93629dd82 100644 --- a/tests/ui/proc-macro/mixed-site-span.rs +++ b/tests/ui/proc-macro/mixed-site-span.rs @@ -12,9 +12,9 @@ fn main() { let local_use = 1; proc_macro_rules!(); //~^ ERROR use of undeclared label `'label_use` - //~| ERROR cannot find value `local_use` in this scope + //~| ERROR cannot find value `local_use` ItemDef; // OK - local_def; //~ ERROR cannot find value `local_def` in this scope + local_def; //~ ERROR cannot find value `local_def` } } diff --git a/tests/ui/proc-macro/mixed-site-span.stderr b/tests/ui/proc-macro/mixed-site-span.stderr index 1378608012464..982f57d4182a9 100644 --- a/tests/ui/proc-macro/mixed-site-span.stderr +++ b/tests/ui/proc-macro/mixed-site-span.stderr @@ -6,11 +6,11 @@ LL | proc_macro_rules!(); | = note: this error originates in the macro `proc_macro_rules` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0425]: cannot find value `local_use` in this scope +error[E0425]: cannot find value `local_use` in the expanded code of procedural macro `proc_macro_rules` --> $DIR/mixed-site-span.rs:13:9 | LL | proc_macro_rules!(); - | ^^^^^^^^^^^^^^^^^^^ help: a local variable with a similar name exists: `local_def` + | ^^^^^^^^^^^^^^^^^^^ `local_use` not found in expanded code of this procedural macro | = note: this error originates in the macro `proc_macro_rules` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/proc-macro/parent-source-spans.rs b/tests/ui/proc-macro/parent-source-spans.rs index 354657db4db38..c4c38f065120e 100644 --- a/tests/ui/proc-macro/parent-source-spans.rs +++ b/tests/ui/proc-macro/parent-source-spans.rs @@ -27,9 +27,9 @@ macro three($($tokens:tt)*) { macro four($($tokens:tt)*) { parent_source_spans!($($tokens)*); - //~^ ERROR cannot find value `ok` in this scope - //~| ERROR cannot find value `ok` in this scope - //~| ERROR cannot find value `ok` in this scope + //~^ ERROR cannot find value `ok` + //~| ERROR cannot find value `ok` + //~| ERROR cannot find value `ok` } fn main() { diff --git a/tests/ui/proc-macro/parent-source-spans.stderr b/tests/ui/proc-macro/parent-source-spans.stderr index a3b27fd7bcc1b..2a75686805ea2 100644 --- a/tests/ui/proc-macro/parent-source-spans.stderr +++ b/tests/ui/proc-macro/parent-source-spans.stderr @@ -136,45 +136,36 @@ error: second source: "hop" LL | three!("hip", "hop"); | ^^^^^ -error[E0425]: cannot find value `ok` in this scope +error[E0425]: cannot find value `ok` in the expanded code of procedural macro `parent_source_spans` --> $DIR/parent-source-spans.rs:29:5 | LL | parent_source_spans!($($tokens)*); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: a tuple variant with a similar name exists: `Ok` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ok` not found in expanded code of this procedural macro ... LL | one!("hello", "world"); | ---------------------- in this macro invocation - --> $SRC_DIR/core/src/result.rs:LL:COL - | - = note: similarly named tuple variant `Ok` defined here | = note: this error originates in the macro `parent_source_spans` which comes from the expansion of the macro `one` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0425]: cannot find value `ok` in this scope +error[E0425]: cannot find value `ok` in the expanded code of procedural macro `parent_source_spans` --> $DIR/parent-source-spans.rs:29:5 | LL | parent_source_spans!($($tokens)*); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: a tuple variant with a similar name exists: `Ok` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ok` not found in expanded code of this procedural macro ... LL | two!("yay", "rust"); | ------------------- in this macro invocation - --> $SRC_DIR/core/src/result.rs:LL:COL - | - = note: similarly named tuple variant `Ok` defined here | = note: this error originates in the macro `parent_source_spans` which comes from the expansion of the macro `two` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0425]: cannot find value `ok` in this scope +error[E0425]: cannot find value `ok` in the expanded code of procedural macro `parent_source_spans` --> $DIR/parent-source-spans.rs:29:5 | LL | parent_source_spans!($($tokens)*); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: a tuple variant with a similar name exists: `Ok` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ok` not found in expanded code of this procedural macro ... LL | three!("hip", "hop"); | -------------------- in this macro invocation - --> $SRC_DIR/core/src/result.rs:LL:COL - | - = note: similarly named tuple variant `Ok` defined here | = note: this error originates in the macro `parent_source_spans` which comes from the expansion of the macro `three` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/type/type-check/point-at-inference-4.rs b/tests/ui/type/type-check/point-at-inference-4.rs index 3deb234c2751e..eacf9985ac59a 100644 --- a/tests/ui/type/type-check/point-at-inference-4.rs +++ b/tests/ui/type/type-check/point-at-inference-4.rs @@ -16,6 +16,7 @@ fn main() { //~| NOTE an argument is missing //~| HELP provide the argument //~| HELP change the type of the numeric literal from `i32` to `u32` + //~| NOTE in this expansion of desugaring of a resized `Span` let t: S = s; //~^ ERROR mismatched types //~| NOTE expected `S`, found `S` diff --git a/tests/ui/type/type-check/point-at-inference-4.stderr b/tests/ui/type/type-check/point-at-inference-4.stderr index 5f7bb8b9367ec..7502d6d3d366c 100644 --- a/tests/ui/type/type-check/point-at-inference-4.stderr +++ b/tests/ui/type/type-check/point-at-inference-4.stderr @@ -15,7 +15,7 @@ LL | s.infer(0i32, /* b */); | ~~~~~~~~~~~~~~~ error[E0308]: mismatched types - --> $DIR/point-at-inference-4.rs:19:24 + --> $DIR/point-at-inference-4.rs:20:24 | LL | s.infer(0i32); | - ---- this argument has type `i32`...